Files
medusa-store/packages/modules/link-modules/src/definitions/sales-channel-location.ts
Harminder Virk d3e725a907 feat: add hasMany flag to enforce in app link uniqueness (#12039)
* feat: add createMultiple flag to enforce inApp link uniqueness

* changes

* mocks

* default

* many to many

---------

Co-authored-by: Carlos R. L. Rodrigues <rodrigolr@gmail.com>
2025-04-02 10:46:51 +02:00

79 lines
1.9 KiB
TypeScript

import { ModuleJoinerConfig } from "@medusajs/framework/types"
import { LINKS, Modules } from "@medusajs/framework/utils"
export const SalesChannelLocation: ModuleJoinerConfig = {
serviceName: LINKS.SalesChannelLocation,
isLink: true,
databaseConfig: {
tableName: "sales_channel_stock_location",
idPrefix: "scloc",
},
alias: [
{
name: ["sales_channel_location", "sales_channel_locations"],
entity: "LinkSalesChannelLocation",
},
],
primaryKeys: ["id", "sales_channel_id", "stock_location_id"],
relationships: [
{
serviceName: Modules.SALES_CHANNEL,
entity: "SalesChannel",
primaryKey: "id",
foreignKey: "sales_channel_id",
alias: "sales_channel",
args: {
methodSuffix: "SalesChannels",
},
hasMany: true,
},
{
serviceName: Modules.STOCK_LOCATION,
entity: "StockLocation",
primaryKey: "id",
foreignKey: "stock_location_id",
alias: "location",
args: {
methodSuffix: "StockLocations",
},
hasMany: true,
},
],
extends: [
{
serviceName: Modules.SALES_CHANNEL,
entity: "SalesChannel",
fieldAlias: {
stock_locations: {
path: "locations_link.location",
isList: true,
},
},
relationship: {
serviceName: LINKS.SalesChannelLocation,
primaryKey: "sales_channel_id",
foreignKey: "id",
alias: "locations_link",
isList: true,
},
},
{
serviceName: Modules.STOCK_LOCATION,
entity: "StockLocation",
fieldAlias: {
sales_channels: {
path: "sales_channels_link.sales_channel",
isList: true,
},
},
relationship: {
serviceName: LINKS.SalesChannelLocation,
primaryKey: "stock_location_id",
foreignKey: "id",
alias: "sales_channels_link",
isList: true,
},
},
],
}