chore(): Allow to register modules through array (#9522)

This commit is contained in:
Adrien de Peretti
2024-10-11 15:17:00 +02:00
committed by GitHub
parent 9c73503084
commit 1d8939df3a
35 changed files with 954 additions and 349 deletions
@@ -56,7 +56,7 @@ moduleIntegrationTestRunner<IApiKeyModuleService>({
linkable: "api_key_id",
entity: "ApiKey",
primaryKey: "id",
serviceName: "ApiKey",
serviceName: "api_key",
field: "apiKey",
},
publishable_key_id: {
@@ -64,7 +64,7 @@ moduleIntegrationTestRunner<IApiKeyModuleService>({
entity: "ApiKey",
linkable: "publishable_key_id",
primaryKey: "publishable_key_id",
serviceName: "ApiKey",
serviceName: "api_key",
},
})
})
@@ -54,7 +54,7 @@ moduleIntegrationTestRunner({
linkable: "auth_identity_id",
entity: "AuthIdentity",
primaryKey: "id",
serviceName: "Auth",
serviceName: "auth",
field: "authIdentity",
},
})
@@ -66,7 +66,7 @@ moduleIntegrationTestRunner({
linkable: "provider_identity_id",
entity: "ProviderIdentity",
primaryKey: "id",
serviceName: "Auth",
serviceName: "auth",
field: "providerIdentity",
},
})
@@ -36,7 +36,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
linkable: "cart_id",
entity: "Cart",
primaryKey: "id",
serviceName: "Cart",
serviceName: "cart",
field: "cart",
},
},
@@ -45,7 +45,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
linkable: "address_id",
entity: "Address",
primaryKey: "id",
serviceName: "Cart",
serviceName: "cart",
field: "address",
},
},
@@ -54,7 +54,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
linkable: "line_item_id",
entity: "LineItem",
primaryKey: "id",
serviceName: "Cart",
serviceName: "cart",
field: "lineItem",
},
},
@@ -63,7 +63,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
linkable: "line_item_adjustment_id",
entity: "LineItemAdjustment",
primaryKey: "id",
serviceName: "Cart",
serviceName: "cart",
field: "lineItemAdjustment",
},
},
@@ -72,7 +72,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
linkable: "line_item_tax_line_id",
entity: "LineItemTaxLine",
primaryKey: "id",
serviceName: "Cart",
serviceName: "cart",
field: "lineItemTaxLine",
},
},
@@ -81,7 +81,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
linkable: "shipping_method_id",
entity: "ShippingMethod",
primaryKey: "id",
serviceName: "Cart",
serviceName: "cart",
field: "shippingMethod",
},
},
@@ -90,7 +90,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
linkable: "shipping_method_adjustment_id",
entity: "ShippingMethodAdjustment",
primaryKey: "id",
serviceName: "Cart",
serviceName: "cart",
field: "shippingMethodAdjustment",
},
},
@@ -99,7 +99,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
linkable: "shipping_method_tax_line_id",
entity: "ShippingMethodTaxLine",
primaryKey: "id",
serviceName: "Cart",
serviceName: "cart",
field: "shippingMethodTaxLine",
},
},
@@ -26,7 +26,7 @@ moduleIntegrationTestRunner<ICurrencyModuleService>({
linkable: "currency_code",
entity: "Currency",
primaryKey: "code",
serviceName: "Currency",
serviceName: "currency",
field: "currency",
},
},
@@ -31,7 +31,7 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
linkable: "customer_address_id",
entity: "CustomerAddress",
primaryKey: "id",
serviceName: "Customer",
serviceName: "customer",
field: "customerAddress",
},
},
@@ -40,7 +40,7 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
linkable: "customer_group_customer_id",
entity: "CustomerGroupCustomer",
primaryKey: "id",
serviceName: "Customer",
serviceName: "customer",
field: "customerGroupCustomer",
},
},
@@ -49,7 +49,7 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
linkable: "customer_group_id",
entity: "CustomerGroup",
primaryKey: "id",
serviceName: "Customer",
serviceName: "customer",
field: "customerGroup",
},
},
@@ -58,7 +58,7 @@ moduleIntegrationTestRunner<ICustomerModuleService>({
linkable: "customer_id",
entity: "Customer",
primaryKey: "id",
serviceName: "Customer",
serviceName: "customer",
field: "customer",
},
},
@@ -13,7 +13,7 @@ export function buildExpectedEventMessageShape(options: {
metadata: {
action: options.action,
eventGroupId: options.eventGroupId,
source: "Fulfillment",
source: "fulfillment",
object: options.object,
},
data: options.data,
@@ -137,7 +137,7 @@ moduleIntegrationTestRunner({
linkable: "fulfillment_address_id",
entity: "FulfillmentAddress",
primaryKey: "id",
serviceName: "Fulfillment",
serviceName: "fulfillment",
field: "fulfillmentAddress",
},
},
@@ -146,7 +146,7 @@ moduleIntegrationTestRunner({
linkable: "fulfillment_item_id",
entity: "FulfillmentItem",
primaryKey: "id",
serviceName: "Fulfillment",
serviceName: "fulfillment",
field: "fulfillmentItem",
},
},
@@ -155,7 +155,7 @@ moduleIntegrationTestRunner({
linkable: "fulfillment_label_id",
entity: "FulfillmentLabel",
primaryKey: "id",
serviceName: "Fulfillment",
serviceName: "fulfillment",
field: "fulfillmentLabel",
},
},
@@ -164,7 +164,7 @@ moduleIntegrationTestRunner({
linkable: "fulfillment_provider_id",
entity: "FulfillmentProvider",
primaryKey: "id",
serviceName: "Fulfillment",
serviceName: "fulfillment",
field: "fulfillmentProvider",
},
},
@@ -173,7 +173,7 @@ moduleIntegrationTestRunner({
linkable: "fulfillment_set_id",
entity: "FulfillmentSet",
primaryKey: "id",
serviceName: "Fulfillment",
serviceName: "fulfillment",
field: "fulfillmentSet",
},
},
@@ -182,7 +182,7 @@ moduleIntegrationTestRunner({
linkable: "fulfillment_id",
entity: "Fulfillment",
primaryKey: "id",
serviceName: "Fulfillment",
serviceName: "fulfillment",
field: "fulfillment",
},
},
@@ -191,7 +191,7 @@ moduleIntegrationTestRunner({
linkable: "geo_zone_id",
entity: "GeoZone",
primaryKey: "id",
serviceName: "Fulfillment",
serviceName: "fulfillment",
field: "geoZone",
},
},
@@ -200,7 +200,7 @@ moduleIntegrationTestRunner({
linkable: "service_zone_id",
entity: "ServiceZone",
primaryKey: "id",
serviceName: "Fulfillment",
serviceName: "fulfillment",
field: "serviceZone",
},
},
@@ -209,7 +209,7 @@ moduleIntegrationTestRunner({
linkable: "shipping_option_rule_id",
entity: "ShippingOptionRule",
primaryKey: "id",
serviceName: "Fulfillment",
serviceName: "fulfillment",
field: "shippingOptionRule",
},
},
@@ -218,7 +218,7 @@ moduleIntegrationTestRunner({
linkable: "shipping_option_type_id",
entity: "ShippingOptionType",
primaryKey: "id",
serviceName: "Fulfillment",
serviceName: "fulfillment",
field: "shippingOptionType",
},
},
@@ -227,7 +227,7 @@ moduleIntegrationTestRunner({
linkable: "shipping_option_id",
entity: "ShippingOption",
primaryKey: "id",
serviceName: "Fulfillment",
serviceName: "fulfillment",
field: "shippingOption",
},
},
@@ -236,7 +236,7 @@ moduleIntegrationTestRunner({
linkable: "shipping_profile_id",
entity: "ShippingProfile",
primaryKey: "id",
serviceName: "Fulfillment",
serviceName: "fulfillment",
field: "shippingProfile",
},
},
@@ -1,18 +1,20 @@
import { Modules } from "@medusajs/utils"
export const defaultSchema = `
type Product @Listeners(values: ["Product.product.created", "Product.product.updated", "Product.product.deleted"]) {
type Product @Listeners(values: ["${Modules.PRODUCT}.product.created", "${Modules.PRODUCT}.product.updated", "${Modules.PRODUCT}.product.deleted"]) {
id: String
title: String
variants: [ProductVariant]
}
type ProductVariant @Listeners(values: ["Product.product-variant.created", "Product.product-variant.updated", "Product.product-variant.deleted"]) {
type ProductVariant @Listeners(values: ["${Modules.PRODUCT}.product-variant.created", "${Modules.PRODUCT}.product-variant.updated", "${Modules.PRODUCT}.product-variant.deleted"]) {
id: String
product_id: String
sku: String
prices: [Price]
}
type Price @Listeners(values: ["Pricing.price.created", "Pricing.price.updated", "Pricing.price.deleted"]) {
type Price @Listeners(values: ["${Modules.PRICING}.price.created", "${Modules.PRICING}.price.updated", "${Modules.PRICING}.price.deleted"]) {
amount: Int
currency_code: String
}
@@ -31,7 +31,7 @@ moduleIntegrationTestRunner<IInventoryService>({
entity: "InventoryItem",
linkable: "inventory_item_id",
primaryKey: "id",
serviceName: "Inventory",
serviceName: "inventory",
},
},
inventoryLevel: {
@@ -40,7 +40,7 @@ moduleIntegrationTestRunner<IInventoryService>({
entity: "InventoryLevel",
linkable: "inventory_level_id",
primaryKey: "id",
serviceName: "Inventory",
serviceName: "inventory",
},
},
reservationItem: {
@@ -49,7 +49,7 @@ moduleIntegrationTestRunner<IInventoryService>({
entity: "ReservationItem",
linkable: "reservation_item_id",
primaryKey: "id",
serviceName: "Inventory",
serviceName: "inventory",
},
},
})
@@ -60,7 +60,7 @@ moduleIntegrationTestRunner<INotificationModuleService>({
linkable: "notification_id",
entity: "Notification",
primaryKey: "id",
serviceName: "Notification",
serviceName: "notification",
field: "notification",
},
},
@@ -35,7 +35,7 @@ moduleIntegrationTestRunner<IOrderModuleService>({
linkable: "order_id",
entity: "Order",
primaryKey: "id",
serviceName: "Order",
serviceName: "order",
field: "order",
},
},
@@ -44,7 +44,7 @@ moduleIntegrationTestRunner<IOrderModuleService>({
linkable: "order_address_id",
entity: "OrderAddress",
primaryKey: "id",
serviceName: "Order",
serviceName: "order",
field: "orderAddress",
},
},
@@ -53,7 +53,7 @@ moduleIntegrationTestRunner<IOrderModuleService>({
linkable: "order_change_id",
entity: "OrderChange",
primaryKey: "id",
serviceName: "Order",
serviceName: "order",
field: "orderChange",
},
},
@@ -62,14 +62,14 @@ moduleIntegrationTestRunner<IOrderModuleService>({
linkable: "order_claim_id",
entity: "OrderClaim",
primaryKey: "id",
serviceName: "Order",
serviceName: "order",
field: "orderClaim",
},
claim_id: {
linkable: "claim_id",
entity: "OrderClaim",
primaryKey: "claim_id",
serviceName: "Order",
serviceName: "order",
field: "orderClaim",
},
},
@@ -78,14 +78,14 @@ moduleIntegrationTestRunner<IOrderModuleService>({
linkable: "order_exchange_id",
entity: "OrderExchange",
primaryKey: "id",
serviceName: "Order",
serviceName: "order",
field: "orderExchange",
},
exchange_id: {
linkable: "exchange_id",
entity: "OrderExchange",
primaryKey: "exchange_id",
serviceName: "Order",
serviceName: "order",
field: "orderExchange",
},
},
@@ -94,7 +94,7 @@ moduleIntegrationTestRunner<IOrderModuleService>({
linkable: "order_line_item_id",
entity: "OrderLineItem",
primaryKey: "id",
serviceName: "Order",
serviceName: "order",
field: "orderLineItem",
},
},
@@ -103,7 +103,7 @@ moduleIntegrationTestRunner<IOrderModuleService>({
linkable: "order_shipping_method_id",
entity: "OrderShippingMethod",
primaryKey: "id",
serviceName: "Order",
serviceName: "order",
field: "orderShippingMethod",
},
},
@@ -112,7 +112,7 @@ moduleIntegrationTestRunner<IOrderModuleService>({
linkable: "order_transaction_id",
entity: "OrderTransaction",
primaryKey: "id",
serviceName: "Order",
serviceName: "order",
field: "orderTransaction",
},
},
@@ -121,7 +121,7 @@ moduleIntegrationTestRunner<IOrderModuleService>({
linkable: "return_id",
entity: "Return",
primaryKey: "id",
serviceName: "Order",
serviceName: "order",
field: "return",
},
},
@@ -130,7 +130,7 @@ moduleIntegrationTestRunner<IOrderModuleService>({
linkable: "return_reason_id",
entity: "ReturnReason",
primaryKey: "id",
serviceName: "Order",
serviceName: "order",
field: "returnReason",
},
},
@@ -37,7 +37,7 @@ moduleIntegrationTestRunner<IPaymentModuleService>({
linkable: "payment_id",
entity: "Payment",
primaryKey: "id",
serviceName: "Payment",
serviceName: "payment",
field: "payment",
},
},
@@ -46,7 +46,7 @@ moduleIntegrationTestRunner<IPaymentModuleService>({
linkable: "payment_collection_id",
entity: "PaymentCollection",
primaryKey: "id",
serviceName: "Payment",
serviceName: "payment",
field: "paymentCollection",
},
},
@@ -55,7 +55,7 @@ moduleIntegrationTestRunner<IPaymentModuleService>({
linkable: "payment_provider_id",
entity: "PaymentProvider",
primaryKey: "id",
serviceName: "Payment",
serviceName: "payment",
field: "paymentProvider",
},
},
@@ -65,7 +65,7 @@ moduleIntegrationTestRunner<IPaymentModuleService>({
entity: "PaymentSession",
linkable: "payment_session_id",
primaryKey: "id",
serviceName: "Payment",
serviceName: "payment",
},
},
refundReason: {
@@ -73,7 +73,7 @@ moduleIntegrationTestRunner<IPaymentModuleService>({
linkable: "refund_reason_id",
entity: "RefundReason",
primaryKey: "id",
serviceName: "Payment",
serviceName: "payment",
field: "refundReason",
},
},
@@ -29,7 +29,7 @@ moduleIntegrationTestRunner<IPricingModuleService>({
linkable: "price_set_id",
entity: "PriceSet",
primaryKey: "id",
serviceName: "Pricing",
serviceName: "pricing",
field: "priceSet",
},
},
@@ -38,7 +38,7 @@ moduleIntegrationTestRunner<IPricingModuleService>({
linkable: "price_list_id",
entity: "PriceList",
primaryKey: "id",
serviceName: "Pricing",
serviceName: "pricing",
field: "priceList",
},
},
@@ -47,7 +47,7 @@ moduleIntegrationTestRunner<IPricingModuleService>({
linkable: "price_id",
entity: "Price",
primaryKey: "id",
serviceName: "Pricing",
serviceName: "pricing",
field: "price",
},
},
@@ -56,7 +56,7 @@ moduleIntegrationTestRunner<IPricingModuleService>({
linkable: "price_preference_id",
entity: "PricePreference",
primaryKey: "id",
serviceName: "Pricing",
serviceName: "pricing",
field: "pricePreference",
},
},
@@ -692,7 +692,7 @@ moduleIntegrationTestRunner<IProductModuleService>({
[
expect.objectContaining({
data: { id: productCategoryOne.id },
name: "Product.product-category.deleted",
name: "product.product-category.deleted",
metadata: {
action: CommonEvents.DELETED,
object: "product_category",
@@ -281,7 +281,7 @@ moduleIntegrationTestRunner<IProductModuleService>({
expect(eventBusSpy).toHaveBeenCalledWith(
[
{
name: "Product.product-collection.deleted",
name: "product.product-collection.deleted",
data: { id: collectionId },
metadata: {
action: CommonEvents.DELETED,
@@ -72,7 +72,7 @@ moduleIntegrationTestRunner<Service>({
linkable: "product_id",
entity: "Product",
primaryKey: "id",
serviceName: "Product",
serviceName: "product",
field: "product",
},
},
@@ -81,7 +81,7 @@ moduleIntegrationTestRunner<Service>({
linkable: "product_variant_id",
entity: "ProductVariant",
primaryKey: "id",
serviceName: "Product",
serviceName: "product",
field: "productVariant",
},
variant_id: {
@@ -89,7 +89,7 @@ moduleIntegrationTestRunner<Service>({
entity: "ProductVariant",
linkable: "variant_id",
primaryKey: "variant_id",
serviceName: "Product",
serviceName: "product",
},
},
productOption: {
@@ -97,7 +97,7 @@ moduleIntegrationTestRunner<Service>({
linkable: "product_option_id",
entity: "ProductOption",
primaryKey: "id",
serviceName: "Product",
serviceName: "product",
field: "productOption",
},
},
@@ -106,7 +106,7 @@ moduleIntegrationTestRunner<Service>({
linkable: "product_type_id",
entity: "ProductType",
primaryKey: "id",
serviceName: "Product",
serviceName: "product",
field: "productType",
},
},
@@ -115,7 +115,7 @@ moduleIntegrationTestRunner<Service>({
linkable: "product_image_id",
entity: "ProductImage",
primaryKey: "id",
serviceName: "Product",
serviceName: "product",
field: "productImage",
},
},
@@ -124,7 +124,7 @@ moduleIntegrationTestRunner<Service>({
linkable: "product_tag_id",
entity: "ProductTag",
primaryKey: "id",
serviceName: "Product",
serviceName: "product",
field: "productTag",
},
},
@@ -133,7 +133,7 @@ moduleIntegrationTestRunner<Service>({
linkable: "product_collection_id",
entity: "ProductCollection",
primaryKey: "id",
serviceName: "Product",
serviceName: "product",
field: "productCollection",
},
},
@@ -142,7 +142,7 @@ moduleIntegrationTestRunner<Service>({
linkable: "product_category_id",
entity: "ProductCategory",
primaryKey: "id",
serviceName: "Product",
serviceName: "product",
field: "productCategory",
},
},
@@ -49,7 +49,7 @@ moduleIntegrationTestRunner({
linkable: "promotion_id",
entity: "Promotion",
primaryKey: "id",
serviceName: "Promotion",
serviceName: "promotion",
field: "promotion",
},
},
@@ -58,7 +58,7 @@ moduleIntegrationTestRunner({
linkable: "campaign_id",
entity: "Campaign",
primaryKey: "id",
serviceName: "Promotion",
serviceName: "promotion",
field: "campaign",
},
},
@@ -67,7 +67,7 @@ moduleIntegrationTestRunner({
linkable: "promotion_rule_id",
entity: "PromotionRule",
primaryKey: "id",
serviceName: "Promotion",
serviceName: "promotion",
field: "promotionRule",
},
},
@@ -26,7 +26,7 @@ moduleIntegrationTestRunner<IRegionModuleService>({
linkable: "region_id",
entity: "Region",
primaryKey: "id",
serviceName: "Region",
serviceName: "region",
field: "region",
},
},
@@ -35,7 +35,7 @@ moduleIntegrationTestRunner<IRegionModuleService>({
linkable: "country_iso_2",
entity: "Country",
primaryKey: "iso_2",
serviceName: "Region",
serviceName: "region",
field: "country",
},
},
@@ -51,7 +51,7 @@ moduleIntegrationTestRunner<ISalesChannelModuleService>({
linkable: "sales_channel_id",
entity: "SalesChannel",
primaryKey: "id",
serviceName: "SalesChannel",
serviceName: "sales_channel",
field: "salesChannel",
},
},
@@ -30,7 +30,7 @@ moduleIntegrationTestRunner<IStockLocationService>({
linkable: "stock_location_address_id",
entity: "StockLocationAddress",
primaryKey: "id",
serviceName: "StockLocation",
serviceName: "stock_location",
field: "stockLocationAddress",
},
},
@@ -40,13 +40,13 @@ moduleIntegrationTestRunner<IStockLocationService>({
entity: "StockLocation",
linkable: "stock_location_id",
primaryKey: "id",
serviceName: "StockLocation",
serviceName: "stock_location",
},
location_id: {
linkable: "location_id",
entity: "StockLocation",
primaryKey: "location_id",
serviceName: "StockLocation",
serviceName: "stock_location",
field: "stockLocation",
},
},
@@ -27,7 +27,7 @@ moduleIntegrationTestRunner<IStoreModuleService>({
linkable: "store_id",
entity: "Store",
primaryKey: "id",
serviceName: "Store",
serviceName: "store",
field: "store",
},
},
@@ -36,7 +36,7 @@ moduleIntegrationTestRunner<IStoreModuleService>({
linkable: "store_currency_id",
entity: "StoreCurrency",
primaryKey: "id",
serviceName: "Store",
serviceName: "store",
field: "storeCurrency",
},
},
@@ -32,7 +32,7 @@ moduleIntegrationTestRunner<ITaxModuleService>({
linkable: "tax_rate_id",
entity: "TaxRate",
primaryKey: "id",
serviceName: "Tax",
serviceName: "tax",
field: "taxRate",
},
},
@@ -41,7 +41,7 @@ moduleIntegrationTestRunner<ITaxModuleService>({
linkable: "tax_region_id",
entity: "TaxRegion",
primaryKey: "id",
serviceName: "Tax",
serviceName: "tax",
field: "taxRegion",
},
},
@@ -50,7 +50,7 @@ moduleIntegrationTestRunner<ITaxModuleService>({
linkable: "tax_rate_rule_id",
entity: "TaxRateRule",
primaryKey: "id",
serviceName: "Tax",
serviceName: "tax",
field: "taxRateRule",
},
},
@@ -59,7 +59,7 @@ moduleIntegrationTestRunner<ITaxModuleService>({
linkable: "tax_provider_id",
entity: "TaxProvider",
primaryKey: "id",
serviceName: "Tax",
serviceName: "tax",
field: "taxProvider",
},
},
@@ -45,7 +45,7 @@ moduleIntegrationTestRunner<IUserModuleService>({
linkable: "user_id",
entity: "User",
primaryKey: "id",
serviceName: "User",
serviceName: "user",
field: "user",
},
},
@@ -54,7 +54,7 @@ moduleIntegrationTestRunner<IUserModuleService>({
linkable: "invite_id",
entity: "Invite",
primaryKey: "id",
serviceName: "User",
serviceName: "user",
field: "invite",
},
},
@@ -57,7 +57,7 @@ moduleIntegrationTestRunner<IWorkflowEngineService>({
linkable: "workflow_execution_id",
entity: "WorkflowExecution",
primaryKey: "id",
serviceName: "Workflows",
serviceName: "workflows",
field: "workflowExecution",
},
},
@@ -83,7 +83,7 @@ moduleIntegrationTestRunner<IWorkflowEngineService>({
linkable: "workflow_execution_id",
entity: "WorkflowExecution",
primaryKey: "id",
serviceName: "Workflows",
serviceName: "workflows",
field: "workflowExecution",
},
},