@medusajs/link-modules 0.2.12-snapshot-20240718083016 → 0.2.12-snapshot-20240719133408

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. package/dist/definitions/cart-payment-collection.d.ts +1 -0
  2. package/dist/definitions/cart-payment-collection.d.ts.map +1 -0
  3. package/dist/definitions/cart-payment-collection.js +10 -5
  4. package/dist/definitions/cart-promotion.d.ts +1 -0
  5. package/dist/definitions/cart-promotion.d.ts.map +1 -0
  6. package/dist/definitions/cart-promotion.js +14 -14
  7. package/dist/definitions/fulfillment-set-location.d.ts +2 -1
  8. package/dist/definitions/fulfillment-set-location.d.ts.map +1 -0
  9. package/dist/definitions/fulfillment-set-location.js +35 -30
  10. package/dist/definitions/index.d.ts +5 -9
  11. package/dist/definitions/index.d.ts.map +1 -0
  12. package/dist/definitions/index.js +4 -9
  13. package/dist/definitions/order-cart.d.ts +3 -0
  14. package/dist/definitions/order-cart.d.ts.map +1 -0
  15. package/dist/definitions/order-cart.js +67 -0
  16. package/dist/definitions/order-claim-payment-collection.d.ts +3 -0
  17. package/dist/definitions/order-claim-payment-collection.d.ts.map +1 -0
  18. package/dist/definitions/order-claim-payment-collection.js +73 -0
  19. package/dist/definitions/order-exchange-payment-collection.d.ts +3 -0
  20. package/dist/definitions/order-exchange-payment-collection.d.ts.map +1 -0
  21. package/dist/definitions/order-exchange-payment-collection.js +73 -0
  22. package/dist/definitions/order-fulfillment.d.ts +3 -0
  23. package/dist/definitions/order-fulfillment.d.ts.map +1 -0
  24. package/dist/definitions/order-fulfillment.js +66 -0
  25. package/dist/definitions/order-payment-collection.d.ts +3 -0
  26. package/dist/definitions/order-payment-collection.d.ts.map +1 -0
  27. package/dist/definitions/order-payment-collection.js +70 -0
  28. package/dist/definitions/order-promotion.d.ts +1 -0
  29. package/dist/definitions/order-promotion.d.ts.map +1 -0
  30. package/dist/definitions/order-promotion.js +15 -7
  31. package/dist/definitions/product-sales-channel.d.ts +1 -0
  32. package/dist/definitions/product-sales-channel.d.ts.map +1 -0
  33. package/dist/definitions/product-sales-channel.js +10 -7
  34. package/dist/definitions/product-variant-inventory-item.d.ts +1 -0
  35. package/dist/definitions/product-variant-inventory-item.d.ts.map +1 -0
  36. package/dist/definitions/product-variant-inventory-item.js +13 -7
  37. package/dist/definitions/product-variant-price-set.d.ts +1 -0
  38. package/dist/definitions/product-variant-price-set.d.ts.map +1 -0
  39. package/dist/definitions/product-variant-price-set.js +9 -8
  40. package/dist/definitions/publishable-api-key-sales-channel.d.ts +1 -0
  41. package/dist/definitions/publishable-api-key-sales-channel.d.ts.map +1 -0
  42. package/dist/definitions/publishable-api-key-sales-channel.js +10 -5
  43. package/dist/definitions/{cart-customer.d.ts → readonly/cart-customer.d.ts} +1 -0
  44. package/dist/definitions/readonly/cart-customer.d.ts.map +1 -0
  45. package/dist/definitions/{cart-customer.js → readonly/cart-customer.js} +11 -5
  46. package/dist/definitions/readonly/cart-product.d.ts +3 -0
  47. package/dist/definitions/readonly/cart-product.d.ts.map +1 -0
  48. package/dist/definitions/readonly/cart-product.js +47 -0
  49. package/dist/definitions/{cart-region.d.ts → readonly/cart-region.d.ts} +1 -0
  50. package/dist/definitions/readonly/cart-region.d.ts.map +1 -0
  51. package/dist/definitions/{cart-region.js → readonly/cart-region.js} +11 -5
  52. package/dist/definitions/{cart-sales-channel.d.ts → readonly/cart-sales-channel.d.ts} +1 -0
  53. package/dist/definitions/readonly/cart-sales-channel.d.ts.map +1 -0
  54. package/dist/definitions/{cart-sales-channel.js → readonly/cart-sales-channel.js} +11 -5
  55. package/dist/definitions/readonly/index.d.ts +12 -0
  56. package/dist/definitions/readonly/index.d.ts.map +1 -0
  57. package/dist/definitions/readonly/index.js +27 -0
  58. package/dist/definitions/{inventory-level-stock-location.d.ts → readonly/inventory-level-stock-location.d.ts} +1 -0
  59. package/dist/definitions/readonly/inventory-level-stock-location.d.ts.map +1 -0
  60. package/dist/definitions/{inventory-level-stock-location.js → readonly/inventory-level-stock-location.js} +6 -3
  61. package/dist/definitions/readonly/line-item-adjustment-promotion.d.ts +3 -0
  62. package/dist/definitions/readonly/line-item-adjustment-promotion.d.ts.map +1 -0
  63. package/dist/definitions/readonly/line-item-adjustment-promotion.js +22 -0
  64. package/dist/definitions/{order-customer.d.ts → readonly/order-customer.d.ts} +1 -0
  65. package/dist/definitions/readonly/order-customer.d.ts.map +1 -0
  66. package/dist/definitions/{order-customer.js → readonly/order-customer.js} +11 -5
  67. package/dist/definitions/readonly/order-product.d.ts +3 -0
  68. package/dist/definitions/readonly/order-product.d.ts.map +1 -0
  69. package/dist/definitions/readonly/order-product.js +47 -0
  70. package/dist/definitions/{order-region.d.ts → readonly/order-region.d.ts} +1 -0
  71. package/dist/definitions/readonly/order-region.d.ts.map +1 -0
  72. package/dist/definitions/{order-region.js → readonly/order-region.js} +11 -5
  73. package/dist/definitions/{order-sales-channel.d.ts → readonly/order-sales-channel.d.ts} +1 -0
  74. package/dist/definitions/readonly/order-sales-channel.d.ts.map +1 -0
  75. package/dist/definitions/readonly/order-sales-channel.js +35 -0
  76. package/dist/definitions/readonly/store-currency.d.ts +3 -0
  77. package/dist/definitions/readonly/store-currency.d.ts.map +1 -0
  78. package/dist/definitions/readonly/store-currency.js +22 -0
  79. package/dist/definitions/region-payment-provider.d.ts +1 -0
  80. package/dist/definitions/region-payment-provider.d.ts.map +1 -0
  81. package/dist/definitions/region-payment-provider.js +7 -5
  82. package/dist/definitions/sales-channel-location.d.ts +1 -0
  83. package/dist/definitions/sales-channel-location.d.ts.map +1 -0
  84. package/dist/definitions/sales-channel-location.js +10 -5
  85. package/dist/definitions/shipping-option-price-set.d.ts +1 -0
  86. package/dist/definitions/shipping-option-price-set.d.ts.map +1 -0
  87. package/dist/definitions/shipping-option-price-set.js +7 -5
  88. package/dist/index.d.ts +1 -0
  89. package/dist/index.d.ts.map +1 -0
  90. package/dist/initialize/index.d.ts +2 -0
  91. package/dist/initialize/index.d.ts.map +1 -0
  92. package/dist/initialize/index.js +30 -14
  93. package/dist/initialize/module-definition.d.ts +1 -0
  94. package/dist/initialize/module-definition.d.ts.map +1 -0
  95. package/dist/loaders/connection.d.ts +1 -0
  96. package/dist/loaders/connection.d.ts.map +1 -0
  97. package/dist/loaders/container.d.ts +1 -0
  98. package/dist/loaders/container.d.ts.map +1 -0
  99. package/dist/loaders/index.d.ts +1 -0
  100. package/dist/loaders/index.d.ts.map +1 -0
  101. package/dist/migration/index.d.ts +2 -0
  102. package/dist/migration/index.d.ts.map +1 -0
  103. package/dist/migration/index.js +31 -7
  104. package/dist/repositories/index.d.ts +1 -0
  105. package/dist/repositories/index.d.ts.map +1 -0
  106. package/dist/repositories/link.d.ts +6 -4
  107. package/dist/repositories/link.d.ts.map +1 -0
  108. package/dist/services/dynamic-service-class.d.ts +1 -0
  109. package/dist/services/dynamic-service-class.d.ts.map +1 -0
  110. package/dist/services/dynamic-service-class.js +7 -0
  111. package/dist/services/index.d.ts +1 -0
  112. package/dist/services/index.d.ts.map +1 -0
  113. package/dist/services/link-module-service.d.ts +1 -0
  114. package/dist/services/link-module-service.d.ts.map +1 -0
  115. package/dist/services/link-module-service.js +28 -36
  116. package/dist/services/link.d.ts +1 -0
  117. package/dist/services/link.d.ts.map +1 -0
  118. package/dist/types/index.d.ts +1 -0
  119. package/dist/types/index.d.ts.map +1 -0
  120. package/dist/utils/compose-link-name.d.ts +1 -0
  121. package/dist/utils/compose-link-name.d.ts.map +1 -0
  122. package/dist/utils/generate-entity.d.ts +1 -0
  123. package/dist/utils/generate-entity.d.ts.map +1 -0
  124. package/dist/utils/generate-schema.d.ts +1 -0
  125. package/dist/utils/generate-schema.d.ts.map +1 -0
  126. package/dist/utils/generate-schema.js +5 -4
  127. package/dist/utils/index.d.ts +1 -0
  128. package/dist/utils/index.d.ts.map +1 -0
  129. package/dist/utils/index.js +2 -2
  130. package/package.json +6 -7
  131. package/dist/definitions/order-sales-channel.js +0 -67
  132. package/dist/definitions/product-shipping-profile.d.ts +0 -2
  133. package/dist/definitions/product-shipping-profile.js +0 -61
  134. package/dist/definitions/store-default-currency.d.ts +0 -2
  135. package/dist/definitions/store-default-currency.js +0 -19
@@ -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
  },
@@ -0,0 +1,3 @@
1
+ import { ModuleJoinerConfig } from "@medusajs/types";
2
+ export declare const LineItemAdjustmentPromotion: ModuleJoinerConfig;
3
+ //# sourceMappingURL=line-item-adjustment-promotion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"line-item-adjustment-promotion.d.ts","sourceRoot":"","sources":["../../../src/definitions/readonly/line-item-adjustment-promotion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAGpD,eAAO,MAAM,2BAA2B,EAAE,kBAiBzC,CAAA"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LineItemAdjustmentPromotion = void 0;
4
+ const utils_1 = require("@medusajs/utils");
5
+ exports.LineItemAdjustmentPromotion = {
6
+ isLink: true,
7
+ isReadOnlyLink: true,
8
+ extends: [
9
+ {
10
+ serviceName: utils_1.Modules.CART,
11
+ relationship: {
12
+ serviceName: utils_1.Modules.PROMOTION,
13
+ primaryKey: "id",
14
+ foreignKey: "promotion_id",
15
+ alias: "promotion",
16
+ args: {
17
+ methodSuffix: "Promotions",
18
+ },
19
+ },
20
+ },
21
+ ],
22
+ };
@@ -1,2 +1,3 @@
1
1
  import { ModuleJoinerConfig } from "@medusajs/types";
2
2
  export declare const OrderCustomer: ModuleJoinerConfig;
3
+ //# sourceMappingURL=order-customer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"order-customer.d.ts","sourceRoot":"","sources":["../../../src/definitions/readonly/order-customer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAGpD,eAAO,MAAM,aAAa,EAAE,kBA8B3B,CAAA"}
@@ -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
  },
@@ -0,0 +1,3 @@
1
+ import { ModuleJoinerConfig } from "@medusajs/types";
2
+ export declare const OrderProduct: ModuleJoinerConfig;
3
+ //# sourceMappingURL=order-product.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"order-product.d.ts","sourceRoot":"","sources":["../../../src/definitions/readonly/order-product.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAGpD,eAAO,MAAM,YAAY,EAAE,kBA0C1B,CAAA"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrderProduct = void 0;
4
+ const utils_1 = require("@medusajs/utils");
5
+ exports.OrderProduct = {
6
+ isLink: true,
7
+ isReadOnlyLink: true,
8
+ extends: [
9
+ {
10
+ serviceName: utils_1.Modules.ORDER,
11
+ relationship: {
12
+ serviceName: utils_1.Modules.PRODUCT,
13
+ primaryKey: "id",
14
+ foreignKey: "items.product_id",
15
+ alias: "product",
16
+ args: {
17
+ methodSuffix: "Products",
18
+ },
19
+ },
20
+ },
21
+ {
22
+ serviceName: utils_1.Modules.ORDER,
23
+ relationship: {
24
+ serviceName: utils_1.Modules.PRODUCT,
25
+ primaryKey: "id",
26
+ foreignKey: "items.variant_id",
27
+ alias: "variant",
28
+ args: {
29
+ methodSuffix: "ProductVariants",
30
+ },
31
+ },
32
+ },
33
+ {
34
+ serviceName: utils_1.Modules.PRODUCT,
35
+ relationship: {
36
+ serviceName: utils_1.Modules.ORDER,
37
+ primaryKey: "variant_id",
38
+ foreignKey: "id",
39
+ alias: "order_items",
40
+ isList: true,
41
+ args: {
42
+ methodSuffix: "LineItems",
43
+ },
44
+ },
45
+ },
46
+ ],
47
+ };
@@ -1,2 +1,3 @@
1
1
  import { ModuleJoinerConfig } from "@medusajs/types";
2
2
  export declare const OrderRegion: ModuleJoinerConfig;
3
+ //# sourceMappingURL=order-region.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"order-region.d.ts","sourceRoot":"","sources":["../../../src/definitions/readonly/order-region.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAGpD,eAAO,MAAM,WAAW,EAAE,kBA8BzB,CAAA"}
@@ -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,2 +1,3 @@
1
1
  import { ModuleJoinerConfig } from "@medusajs/types";
2
2
  export declare const OrderSalesChannel: ModuleJoinerConfig;
3
+ //# sourceMappingURL=order-sales-channel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"order-sales-channel.d.ts","sourceRoot":"","sources":["../../../src/definitions/readonly/order-sales-channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAGpD,eAAO,MAAM,iBAAiB,EAAE,kBA8B/B,CAAA"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrderSalesChannel = void 0;
4
+ const utils_1 = require("@medusajs/utils");
5
+ exports.OrderSalesChannel = {
6
+ isLink: true,
7
+ isReadOnlyLink: true,
8
+ extends: [
9
+ {
10
+ serviceName: utils_1.Modules.ORDER,
11
+ relationship: {
12
+ serviceName: utils_1.Modules.SALES_CHANNEL,
13
+ primaryKey: "id",
14
+ foreignKey: "sales_channel_id",
15
+ alias: "sales_channel",
16
+ args: {
17
+ methodSuffix: "SalesChannels",
18
+ },
19
+ },
20
+ },
21
+ {
22
+ serviceName: utils_1.Modules.SALES_CHANNEL,
23
+ relationship: {
24
+ serviceName: utils_1.Modules.ORDER,
25
+ primaryKey: "sales_channel_id",
26
+ foreignKey: "id",
27
+ alias: "orders",
28
+ args: {
29
+ methodSuffix: "Orders",
30
+ },
31
+ isList: true,
32
+ },
33
+ },
34
+ ],
35
+ };
@@ -0,0 +1,3 @@
1
+ import { ModuleJoinerConfig } from "@medusajs/types";
2
+ export declare const StoreCurrencies: ModuleJoinerConfig;
3
+ //# sourceMappingURL=store-currency.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-currency.d.ts","sourceRoot":"","sources":["../../../src/definitions/readonly/store-currency.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAGpD,eAAO,MAAM,eAAe,EAAE,kBAiB7B,CAAA"}
@@ -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,2 +1,3 @@
1
1
  import { ModuleJoinerConfig } from "@medusajs/types";
2
2
  export declare const RegionPaymentProvider: ModuleJoinerConfig;
3
+ //# sourceMappingURL=region-payment-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"region-payment-provider.d.ts","sourceRoot":"","sources":["../../src/definitions/region-payment-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAGpD,eAAO,MAAM,qBAAqB,EAAE,kBA8DnC,CAAA"}
@@ -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,2 +1,3 @@
1
1
  import { ModuleJoinerConfig } from "@medusajs/types";
2
2
  export declare const SalesChannelLocation: ModuleJoinerConfig;
3
+ //# sourceMappingURL=sales-channel-location.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sales-channel-location.d.ts","sourceRoot":"","sources":["../../src/definitions/sales-channel-location.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAGpD,eAAO,MAAM,oBAAoB,EAAE,kBAgElC,CAAA"}
@@ -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,2 +1,3 @@
1
1
  import { ModuleJoinerConfig } from "@medusajs/types";
2
2
  export declare const ShippingOptionPriceSet: ModuleJoinerConfig;
3
+ //# sourceMappingURL=shipping-option-price-set.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shipping-option-price-set.d.ts","sourceRoot":"","sources":["../../src/definitions/shipping-option-price-set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAGpD,eAAO,MAAM,sBAAsB,EAAE,kBAsEpC,CAAA"}
@@ -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",
package/dist/index.d.ts CHANGED
@@ -3,3 +3,4 @@ export * from "./types";
3
3
  export * from "./loaders";
4
4
  export * from "./services";
5
5
  export * from "./utils/compose-link-name";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,2BAA2B,CAAA"}
@@ -5,3 +5,5 @@ export declare const initialize: (options?: ModuleServiceInitializeOptions | Mod
5
5
  [link: string]: ILinkModule;
6
6
  }>;
7
7
  export declare function runMigrations({ options, logger, }: Omit<LoaderOptions<ModuleServiceInitializeOptions>, "container">, modulesDefinition?: ModuleJoinerConfig[]): Promise<void>;
8
+ export declare function revertMigrations({ options, logger, }: Omit<LoaderOptions<ModuleServiceInitializeOptions>, "container">, modulesDefinition?: ModuleJoinerConfig[]): Promise<void>;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/initialize/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EAI1B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,yBAAyB,EACzB,WAAW,EAEX,aAAa,EAEb,kBAAkB,EAClB,6CAA6C,EAC7C,8BAA8B,EAC/B,MAAM,iBAAiB,CAAA;AAWxB,OAAO,EAAE,sCAAsC,EAAE,MAAM,UAAU,CAAA;AAQjE,eAAO,MAAM,UAAU,aAEjB,8BAA8B,GAC9B,6CAA6C,GAC7C,yBAAyB,GACzB,yBAAyB,sBACT,kBAAkB,EAAE,yBACjB,sCAAsC,KAC5D,QAAQ;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAA;CAAE,CAgJzC,CAAA;AA6DD,wBAAsB,aAAa,CACjC,EACE,OAAO,EACP,MAAM,GACP,EAAE,IAAI,CAAC,aAAa,CAAC,8BAA8B,CAAC,EAAE,WAAW,CAAC,EACnE,iBAAiB,CAAC,EAAE,kBAAkB,EAAE,iBAGzC;AAED,wBAAsB,gBAAgB,CACpC,EACE,OAAO,EACP,MAAM,GACP,EAAE,IAAI,CAAC,aAAa,CAAC,8BAA8B,CAAC,EAAE,WAAW,CAAC,EACnE,iBAAiB,CAAC,EAAE,kBAAkB,EAAE,iBAGzC"}
@@ -23,9 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.runMigrations = exports.initialize = void 0;
26
+ exports.revertMigrations = exports.runMigrations = exports.initialize = void 0;
27
27
  const modules_sdk_1 = require("@medusajs/modules-sdk");
28
- const types_1 = require("@medusajs/types");
29
28
  const utils_1 = require("@medusajs/utils");
30
29
  const linkDefinitions = __importStar(require("../definitions"));
31
30
  const migration_1 = require("../migration");
@@ -45,6 +44,14 @@ const initialize = async (options, modulesDefinition, injectedDependencies) => {
45
44
  !definition.isReadOnlyLink) {
46
45
  throw new Error(`Foreign key cannot be a composed key.`);
47
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
+ }
48
55
  const serviceKey = !definition.isReadOnlyLink
49
56
  ? (0, utils_1.lowerCaseFirst)(definition.serviceName ??
50
57
  (0, utils_2.composeLinkName)(primary.serviceName, primary.foreignKey, foreign.serviceName, foreign.foreignKey))
@@ -68,19 +75,19 @@ const initialize = async (options, modulesDefinition, injectedDependencies) => {
68
75
  continue;
69
76
  }
70
77
  }
71
- else if ((!primary.isInternalService &&
72
- !modulesLoadedKeys.includes(primary.serviceName)) ||
73
- (!foreign.isInternalService &&
74
- !modulesLoadedKeys.includes(foreign.serviceName))) {
78
+ else if (!modulesLoadedKeys.includes(primary.serviceName) ||
79
+ !modulesLoadedKeys.includes(foreign.serviceName)) {
75
80
  continue;
76
81
  }
77
82
  const logger = injectedDependencies?.[utils_1.ContainerRegistrationKeys.LOGGER] ?? console;
78
83
  definition.schema = (0, utils_2.generateGraphQLSchema)(definition, primary, foreign, {
79
84
  logger,
80
85
  });
81
- definition.alias ?? (definition.alias = []);
86
+ if (!Array.isArray(definition.alias)) {
87
+ definition.alias = definition.alias ? [definition.alias] : [];
88
+ }
82
89
  for (const alias of definition.alias) {
83
- alias.args ?? (alias.args = {});
90
+ alias.args ??= {};
84
91
  alias.args.entity = (0, utils_1.toPascalCase)("Link_" +
85
92
  (definition.databaseConfig?.tableName ??
86
93
  (0, utils_2.composeTableName)(primary.serviceName, primary.foreignKey, foreign.serviceName, foreign.foreignKey)));
@@ -90,12 +97,12 @@ const initialize = async (options, modulesDefinition, injectedDependencies) => {
90
97
  key: serviceKey,
91
98
  registrationName: serviceKey,
92
99
  label: serviceKey,
93
- dependencies: [modules_sdk_1.ModuleRegistrationName.EVENT_BUS],
100
+ dependencies: [utils_1.ModuleRegistrationName.EVENT_BUS],
94
101
  defaultModuleDeclaration: {
95
- scope: types_1.MODULE_SCOPE.INTERNAL,
102
+ scope: modules_sdk_1.MODULE_SCOPE.INTERNAL,
96
103
  resources: injectedDependencies?.[utils_1.ContainerRegistrationKeys.PG_CONNECTION]
97
- ? types_1.MODULE_RESOURCE_TYPE.SHARED
98
- : types_1.MODULE_RESOURCE_TYPE.ISOLATED,
104
+ ? modules_sdk_1.MODULE_RESOURCE_TYPE.SHARED
105
+ : modules_sdk_1.MODULE_RESOURCE_TYPE.ISOLATED,
99
106
  },
100
107
  };
101
108
  const loaded = await modules_sdk_1.MedusaModule.bootstrapLink({
@@ -109,7 +116,7 @@ const initialize = async (options, modulesDefinition, injectedDependencies) => {
109
116
  return allLinks;
110
117
  };
111
118
  exports.initialize = initialize;
112
- async function runMigrations({ options, logger, }, modulesDefinition) {
119
+ async function applyMigrationUpOrDown({ options, logger, }, modulesDefinition, revert = false) {
113
120
  const modulesLoadedKeys = modules_sdk_1.MedusaModule.getLoadedModules().map((mod) => Object.keys(mod)[0]);
114
121
  const allLinksToLoad = Object.values(linkDefinitions).concat(modulesDefinition ?? []);
115
122
  const allLinks = new Set();
@@ -131,8 +138,17 @@ async function runMigrations({ options, logger, }, modulesDefinition) {
131
138
  !modulesLoadedKeys.includes(foreign.serviceName)) {
132
139
  continue;
133
140
  }
134
- const migrate = (0, migration_1.getMigration)(definition, serviceKey, primary, foreign);
141
+ const migrate = revert
142
+ ? (0, migration_1.getRevertMigration)(definition, serviceKey, primary, foreign)
143
+ : (0, migration_1.getMigration)(definition, serviceKey, primary, foreign);
135
144
  await migrate({ options, logger });
136
145
  }
137
146
  }
147
+ async function runMigrations({ options, logger, }, modulesDefinition) {
148
+ await applyMigrationUpOrDown({ options, logger }, modulesDefinition);
149
+ }
138
150
  exports.runMigrations = runMigrations;
151
+ async function revertMigrations({ options, logger, }, modulesDefinition) {
152
+ await applyMigrationUpOrDown({ options, logger }, modulesDefinition, true);
153
+ }
154
+ exports.revertMigrations = revertMigrations;
@@ -1,2 +1,3 @@
1
1
  import { JoinerRelationship, ModuleExports, ModuleJoinerConfig } from "@medusajs/types";
2
2
  export declare function getLinkModuleDefinition(joinerConfig: ModuleJoinerConfig, primary: JoinerRelationship, foreign: JoinerRelationship): ModuleExports;
3
+ //# sourceMappingURL=module-definition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-definition.d.ts","sourceRoot":"","sources":["../../src/initialize/module-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EACnB,MAAM,iBAAiB,CAAA;AAIxB,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,kBAAkB,EAChC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,kBAAkB,GAC1B,aAAa,CAWf"}
@@ -1,3 +1,4 @@
1
1
  import { InternalModuleDeclaration, LoaderOptions, ModuleServiceInitializeCustomDataLayerOptions, ModuleServiceInitializeOptions } from "@medusajs/modules-sdk";
2
2
  import { EntitySchema } from "@mikro-orm/core";
3
3
  export declare function connectionLoader(entity: EntitySchema): ({ options, container, logger, }: LoaderOptions<ModuleServiceInitializeOptions | ModuleServiceInitializeCustomDataLayerOptions>, moduleDeclaration?: InternalModuleDeclaration) => Promise<void>;
4
+ //# sourceMappingURL=connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/loaders/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,aAAa,EACb,6CAA6C,EAC7C,8BAA8B,EAC/B,MAAM,uBAAuB,CAAA;AAG9B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,qCAM9C,cACC,8BAA8B,GAC9B,6CAA6C,CAChD,sBACmB,yBAAyB,KAC5C,QAAQ,IAAI,CAAC,CAajB"}
@@ -1,3 +1,4 @@
1
1
  import { LoaderOptions } from "@medusajs/modules-sdk";
2
2
  import { InternalModuleDeclaration, ModuleJoinerConfig, ModulesSdkTypes } from "@medusajs/types";
3
3
  export declare function containerLoader(entity: any, joinerConfig: ModuleJoinerConfig): ({ options, container, }: LoaderOptions<ModulesSdkTypes.ModuleServiceInitializeOptions | ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions>, moduleDeclaration?: InternalModuleDeclaration) => Promise<void>;
4
+ //# sourceMappingURL=container.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/loaders/container.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,eAAe,EAChB,MAAM,iBAAiB,CAAA;AAKxB,wBAAgB,eAAe,CAAC,MAAM,KAAA,EAAE,YAAY,EAAE,kBAAkB,6BAKjE,cACC,gBAAgB,8BAA8B,GAC9C,gBAAgB,6CAA6C,CAChE,sBACmB,yBAAyB,KAC5C,QAAQ,IAAI,CAAC,CA2CjB"}
@@ -4,3 +4,4 @@ export declare function getLoaders({ joinerConfig, primary, foreign, }: {
4
4
  primary: JoinerRelationship;
5
5
  foreign: JoinerRelationship;
6
6
  }): ModuleLoaderFunction[];
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/loaders/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,iBAAiB,CAAA;AAMxB,wBAAgB,UAAU,CAAC,EACzB,YAAY,EACZ,OAAO,EACP,OAAO,GACR,EAAE;IACD,YAAY,EAAE,kBAAkB,CAAA;IAChC,OAAO,EAAE,kBAAkB,CAAA;IAC3B,OAAO,EAAE,kBAAkB,CAAA;CAC5B,GAAG,oBAAoB,EAAE,CAOzB"}
@@ -1,2 +1,4 @@
1
1
  import { JoinerRelationship, LoaderOptions, ModuleJoinerConfig, ModuleServiceInitializeOptions } from "@medusajs/types";
2
2
  export declare function getMigration(joinerConfig: ModuleJoinerConfig, serviceName: string, primary: JoinerRelationship, foreign: JoinerRelationship): ({ options, logger, }?: Pick<LoaderOptions<ModuleServiceInitializeOptions>, "options" | "logger">) => Promise<void>;
3
+ export declare function getRevertMigration(joinerConfig: ModuleJoinerConfig, serviceName: string, primary: JoinerRelationship, foreign: JoinerRelationship): ({ options, logger, }?: Pick<LoaderOptions<ModuleServiceInitializeOptions>, "options" | "logger">) => Promise<void>;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,aAAa,EAEb,kBAAkB,EAClB,8BAA8B,EAC/B,MAAM,iBAAiB,CAAA;AAKxB,wBAAgB,YAAY,CAC1B,YAAY,EAAE,kBAAkB,EAChC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,kBAAkB,2BAMtB,KACD,cAAc,8BAA8B,CAAC,EAC7C,SAAS,GAAG,QAAQ,CACrB,mBAkEJ;AAED,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,kBAAkB,EAChC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,kBAAkB,2BAMtB,KACD,cAAc,8BAA8B,CAAC,EAC7C,SAAS,GAAG,QAAQ,CACrB,mBA4BJ"}