1 import { ModuleJoinerConfig } from "@medusajs/framework/types"
2 import { LINKS, Modules } from "@medusajs/framework/utils"
3
4 export const ProductSalesChannel: ModuleJoinerConfig = {
5 serviceName: LINKS.ProductSalesChannel,
6 isLink: true,
7 databaseConfig: {
8 tableName: "product_sales_channel",
9 idPrefix: "prodsc",
10 },
11 alias: [
12 {
13 name: "product_sales_channel",
14 },
15 {
16 name: "product_sales_channels",
17 },
18 ],
19 primaryKeys: ["id", "product_id", "sales_channel_id"],
20 relationships: [
21 {
22 serviceName: Modules.PRODUCT,
23 entity: "Product",
24 primaryKey: "id",
25 foreignKey: "product_id",
26 alias: "product",
27 args: {
28 methodSuffix: "Products",
29 },
30 hasMany: true,
31 },
32 {
33 serviceName: Modules.SALES_CHANNEL,
34 entity: "SalesChannel",
35 primaryKey: "id",
36 foreignKey: "sales_channel_id",
37 alias: "sales_channel",
38 args: {
39 methodSuffix: "SalesChannels",
40 },
41 hasMany: true,
42 },
43 ],
44 extends: [
45 {
46 serviceName: Modules.PRODUCT,
47 entity: "Product",
48 fieldAlias: {
49 sales_channels: {
50 path: "sales_channels_link.sales_channel",
51 isList: true,
52 },
53 },
54 relationship: {
55 serviceName: LINKS.ProductSalesChannel,
56 primaryKey: "product_id",
57 foreignKey: "id",
58 alias: "sales_channels_link",
59 isList: true,
60 },
61 },
62 {
63 serviceName: Modules.SALES_CHANNEL,
64 entity: "SalesChannel",
65 relationship: {
66 serviceName: LINKS.ProductSalesChannel,
67 primaryKey: "sales_channel_id",
68 foreignKey: "id",
69 alias: "products_link",
70 isList: true,
71 },
72 },
73 ],
74 }