@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,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getMigration = void 0;
3
+ exports.getRevertMigration = exports.getMigration = void 0;
4
4
  const utils_1 = require("../utils");
5
5
  const utils_2 = require("@medusajs/utils");
6
6
  function getMigration(joinerConfig, serviceName, primary, foreign) {
7
7
  return async function runMigrations({ options, logger, } = {}) {
8
- logger ?? (logger = console);
8
+ logger ??= console;
9
9
  const dbData = utils_2.ModulesSdkUtils.loadDatabaseConfig("link_modules", options);
10
10
  const entity = (0, utils_1.generateEntity)(joinerConfig, primary, foreign);
11
11
  const pathToMigrations = __dirname + "/../migrations";
@@ -13,7 +13,9 @@ function getMigration(joinerConfig, serviceName, primary, foreign) {
13
13
  const tableName = entity.meta.collection;
14
14
  let hasTable = false;
15
15
  try {
16
- await orm.em.getConnection().execute(`SELECT 1 FROM ${tableName} LIMIT 0`);
16
+ await orm.em
17
+ .getConnection()
18
+ .execute(`SELECT 1 FROM "${tableName}" LIMIT 0`);
17
19
  hasTable = true;
18
20
  }
19
21
  catch { }
@@ -33,24 +35,46 @@ function getMigration(joinerConfig, serviceName, primary, foreign) {
33
35
  logger.info(`Link module "${serviceName}" migration executed`)
34
36
  } catch (error) {
35
37
  logger.error(
36
- `Link module "${serviceName}" migration failed to run - Error: ${error}`
38
+ `Link module "${serviceName}" migration failed to run - Error: ${error.errros ?? error}`
37
39
  )
38
40
  }
39
41
  } else {
40
42
  logger.info(`Skipping "${tableName}" migration.`)
41
43
  }*/
42
- logger.info(`Link module "${serviceName}" table update skipped because the table already exists. Please write your own migration if needed.`);
44
+ // Note: Temporarily skipping this for handling no logs on the CI. Bring this back if necessary.
45
+ // logger.info(
46
+ // `Link module('${serviceName}'): Table already exists. Write your own migration if needed.`
47
+ // )
43
48
  }
44
49
  else {
45
50
  try {
46
51
  await generator.createSchema();
47
- logger.info(`Link module "${serviceName}" migration executed`);
52
+ logger.info(`Link module('${serviceName}'): Migration executed`);
48
53
  }
49
54
  catch (error) {
50
- logger.error(`Link module "${serviceName}" migration failed to run - Error: ${error}`);
55
+ logger.error(`Link module('${serviceName}'): Migration failed - Error: ${error.errros ?? error}`);
51
56
  }
52
57
  }
53
58
  await orm.close();
54
59
  };
55
60
  }
56
61
  exports.getMigration = getMigration;
62
+ function getRevertMigration(joinerConfig, serviceName, primary, foreign) {
63
+ return async function revertMigrations({ options, logger, } = {}) {
64
+ logger ??= console;
65
+ const dbData = utils_2.ModulesSdkUtils.loadDatabaseConfig("link_modules", options);
66
+ const entity = (0, utils_1.generateEntity)(joinerConfig, primary, foreign);
67
+ const pathToMigrations = __dirname + "/../migrations";
68
+ const orm = await utils_2.DALUtils.mikroOrmCreateConnection(dbData, [entity], pathToMigrations);
69
+ try {
70
+ const migrator = orm.getMigrator();
71
+ await migrator.down();
72
+ logger.info(`Link module "${serviceName}" migration executed`);
73
+ }
74
+ catch (error) {
75
+ logger.error(`Link module "${serviceName}" migration failed to run - Error: ${error.errros ?? error}`);
76
+ }
77
+ await orm.close();
78
+ };
79
+ }
80
+ exports.getRevertMigration = getRevertMigration;
@@ -1,2 +1,3 @@
1
1
  export { MikroOrmBaseRepository as BaseRepository } from "@medusajs/utils";
2
2
  export { getLinkRepository } from "./link";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/repositories/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,IAAI,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA"}
@@ -14,10 +14,11 @@ 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[]>;
18
- softDelete(idsOrFilter: string[] | {
19
- [x: string]: any;
20
- }, sharedContext?: Context | undefined): Promise<[object[], Record<string, unknown[]>]>;
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
+ }>;
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[]>]>;
21
22
  restore(idsOrFilter: string[] | {
22
23
  [x: string]: any;
23
24
  }, sharedContext?: Context | undefined): Promise<[object[], Record<string, unknown[]>]>;
@@ -35,3 +36,4 @@ export declare function getLinkRepository(model: EntitySchema): {
35
36
  serialize<TOutput extends object | object[]>(data: any, options?: any): Promise<TOutput>;
36
37
  };
37
38
  };
39
+ //# sourceMappingURL=link.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../src/repositories/link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAQ9C,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY;2BAInB;QAAE,YAAY,EAAE,kBAAkB,CAAA;KAAE;gCAF1C,kBAAkB;qBAQvB,GAAG,YAAW,OAAO,GAAQ,QAAQ,IAAI,CAAC;qBAY1C,MAAM,EAAE,YAAW,OAAO,GAAQ,QAAQ,MAAM,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBzE"}
@@ -5,3 +5,4 @@ export declare function getReadOnlyModuleService(joinerConfig: ModuleJoinerConfi
5
5
  __joinerConfig(): ModuleJoinerConfig;
6
6
  };
7
7
  };
8
+ //# sourceMappingURL=dynamic-service-class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamic-service-class.d.ts","sourceRoot":"","sources":["../../src/services/dynamic-service-class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAI9E,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,kBAAkB,GAC/B,WAAW,CAAC,WAAW,CAAC,CAmB1B;AAED,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,kBAAkB;;0BAEnD,kBAAkB;;EAIvC"}
@@ -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_;
@@ -1,3 +1,4 @@
1
1
  export * from "./dynamic-service-class";
2
2
  export { default as LinkService } from "./link";
3
3
  export { default as LinkModuleService } from "./link-module-service";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAA;AAC/C,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CAAA"}
@@ -37,3 +37,4 @@ export default class LinkModuleService<TLink> implements ILinkModule {
37
37
  restore_(data: any, sharedContext?: Context): Promise<[object[], Record<string, string[]>]>;
38
38
  }
39
39
  export {};
40
+ //# sourceMappingURL=link-module-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link-module-service.d.ts","sourceRoot":"","sources":["../../src/services/link-module-service.ts"],"names":[],"mappings":"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"}
@@ -92,16 +92,14 @@ class LinkModuleService {
92
92
  }
93
93
  const links = await this.linkService_.create(data, sharedContext);
94
94
  await this.eventBusModuleService_?.emit(data.map(({ id }) => ({
95
- eventName: this.entityName_ + "." + utils_1.CommonEvents.ATTACHED,
96
- body: {
97
- metadata: {
98
- service: this.serviceName_,
99
- action: utils_1.CommonEvents.ATTACHED,
100
- object: this.entityName_,
101
- eventGroupId: sharedContext.eventGroupId,
102
- },
103
- data: { id },
95
+ name: this.entityName_ + "." + utils_1.CommonEvents.ATTACHED,
96
+ metadata: {
97
+ source: this.serviceName_,
98
+ action: utils_1.CommonEvents.ATTACHED,
99
+ object: this.entityName_,
100
+ eventGroupId: sharedContext.eventGroupId,
104
101
  },
102
+ data: { id },
105
103
  })));
106
104
  return await this.baseRepository_.serialize(links);
107
105
  }
@@ -123,16 +121,14 @@ class LinkModuleService {
123
121
  await this.linkService_.delete(data, sharedContext);
124
122
  const allData = Array.isArray(data) ? data : [data];
125
123
  await this.eventBusModuleService_?.emit(allData.map(({ id }) => ({
126
- eventName: this.entityName_ + "." + utils_1.CommonEvents.DETACHED,
127
- body: {
128
- metadata: {
129
- service: this.serviceName_,
130
- action: utils_1.CommonEvents.DETACHED,
131
- object: this.entityName_,
132
- eventGroupId: sharedContext.eventGroupId,
133
- },
134
- data: { id },
124
+ name: this.entityName_ + "." + utils_1.CommonEvents.DETACHED,
125
+ metadata: {
126
+ source: this.serviceName_,
127
+ action: utils_1.CommonEvents.DETACHED,
128
+ object: this.entityName_,
129
+ eventGroupId: sharedContext.eventGroupId,
135
130
  },
131
+ data: { id },
136
132
  })));
137
133
  }
138
134
  async softDelete(data, { returnLinkableKeys } = {}, sharedContext = {}) {
@@ -155,16 +151,14 @@ class LinkModuleService {
155
151
  });
156
152
  }
157
153
  await this.eventBusModuleService_?.emit(deletedEntities.map(({ id }) => ({
158
- eventName: this.entityName_ + "." + utils_1.CommonEvents.DETACHED,
159
- body: {
160
- metadata: {
161
- service: this.serviceName_,
162
- action: utils_1.CommonEvents.DETACHED,
163
- object: this.entityName_,
164
- eventGroupId: sharedContext.eventGroupId,
165
- },
166
- data: { id },
154
+ name: this.entityName_ + "." + utils_1.CommonEvents.DETACHED,
155
+ metadata: {
156
+ source: this.serviceName_,
157
+ action: utils_1.CommonEvents.DETACHED,
158
+ object: this.entityName_,
159
+ eventGroupId: sharedContext.eventGroupId,
167
160
  },
161
+ data: { id },
168
162
  })));
169
163
  return mappedCascadedEntitiesMap ? mappedCascadedEntitiesMap : void 0;
170
164
  }
@@ -191,16 +185,14 @@ class LinkModuleService {
191
185
  });
192
186
  }
193
187
  await this.eventBusModuleService_?.emit(restoredEntities.map(({ id }) => ({
194
- eventName: this.entityName_ + "." + utils_1.CommonEvents.ATTACHED,
195
- body: {
196
- metadata: {
197
- service: this.serviceName_,
198
- action: utils_1.CommonEvents.ATTACHED,
199
- object: this.entityName_,
200
- eventGroupId: sharedContext.eventGroupId,
201
- },
202
- data: { id },
188
+ name: this.entityName_ + "." + utils_1.CommonEvents.ATTACHED,
189
+ metadata: {
190
+ source: this.serviceName_,
191
+ action: utils_1.CommonEvents.ATTACHED,
192
+ object: this.entityName_,
193
+ eventGroupId: sharedContext.eventGroupId,
203
194
  },
195
+ data: { id },
204
196
  })));
205
197
  return mappedCascadedEntitiesMap ? mappedCascadedEntitiesMap : void 0;
206
198
  }
@@ -14,3 +14,4 @@ export default class LinkService<TEntity> {
14
14
  restore(data: any, sharedContext?: Context): Promise<[object[], Record<string, string[]>]>;
15
15
  }
16
16
  export {};
17
+ //# sourceMappingURL=link.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../src/services/link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AASrD,KAAK,oBAAoB,GAAG;IAC1B,cAAc,EAAE,GAAG,CAAA;CACpB,CAAA;AAED,MAAM,CAAC,OAAO,OAAO,WAAW,CAAC,OAAO;IACtC,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,GAAG,CAAA;gBAE3B,EAAE,cAAc,EAAE,EAAE,oBAAoB;IAK9C,IAAI,CACR,OAAO,GAAE,OAAY,EACrB,MAAM,GAAE,UAAU,CAAC,OAAO,CAAM,EACf,aAAa,GAAE,OAAY,GAC3C,OAAO,CAAC,OAAO,EAAE,CAAC;IASf,YAAY,CAChB,OAAO,KAAK,EACZ,MAAM,GAAE,UAAU,CAAC,OAAO,CAAM,EACf,aAAa,GAAE,OAAY,GAC3C,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC;IAMzB,MAAM,CACV,IAAI,EAAE,OAAO,EAAE,EACE,aAAa,GAAE,OAAY,GAC3C,OAAO,CAAC,OAAO,EAAE,CAAC;IAOf,OAAO,CACX,IAAI,EAAE,OAAO,EAAE,EACE,aAAa,GAAE,OAAY,GAC3C,OAAO,CAAC,OAAO,EAAE,CAAC;IAqBf,MAAM,CACV,IAAI,EAAE,OAAO,EACI,aAAa,GAAE,OAAY,GAC3C,OAAO,CAAC,IAAI,CAAC;IAOV,UAAU,CACd,IAAI,EAAE,GAAG,EAAE,EACM,aAAa,GAAE,OAAY,GAC3C,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAqB1C,OAAO,CACX,IAAI,EAAE,GAAG,EACQ,aAAa,GAAE,OAAY,GAC3C,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;CAmBjD"}
@@ -2,3 +2,4 @@ import { Logger } from "@medusajs/types";
2
2
  export type InitializeModuleInjectableDependencies = {
3
3
  logger?: Logger;
4
4
  };
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAExC,MAAM,MAAM,sCAAsC,GAAG;IACnD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA"}
@@ -1,2 +1,3 @@
1
1
  export declare const composeLinkName: (...args: any[]) => string;
2
2
  export declare const composeTableName: (...args: any[]) => string;
3
+ //# sourceMappingURL=compose-link-name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose-link-name.d.ts","sourceRoot":"","sources":["../../src/utils/compose-link-name.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,4BAE3B,CAAA;AAED,eAAO,MAAM,gBAAgB,4BAE5B,CAAA"}
@@ -1,3 +1,4 @@
1
1
  import { JoinerRelationship, ModuleJoinerConfig } from "@medusajs/types";
2
2
  import { EntitySchema } from "@mikro-orm/core";
3
3
  export declare function generateEntity(joinerConfig: ModuleJoinerConfig, primary: JoinerRelationship, foreign: JoinerRelationship): EntitySchema<any, never>;
4
+ //# sourceMappingURL=generate-entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-entity.d.ts","sourceRoot":"","sources":["../../src/utils/generate-entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAOxE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAa9C,wBAAgB,cAAc,CAC5B,YAAY,EAAE,kBAAkB,EAChC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,kBAAkB,4BA6F5B"}
@@ -2,3 +2,4 @@ import { ModuleJoinerConfig, ModuleJoinerRelationship } from "@medusajs/types";
2
2
  export declare function generateGraphQLSchema(joinerConfig: ModuleJoinerConfig, primary: ModuleJoinerRelationship, foreign: ModuleJoinerRelationship, { logger }?: {
3
3
  logger: any;
4
4
  }): string;
5
+ //# sourceMappingURL=generate-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-schema.d.ts","sourceRoot":"","sources":["../../src/utils/generate-schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AAI9E,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,kBAAkB,EAChC,OAAO,EAAE,wBAAwB,EACjC,OAAO,EAAE,wBAAwB,EACjC,EAAE,MAAM,EAAE,GAAE;IAAE,MAAM,MAAA;CAAwB,UAiH7C"}
@@ -7,7 +7,8 @@ const compose_link_name_1 = require("./compose-link-name");
7
7
  function generateGraphQLSchema(joinerConfig, primary, foreign, { logger } = { logger: console }) {
8
8
  let fieldNames;
9
9
  let entityName;
10
- if (!joinerConfig.isReadOnlyLink) {
10
+ const isReadOnlyLink = joinerConfig.isReadOnlyLink;
11
+ if (!isReadOnlyLink) {
11
12
  fieldNames = primary.foreignKey.split(",").concat(foreign.foreignKey);
12
13
  entityName = (0, utils_1.toPascalCase)("Link_" +
13
14
  (joinerConfig.databaseConfig?.tableName ??
@@ -16,12 +17,12 @@ function generateGraphQLSchema(joinerConfig, primary, foreign, { logger } = { lo
16
17
  let typeDef = "";
17
18
  for (const extend of joinerConfig.extends ?? []) {
18
19
  const extendedModule = modules_sdk_1.MedusaModule.getModuleInstance(extend.serviceName);
19
- if (!extendedModule && !extend.relationship.isInternalService) {
20
+ if (!extendedModule) {
20
21
  throw new Error(`Module ${extend.serviceName} not found. Please verify that the module is configured and installed, also the module must be loaded before the link modules.`);
21
22
  }
22
23
  const extJoinerConfig = modules_sdk_1.MedusaModule.getJoinerConfig(extend.relationship.serviceName);
23
24
  let extendedEntityName = extJoinerConfig?.linkableKeys?.[extend.relationship.foreignKey];
24
- if (!extendedEntityName && (!primary || !foreign)) {
25
+ if (!isReadOnlyLink && !extendedEntityName && (!primary || !foreign)) {
25
26
  logger.warn(`Link modules schema: No linkable key found for ${extend.relationship.foreignKey} on module ${extend.relationship.serviceName}.`);
26
27
  continue;
27
28
  }
@@ -38,7 +39,7 @@ function generateGraphQLSchema(joinerConfig, primary, foreign, { logger } = { lo
38
39
  }
39
40
  `;
40
41
  }
41
- if (joinerConfig.isReadOnlyLink) {
42
+ if (isReadOnlyLink) {
42
43
  return typeDef;
43
44
  }
44
45
  // Pivot table fields
@@ -3,3 +3,4 @@ export * from "./generate-entity";
3
3
  export * from "./generate-schema";
4
4
  export declare function shouldForceTransaction(target: any): boolean;
5
5
  export declare function doNotForceTransaction(): boolean;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAEA,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AAEjC,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAE3D;AAED,wBAAgB,qBAAqB,IAAI,OAAO,CAE/C"}
@@ -15,12 +15,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.doNotForceTransaction = exports.shouldForceTransaction = void 0;
18
- const types_1 = require("@medusajs/types");
18
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
19
19
  __exportStar(require("./compose-link-name"), exports);
20
20
  __exportStar(require("./generate-entity"), exports);
21
21
  __exportStar(require("./generate-schema"), exports);
22
22
  function shouldForceTransaction(target) {
23
- return target.moduleDeclaration?.resources === types_1.MODULE_RESOURCE_TYPE.ISOLATED;
23
+ return target.moduleDeclaration?.resources === modules_sdk_1.MODULE_RESOURCE_TYPE.ISOLATED;
24
24
  }
25
25
  exports.shouldForceTransaction = shouldForceTransaction;
26
26
  function doNotForceTransaction() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/link-modules",
3
- "version": "0.2.12-snapshot-20240718083016",
3
+ "version": "0.2.12-snapshot-20240719133408",
4
4
  "description": "Medusa Default Link Modules Package and Definitions",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -16,7 +16,7 @@
16
16
  "access": "public"
17
17
  },
18
18
  "engines": {
19
- "node": ">=16"
19
+ "node": ">=20"
20
20
  },
21
21
  "author": "Medusa",
22
22
  "license": "MIT",
@@ -29,19 +29,18 @@
29
29
  "test:integration": "jest --passWithNoTests"
30
30
  },
31
31
  "devDependencies": {
32
+ "@medusajs/types": "1.12.0-snapshot-20240719133408",
32
33
  "cross-env": "^5.2.1",
33
- "jest": "^29.6.3",
34
+ "jest": "^29.7.0",
34
35
  "pg-god": "^1.0.12",
35
36
  "rimraf": "^5.0.1",
36
- "ts-jest": "^29.1.1",
37
37
  "ts-node": "^10.9.1",
38
38
  "tsc-alias": "^1.8.6",
39
39
  "typescript": "^5.1.6"
40
40
  },
41
41
  "dependencies": {
42
- "@medusajs/modules-sdk": "1.12.12-snapshot-20240718083016",
43
- "@medusajs/types": "1.11.17-snapshot-20240718083016",
44
- "@medusajs/utils": "1.11.10-snapshot-20240718083016",
42
+ "@medusajs/modules-sdk": "1.13.0-snapshot-20240719133408",
43
+ "@medusajs/utils": "1.12.0-snapshot-20240719133408",
45
44
  "@mikro-orm/core": "5.9.7",
46
45
  "@mikro-orm/postgresql": "5.9.7",
47
46
  "awilix": "^8.0.0"
@@ -1,67 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OrderSalesChannel = void 0;
4
- const modules_sdk_1 = require("@medusajs/modules-sdk");
5
- const utils_1 = require("@medusajs/utils");
6
- exports.OrderSalesChannel = {
7
- serviceName: utils_1.LINKS.OrderSalesChannel,
8
- isLink: true,
9
- databaseConfig: {
10
- tableName: "order_sales_channel",
11
- idPrefix: "ordersc",
12
- },
13
- alias: [
14
- {
15
- name: "order_sales_channel",
16
- },
17
- {
18
- name: "order_sales_channels",
19
- },
20
- ],
21
- primaryKeys: ["id", "order_id", "sales_channel_id"],
22
- relationships: [
23
- {
24
- serviceName: modules_sdk_1.Modules.ORDER,
25
- isInternalService: true,
26
- primaryKey: "id",
27
- foreignKey: "order_id",
28
- alias: "order",
29
- },
30
- {
31
- serviceName: "salesChannelService",
32
- isInternalService: true,
33
- primaryKey: "id",
34
- foreignKey: "sales_channel_id",
35
- alias: "sales_channel",
36
- },
37
- ],
38
- extends: [
39
- {
40
- serviceName: modules_sdk_1.Modules.ORDER,
41
- fieldAlias: {
42
- sales_channel: "sales_channel_link.sales_channel",
43
- },
44
- relationship: {
45
- serviceName: utils_1.LINKS.OrderSalesChannel,
46
- isInternalService: true,
47
- primaryKey: "order_id",
48
- foreignKey: "id",
49
- alias: "sales_channel_link",
50
- },
51
- },
52
- {
53
- serviceName: "salesChannelService",
54
- fieldAlias: {
55
- orders: "order_link.order",
56
- },
57
- relationship: {
58
- serviceName: utils_1.LINKS.OrderSalesChannel,
59
- isInternalService: true,
60
- primaryKey: "sales_channel_id",
61
- foreignKey: "id",
62
- alias: "order_link",
63
- isList: true,
64
- },
65
- },
66
- ],
67
- };
@@ -1,2 +0,0 @@
1
- import { ModuleJoinerConfig } from "@medusajs/types";
2
- export declare const ProductShippingProfile: ModuleJoinerConfig;
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProductShippingProfile = void 0;
4
- const modules_sdk_1 = require("@medusajs/modules-sdk");
5
- const utils_1 = require("@medusajs/utils");
6
- exports.ProductShippingProfile = {
7
- serviceName: utils_1.LINKS.ProductShippingProfile,
8
- isLink: true,
9
- databaseConfig: {
10
- tableName: "product_shipping_profile",
11
- idPrefix: "psprof",
12
- },
13
- alias: [
14
- {
15
- name: "product_shipping_profile",
16
- args: {
17
- entity: "LinkProductShippingProfile",
18
- },
19
- },
20
- ],
21
- primaryKeys: ["id", "product_id", "profile_id"],
22
- relationships: [
23
- {
24
- serviceName: modules_sdk_1.Modules.PRODUCT,
25
- primaryKey: "id",
26
- foreignKey: "product_id",
27
- alias: "product",
28
- },
29
- {
30
- serviceName: "shippingProfileService",
31
- isInternalService: true,
32
- primaryKey: "id",
33
- foreignKey: "profile_id",
34
- alias: "profile",
35
- },
36
- ],
37
- extends: [
38
- {
39
- serviceName: modules_sdk_1.Modules.PRODUCT,
40
- fieldAlias: {
41
- profile: "shipping_profile.profile",
42
- },
43
- relationship: {
44
- serviceName: utils_1.LINKS.ProductShippingProfile,
45
- primaryKey: "product_id",
46
- foreignKey: "id",
47
- alias: "shipping_profile",
48
- },
49
- },
50
- {
51
- serviceName: "shippingProfileService",
52
- relationship: {
53
- serviceName: utils_1.LINKS.ProductShippingProfile,
54
- isInternalService: true,
55
- primaryKey: "profile_id",
56
- foreignKey: "id",
57
- alias: "product_link",
58
- },
59
- },
60
- ],
61
- };
@@ -1,2 +0,0 @@
1
- import { ModuleJoinerConfig } from "@medusajs/types";
2
- export declare const StoreDefaultCurrency: ModuleJoinerConfig;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StoreDefaultCurrency = void 0;
4
- const modules_sdk_1 = require("@medusajs/modules-sdk");
5
- exports.StoreDefaultCurrency = {
6
- isLink: true,
7
- isReadOnlyLink: true,
8
- extends: [
9
- {
10
- serviceName: modules_sdk_1.Modules.STORE,
11
- relationship: {
12
- serviceName: modules_sdk_1.Modules.CURRENCY,
13
- primaryKey: "code",
14
- foreignKey: "default_currency_code",
15
- alias: "default_currency",
16
- },
17
- },
18
- ],
19
- };