@medusajs/link-modules 0.2.12-snapshot-20240531102054 → 0.2.12-snapshot-20240701122250

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. package/dist/definitions/cart-payment-collection.js +10 -5
  2. package/dist/definitions/cart-promotion.js +9 -4
  3. package/dist/definitions/fulfillment-set-location.js +10 -5
  4. package/dist/definitions/index.d.ts +2 -2
  5. package/dist/definitions/index.js +2 -2
  6. package/dist/definitions/order-cart.d.ts +2 -0
  7. package/dist/definitions/order-cart.js +67 -0
  8. package/dist/definitions/order-fulfillment.js +7 -5
  9. package/dist/definitions/order-payment-collection.js +10 -5
  10. package/dist/definitions/order-promotion.js +10 -5
  11. package/dist/definitions/product-sales-channel.js +10 -5
  12. package/dist/definitions/product-variant-inventory-item.js +10 -7
  13. package/dist/definitions/product-variant-price-set.js +8 -6
  14. package/dist/definitions/publishable-api-key-sales-channel.js +10 -5
  15. package/dist/definitions/readonly/cart-customer.js +11 -5
  16. package/dist/definitions/readonly/cart-product.js +11 -8
  17. package/dist/definitions/readonly/cart-region.js +11 -5
  18. package/dist/definitions/readonly/cart-sales-channel.js +11 -5
  19. package/dist/definitions/readonly/index.d.ts +1 -1
  20. package/dist/definitions/readonly/index.js +1 -1
  21. package/dist/definitions/readonly/inventory-level-stock-location.js +6 -3
  22. package/dist/definitions/readonly/line-item-adjustment-promotion.js +6 -3
  23. package/dist/definitions/readonly/order-customer.js +11 -5
  24. package/dist/definitions/readonly/order-product.js +11 -8
  25. package/dist/definitions/readonly/order-region.js +11 -5
  26. package/dist/definitions/readonly/order-sales-channel.js +11 -5
  27. package/dist/definitions/readonly/store-currency.d.ts +2 -0
  28. package/dist/definitions/readonly/store-currency.js +22 -0
  29. package/dist/definitions/region-payment-provider.js +7 -5
  30. package/dist/definitions/sales-channel-location.js +10 -5
  31. package/dist/definitions/shipping-option-price-set.js +7 -5
  32. package/dist/initialize/index.js +11 -1
  33. package/dist/repositories/link.d.ts +4 -1
  34. package/dist/services/dynamic-service-class.js +7 -0
  35. package/dist/services/link-module-service.js +24 -32
  36. package/package.json +6 -7
  37. package/dist/definitions/readonly/store-default-currency.d.ts +0 -2
  38. package/dist/definitions/readonly/store-default-currency.js +0 -19
@@ -1,36 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CartProduct = void 0;
4
- const modules_sdk_1 = require("@medusajs/modules-sdk");
4
+ const utils_1 = require("@medusajs/utils");
5
5
  exports.CartProduct = {
6
6
  isLink: true,
7
7
  isReadOnlyLink: true,
8
8
  extends: [
9
9
  {
10
- serviceName: modules_sdk_1.Modules.CART,
10
+ serviceName: utils_1.Modules.CART,
11
11
  relationship: {
12
- serviceName: modules_sdk_1.Modules.PRODUCT,
12
+ serviceName: utils_1.Modules.PRODUCT,
13
13
  primaryKey: "id",
14
14
  foreignKey: "items.product_id",
15
15
  alias: "product",
16
+ args: {
17
+ methodSuffix: "Products",
18
+ },
16
19
  },
17
20
  },
18
21
  {
19
- serviceName: modules_sdk_1.Modules.CART,
22
+ serviceName: utils_1.Modules.CART,
20
23
  relationship: {
21
- serviceName: modules_sdk_1.Modules.PRODUCT,
24
+ serviceName: utils_1.Modules.PRODUCT,
22
25
  primaryKey: "id",
23
26
  foreignKey: "items.variant_id",
24
27
  alias: "variant",
25
28
  args: {
26
- methodSuffix: "Variants",
29
+ methodSuffix: "ProductVariants",
27
30
  },
28
31
  },
29
32
  },
30
33
  {
31
- serviceName: modules_sdk_1.Modules.PRODUCT,
34
+ serviceName: utils_1.Modules.PRODUCT,
32
35
  relationship: {
33
- serviceName: modules_sdk_1.Modules.CART,
36
+ serviceName: utils_1.Modules.CART,
34
37
  primaryKey: "variant_id",
35
38
  foreignKey: "id",
36
39
  alias: "cart_items",
@@ -1,27 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CartRegion = void 0;
4
- const modules_sdk_1 = require("@medusajs/modules-sdk");
4
+ const utils_1 = require("@medusajs/utils");
5
5
  exports.CartRegion = {
6
6
  isLink: true,
7
7
  isReadOnlyLink: true,
8
8
  extends: [
9
9
  {
10
- serviceName: modules_sdk_1.Modules.CART,
10
+ serviceName: utils_1.Modules.CART,
11
11
  relationship: {
12
- serviceName: modules_sdk_1.Modules.REGION,
12
+ serviceName: utils_1.Modules.REGION,
13
13
  primaryKey: "id",
14
14
  foreignKey: "region_id",
15
15
  alias: "region",
16
+ args: {
17
+ methodSuffix: "Regions",
18
+ },
16
19
  },
17
20
  },
18
21
  {
19
- serviceName: modules_sdk_1.Modules.REGION,
22
+ serviceName: utils_1.Modules.REGION,
20
23
  relationship: {
21
- serviceName: modules_sdk_1.Modules.CART,
24
+ serviceName: utils_1.Modules.CART,
22
25
  primaryKey: "region_id",
23
26
  foreignKey: "id",
24
27
  alias: "carts",
28
+ args: {
29
+ methodSuffix: "Carts",
30
+ },
25
31
  isList: true,
26
32
  },
27
33
  },
@@ -1,27 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CartSalesChannel = void 0;
4
- const modules_sdk_1 = require("@medusajs/modules-sdk");
4
+ const utils_1 = require("@medusajs/utils");
5
5
  exports.CartSalesChannel = {
6
6
  isLink: true,
7
7
  isReadOnlyLink: true,
8
8
  extends: [
9
9
  {
10
- serviceName: modules_sdk_1.Modules.CART,
10
+ serviceName: utils_1.Modules.CART,
11
11
  relationship: {
12
- serviceName: modules_sdk_1.Modules.SALES_CHANNEL,
12
+ serviceName: utils_1.Modules.SALES_CHANNEL,
13
13
  primaryKey: "id",
14
14
  foreignKey: "sales_channel_id",
15
15
  alias: "sales_channel",
16
+ args: {
17
+ methodSuffix: "SalesChannels",
18
+ },
16
19
  },
17
20
  },
18
21
  {
19
- serviceName: modules_sdk_1.Modules.SALES_CHANNEL,
22
+ serviceName: utils_1.Modules.SALES_CHANNEL,
20
23
  relationship: {
21
- serviceName: modules_sdk_1.Modules.CART,
24
+ serviceName: utils_1.Modules.CART,
22
25
  primaryKey: "sales_channel_id",
23
26
  foreignKey: "id",
24
27
  alias: "carts",
28
+ args: {
29
+ methodSuffix: "Carts",
30
+ },
25
31
  isList: true,
26
32
  },
27
33
  },
@@ -8,4 +8,4 @@ export * from "./order-customer";
8
8
  export * from "./order-product";
9
9
  export * from "./order-region";
10
10
  export * from "./order-sales-channel";
11
- export * from "./store-default-currency";
11
+ export * from "./store-currency";
@@ -24,4 +24,4 @@ __exportStar(require("./order-customer"), exports);
24
24
  __exportStar(require("./order-product"), exports);
25
25
  __exportStar(require("./order-region"), exports);
26
26
  __exportStar(require("./order-sales-channel"), exports);
27
- __exportStar(require("./store-default-currency"), exports);
27
+ __exportStar(require("./store-currency"), exports);
@@ -1,18 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InventoryLevelStockLocation = void 0;
4
- const modules_sdk_1 = require("@medusajs/modules-sdk");
4
+ const utils_1 = require("@medusajs/utils");
5
5
  exports.InventoryLevelStockLocation = {
6
6
  isLink: true,
7
7
  isReadOnlyLink: true,
8
8
  extends: [
9
9
  {
10
- serviceName: modules_sdk_1.Modules.INVENTORY,
10
+ serviceName: utils_1.Modules.INVENTORY,
11
11
  relationship: {
12
- serviceName: modules_sdk_1.Modules.STOCK_LOCATION,
12
+ serviceName: utils_1.Modules.STOCK_LOCATION,
13
13
  primaryKey: "id",
14
14
  foreignKey: "location_id",
15
15
  alias: "stock_locations",
16
+ args: {
17
+ methodSuffix: "StockLocations",
18
+ },
16
19
  isList: true,
17
20
  },
18
21
  },
@@ -1,18 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LineItemAdjustmentPromotion = void 0;
4
- const modules_sdk_1 = require("@medusajs/modules-sdk");
4
+ const utils_1 = require("@medusajs/utils");
5
5
  exports.LineItemAdjustmentPromotion = {
6
6
  isLink: true,
7
7
  isReadOnlyLink: true,
8
8
  extends: [
9
9
  {
10
- serviceName: modules_sdk_1.Modules.CART,
10
+ serviceName: utils_1.Modules.CART,
11
11
  relationship: {
12
- serviceName: modules_sdk_1.Modules.PROMOTION,
12
+ serviceName: utils_1.Modules.PROMOTION,
13
13
  primaryKey: "id",
14
14
  foreignKey: "promotion_id",
15
15
  alias: "promotion",
16
+ args: {
17
+ methodSuffix: "Promotions",
18
+ },
16
19
  },
17
20
  },
18
21
  ],
@@ -1,27 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OrderCustomer = void 0;
4
- const modules_sdk_1 = require("@medusajs/modules-sdk");
4
+ const utils_1 = require("@medusajs/utils");
5
5
  exports.OrderCustomer = {
6
6
  isLink: true,
7
7
  isReadOnlyLink: true,
8
8
  extends: [
9
9
  {
10
- serviceName: modules_sdk_1.Modules.ORDER,
10
+ serviceName: utils_1.Modules.ORDER,
11
11
  relationship: {
12
- serviceName: modules_sdk_1.Modules.CUSTOMER,
12
+ serviceName: utils_1.Modules.CUSTOMER,
13
13
  primaryKey: "id",
14
14
  foreignKey: "customer_id",
15
15
  alias: "customer",
16
+ args: {
17
+ methodSuffix: "Customers",
18
+ },
16
19
  },
17
20
  },
18
21
  {
19
- serviceName: modules_sdk_1.Modules.CUSTOMER,
22
+ serviceName: utils_1.Modules.CUSTOMER,
20
23
  relationship: {
21
- serviceName: modules_sdk_1.Modules.ORDER,
24
+ serviceName: utils_1.Modules.ORDER,
22
25
  primaryKey: "customer_id",
23
26
  foreignKey: "id",
24
27
  alias: "orders",
28
+ args: {
29
+ methodSuffix: "Orders",
30
+ },
25
31
  isList: true,
26
32
  },
27
33
  },
@@ -1,36 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OrderProduct = void 0;
4
- const modules_sdk_1 = require("@medusajs/modules-sdk");
4
+ const utils_1 = require("@medusajs/utils");
5
5
  exports.OrderProduct = {
6
6
  isLink: true,
7
7
  isReadOnlyLink: true,
8
8
  extends: [
9
9
  {
10
- serviceName: modules_sdk_1.Modules.ORDER,
10
+ serviceName: utils_1.Modules.ORDER,
11
11
  relationship: {
12
- serviceName: modules_sdk_1.Modules.PRODUCT,
12
+ serviceName: utils_1.Modules.PRODUCT,
13
13
  primaryKey: "id",
14
14
  foreignKey: "items.product_id",
15
15
  alias: "product",
16
+ args: {
17
+ methodSuffix: "Products",
18
+ },
16
19
  },
17
20
  },
18
21
  {
19
- serviceName: modules_sdk_1.Modules.ORDER,
22
+ serviceName: utils_1.Modules.ORDER,
20
23
  relationship: {
21
- serviceName: modules_sdk_1.Modules.PRODUCT,
24
+ serviceName: utils_1.Modules.PRODUCT,
22
25
  primaryKey: "id",
23
26
  foreignKey: "items.variant_id",
24
27
  alias: "variant",
25
28
  args: {
26
- methodSuffix: "Variants",
29
+ methodSuffix: "ProductVariants",
27
30
  },
28
31
  },
29
32
  },
30
33
  {
31
- serviceName: modules_sdk_1.Modules.PRODUCT,
34
+ serviceName: utils_1.Modules.PRODUCT,
32
35
  relationship: {
33
- serviceName: modules_sdk_1.Modules.ORDER,
36
+ serviceName: utils_1.Modules.ORDER,
34
37
  primaryKey: "variant_id",
35
38
  foreignKey: "id",
36
39
  alias: "order_items",
@@ -1,27 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OrderRegion = void 0;
4
- const modules_sdk_1 = require("@medusajs/modules-sdk");
4
+ const utils_1 = require("@medusajs/utils");
5
5
  exports.OrderRegion = {
6
6
  isLink: true,
7
7
  isReadOnlyLink: true,
8
8
  extends: [
9
9
  {
10
- serviceName: modules_sdk_1.Modules.ORDER,
10
+ serviceName: utils_1.Modules.ORDER,
11
11
  relationship: {
12
- serviceName: modules_sdk_1.Modules.REGION,
12
+ serviceName: utils_1.Modules.REGION,
13
13
  primaryKey: "id",
14
14
  foreignKey: "region_id",
15
15
  alias: "region",
16
+ args: {
17
+ methodSuffix: "Regions",
18
+ },
16
19
  },
17
20
  },
18
21
  {
19
- serviceName: modules_sdk_1.Modules.REGION,
22
+ serviceName: utils_1.Modules.REGION,
20
23
  relationship: {
21
- serviceName: modules_sdk_1.Modules.ORDER,
24
+ serviceName: utils_1.Modules.ORDER,
22
25
  primaryKey: "region_id",
23
26
  foreignKey: "id",
24
27
  alias: "orders",
28
+ args: {
29
+ methodSuffix: "Orders",
30
+ },
25
31
  isList: true,
26
32
  },
27
33
  },
@@ -1,27 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OrderSalesChannel = void 0;
4
- const modules_sdk_1 = require("@medusajs/modules-sdk");
4
+ const utils_1 = require("@medusajs/utils");
5
5
  exports.OrderSalesChannel = {
6
6
  isLink: true,
7
7
  isReadOnlyLink: true,
8
8
  extends: [
9
9
  {
10
- serviceName: modules_sdk_1.Modules.ORDER,
10
+ serviceName: utils_1.Modules.ORDER,
11
11
  relationship: {
12
- serviceName: modules_sdk_1.Modules.SALES_CHANNEL,
12
+ serviceName: utils_1.Modules.SALES_CHANNEL,
13
13
  primaryKey: "id",
14
14
  foreignKey: "sales_channel_id",
15
15
  alias: "sales_channel",
16
+ args: {
17
+ methodSuffix: "SalesChannels",
18
+ },
16
19
  },
17
20
  },
18
21
  {
19
- serviceName: modules_sdk_1.Modules.SALES_CHANNEL,
22
+ serviceName: utils_1.Modules.SALES_CHANNEL,
20
23
  relationship: {
21
- serviceName: modules_sdk_1.Modules.ORDER,
24
+ serviceName: utils_1.Modules.ORDER,
22
25
  primaryKey: "sales_channel_id",
23
26
  foreignKey: "id",
24
27
  alias: "orders",
28
+ args: {
29
+ methodSuffix: "Orders",
30
+ },
25
31
  isList: true,
26
32
  },
27
33
  },
@@ -0,0 +1,2 @@
1
+ import { ModuleJoinerConfig } from "@medusajs/types";
2
+ export declare const StoreCurrencies: ModuleJoinerConfig;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StoreCurrencies = void 0;
4
+ const utils_1 = require("@medusajs/utils");
5
+ exports.StoreCurrencies = {
6
+ isLink: true,
7
+ isReadOnlyLink: true,
8
+ extends: [
9
+ {
10
+ serviceName: utils_1.Modules.STORE,
11
+ relationship: {
12
+ serviceName: utils_1.Modules.CURRENCY,
13
+ primaryKey: "code",
14
+ foreignKey: "supported_currencies.currency_code",
15
+ alias: "currency",
16
+ args: {
17
+ methodSuffix: "Currencies",
18
+ },
19
+ },
20
+ },
21
+ ],
22
+ };
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RegionPaymentProvider = void 0;
4
- const modules_sdk_1 = require("@medusajs/modules-sdk");
5
4
  const utils_1 = require("@medusajs/utils");
6
5
  exports.RegionPaymentProvider = {
7
6
  serviceName: utils_1.LINKS.RegionPaymentProvider,
@@ -21,13 +20,16 @@ exports.RegionPaymentProvider = {
21
20
  primaryKeys: ["id", "region_id", "payment_provider_id"],
22
21
  relationships: [
23
22
  {
24
- serviceName: modules_sdk_1.Modules.REGION,
23
+ serviceName: utils_1.Modules.REGION,
25
24
  primaryKey: "id",
26
25
  foreignKey: "region_id",
27
26
  alias: "region",
27
+ args: {
28
+ methodSuffix: "Regions",
29
+ },
28
30
  },
29
31
  {
30
- serviceName: modules_sdk_1.Modules.PAYMENT,
32
+ serviceName: utils_1.Modules.PAYMENT,
31
33
  primaryKey: "id",
32
34
  foreignKey: "payment_provider_id",
33
35
  alias: "payment_provider",
@@ -36,7 +38,7 @@ exports.RegionPaymentProvider = {
36
38
  ],
37
39
  extends: [
38
40
  {
39
- serviceName: modules_sdk_1.Modules.REGION,
41
+ serviceName: utils_1.Modules.REGION,
40
42
  fieldAlias: {
41
43
  payment_providers: "payment_provider_link.payment_provider",
42
44
  },
@@ -49,7 +51,7 @@ exports.RegionPaymentProvider = {
49
51
  },
50
52
  },
51
53
  {
52
- serviceName: modules_sdk_1.Modules.PAYMENT,
54
+ serviceName: utils_1.Modules.PAYMENT,
53
55
  fieldAlias: {
54
56
  regions: "region_link.region",
55
57
  },
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SalesChannelLocation = void 0;
4
- const modules_sdk_1 = require("@medusajs/modules-sdk");
5
4
  const utils_1 = require("@medusajs/utils");
6
5
  exports.SalesChannelLocation = {
7
6
  serviceName: utils_1.LINKS.SalesChannelLocation,
@@ -21,21 +20,27 @@ exports.SalesChannelLocation = {
21
20
  primaryKeys: ["id", "sales_channel_id", "stock_location_id"],
22
21
  relationships: [
23
22
  {
24
- serviceName: modules_sdk_1.Modules.SALES_CHANNEL,
23
+ serviceName: utils_1.Modules.SALES_CHANNEL,
25
24
  primaryKey: "id",
26
25
  foreignKey: "sales_channel_id",
27
26
  alias: "sales_channel",
27
+ args: {
28
+ methodSuffix: "SalesChannels",
29
+ },
28
30
  },
29
31
  {
30
- serviceName: modules_sdk_1.Modules.STOCK_LOCATION,
32
+ serviceName: utils_1.Modules.STOCK_LOCATION,
31
33
  primaryKey: "id",
32
34
  foreignKey: "stock_location_id",
33
35
  alias: "location",
36
+ args: {
37
+ methodSuffix: "StockLocations",
38
+ },
34
39
  },
35
40
  ],
36
41
  extends: [
37
42
  {
38
- serviceName: modules_sdk_1.Modules.SALES_CHANNEL,
43
+ serviceName: utils_1.Modules.SALES_CHANNEL,
39
44
  fieldAlias: {
40
45
  stock_locations: "locations_link.location",
41
46
  },
@@ -48,7 +53,7 @@ exports.SalesChannelLocation = {
48
53
  },
49
54
  },
50
55
  {
51
- serviceName: modules_sdk_1.Modules.STOCK_LOCATION,
56
+ serviceName: utils_1.Modules.STOCK_LOCATION,
52
57
  fieldAlias: {
53
58
  sales_channels: "sales_channels_link.sales_channel",
54
59
  },
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ShippingOptionPriceSet = void 0;
4
- const modules_sdk_1 = require("@medusajs/modules-sdk");
5
4
  const utils_1 = require("@medusajs/utils");
6
5
  exports.ShippingOptionPriceSet = {
7
6
  serviceName: utils_1.LINKS.ShippingOptionPriceSet,
@@ -21,7 +20,7 @@ exports.ShippingOptionPriceSet = {
21
20
  primaryKeys: ["id", "shipping_option_id", "price_set_id"],
22
21
  relationships: [
23
22
  {
24
- serviceName: modules_sdk_1.Modules.FULFILLMENT,
23
+ serviceName: utils_1.Modules.FULFILLMENT,
25
24
  primaryKey: "id",
26
25
  foreignKey: "shipping_option_id",
27
26
  alias: "shipping_option",
@@ -30,16 +29,19 @@ exports.ShippingOptionPriceSet = {
30
29
  },
31
30
  },
32
31
  {
33
- serviceName: modules_sdk_1.Modules.PRICING,
32
+ serviceName: utils_1.Modules.PRICING,
34
33
  primaryKey: "id",
35
34
  foreignKey: "price_set_id",
36
35
  alias: "price_set",
36
+ args: {
37
+ methodSuffix: "PriceSets",
38
+ },
37
39
  deleteCascade: true,
38
40
  },
39
41
  ],
40
42
  extends: [
41
43
  {
42
- serviceName: modules_sdk_1.Modules.FULFILLMENT,
44
+ serviceName: utils_1.Modules.FULFILLMENT,
43
45
  fieldAlias: {
44
46
  prices: {
45
47
  path: "price_set_link.price_set.prices",
@@ -58,7 +60,7 @@ exports.ShippingOptionPriceSet = {
58
60
  },
59
61
  },
60
62
  {
61
- serviceName: modules_sdk_1.Modules.PRICING,
63
+ serviceName: utils_1.Modules.PRICING,
62
64
  relationship: {
63
65
  serviceName: utils_1.LINKS.ShippingOptionPriceSet,
64
66
  primaryKey: "price_set_id",
@@ -44,6 +44,14 @@ const initialize = async (options, modulesDefinition, injectedDependencies) => {
44
44
  !definition.isReadOnlyLink) {
45
45
  throw new Error(`Foreign key cannot be a composed key.`);
46
46
  }
47
+ if (Array.isArray(definition.extraDataFields)) {
48
+ const extraDataFields = definition.extraDataFields;
49
+ const definedDbFields = Object.keys(definition.databaseConfig?.extraFields || {});
50
+ const difference = (0, utils_1.arrayDifference)(extraDataFields, definedDbFields);
51
+ if (difference.length) {
52
+ throw new Error(`extraDataFields (fieldNames: ${difference.join(",")}) need to be configured under databaseConfig (serviceName: ${definition.serviceName}).`);
53
+ }
54
+ }
47
55
  const serviceKey = !definition.isReadOnlyLink
48
56
  ? (0, utils_1.lowerCaseFirst)(definition.serviceName ??
49
57
  (0, utils_2.composeLinkName)(primary.serviceName, primary.foreignKey, foreign.serviceName, foreign.foreignKey))
@@ -75,7 +83,9 @@ const initialize = async (options, modulesDefinition, injectedDependencies) => {
75
83
  definition.schema = (0, utils_2.generateGraphQLSchema)(definition, primary, foreign, {
76
84
  logger,
77
85
  });
78
- definition.alias ??= [];
86
+ if (!Array.isArray(definition.alias)) {
87
+ definition.alias = definition.alias ? [definition.alias] : [];
88
+ }
79
89
  for (const alias of definition.alias) {
80
90
  alias.args ??= {};
81
91
  alias.args.entity = (0, utils_1.toPascalCase)("Link_" +
@@ -14,7 +14,10 @@ export declare function getLinkRepository(model: EntitySchema): {
14
14
  find(options?: import("@medusajs/types").FindOptions<object> | undefined, context?: Context | undefined): Promise<object[]>;
15
15
  findAndCount(options?: import("@medusajs/types").FindOptions<object> | undefined, context?: Context | undefined): Promise<[object[], number]>;
16
16
  upsert(data: unknown[], context?: Context | undefined): Promise<object[]>;
17
- upsertWithReplace(data: unknown[], config?: import("@medusajs/types").UpsertWithReplaceConfig<object> | undefined, context?: Context | undefined): Promise<object[]>;
17
+ upsertWithReplace(data: unknown[], config?: import("@medusajs/types").UpsertWithReplaceConfig<object> | undefined, context?: Context | undefined): Promise<{
18
+ entities: object[];
19
+ performedActions: import("@medusajs/types").PerformedActions;
20
+ }>;
18
21
  softDelete(filters: string | string[] | (object & import("@medusajs/types").BaseFilterable<object>) | (object & import("@medusajs/types").BaseFilterable<object>)[], sharedContext?: Context | undefined): Promise<[object[], Record<string, unknown[]>]>;
19
22
  restore(idsOrFilter: string[] | {
20
23
  [x: string]: any;
@@ -1,10 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getReadOnlyModuleService = exports.getModuleService = void 0;
4
+ const utils_1 = require("@medusajs/utils");
4
5
  const _services_1 = require(".");
5
6
  function getModuleService(joinerConfig) {
6
7
  const joinerConfig_ = JSON.parse(JSON.stringify(joinerConfig));
8
+ const databaseConfig = joinerConfig_.databaseConfig;
7
9
  delete joinerConfig_.databaseConfig;
10
+ // If extraDataFields is not defined, pick the fields to populate and validate from the
11
+ // database config if any fields are provided.
12
+ if (!(0, utils_1.isDefined)(joinerConfig_.extraDataFields)) {
13
+ joinerConfig_.extraDataFields = Object.keys(databaseConfig.extraFields || {});
14
+ }
8
15
  return class LinkService extends _services_1.LinkModuleService {
9
16
  __joinerConfig() {
10
17
  return joinerConfig_;