Files
medusa-store/packages/modules/link-modules/src/definitions/fulfillment-provider-location.ts
T
2024-11-08 07:54:50 -03:00

72 lines
1.9 KiB
TypeScript

import { ModuleJoinerConfig } from "@medusajs/framework/types"
import { LINKS, Modules } from "@medusajs/framework/utils"
export const LocationFulfillmentProvider: ModuleJoinerConfig = {
serviceName: LINKS.LocationFulfillmentProvider,
isLink: true,
databaseConfig: {
tableName: "location_fulfillment_provider",
idPrefix: "locfp",
},
alias: [
{
name: ["location_fulfillment_provider", "location_fulfillment_providers"],
entity: "LinkLocationFulfillmentProvider",
},
],
primaryKeys: ["id", "stock_location_id", "fulfillment_provider_id"],
relationships: [
{
serviceName: Modules.STOCK_LOCATION,
entity: "StockLocation",
primaryKey: "id",
foreignKey: "stock_location_id",
alias: "location",
args: { methodSuffix: "StockLocations" },
},
{
serviceName: Modules.FULFILLMENT,
entity: "FulfillmentProvider",
primaryKey: "id",
foreignKey: "fulfillment_provider_id",
alias: "fulfillment_provider",
args: { methodSuffix: "FulfillmentProviders" },
},
],
extends: [
{
serviceName: Modules.STOCK_LOCATION,
relationship: {
serviceName: LINKS.LocationFulfillmentProvider,
primaryKey: "stock_location_id",
foreignKey: "id",
alias: "fulfillment_provider_link",
isList: true,
},
fieldAlias: {
fulfillment_providers: {
path: "fulfillment_provider_link.fulfillment_provider",
isList: true,
},
},
},
{
serviceName: Modules.FULFILLMENT,
entity: "FulfillmentProvider",
relationship: {
serviceName: LINKS.LocationFulfillmentProvider,
primaryKey: "fulfillment_provider_id",
foreignKey: "id",
alias: "locations_link",
isList: true,
},
fieldAlias: {
locations: {
path: "locations_link.location",
isList: true,
},
},
},
],
}