1 import { ModuleJoinerConfig } from "@medusajs/framework/types"
2 import { LINKS, Modules } from "@medusajs/framework/utils"
3
4 export const CustomerAccountHolder: ModuleJoinerConfig = {
5 serviceName: LINKS.CustomerAccountHolder,
6 isLink: true,
7 databaseConfig: {
8 tableName: "customer_account_holder",
9 idPrefix: "custacchldr",
10 },
11 alias: [
12 {
13 name: ["customer_account_holder", "customer_account_holders"],
14 entity: "LinkCustomerAccountHolder",
15 },
16 ],
17 primaryKeys: ["id", "customer_id", "account_holder_id"],
18 relationships: [
19 {
20 serviceName: Modules.CUSTOMER,
21 entity: "Customer",
22 primaryKey: "id",
23 foreignKey: "customer_id",
24 alias: "customer",
25 args: {
26 methodSuffix: "Customers",
27 },
28 },
29 {
30 serviceName: Modules.PAYMENT,
31 entity: "AccountHolder",
32 primaryKey: "id",
33 foreignKey: "account_holder_id",
34 alias: "account_holder",
35 args: {
36 methodSuffix: "AccountHolders",
37 },
38 hasMany: true,
39 },
40 ],
41 extends: [
42 {
43 serviceName: Modules.CUSTOMER,
44 entity: "Customer",
45 fieldAlias: {
46 account_holders: {
47 path: "account_holder_link.account_holder",
48 isList: true,
49 },
50 },
51 relationship: {
52 serviceName: LINKS.CustomerAccountHolder,
53 primaryKey: "customer_id",
54 foreignKey: "id",
55 alias: "account_holder_link",
56 isList: true,
57 },
58 },
59 {
60 serviceName: Modules.PAYMENT,
61 entity: "AccountHolder",
62 fieldAlias: {
63 customer: "customer_link.customer",
64 },
65 relationship: {
66 serviceName: LINKS.CustomerAccountHolder,
67 primaryKey: "account_holder_id",
68 foreignKey: "id",
69 alias: "customer_link",
70 },
71 },
72 ],
73 }