@medusajs/link-modules 0.2.12 → 1.0.0-rc-20241003153304

Sign up to get free protection for your applications and to get access to all the features.
Files changed (212) hide show
  1. package/dist/definitions/cart-payment-collection.d.ts +2 -1
  2. package/dist/definitions/cart-payment-collection.d.ts.map +1 -0
  3. package/dist/definitions/cart-payment-collection.js +15 -9
  4. package/dist/definitions/cart-payment-collection.js.map +1 -0
  5. package/dist/definitions/cart-promotion.d.ts +2 -1
  6. package/dist/definitions/cart-promotion.d.ts.map +1 -0
  7. package/dist/definitions/cart-promotion.js +22 -18
  8. package/dist/definitions/cart-promotion.js.map +1 -0
  9. package/dist/definitions/fulfillment-provider-location.d.ts +3 -0
  10. package/dist/definitions/fulfillment-provider-location.d.ts.map +1 -0
  11. package/dist/definitions/fulfillment-provider-location.js +72 -0
  12. package/dist/definitions/fulfillment-provider-location.js.map +1 -0
  13. package/dist/definitions/fulfillment-set-location.d.ts +3 -2
  14. package/dist/definitions/fulfillment-set-location.d.ts.map +1 -0
  15. package/dist/definitions/fulfillment-set-location.js +42 -33
  16. package/dist/definitions/fulfillment-set-location.js.map +1 -0
  17. package/dist/definitions/index.d.ts +7 -9
  18. package/dist/definitions/index.d.ts.map +1 -0
  19. package/dist/definitions/index.js +7 -9
  20. package/dist/definitions/index.js.map +1 -0
  21. package/dist/definitions/order-cart.d.ts +3 -0
  22. package/dist/definitions/order-cart.d.ts.map +1 -0
  23. package/dist/definitions/order-cart.js +68 -0
  24. package/dist/definitions/order-cart.js.map +1 -0
  25. package/dist/definitions/order-claim-payment-collection.d.ts +3 -0
  26. package/dist/definitions/order-claim-payment-collection.d.ts.map +1 -0
  27. package/dist/definitions/order-claim-payment-collection.js +74 -0
  28. package/dist/definitions/order-claim-payment-collection.js.map +1 -0
  29. package/dist/definitions/order-exchange-payment-collection.d.ts +3 -0
  30. package/dist/definitions/order-exchange-payment-collection.d.ts.map +1 -0
  31. package/dist/definitions/order-exchange-payment-collection.js +74 -0
  32. package/dist/definitions/order-exchange-payment-collection.js.map +1 -0
  33. package/dist/definitions/order-fulfillment.d.ts +3 -0
  34. package/dist/definitions/order-fulfillment.d.ts.map +1 -0
  35. package/dist/definitions/order-fulfillment.js +72 -0
  36. package/dist/definitions/order-fulfillment.js.map +1 -0
  37. package/dist/definitions/order-payment-collection.d.ts +3 -0
  38. package/dist/definitions/order-payment-collection.d.ts.map +1 -0
  39. package/dist/definitions/order-payment-collection.js +72 -0
  40. package/dist/definitions/order-payment-collection.js.map +1 -0
  41. package/dist/definitions/order-promotion.d.ts +2 -1
  42. package/dist/definitions/order-promotion.d.ts.map +1 -0
  43. package/dist/definitions/order-promotion.js +20 -11
  44. package/dist/definitions/order-promotion.js.map +1 -0
  45. package/dist/definitions/order-return-fulfillment.d.ts +3 -0
  46. package/dist/definitions/order-return-fulfillment.d.ts.map +1 -0
  47. package/dist/definitions/order-return-fulfillment.js +69 -0
  48. package/dist/definitions/order-return-fulfillment.js.map +1 -0
  49. package/dist/definitions/product-sales-channel.d.ts +2 -1
  50. package/dist/definitions/product-sales-channel.d.ts.map +1 -0
  51. package/dist/definitions/product-sales-channel.js +18 -9
  52. package/dist/definitions/product-sales-channel.js.map +1 -0
  53. package/dist/definitions/product-variant-inventory-item.d.ts +2 -1
  54. package/dist/definitions/product-variant-inventory-item.d.ts.map +1 -0
  55. package/dist/definitions/product-variant-inventory-item.js +21 -11
  56. package/dist/definitions/product-variant-inventory-item.js.map +1 -0
  57. package/dist/definitions/product-variant-price-set.d.ts +2 -1
  58. package/dist/definitions/product-variant-price-set.d.ts.map +1 -0
  59. package/dist/definitions/product-variant-price-set.js +18 -12
  60. package/dist/definitions/product-variant-price-set.js.map +1 -0
  61. package/dist/definitions/publishable-api-key-sales-channel.d.ts +2 -1
  62. package/dist/definitions/publishable-api-key-sales-channel.d.ts.map +1 -0
  63. package/dist/definitions/publishable-api-key-sales-channel.js +22 -8
  64. package/dist/definitions/publishable-api-key-sales-channel.js.map +1 -0
  65. package/dist/definitions/readonly/cart-customer.d.ts +3 -0
  66. package/dist/definitions/readonly/cart-customer.d.ts.map +1 -0
  67. package/dist/definitions/{cart-customer.js → readonly/cart-customer.js} +14 -5
  68. package/dist/definitions/readonly/cart-customer.js.map +1 -0
  69. package/dist/definitions/readonly/cart-product.d.ts +3 -0
  70. package/dist/definitions/readonly/cart-product.d.ts.map +1 -0
  71. package/dist/definitions/readonly/cart-product.js +50 -0
  72. package/dist/definitions/readonly/cart-product.js.map +1 -0
  73. package/dist/definitions/readonly/cart-region.d.ts +3 -0
  74. package/dist/definitions/readonly/cart-region.d.ts.map +1 -0
  75. package/dist/definitions/{cart-region.js → readonly/cart-region.js} +14 -5
  76. package/dist/definitions/readonly/cart-region.js.map +1 -0
  77. package/dist/definitions/readonly/cart-sales-channel.d.ts +3 -0
  78. package/dist/definitions/readonly/cart-sales-channel.d.ts.map +1 -0
  79. package/dist/definitions/{cart-sales-channel.js → readonly/cart-sales-channel.js} +14 -5
  80. package/dist/definitions/readonly/cart-sales-channel.js.map +1 -0
  81. package/dist/definitions/readonly/index.d.ts +12 -0
  82. package/dist/definitions/readonly/index.d.ts.map +1 -0
  83. package/dist/definitions/readonly/index.js +28 -0
  84. package/dist/definitions/readonly/index.js.map +1 -0
  85. package/dist/definitions/readonly/inventory-level-stock-location.d.ts +3 -0
  86. package/dist/definitions/readonly/inventory-level-stock-location.d.ts.map +1 -0
  87. package/dist/definitions/{inventory-level-stock-location.js → readonly/inventory-level-stock-location.js} +8 -3
  88. package/dist/definitions/readonly/inventory-level-stock-location.js.map +1 -0
  89. package/dist/definitions/readonly/line-item-adjustment-promotion.d.ts +3 -0
  90. package/dist/definitions/readonly/line-item-adjustment-promotion.d.ts.map +1 -0
  91. package/dist/definitions/readonly/line-item-adjustment-promotion.js +24 -0
  92. package/dist/definitions/readonly/line-item-adjustment-promotion.js.map +1 -0
  93. package/dist/definitions/readonly/order-customer.d.ts +3 -0
  94. package/dist/definitions/readonly/order-customer.d.ts.map +1 -0
  95. package/dist/definitions/{order-customer.js → readonly/order-customer.js} +14 -5
  96. package/dist/definitions/readonly/order-customer.js.map +1 -0
  97. package/dist/definitions/readonly/order-product.d.ts +3 -0
  98. package/dist/definitions/readonly/order-product.d.ts.map +1 -0
  99. package/dist/definitions/readonly/order-product.js +51 -0
  100. package/dist/definitions/readonly/order-product.js.map +1 -0
  101. package/dist/definitions/readonly/order-region.d.ts +3 -0
  102. package/dist/definitions/readonly/order-region.d.ts.map +1 -0
  103. package/dist/definitions/{order-region.js → readonly/order-region.js} +14 -5
  104. package/dist/definitions/readonly/order-region.js.map +1 -0
  105. package/dist/definitions/readonly/order-sales-channel.d.ts +3 -0
  106. package/dist/definitions/readonly/order-sales-channel.d.ts.map +1 -0
  107. package/dist/definitions/readonly/order-sales-channel.js +38 -0
  108. package/dist/definitions/readonly/order-sales-channel.js.map +1 -0
  109. package/dist/definitions/readonly/store-currency.d.ts +3 -0
  110. package/dist/definitions/readonly/store-currency.d.ts.map +1 -0
  111. package/dist/definitions/readonly/store-currency.js +24 -0
  112. package/dist/definitions/readonly/store-currency.js.map +1 -0
  113. package/dist/definitions/region-payment-provider.d.ts +2 -1
  114. package/dist/definitions/region-payment-provider.d.ts.map +1 -0
  115. package/dist/definitions/region-payment-provider.js +20 -11
  116. package/dist/definitions/region-payment-provider.js.map +1 -0
  117. package/dist/definitions/sales-channel-location.d.ts +2 -1
  118. package/dist/definitions/sales-channel-location.d.ts.map +1 -0
  119. package/dist/definitions/sales-channel-location.js +23 -11
  120. package/dist/definitions/sales-channel-location.js.map +1 -0
  121. package/dist/definitions/shipping-option-price-set.d.ts +2 -1
  122. package/dist/definitions/shipping-option-price-set.d.ts.map +1 -0
  123. package/dist/definitions/shipping-option-price-set.js +12 -9
  124. package/dist/definitions/shipping-option-price-set.js.map +1 -0
  125. package/dist/index.d.ts +3 -2
  126. package/dist/index.d.ts.map +1 -0
  127. package/dist/index.js +3 -2
  128. package/dist/index.js.map +1 -0
  129. package/dist/initialize/index.d.ts +13 -4
  130. package/dist/initialize/index.d.ts.map +1 -0
  131. package/dist/initialize/index.js +42 -28
  132. package/dist/initialize/index.js.map +1 -0
  133. package/dist/initialize/module-definition.d.ts +2 -1
  134. package/dist/initialize/module-definition.d.ts.map +1 -0
  135. package/dist/initialize/module-definition.js +2 -2
  136. package/dist/initialize/module-definition.js.map +1 -0
  137. package/dist/loaders/connection.d.ts +2 -1
  138. package/dist/loaders/connection.d.ts.map +1 -0
  139. package/dist/loaders/connection.js +3 -3
  140. package/dist/loaders/connection.js.map +1 -0
  141. package/dist/loaders/container.d.ts +2 -2
  142. package/dist/loaders/container.d.ts.map +1 -0
  143. package/dist/loaders/container.js +6 -7
  144. package/dist/loaders/container.js.map +1 -0
  145. package/dist/loaders/index.d.ts +2 -1
  146. package/dist/loaders/index.d.ts.map +1 -0
  147. package/dist/loaders/index.js +2 -2
  148. package/dist/loaders/index.js.map +1 -0
  149. package/dist/migration/index.d.ts +103 -2
  150. package/dist/migration/index.d.ts.map +1 -0
  151. package/dist/migration/index.js +341 -46
  152. package/dist/migration/index.js.map +1 -0
  153. package/dist/repositories/index.d.ts +2 -1
  154. package/dist/repositories/index.d.ts.map +1 -0
  155. package/dist/repositories/index.js +2 -1
  156. package/dist/repositories/index.js.map +1 -0
  157. package/dist/repositories/link.d.ts +20 -20
  158. package/dist/repositories/link.d.ts.map +1 -0
  159. package/dist/repositories/link.js +3 -3
  160. package/dist/repositories/link.js.map +1 -0
  161. package/dist/services/dynamic-service-class.d.ts +2 -1
  162. package/dist/services/dynamic-service-class.d.ts.map +1 -0
  163. package/dist/services/dynamic-service-class.js +10 -3
  164. package/dist/services/dynamic-service-class.js.map +1 -0
  165. package/dist/services/index.d.ts +1 -0
  166. package/dist/services/index.d.ts.map +1 -0
  167. package/dist/services/index.js +1 -0
  168. package/dist/services/index.js.map +1 -0
  169. package/dist/services/link-module-service.d.ts +9 -7
  170. package/dist/services/link-module-service.d.ts.map +1 -0
  171. package/dist/services/link-module-service.js +38 -45
  172. package/dist/services/link-module-service.js.map +1 -0
  173. package/dist/services/link.d.ts +2 -1
  174. package/dist/services/link.d.ts.map +1 -0
  175. package/dist/services/link.js +2 -1
  176. package/dist/services/link.js.map +1 -0
  177. package/dist/tsconfig.tsbuildinfo +1 -0
  178. package/dist/types/index.d.ts +2 -1
  179. package/dist/types/index.d.ts.map +1 -0
  180. package/dist/types/index.js +1 -0
  181. package/dist/types/index.js.map +1 -0
  182. package/dist/utils/compress-name.d.ts +2 -0
  183. package/dist/utils/compress-name.d.ts.map +1 -0
  184. package/dist/utils/compress-name.js +33 -0
  185. package/dist/utils/compress-name.js.map +1 -0
  186. package/dist/utils/generate-entity.d.ts +2 -1
  187. package/dist/utils/generate-entity.d.ts.map +1 -0
  188. package/dist/utils/generate-entity.js +6 -6
  189. package/dist/utils/generate-entity.js.map +1 -0
  190. package/dist/utils/generate-schema.d.ts +2 -1
  191. package/dist/utils/generate-schema.d.ts.map +1 -0
  192. package/dist/utils/generate-schema.js +76 -20
  193. package/dist/utils/generate-schema.js.map +1 -0
  194. package/dist/utils/index.d.ts +1 -1
  195. package/dist/utils/index.d.ts.map +1 -0
  196. package/dist/utils/index.js +5 -6
  197. package/dist/utils/index.js.map +1 -0
  198. package/package.json +22 -15
  199. package/dist/definitions/cart-customer.d.ts +0 -2
  200. package/dist/definitions/cart-region.d.ts +0 -2
  201. package/dist/definitions/cart-sales-channel.d.ts +0 -2
  202. package/dist/definitions/inventory-level-stock-location.d.ts +0 -2
  203. package/dist/definitions/order-customer.d.ts +0 -2
  204. package/dist/definitions/order-region.d.ts +0 -2
  205. package/dist/definitions/order-sales-channel.d.ts +0 -2
  206. package/dist/definitions/order-sales-channel.js +0 -67
  207. package/dist/definitions/product-shipping-profile.d.ts +0 -2
  208. package/dist/definitions/product-shipping-profile.js +0 -61
  209. package/dist/definitions/store-default-currency.d.ts +0 -2
  210. package/dist/definitions/store-default-currency.js +0 -19
  211. package/dist/utils/compose-link-name.d.ts +0 -2
  212. package/dist/utils/compose-link-name.js +0 -12
@@ -23,18 +23,18 @@ 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;
27
- const modules_sdk_1 = require("@medusajs/modules-sdk");
28
- const types_1 = require("@medusajs/types");
29
- const utils_1 = require("@medusajs/utils");
26
+ exports.initialize = void 0;
27
+ exports.getMigrationPlanner = getMigrationPlanner;
28
+ const modules_sdk_1 = require("@medusajs/framework/modules-sdk");
29
+ const utils_1 = require("@medusajs/framework/utils");
30
30
  const linkDefinitions = __importStar(require("../definitions"));
31
31
  const migration_1 = require("../migration");
32
32
  const utils_2 = require("../utils");
33
33
  const module_definition_1 = require("./module-definition");
34
- const initialize = async (options, modulesDefinition, injectedDependencies) => {
34
+ const initialize = async (options, pluginLinksDefinitions, injectedDependencies) => {
35
35
  const allLinks = {};
36
36
  const modulesLoadedKeys = modules_sdk_1.MedusaModule.getLoadedModules().map((mod) => Object.keys(mod)[0]);
37
- const allLinksToLoad = Object.values(linkDefinitions).concat(modulesDefinition ?? []);
37
+ const allLinksToLoad = Object.values(linkDefinitions).concat(pluginLinksDefinitions ?? []);
38
38
  for (const linkDefinition of allLinksToLoad) {
39
39
  const definition = JSON.parse(JSON.stringify(linkDefinition));
40
40
  const [primary, foreign] = definition.relationships ?? [];
@@ -45,9 +45,17 @@ const initialize = async (options, modulesDefinition, injectedDependencies) => {
45
45
  !definition.isReadOnlyLink) {
46
46
  throw new Error(`Foreign key cannot be a composed key.`);
47
47
  }
48
+ if (Array.isArray(definition.extraDataFields)) {
49
+ const extraDataFields = definition.extraDataFields;
50
+ const definedDbFields = Object.keys(definition.databaseConfig?.extraFields || {});
51
+ const difference = (0, utils_1.arrayDifference)(extraDataFields, definedDbFields);
52
+ if (difference.length) {
53
+ throw new Error(`extraDataFields (fieldNames: ${difference.join(",")}) need to be configured under databaseConfig (serviceName: ${definition.serviceName}).`);
54
+ }
55
+ }
48
56
  const serviceKey = !definition.isReadOnlyLink
49
- ? (0, utils_1.lowerCaseFirst)(definition.serviceName ??
50
- (0, utils_2.composeLinkName)(primary.serviceName, primary.foreignKey, foreign.serviceName, foreign.foreignKey))
57
+ ? definition.serviceName ??
58
+ (0, utils_1.composeLinkName)(primary.serviceName, primary.foreignKey, foreign.serviceName, foreign.foreignKey)
51
59
  : (0, utils_1.simpleHash)(JSON.stringify(definition.extends));
52
60
  if (modulesLoadedKeys.includes(serviceKey)) {
53
61
  continue;
@@ -68,34 +76,33 @@ const initialize = async (options, modulesDefinition, injectedDependencies) => {
68
76
  continue;
69
77
  }
70
78
  }
71
- else if ((!primary.isInternalService &&
72
- !modulesLoadedKeys.includes(primary.serviceName)) ||
73
- (!foreign.isInternalService &&
74
- !modulesLoadedKeys.includes(foreign.serviceName))) {
79
+ else if (!modulesLoadedKeys.includes(primary.serviceName) ||
80
+ !modulesLoadedKeys.includes(foreign.serviceName)) {
75
81
  continue;
76
82
  }
77
83
  const logger = injectedDependencies?.[utils_1.ContainerRegistrationKeys.LOGGER] ?? console;
78
84
  definition.schema = (0, utils_2.generateGraphQLSchema)(definition, primary, foreign, {
79
85
  logger,
80
86
  });
81
- definition.alias ?? (definition.alias = []);
87
+ if (!Array.isArray(definition.alias)) {
88
+ definition.alias = definition.alias ? [definition.alias] : [];
89
+ }
82
90
  for (const alias of definition.alias) {
83
- alias.args ?? (alias.args = {});
84
- alias.args.entity = (0, utils_1.toPascalCase)("Link_" +
91
+ alias.args ??= {};
92
+ alias.entity = (0, utils_1.toPascalCase)("Link_" +
85
93
  (definition.databaseConfig?.tableName ??
86
- (0, utils_2.composeTableName)(primary.serviceName, primary.foreignKey, foreign.serviceName, foreign.foreignKey)));
94
+ (0, utils_1.composeTableName)(primary.serviceName, primary.foreignKey, foreign.serviceName, foreign.foreignKey)));
87
95
  }
88
96
  const moduleDefinition = (0, module_definition_1.getLinkModuleDefinition)(definition, primary, foreign);
89
97
  const linkModuleDefinition = {
90
98
  key: serviceKey,
91
- registrationName: serviceKey,
92
99
  label: serviceKey,
93
- dependencies: [modules_sdk_1.ModuleRegistrationName.EVENT_BUS],
100
+ dependencies: [utils_1.Modules.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,9 +116,17 @@ 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
+ /**
120
+ * Prepare an execution plan and run the migrations accordingly.
121
+ * It includes creating, updating, deleting the tables according to the execution plan.
122
+ * If any unsafe sql is identified then we will notify the user to act manually.
123
+ *
124
+ * @param options
125
+ * @param pluginLinksDefinition
126
+ */
127
+ function getMigrationPlanner(options, pluginLinksDefinition) {
113
128
  const modulesLoadedKeys = modules_sdk_1.MedusaModule.getLoadedModules().map((mod) => Object.keys(mod)[0]);
114
- const allLinksToLoad = Object.values(linkDefinitions).concat(modulesDefinition ?? []);
129
+ const allLinksToLoad = Object.values(linkDefinitions).concat(pluginLinksDefinition ?? []);
115
130
  const allLinks = new Set();
116
131
  for (const definition of allLinksToLoad) {
117
132
  if (definition.isReadOnlyLink) {
@@ -121,8 +136,8 @@ async function runMigrations({ options, logger, }, modulesDefinition) {
121
136
  throw new Error(`Link module ${definition.serviceName} must have 2 relationships.`);
122
137
  }
123
138
  const [primary, foreign] = definition.relationships ?? [];
124
- const serviceKey = (0, utils_1.lowerCaseFirst)(definition.serviceName ??
125
- (0, utils_2.composeLinkName)(primary.serviceName, primary.foreignKey, foreign.serviceName, foreign.foreignKey));
139
+ const serviceKey = definition.serviceName ??
140
+ (0, utils_1.composeLinkName)(primary.serviceName, primary.foreignKey, foreign.serviceName, foreign.foreignKey);
126
141
  if (allLinks.has(serviceKey)) {
127
142
  throw new Error(`Link module ${serviceKey} already exists.`);
128
143
  }
@@ -131,8 +146,7 @@ async function runMigrations({ options, logger, }, modulesDefinition) {
131
146
  !modulesLoadedKeys.includes(foreign.serviceName)) {
132
147
  continue;
133
148
  }
134
- const migrate = (0, migration_1.getMigration)(definition, serviceKey, primary, foreign);
135
- await migrate({ options, logger });
136
149
  }
150
+ return new migration_1.MigrationsExecutionPlanner(allLinksToLoad, options);
137
151
  }
138
- exports.runMigrations = runMigrations;
152
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/initialize/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6LA,kDAiDC;AA9OD,iEAIwC;AAWxC,qDAQkC;AAClC,gEAAiD;AACjD,4CAAyD;AAEzD,oCAAgD;AAChD,2DAA6D;AAEtD,MAAM,UAAU,GAAG,KAAK,EAC7B,OAI6B,EAC7B,sBAA6C,EAC7C,oBAA6D,EACnB,EAAE;IAC5C,MAAM,QAAQ,GAAG,EAAE,CAAA;IACnB,MAAM,iBAAiB,GAAG,0BAAY,CAAC,gBAAgB,EAAE,CAAC,GAAG,CAC3D,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAC7B,CAAA;IAED,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,MAAM,CAC1D,sBAAsB,IAAI,EAAE,CAC7B,CAAA;IAED,KAAK,MAAM,cAAc,IAAI,cAAc,EAAE,CAAC;QAC5C,MAAM,UAAU,GAAuB,IAAI,CAAC,KAAK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AQ,CAAC,OAAO,CAAC,WAAW,CAAC,EAChD,CAAC;YACD,SAAQ;QACV,CAAC;IACH,CAAC;IAED,OAAO,IAAI,sCAA0B,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;AAChE,CAAC"}
@@ -1,2 +1,3 @@
1
- import { JoinerRelationship, ModuleExports, ModuleJoinerConfig } from "@medusajs/types";
1
+ import { JoinerRelationship, ModuleExports, ModuleJoinerConfig } from "@medusajs/framework/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,2BAA2B,CAAA;AAIlC,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,kBAAkB,EAChC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,kBAAkB,GAC1B,aAAa,CAWf"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLinkModuleDefinition = void 0;
3
+ exports.getLinkModuleDefinition = getLinkModuleDefinition;
4
4
  const _services_1 = require("../services");
5
5
  const loaders_1 = require("../loaders");
6
6
  function getLinkModuleDefinition(joinerConfig, primary, foreign) {
@@ -15,4 +15,4 @@ function getLinkModuleDefinition(joinerConfig, primary, foreign) {
15
15
  }),
16
16
  };
17
17
  }
18
- exports.getLinkModuleDefinition = getLinkModuleDefinition;
18
+ //# sourceMappingURL=module-definition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-definition.js","sourceRoot":"","sources":["../../src/initialize/module-definition.ts"],"names":[],"mappings":";;AAQA,0DAeC;AAlBD,yCAAsE;AACtE,wCAAuC;AAEvC,SAAgB,uBAAuB,CACrC,YAAgC,EAChC,OAA2B,EAC3B,OAA2B;IAE3B,OAAO;QACL,OAAO,EAAE,YAAY,CAAC,cAAc;YAClC,CAAC,CAAC,IAAA,oCAAwB,EAAC,YAAY,CAAC;YACxC,CAAC,CAAC,IAAA,4BAAgB,EAAC,YAAY,CAAC;QAClC,OAAO,EAAE,IAAA,oBAAU,EAAC;YAClB,YAAY;YACZ,OAAO;YACP,OAAO;SACR,CAAC;KACH,CAAA;AACH,CAAC"}
@@ -1,3 +1,4 @@
1
- import { InternalModuleDeclaration, LoaderOptions, ModuleServiceInitializeCustomDataLayerOptions, ModuleServiceInitializeOptions } from "@medusajs/modules-sdk";
1
+ import { InternalModuleDeclaration, LoaderOptions, ModuleServiceInitializeCustomDataLayerOptions, ModuleServiceInitializeOptions } from "@medusajs/framework/types";
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,2BAA2B,CAAA;AAGlC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,qCAM9C,aAAa,CACZ,8BAA8B,GAC9B,6CAA6C,CAChD,sBACmB,yBAAyB,KAC5C,OAAO,CAAC,IAAI,CAAC,CAajB"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.connectionLoader = void 0;
4
- const utils_1 = require("@medusajs/utils");
3
+ exports.connectionLoader = connectionLoader;
4
+ const utils_1 = require("@medusajs/framework/utils");
5
5
  function connectionLoader(entity) {
6
6
  return async ({ options, container, logger, }, moduleDeclaration) => {
7
7
  const pathToMigrations = __dirname + "/../migrations";
@@ -16,4 +16,4 @@ function connectionLoader(entity) {
16
16
  });
17
17
  };
18
18
  }
19
- exports.connectionLoader = connectionLoader;
19
+ //# sourceMappingURL=connection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/loaders/connection.ts"],"names":[],"mappings":";;AAUA,4CAwBC;AA5BD,qDAA2D;AAI3D,SAAgB,gBAAgB,CAAC,MAAoB;IACnD,OAAO,KAAK,EACV,EACE,OAAO,EACP,SAAS,EACT,MAAM,GAIP,EACD,iBAA6C,EAC9B,EAAE;QACjB,MAAM,gBAAgB,GAAG,SAAS,GAAG,gBAAgB,CAAA;QAErD,MAAM,uBAAe,CAAC,wBAAwB,CAAC;YAC7C,UAAU,EAAE,aAAa;YACzB,QAAQ,EAAE,CAAC,MAAM,CAAC;YAClB,SAAS;YACT,OAAO;YACP,iBAAiB;YACjB,MAAM;YACN,gBAAgB;SACjB,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC"}
@@ -1,3 +1,3 @@
1
- import { LoaderOptions } from "@medusajs/modules-sdk";
2
- import { InternalModuleDeclaration, ModuleJoinerConfig, ModulesSdkTypes } from "@medusajs/types";
1
+ import { InternalModuleDeclaration, LoaderOptions, ModuleJoinerConfig, ModulesSdkTypes } from "@medusajs/framework/types";
3
2
  export declare function containerLoader(entity: any, joinerConfig: ModuleJoinerConfig): ({ options, container, }: LoaderOptions<ModulesSdkTypes.ModuleServiceInitializeOptions | ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions>, moduleDeclaration?: InternalModuleDeclaration) => Promise<void>;
3
+ //# 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,EACL,yBAAyB,EACzB,aAAa,EACb,kBAAkB,EAClB,eAAe,EAChB,MAAM,2BAA2B,CAAA;AAQlC,wBAAgB,eAAe,CAAC,MAAM,KAAA,EAAE,YAAY,EAAE,kBAAkB,6BAKjE,aAAa,CACZ,eAAe,CAAC,8BAA8B,GAC9C,eAAe,CAAC,6CAA6C,CAChE,sBACmB,yBAAyB,KAC5C,OAAO,CAAC,IAAI,CAAC,CAyCjB"}
@@ -1,21 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.containerLoader = void 0;
3
+ exports.containerLoader = containerLoader;
4
4
  const _repositories_1 = require("../repositories");
5
5
  const _services_1 = require("../services");
6
- const utils_1 = require("@medusajs/utils");
6
+ const utils_1 = require("@medusajs/framework/utils");
7
7
  const awilix_1 = require("awilix");
8
- const utils_2 = require("../utils");
9
8
  function containerLoader(entity, joinerConfig) {
10
9
  return async ({ options, container, }, moduleDeclaration) => {
11
10
  const [primary, foreign] = joinerConfig.relationships;
12
11
  const serviceName = !joinerConfig.isReadOnlyLink
13
- ? (0, utils_1.lowerCaseFirst)(joinerConfig.serviceName ??
14
- (0, utils_2.composeLinkName)(primary.serviceName, primary.foreignKey, foreign.serviceName, foreign.foreignKey))
12
+ ? joinerConfig.serviceName ??
13
+ (0, utils_1.composeLinkName)(primary.serviceName, primary.foreignKey, foreign.serviceName, foreign.foreignKey)
15
14
  : (0, utils_1.simpleHash)(JSON.stringify(joinerConfig.extends));
16
15
  const entityName = (0, utils_1.toPascalCase)("Link_" +
17
16
  (joinerConfig.databaseConfig?.tableName ??
18
- (0, utils_2.composeTableName)(primary.serviceName, primary.foreignKey, foreign.serviceName, foreign.foreignKey)));
17
+ (0, utils_1.composeTableName)(primary.serviceName, primary.foreignKey, foreign.serviceName, foreign.foreignKey)));
19
18
  container.register({
20
19
  joinerConfig: (0, awilix_1.asValue)(joinerConfig),
21
20
  primaryKey: (0, awilix_1.asValue)(primary.foreignKey.split(",")),
@@ -30,4 +29,4 @@ function containerLoader(entity, joinerConfig) {
30
29
  });
31
30
  };
32
31
  }
33
- exports.containerLoader = containerLoader;
32
+ //# sourceMappingURL=container.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container.js","sourceRoot":"","sources":["../../src/loaders/container.ts"],"names":[],"mappings":";;AAgBA,0CAmDC;AAnED,iDAAiE;AACjE,yCAAyD;AAQzD,qDAKkC;AAClC,mCAAyC;AACzC,SAAgB,eAAe,CAAC,MAAM,EAAE,YAAgC;IACtE,OAAO,KAAK,EACV,EACE,OAAO,EACP,SAAS,GAIV,EACD,iBAA6C,EAC9B,EAAE;QACjB,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,YAAY,CAAC,aAAc,CAAA;QAEtD,MAAM,WAAW,GAAG,CAAC,YAAY,CAAC,cAAc;YAC9C,CAAC,CAAC,YAAY,CAAC,WAAW;gBACxB,IAAA,uBAAe,EACb,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,UAAU,CACnB;YACH,CAAC,CAAC,IAAA,kBAAU,EAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAA;QAEpD,MAAM,UAAU,GAAG,IAAA,oBAAY,EAC7B,OAAO;YACL,CAAC,YAAY,CAAC,cAAc,EAAE,SAAS;gBACrC,IAAA,wBAAgB,EACd,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,UAAU,CACnB,CAAC,CACP,CAAA;QAED,SAAS,CAAC,QAAQ,CAAC;YACjB,YAAY,EAAE,IAAA,gBAAO,EAAC,YAAY,CAAC;YACnC,UAAU,EAAE,IAAA,gBAAO,EAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAClD,UAAU,EAAE,IAAA,gBAAO,EAAC,OAAO,CAAC,UAAU,CAAC;YACvC,WAAW,EAAE,IAAA,gBAAO,EAClB,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,WAAW,IAAI,EAAE,CAAC,CAC5D;YAED,iBAAiB,EAAE,IAAA,gBAAO,EAAC,IAAA,4BAAgB,EAAC,YAAY,CAAC,CAAC,CAAC,SAAS,EAAE;YACtE,WAAW,EAAE,IAAA,gBAAO,EAAC,uBAAW,CAAC,CAAC,SAAS,EAAE;YAE7C,cAAc,EAAE,IAAA,gBAAO,EAAC,8BAAc,CAAC,CAAC,SAAS,EAAE;YACnD,cAAc,EAAE,IAAA,gBAAO,EAAC,IAAA,iCAAiB,EAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAAE;YAC9D,UAAU,EAAE,IAAA,gBAAO,EAAC,UAAU,CAAC;YAC/B,WAAW,EAAE,IAAA,gBAAO,EAAC,WAAW,CAAC;SAClC,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC"}
@@ -1,6 +1,7 @@
1
- import { JoinerRelationship, ModuleJoinerConfig, ModuleLoaderFunction } from "@medusajs/types";
1
+ import { JoinerRelationship, ModuleJoinerConfig, ModuleLoaderFunction } from "@medusajs/framework/types";
2
2
  export declare function getLoaders({ joinerConfig, primary, foreign, }: {
3
3
  joinerConfig: ModuleJoinerConfig;
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,2BAA2B,CAAA;AAMlC,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,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLoaders = void 0;
3
+ exports.getLoaders = getLoaders;
4
4
  const utils_1 = require("../utils");
5
5
  const connection_1 = require("./connection");
6
6
  const container_1 = require("./container");
@@ -11,4 +11,4 @@ function getLoaders({ joinerConfig, primary, foreign, }) {
11
11
  const entity = (0, utils_1.generateEntity)(joinerConfig, primary, foreign);
12
12
  return [(0, connection_1.connectionLoader)(entity), (0, container_1.containerLoader)(entity, joinerConfig)];
13
13
  }
14
- exports.getLoaders = getLoaders;
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/loaders/index.ts"],"names":[],"mappings":";;AAUA,gCAeC;AAnBD,oCAAyC;AACzC,6CAA+C;AAC/C,2CAA6C;AAE7C,SAAgB,UAAU,CAAC,EACzB,YAAY,EACZ,OAAO,EACP,OAAO,GAKR;IACC,IAAI,YAAY,CAAC,cAAc,EAAE,CAAC;QAChC,OAAO,EAAE,CAAA;IACX,CAAC;IAED,MAAM,MAAM,GAAG,IAAA,sBAAc,EAAC,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IAC7D,OAAO,CAAC,IAAA,6BAAgB,EAAC,MAAM,CAAC,EAAE,IAAA,2BAAe,EAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAA;AAC1E,CAAC"}
@@ -1,2 +1,103 @@
1
- import { JoinerRelationship, LoaderOptions, ModuleJoinerConfig, ModuleServiceInitializeOptions } from "@medusajs/types";
2
- export declare function getMigration(joinerConfig: ModuleJoinerConfig, serviceName: string, primary: JoinerRelationship, foreign: JoinerRelationship): ({ options, logger, }?: Pick<LoaderOptions<ModuleServiceInitializeOptions>, "options" | "logger">) => Promise<void>;
1
+ import { ILinkMigrationsPlanner, LinkMigrationsPlannerAction, ModuleJoinerConfig, ModuleServiceInitializeOptions, PlannerActionLinkDescriptor } from "@medusajs/framework/types";
2
+ import { EntitySchema, MikroORM } from "@mikro-orm/core";
3
+ import { PostgreSqlDriver } from "@mikro-orm/postgresql";
4
+ /**
5
+ * The migrations execution planner creates a plan of SQL queries
6
+ * to be executed to keep link modules database state in sync
7
+ * with the links defined inside the user application.
8
+ */
9
+ export declare class MigrationsExecutionPlanner implements ILinkMigrationsPlanner {
10
+ #private;
11
+ /**
12
+ * The table that keeps a track of tables generated by the link
13
+ * module.
14
+ */
15
+ protected tableName: string;
16
+ constructor(joinerConfig: ModuleJoinerConfig[], options?: ModuleServiceInitializeOptions);
17
+ /**
18
+ * Initializes the ORM using the normalized dbConfig and set
19
+ * of provided entities
20
+ */
21
+ protected createORM(entities?: EntitySchema[]): Promise<MikroORM<PostgreSqlDriver>>;
22
+ /**
23
+ * Ensure the table to track link modules migrations
24
+ * exists.
25
+ *
26
+ * @param orm MikroORM
27
+ */
28
+ protected ensureMigrationsTable(orm: MikroORM<PostgreSqlDriver>): Promise<void>;
29
+ /**
30
+ * Ensure the migrations table is in sync
31
+ *
32
+ * @param orm
33
+ * @protected
34
+ */
35
+ protected ensureMigrationsTableUpToDate(orm: MikroORM<PostgreSqlDriver>): Promise<void>;
36
+ /**
37
+ * Insert tuple to the migrations table and create the link table
38
+ *
39
+ * @param orm
40
+ * @param action
41
+ * @protected
42
+ */
43
+ protected createLinkTable(orm: MikroORM<PostgreSqlDriver>, action: LinkMigrationsPlannerAction & {
44
+ linkDescriptor: PlannerActionLinkDescriptor;
45
+ sql: string;
46
+ }): Promise<void>;
47
+ /**
48
+ * Drops the link table and untracks it from the "link_modules_migrations"
49
+ * table.
50
+ */
51
+ protected dropLinkTable(orm: MikroORM<PostgreSqlDriver>, tableName: string): Promise<void>;
52
+ /**
53
+ * Returns an array of table names that have been tracked during
54
+ * the last run. In short, these tables were created by the
55
+ * link modules migrations runner.
56
+ *
57
+ * @param orm MikroORM
58
+ */
59
+ protected getTrackedLinksTables(orm: MikroORM<PostgreSqlDriver>): Promise<{
60
+ table_name: string;
61
+ link_descriptor: PlannerActionLinkDescriptor;
62
+ }[]>;
63
+ /**
64
+ * Returns the migration plan for a specific link entity.
65
+ */
66
+ protected getEntityMigrationPlan(linkDescriptor: PlannerActionLinkDescriptor, entity: EntitySchema, trackedLinksTables: string[]): Promise<LinkMigrationsPlannerAction>;
67
+ /**
68
+ * This method loops over the tables we have fetched from the
69
+ * "link_module_migrations" tables and checks if their new
70
+ * name is different from the tracked name and in that
71
+ * case it will rename the actual table and also the
72
+ * tracked entry.
73
+ */
74
+ protected migrateOldTables(orm: MikroORM<PostgreSqlDriver>, trackedTables: {
75
+ table_name: string;
76
+ link_descriptor: PlannerActionLinkDescriptor;
77
+ }[]): Promise<{
78
+ table_name: string;
79
+ link_descriptor: PlannerActionLinkDescriptor;
80
+ }[]>;
81
+ /**
82
+ * Renames existing table and also its tracked entry
83
+ */
84
+ protected renameOldTable(orm: MikroORM<PostgreSqlDriver>, oldName: string, newName: string): Promise<void>;
85
+ /**
86
+ * Creates a plan to executed in order to keep the database state in
87
+ * sync with the user-defined links.
88
+ *
89
+ * This method only creates a plan and does not change the database
90
+ * state. You must call the "executePlan" method for that.
91
+ */
92
+ createPlan(): Promise<LinkMigrationsPlannerAction[]>;
93
+ /**
94
+ * Executes the actionsPlan actions where the action is one of 'create' | 'update' | 'delete'.
95
+ * 'noop' and 'notify' actions are implicitly ignored. If a notify action needs to be
96
+ * executed, you can mutate its action to 'update', in that scenario it means that an unsafe
97
+ * update sql (from our point of view) will be executed and some data could be lost.
98
+ *
99
+ * @param actionPlan
100
+ */
101
+ executePlan(actionPlan: LinkMigrationsPlannerAction[]): Promise<void>;
102
+ }
103
+ //# 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,sBAAsB,E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