feat(utils,link-modules): link between fulfillment provider and stock location (#8275)

what:

- adds link between fulfillment provider and stock location

RESOLVES CC-233
This commit is contained in:
Riqwan Thamir
2024-07-25 08:38:19 +02:00
committed by GitHub
parent 44f593a7ca
commit 34cf7a03a2
2 changed files with 74 additions and 0 deletions

View File

@@ -44,6 +44,12 @@ export const LINKS = {
Modules.STOCK_LOCATION,
"location_id"
),
LocationFulfillmentProvider: composeLinkName(
Modules.STOCK_LOCATION,
"stock_location_id",
Modules.FULFILLMENT,
"fulfillment_provider_id"
),
LocationFulfillmentSet: composeLinkName(
Modules.STOCK_LOCATION,
"stock_location_id",

View File

@@ -0,0 +1,68 @@
import { ModuleJoinerConfig } from "@medusajs/types"
import { LINKS, Modules } from "@medusajs/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"],
args: { entity: "LinkLocationFulfillmentProvider" },
},
],
primaryKeys: ["id", "stock_location_id", "fulfillment_provider_id"],
relationships: [
{
serviceName: Modules.STOCK_LOCATION,
primaryKey: "id",
foreignKey: "stock_location_id",
alias: "location",
args: { methodSuffix: "StockLocations" },
},
{
serviceName: Modules.FULFILLMENT,
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,
relationship: {
serviceName: LINKS.LocationFulfillmentProvider,
primaryKey: "fulfillment_provider_id",
foreignKey: "id",
alias: "locations_link",
isList: true,
},
fieldAlias: {
locations: {
path: "locations_link.location",
isList: true,
},
},
},
],
}