@medusajs/link-modules 0.2.12-snapshot-20240503181318 → 0.2.12-snapshot-20240516152256

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. package/dist/definitions/fulfillment-set-location.js +3 -0
  2. package/dist/definitions/index.d.ts +4 -9
  3. package/dist/definitions/index.js +4 -9
  4. package/dist/definitions/order-fulfillment.d.ts +2 -0
  5. package/dist/definitions/order-fulfillment.js +64 -0
  6. package/dist/definitions/order-payment-collection.d.ts +2 -0
  7. package/dist/definitions/order-payment-collection.js +65 -0
  8. package/dist/definitions/order-promotion.js +5 -2
  9. package/dist/definitions/readonly/cart-product.d.ts +2 -0
  10. package/dist/definitions/readonly/cart-product.js +44 -0
  11. package/dist/definitions/readonly/index.d.ts +9 -0
  12. package/dist/definitions/readonly/index.js +25 -0
  13. package/dist/definitions/readonly/order-product.d.ts +2 -0
  14. package/dist/definitions/readonly/order-product.js +44 -0
  15. package/dist/definitions/readonly/order-sales-channel.js +29 -0
  16. package/dist/initialize/index.d.ts +1 -0
  17. package/dist/initialize/index.js +14 -5
  18. package/dist/migration/index.d.ts +1 -0
  19. package/dist/migration/index.js +21 -2
  20. package/package.json +4 -4
  21. package/dist/definitions/order-sales-channel.js +0 -67
  22. package/dist/definitions/product-shipping-profile.d.ts +0 -2
  23. package/dist/definitions/product-shipping-profile.js +0 -61
  24. /package/dist/definitions/{cart-customer.d.ts → readonly/cart-customer.d.ts} +0 -0
  25. /package/dist/definitions/{cart-customer.js → readonly/cart-customer.js} +0 -0
  26. /package/dist/definitions/{cart-region.d.ts → readonly/cart-region.d.ts} +0 -0
  27. /package/dist/definitions/{cart-region.js → readonly/cart-region.js} +0 -0
  28. /package/dist/definitions/{cart-sales-channel.d.ts → readonly/cart-sales-channel.d.ts} +0 -0
  29. /package/dist/definitions/{cart-sales-channel.js → readonly/cart-sales-channel.js} +0 -0
  30. /package/dist/definitions/{inventory-level-stock-location.d.ts → readonly/inventory-level-stock-location.d.ts} +0 -0
  31. /package/dist/definitions/{inventory-level-stock-location.js → readonly/inventory-level-stock-location.js} +0 -0
  32. /package/dist/definitions/{order-customer.d.ts → readonly/order-customer.d.ts} +0 -0
  33. /package/dist/definitions/{order-customer.js → readonly/order-customer.js} +0 -0
  34. /package/dist/definitions/{order-sales-channel.d.ts → readonly/order-sales-channel.d.ts} +0 -0
  35. /package/dist/definitions/{store-default-currency.d.ts → readonly/store-default-currency.d.ts} +0 -0
  36. /package/dist/definitions/{store-default-currency.js → readonly/store-default-currency.js} +0 -0
@@ -50,6 +50,9 @@ exports.LocationFulfillmentSet = {
50
50
  },
51
51
  {
52
52
  serviceName: modules_sdk_1.Modules.FULFILLMENT,
53
+ fieldAlias: {
54
+ location: "locations_link.location",
55
+ },
53
56
  relationship: {
54
57
  serviceName: utils_1.LINKS.LocationFulfillmentSet,
55
58
  primaryKey: "fulfillment_set_id",
@@ -1,20 +1,15 @@
1
- export * from "./cart-customer";
2
1
  export * from "./cart-payment-collection";
3
2
  export * from "./cart-promotion";
4
- export * from "./cart-region";
5
- export * from "./cart-sales-channel";
6
- export * from "./inventory-level-stock-location";
7
- export * from "./location-fulfillment-set";
8
- export * from "./order-customer";
3
+ export * from "./fulfillment-set-location";
4
+ export * from "./order-payment-collection";
9
5
  export * from "./order-promotion";
10
6
  export * from "./order-region";
11
- export * from "./order-sales-channel";
12
7
  export * from "./product-sales-channel";
13
- export * from "./product-shipping-profile";
14
8
  export * from "./product-variant-inventory-item";
15
9
  export * from "./product-variant-price-set";
16
10
  export * from "./publishable-api-key-sales-channel";
11
+ export * from "./readonly";
17
12
  export * from "./region-payment-provider";
18
13
  export * from "./sales-channel-location";
19
14
  export * from "./shipping-option-price-set";
20
- export * from "./store-default-currency";
15
+ export * from "./order-fulfillment";
@@ -14,23 +14,18 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./cart-customer"), exports);
18
17
  __exportStar(require("./cart-payment-collection"), exports);
19
18
  __exportStar(require("./cart-promotion"), exports);
20
- __exportStar(require("./cart-region"), exports);
21
- __exportStar(require("./cart-sales-channel"), exports);
22
- __exportStar(require("./inventory-level-stock-location"), exports);
23
- __exportStar(require("./location-fulfillment-set"), exports);
24
- __exportStar(require("./order-customer"), exports);
19
+ __exportStar(require("./fulfillment-set-location"), exports);
20
+ __exportStar(require("./order-payment-collection"), exports);
25
21
  __exportStar(require("./order-promotion"), exports);
26
22
  __exportStar(require("./order-region"), exports);
27
- __exportStar(require("./order-sales-channel"), exports);
28
23
  __exportStar(require("./product-sales-channel"), exports);
29
- __exportStar(require("./product-shipping-profile"), exports);
30
24
  __exportStar(require("./product-variant-inventory-item"), exports);
31
25
  __exportStar(require("./product-variant-price-set"), exports);
32
26
  __exportStar(require("./publishable-api-key-sales-channel"), exports);
27
+ __exportStar(require("./readonly"), exports);
33
28
  __exportStar(require("./region-payment-provider"), exports);
34
29
  __exportStar(require("./sales-channel-location"), exports);
35
30
  __exportStar(require("./shipping-option-price-set"), exports);
36
- __exportStar(require("./store-default-currency"), exports);
31
+ __exportStar(require("./order-fulfillment"), exports);
@@ -0,0 +1,2 @@
1
+ import { ModuleJoinerConfig } from "@medusajs/types";
2
+ export declare const OrderFulfillment: ModuleJoinerConfig;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrderFulfillment = void 0;
4
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
5
+ const utils_1 = require("@medusajs/utils");
6
+ exports.OrderFulfillment = {
7
+ serviceName: utils_1.LINKS.OrderFulfillment,
8
+ isLink: true,
9
+ databaseConfig: {
10
+ tableName: "order_fulfillment",
11
+ idPrefix: "orderful",
12
+ },
13
+ alias: [
14
+ {
15
+ name: ["order_fulfillment", "order_fulfillments"],
16
+ args: {
17
+ entity: "LinkOrderFulfillment",
18
+ },
19
+ },
20
+ ],
21
+ primaryKeys: ["id", "order_id", "fulfillment_id"],
22
+ relationships: [
23
+ {
24
+ serviceName: modules_sdk_1.Modules.ORDER,
25
+ primaryKey: "id",
26
+ foreignKey: "order_id",
27
+ alias: "order",
28
+ },
29
+ {
30
+ serviceName: modules_sdk_1.Modules.FULFILLMENT,
31
+ primaryKey: "id",
32
+ foreignKey: "fulfillment_id",
33
+ alias: "fulfillments",
34
+ args: {
35
+ // TODO: We are not suppose to know the module implementation here, wait for later to think about inferring it
36
+ methodSuffix: "Fulfillments",
37
+ },
38
+ },
39
+ ],
40
+ extends: [
41
+ {
42
+ serviceName: modules_sdk_1.Modules.ORDER,
43
+ fieldAlias: {
44
+ fulfillments: "fulfillment_link.fulfillments",
45
+ },
46
+ relationship: {
47
+ serviceName: utils_1.LINKS.OrderFulfillment,
48
+ primaryKey: "order_id",
49
+ foreignKey: "id",
50
+ alias: "fulfillment_link",
51
+ isList: true,
52
+ },
53
+ },
54
+ {
55
+ serviceName: modules_sdk_1.Modules.FULFILLMENT,
56
+ relationship: {
57
+ serviceName: utils_1.LINKS.OrderFulfillment,
58
+ primaryKey: "fulfillment_id",
59
+ foreignKey: "id",
60
+ alias: "order_link",
61
+ },
62
+ },
63
+ ],
64
+ };
@@ -0,0 +1,2 @@
1
+ import { ModuleJoinerConfig } from "@medusajs/types";
2
+ export declare const OrderPaymentCollection: ModuleJoinerConfig;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrderPaymentCollection = void 0;
4
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
5
+ const utils_1 = require("@medusajs/utils");
6
+ exports.OrderPaymentCollection = {
7
+ serviceName: utils_1.LINKS.OrderPaymentCollection,
8
+ isLink: true,
9
+ databaseConfig: {
10
+ tableName: "order_payment_collection",
11
+ idPrefix: "capaycol",
12
+ },
13
+ alias: [
14
+ {
15
+ name: ["order_payment_collection", "order_payment_collections"],
16
+ args: {
17
+ entity: "LinkOrderPaymentCollection",
18
+ },
19
+ },
20
+ ],
21
+ primaryKeys: ["id", "order_id", "payment_collection_id"],
22
+ relationships: [
23
+ {
24
+ serviceName: modules_sdk_1.Modules.ORDER,
25
+ primaryKey: "id",
26
+ foreignKey: "order_id",
27
+ alias: "order",
28
+ },
29
+ {
30
+ serviceName: modules_sdk_1.Modules.PAYMENT,
31
+ primaryKey: "id",
32
+ foreignKey: "payment_collection_id",
33
+ alias: "payment_collection",
34
+ },
35
+ ],
36
+ extends: [
37
+ {
38
+ serviceName: modules_sdk_1.Modules.ORDER,
39
+ fieldAlias: {
40
+ payment_collections: {
41
+ path: "payment_collections_link.payment_collection",
42
+ isList: true,
43
+ },
44
+ },
45
+ relationship: {
46
+ serviceName: utils_1.LINKS.OrderPaymentCollection,
47
+ primaryKey: "order_id",
48
+ foreignKey: "id",
49
+ alias: "payment_collections_link",
50
+ },
51
+ },
52
+ {
53
+ serviceName: modules_sdk_1.Modules.PAYMENT,
54
+ fieldAlias: {
55
+ order: "order_link.order",
56
+ },
57
+ relationship: {
58
+ serviceName: utils_1.LINKS.OrderPaymentCollection,
59
+ primaryKey: "payment_collection_id",
60
+ foreignKey: "id",
61
+ alias: "order_link",
62
+ },
63
+ },
64
+ ],
65
+ };
@@ -36,11 +36,14 @@ exports.OrderPromotion = {
36
36
  extends: [
37
37
  {
38
38
  serviceName: modules_sdk_1.Modules.ORDER,
39
+ fieldAlias: {
40
+ promotion: "promotion_link.promotion",
41
+ },
39
42
  relationship: {
40
43
  serviceName: utils_1.LINKS.OrderPromotion,
41
44
  primaryKey: "order_id",
42
45
  foreignKey: "id",
43
- alias: "order_link",
46
+ alias: "promotion_link",
44
47
  },
45
48
  },
46
49
  {
@@ -49,7 +52,7 @@ exports.OrderPromotion = {
49
52
  serviceName: utils_1.LINKS.OrderPromotion,
50
53
  primaryKey: "promotion_id",
51
54
  foreignKey: "id",
52
- alias: "promotion_link",
55
+ alias: "order_link",
53
56
  },
54
57
  },
55
58
  ],
@@ -0,0 +1,2 @@
1
+ import { ModuleJoinerConfig } from "@medusajs/types";
2
+ export declare const CartProduct: ModuleJoinerConfig;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CartProduct = void 0;
4
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
5
+ exports.CartProduct = {
6
+ isLink: true,
7
+ isReadOnlyLink: true,
8
+ extends: [
9
+ {
10
+ serviceName: modules_sdk_1.Modules.CART,
11
+ relationship: {
12
+ serviceName: modules_sdk_1.Modules.PRODUCT,
13
+ primaryKey: "id",
14
+ foreignKey: "items.product_id",
15
+ alias: "product",
16
+ },
17
+ },
18
+ {
19
+ serviceName: modules_sdk_1.Modules.CART,
20
+ relationship: {
21
+ serviceName: modules_sdk_1.Modules.PRODUCT,
22
+ primaryKey: "id",
23
+ foreignKey: "items.variant_id",
24
+ alias: "variant",
25
+ args: {
26
+ methodSuffix: "Variants",
27
+ },
28
+ },
29
+ },
30
+ {
31
+ serviceName: modules_sdk_1.Modules.PRODUCT,
32
+ relationship: {
33
+ serviceName: modules_sdk_1.Modules.CART,
34
+ primaryKey: "variant_id",
35
+ foreignKey: "id",
36
+ alias: "cart_items",
37
+ isList: true,
38
+ args: {
39
+ methodSuffix: "LineItems",
40
+ },
41
+ },
42
+ },
43
+ ],
44
+ };
@@ -0,0 +1,9 @@
1
+ export * from "./cart-customer";
2
+ export * from "./cart-product";
3
+ export * from "./cart-region";
4
+ export * from "./cart-sales-channel";
5
+ export * from "./inventory-level-stock-location";
6
+ export * from "./order-customer";
7
+ export * from "./order-product";
8
+ export * from "./order-sales-channel";
9
+ export * from "./store-default-currency";
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./cart-customer"), exports);
18
+ __exportStar(require("./cart-product"), exports);
19
+ __exportStar(require("./cart-region"), exports);
20
+ __exportStar(require("./cart-sales-channel"), exports);
21
+ __exportStar(require("./inventory-level-stock-location"), exports);
22
+ __exportStar(require("./order-customer"), exports);
23
+ __exportStar(require("./order-product"), exports);
24
+ __exportStar(require("./order-sales-channel"), exports);
25
+ __exportStar(require("./store-default-currency"), exports);
@@ -0,0 +1,2 @@
1
+ import { ModuleJoinerConfig } from "@medusajs/types";
2
+ export declare const OrderProduct: ModuleJoinerConfig;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrderProduct = void 0;
4
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
5
+ exports.OrderProduct = {
6
+ isLink: true,
7
+ isReadOnlyLink: true,
8
+ extends: [
9
+ {
10
+ serviceName: modules_sdk_1.Modules.ORDER,
11
+ relationship: {
12
+ serviceName: modules_sdk_1.Modules.PRODUCT,
13
+ primaryKey: "id",
14
+ foreignKey: "items.product_id",
15
+ alias: "product",
16
+ },
17
+ },
18
+ {
19
+ serviceName: modules_sdk_1.Modules.ORDER,
20
+ relationship: {
21
+ serviceName: modules_sdk_1.Modules.PRODUCT,
22
+ primaryKey: "id",
23
+ foreignKey: "items.variant_id",
24
+ alias: "variant",
25
+ args: {
26
+ methodSuffix: "Variants",
27
+ },
28
+ },
29
+ },
30
+ {
31
+ serviceName: modules_sdk_1.Modules.PRODUCT,
32
+ relationship: {
33
+ serviceName: modules_sdk_1.Modules.ORDER,
34
+ primaryKey: "variant_id",
35
+ foreignKey: "id",
36
+ alias: "order_items",
37
+ isList: true,
38
+ args: {
39
+ methodSuffix: "LineItems",
40
+ },
41
+ },
42
+ },
43
+ ],
44
+ };
@@ -0,0 +1,29 @@
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
+ exports.OrderSalesChannel = {
6
+ isLink: true,
7
+ isReadOnlyLink: true,
8
+ extends: [
9
+ {
10
+ serviceName: modules_sdk_1.Modules.ORDER,
11
+ relationship: {
12
+ serviceName: modules_sdk_1.Modules.SALES_CHANNEL,
13
+ primaryKey: "id",
14
+ foreignKey: "sales_channel_id",
15
+ alias: "sales_channel",
16
+ },
17
+ },
18
+ {
19
+ serviceName: modules_sdk_1.Modules.SALES_CHANNEL,
20
+ relationship: {
21
+ serviceName: modules_sdk_1.Modules.ORDER,
22
+ primaryKey: "sales_channel_id",
23
+ foreignKey: "id",
24
+ alias: "orders",
25
+ isList: true,
26
+ },
27
+ },
28
+ ],
29
+ };
@@ -5,3 +5,4 @@ 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>;
@@ -23,7 +23,7 @@ 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
28
  const types_1 = require("@medusajs/types");
29
29
  const utils_1 = require("@medusajs/utils");
@@ -78,9 +78,9 @@ const initialize = async (options, modulesDefinition, injectedDependencies) => {
78
78
  definition.schema = (0, utils_2.generateGraphQLSchema)(definition, primary, foreign, {
79
79
  logger,
80
80
  });
81
- definition.alias ?? (definition.alias = []);
81
+ definition.alias ??= [];
82
82
  for (const alias of definition.alias) {
83
- alias.args ?? (alias.args = {});
83
+ alias.args ??= {};
84
84
  alias.args.entity = (0, utils_1.toPascalCase)("Link_" +
85
85
  (definition.databaseConfig?.tableName ??
86
86
  (0, utils_2.composeTableName)(primary.serviceName, primary.foreignKey, foreign.serviceName, foreign.foreignKey)));
@@ -109,7 +109,7 @@ const initialize = async (options, modulesDefinition, injectedDependencies) => {
109
109
  return allLinks;
110
110
  };
111
111
  exports.initialize = initialize;
112
- async function runMigrations({ options, logger, }, modulesDefinition) {
112
+ async function applyMigrationUpOrDown({ options, logger, }, modulesDefinition, revert = false) {
113
113
  const modulesLoadedKeys = modules_sdk_1.MedusaModule.getLoadedModules().map((mod) => Object.keys(mod)[0]);
114
114
  const allLinksToLoad = Object.values(linkDefinitions).concat(modulesDefinition ?? []);
115
115
  const allLinks = new Set();
@@ -131,8 +131,17 @@ async function runMigrations({ options, logger, }, modulesDefinition) {
131
131
  !modulesLoadedKeys.includes(foreign.serviceName)) {
132
132
  continue;
133
133
  }
134
- const migrate = (0, migration_1.getMigration)(definition, serviceKey, primary, foreign);
134
+ const migrate = revert
135
+ ? (0, migration_1.getRevertMigration)(definition, serviceKey, primary, foreign)
136
+ : (0, migration_1.getMigration)(definition, serviceKey, primary, foreign);
135
137
  await migrate({ options, logger });
136
138
  }
137
139
  }
140
+ async function runMigrations({ options, logger, }, modulesDefinition) {
141
+ await applyMigrationUpOrDown({ options, logger }, modulesDefinition);
142
+ }
138
143
  exports.runMigrations = runMigrations;
144
+ async function revertMigrations({ options, logger, }, modulesDefinition) {
145
+ await applyMigrationUpOrDown({ options, logger }, modulesDefinition, true);
146
+ }
147
+ exports.revertMigrations = revertMigrations;
@@ -1,2 +1,3 @@
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>;
@@ -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";
@@ -54,3 +54,22 @@ function getMigration(joinerConfig, serviceName, primary, foreign) {
54
54
  };
55
55
  }
56
56
  exports.getMigration = getMigration;
57
+ function getRevertMigration(joinerConfig, serviceName, primary, foreign) {
58
+ return async function revertMigrations({ options, logger, } = {}) {
59
+ logger ??= console;
60
+ const dbData = utils_2.ModulesSdkUtils.loadDatabaseConfig("link_modules", options);
61
+ const entity = (0, utils_1.generateEntity)(joinerConfig, primary, foreign);
62
+ const pathToMigrations = __dirname + "/../migrations";
63
+ const orm = await utils_2.DALUtils.mikroOrmCreateConnection(dbData, [entity], pathToMigrations);
64
+ try {
65
+ const migrator = orm.getMigrator();
66
+ await migrator.down();
67
+ logger.info(`Link module "${serviceName}" migration executed`);
68
+ }
69
+ catch (error) {
70
+ logger.error(`Link module "${serviceName}" migration failed to run - Error: ${error}`);
71
+ }
72
+ await orm.close();
73
+ };
74
+ }
75
+ exports.getRevertMigration = getRevertMigration;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/link-modules",
3
- "version": "0.2.12-snapshot-20240503181318",
3
+ "version": "0.2.12-snapshot-20240516152256",
4
4
  "description": "Medusa Default Link Modules Package and Definitions",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -39,9 +39,9 @@
39
39
  "typescript": "^5.1.6"
40
40
  },
41
41
  "dependencies": {
42
- "@medusajs/modules-sdk": "1.12.12-snapshot-20240503181318",
43
- "@medusajs/types": "1.11.17-snapshot-20240503181318",
44
- "@medusajs/utils": "1.11.10-snapshot-20240503181318",
42
+ "@medusajs/modules-sdk": "1.13.0-snapshot-20240516152256",
43
+ "@medusajs/types": "1.12.0-snapshot-20240516152256",
44
+ "@medusajs/utils": "1.12.0-snapshot-20240516152256",
45
45
  "@mikro-orm/core": "5.9.7",
46
46
  "@mikro-orm/postgresql": "5.9.7",
47
47
  "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
- };