Chore/rm main entity concept (#7709)

**What**
Update the `MedusaService` class, factory and types to remove the concept of main modules. The idea being that all method will be explicitly named and suffixes to represent the object you are trying to manipulate.
This pr also includes various fixes in different modules

Co-authored-by: Stevche Radevski <4820812+sradevski@users.noreply.github.com>
Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
Adrien de Peretti
2024-06-19 15:02:16 +02:00
committed by GitHub
parent 2895ccfba8
commit 48963f55ef
533 changed files with 6469 additions and 9769 deletions

View File

@@ -24,12 +24,18 @@ export const CartPaymentCollection: ModuleJoinerConfig = {
primaryKey: "id",
foreignKey: "cart_id",
alias: "cart",
args: {
methodSuffix: "Carts",
},
},
{
serviceName: Modules.PAYMENT,
primaryKey: "id",
foreignKey: "payment_collection_id",
alias: "payment_collection",
args: {
methodSuffix: "PaymentCollections",
},
},
],
extends: [

View File

@@ -24,12 +24,18 @@ export const CartPromotion: ModuleJoinerConfig = {
primaryKey: "id",
foreignKey: "cart_id",
alias: "cart",
args: {
methodSuffix: "Carts",
},
},
{
serviceName: Modules.PROMOTION,
primaryKey: "id",
foreignKey: "promotion_id",
alias: "promotions",
args: {
methodSuffix: "Promotions",
},
},
],
extends: [

View File

@@ -24,12 +24,18 @@ export const LocationFulfillmentSet: ModuleJoinerConfig = {
primaryKey: "id",
foreignKey: "stock_location_id",
alias: "location",
args: {
methodSuffix: "StockLocations",
},
},
{
serviceName: Modules.FULFILLMENT,
primaryKey: "id",
foreignKey: "fulfillment_set_id",
alias: "fulfillment_set",
args: {
methodSuffix: "FulfillmentSets",
},
deleteCascade: true,
},
],

View File

@@ -24,12 +24,18 @@ export const OrderCart: ModuleJoinerConfig = {
primaryKey: "id",
foreignKey: "order_id",
alias: "order",
args: {
methodSuffix: "Orders",
},
},
{
serviceName: Modules.CART,
primaryKey: "id",
foreignKey: "cart_id",
alias: "cart",
args: {
methodSuffix: "Carts",
},
},
],
extends: [

View File

@@ -24,6 +24,9 @@ export const OrderFulfillment: ModuleJoinerConfig = {
primaryKey: "id",
foreignKey: "order_id",
alias: "order",
args: {
methodSuffix: "Orders",
},
},
{
serviceName: Modules.FULFILLMENT,

View File

@@ -24,12 +24,18 @@ export const OrderPaymentCollection: ModuleJoinerConfig = {
primaryKey: "id",
foreignKey: "order_id",
alias: "order",
args: {
methodSuffix: "Orders",
},
},
{
serviceName: Modules.PAYMENT,
primaryKey: "id",
foreignKey: "payment_collection_id",
alias: "payment_collection",
args: {
methodSuffix: "PaymentCollections",
},
},
],
extends: [

View File

@@ -24,12 +24,18 @@ export const OrderPromotion: ModuleJoinerConfig = {
primaryKey: "id",
foreignKey: "order_id",
alias: "order",
args: {
methodSuffix: "Orders",
},
},
{
serviceName: Modules.PROMOTION,
primaryKey: "id",
foreignKey: "promotion_id",
alias: "promotion",
args: {
methodSuffix: "Promotions",
},
},
],
extends: [

View File

@@ -24,12 +24,18 @@ export const ProductSalesChannel: ModuleJoinerConfig = {
primaryKey: "id",
foreignKey: "product_id",
alias: "product",
args: {
methodSuffix: "Products",
},
},
{
serviceName: Modules.SALES_CHANNEL,
primaryKey: "id",
foreignKey: "sales_channel_id",
alias: "sales_channel",
args: {
methodSuffix: "SalesChannels",
},
},
],
extends: [

View File

@@ -34,7 +34,7 @@ export const ProductVariantInventoryItem: ModuleJoinerConfig = {
foreignKey: "variant_id",
alias: "variant",
args: {
methodSuffix: "Variants",
methodSuffix: "ProductVariants",
},
},
{
@@ -42,6 +42,9 @@ export const ProductVariantInventoryItem: ModuleJoinerConfig = {
primaryKey: "id",
foreignKey: "inventory_item_id",
alias: "inventory",
args: {
methodSuffix: "InventoryItems",
},
deleteCascade: true,
},
],

View File

@@ -25,7 +25,7 @@ export const ProductVariantPriceSet: ModuleJoinerConfig = {
foreignKey: "variant_id",
alias: "variant",
args: {
methodSuffix: "Variants",
methodSuffix: "ProductVariants",
},
},
{
@@ -33,6 +33,9 @@ export const ProductVariantPriceSet: ModuleJoinerConfig = {
primaryKey: "id",
foreignKey: "price_set_id",
alias: "price_set",
args: {
methodSuffix: "PriceSets",
},
deleteCascade: true,
},
],

View File

@@ -24,12 +24,18 @@ export const PublishableApiKeySalesChannel: ModuleJoinerConfig = {
primaryKey: "id",
foreignKey: "publishable_key_id",
alias: "api_key",
args: {
methodSuffix: "ApiKeys",
},
},
{
serviceName: Modules.SALES_CHANNEL,
primaryKey: "id",
foreignKey: "sales_channel_id",
alias: "sales_channel",
args: {
methodSuffix: "SalesChannels",
},
},
],
extends: [

View File

@@ -12,6 +12,9 @@ export const CartCustomer: ModuleJoinerConfig = {
primaryKey: "id",
foreignKey: "customer_id",
alias: "customer",
args: {
methodSuffix: "Customers",
},
},
},
{
@@ -21,6 +24,9 @@ export const CartCustomer: ModuleJoinerConfig = {
primaryKey: "customer_id",
foreignKey: "id",
alias: "carts",
args: {
methodSuffix: "Carts",
},
isList: true,
},
},

View File

@@ -12,6 +12,9 @@ export const CartProduct: ModuleJoinerConfig = {
primaryKey: "id",
foreignKey: "items.product_id",
alias: "product",
args: {
methodSuffix: "Products",
},
},
},
{
@@ -22,7 +25,7 @@ export const CartProduct: ModuleJoinerConfig = {
foreignKey: "items.variant_id",
alias: "variant",
args: {
methodSuffix: "Variants",
methodSuffix: "ProductVariants",
},
},
},

View File

@@ -12,6 +12,9 @@ export const CartRegion: ModuleJoinerConfig = {
primaryKey: "id",
foreignKey: "region_id",
alias: "region",
args: {
methodSuffix: "Regions",
},
},
},
{
@@ -21,6 +24,9 @@ export const CartRegion: ModuleJoinerConfig = {
primaryKey: "region_id",
foreignKey: "id",
alias: "carts",
args: {
methodSuffix: "Carts",
},
isList: true,
},
},

View File

@@ -12,6 +12,9 @@ export const CartSalesChannel: ModuleJoinerConfig = {
primaryKey: "id",
foreignKey: "sales_channel_id",
alias: "sales_channel",
args: {
methodSuffix: "SalesChannels",
},
},
},
{
@@ -21,6 +24,9 @@ export const CartSalesChannel: ModuleJoinerConfig = {
primaryKey: "sales_channel_id",
foreignKey: "id",
alias: "carts",
args: {
methodSuffix: "Carts",
},
isList: true,
},
},

View File

@@ -12,6 +12,9 @@ export const InventoryLevelStockLocation: ModuleJoinerConfig = {
primaryKey: "id",
foreignKey: "location_id",
alias: "stock_locations",
args: {
methodSuffix: "StockLocations",
},
isList: true,
},
},

View File

@@ -12,6 +12,9 @@ export const LineItemAdjustmentPromotion: ModuleJoinerConfig = {
primaryKey: "id",
foreignKey: "promotion_id",
alias: "promotion",
args: {
methodSuffix: "Promotions",
},
},
},
],

View File

@@ -12,6 +12,9 @@ export const OrderCustomer: ModuleJoinerConfig = {
primaryKey: "id",
foreignKey: "customer_id",
alias: "customer",
args: {
methodSuffix: "Customers",
},
},
},
{
@@ -21,6 +24,9 @@ export const OrderCustomer: ModuleJoinerConfig = {
primaryKey: "customer_id",
foreignKey: "id",
alias: "orders",
args: {
methodSuffix: "Orders",
},
isList: true,
},
},

View File

@@ -12,6 +12,9 @@ export const OrderProduct: ModuleJoinerConfig = {
primaryKey: "id",
foreignKey: "items.product_id",
alias: "product",
args: {
methodSuffix: "Products",
},
},
},
{
@@ -22,7 +25,7 @@ export const OrderProduct: ModuleJoinerConfig = {
foreignKey: "items.variant_id",
alias: "variant",
args: {
methodSuffix: "Variants",
methodSuffix: "ProductVariants",
},
},
},

View File

@@ -12,6 +12,9 @@ export const OrderRegion: ModuleJoinerConfig = {
primaryKey: "id",
foreignKey: "region_id",
alias: "region",
args: {
methodSuffix: "Regions",
},
},
},
{
@@ -21,6 +24,9 @@ export const OrderRegion: ModuleJoinerConfig = {
primaryKey: "region_id",
foreignKey: "id",
alias: "orders",
args: {
methodSuffix: "Orders",
},
isList: true,
},
},

View File

@@ -13,6 +13,9 @@ export const OrderSalesChannel: ModuleJoinerConfig = {
primaryKey: "id",
foreignKey: "sales_channel_id",
alias: "sales_channel",
args: {
methodSuffix: "SalesChannels",
},
},
},
{
@@ -22,6 +25,9 @@ export const OrderSalesChannel: ModuleJoinerConfig = {
primaryKey: "sales_channel_id",
foreignKey: "id",
alias: "orders",
args: {
methodSuffix: "Orders",
},
isList: true,
},
},

View File

@@ -12,6 +12,9 @@ export const StoreDefaultCurrency: ModuleJoinerConfig = {
primaryKey: "code",
foreignKey: "default_currency_code",
alias: "default_currency",
args: {
methodSuffix: "Currencies",
},
},
},
],

View File

@@ -24,6 +24,9 @@ export const RegionPaymentProvider: ModuleJoinerConfig = {
primaryKey: "id",
foreignKey: "region_id",
alias: "region",
args: {
methodSuffix: "Regions",
},
},
{
serviceName: Modules.PAYMENT,

View File

@@ -24,12 +24,18 @@ export const SalesChannelLocation: ModuleJoinerConfig = {
primaryKey: "id",
foreignKey: "sales_channel_id",
alias: "sales_channel",
args: {
methodSuffix: "SalesChannels",
},
},
{
serviceName: Modules.STOCK_LOCATION,
primaryKey: "id",
foreignKey: "stock_location_id",
alias: "location",
args: {
methodSuffix: "StockLocations",
},
},
],
extends: [

View File

@@ -33,6 +33,9 @@ export const ShippingOptionPriceSet: ModuleJoinerConfig = {
primaryKey: "id",
foreignKey: "price_set_id",
alias: "price_set",
args: {
methodSuffix: "PriceSets",
},
deleteCascade: true,
},
],