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