@medusajs/link-modules 0.2.12-snapshot-20240718073308 → 0.2.12
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/definitions/{readonly/cart-customer.d.ts → cart-customer.d.ts} +0 -1
- package/dist/definitions/{readonly/cart-customer.js → cart-customer.js} +5 -11
- package/dist/definitions/cart-payment-collection.d.ts +0 -1
- package/dist/definitions/cart-payment-collection.js +5 -10
- package/dist/definitions/cart-promotion.d.ts +0 -1
- package/dist/definitions/cart-promotion.js +14 -14
- package/dist/definitions/{readonly/cart-region.d.ts → cart-region.d.ts} +0 -1
- package/dist/definitions/{readonly/cart-region.js → cart-region.js} +5 -11
- package/dist/definitions/{readonly/cart-sales-channel.d.ts → cart-sales-channel.d.ts} +0 -1
- package/dist/definitions/{readonly/cart-sales-channel.js → cart-sales-channel.js} +5 -11
- package/dist/definitions/fulfillment-set-location.d.ts +1 -2
- package/dist/definitions/fulfillment-set-location.js +30 -35
- package/dist/definitions/index.d.ts +9 -5
- package/dist/definitions/index.js +9 -4
- package/dist/definitions/{readonly/inventory-level-stock-location.d.ts → inventory-level-stock-location.d.ts} +0 -1
- package/dist/definitions/{readonly/inventory-level-stock-location.js → inventory-level-stock-location.js} +3 -6
- package/dist/definitions/{readonly/order-customer.d.ts → order-customer.d.ts} +0 -1
- package/dist/definitions/{readonly/order-customer.js → order-customer.js} +5 -11
- package/dist/definitions/order-promotion.d.ts +0 -1
- package/dist/definitions/order-promotion.js +7 -15
- package/dist/definitions/{readonly/order-region.d.ts → order-region.d.ts} +0 -1
- package/dist/definitions/{readonly/order-region.js → order-region.js} +5 -11
- package/dist/definitions/{readonly/order-sales-channel.d.ts → order-sales-channel.d.ts} +0 -1
- package/dist/definitions/order-sales-channel.js +67 -0
- package/dist/definitions/product-sales-channel.d.ts +0 -1
- package/dist/definitions/product-sales-channel.js +7 -10
- package/dist/definitions/product-shipping-profile.d.ts +2 -0
- package/dist/definitions/product-shipping-profile.js +61 -0
- package/dist/definitions/product-variant-inventory-item.d.ts +0 -1
- package/dist/definitions/product-variant-inventory-item.js +7 -13
- package/dist/definitions/product-variant-price-set.d.ts +0 -1
- package/dist/definitions/product-variant-price-set.js +8 -9
- package/dist/definitions/publishable-api-key-sales-channel.d.ts +0 -1
- package/dist/definitions/publishable-api-key-sales-channel.js +5 -10
- package/dist/definitions/region-payment-provider.d.ts +0 -1
- package/dist/definitions/region-payment-provider.js +5 -7
- package/dist/definitions/sales-channel-location.d.ts +0 -1
- package/dist/definitions/sales-channel-location.js +5 -10
- package/dist/definitions/shipping-option-price-set.d.ts +0 -1
- package/dist/definitions/shipping-option-price-set.js +5 -7
- package/dist/definitions/store-default-currency.d.ts +2 -0
- package/dist/definitions/store-default-currency.js +19 -0
- package/dist/index.d.ts +0 -1
- package/dist/initialize/index.d.ts +0 -2
- package/dist/initialize/index.js +14 -30
- package/dist/initialize/module-definition.d.ts +0 -1
- package/dist/loaders/connection.d.ts +0 -1
- package/dist/loaders/container.d.ts +0 -1
- package/dist/loaders/index.d.ts +0 -1
- package/dist/migration/index.d.ts +0 -2
- package/dist/migration/index.js +7 -31
- package/dist/repositories/index.d.ts +0 -1
- package/dist/repositories/link.d.ts +4 -6
- package/dist/services/dynamic-service-class.d.ts +0 -1
- package/dist/services/dynamic-service-class.js +0 -7
- package/dist/services/index.d.ts +0 -1
- package/dist/services/link-module-service.d.ts +0 -1
- package/dist/services/link-module-service.js +36 -28
- package/dist/services/link.d.ts +0 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/utils/compose-link-name.d.ts +0 -1
- package/dist/utils/generate-entity.d.ts +0 -1
- package/dist/utils/generate-schema.d.ts +0 -1
- package/dist/utils/generate-schema.js +4 -5
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +2 -2
- package/package.json +7 -6
- package/dist/definitions/cart-payment-collection.d.ts.map +0 -1
- package/dist/definitions/cart-promotion.d.ts.map +0 -1
- package/dist/definitions/fulfillment-set-location.d.ts.map +0 -1
- package/dist/definitions/index.d.ts.map +0 -1
- package/dist/definitions/order-cart.d.ts +0 -3
- package/dist/definitions/order-cart.d.ts.map +0 -1
- package/dist/definitions/order-cart.js +0 -67
- package/dist/definitions/order-claim-payment-collection.d.ts +0 -3
- package/dist/definitions/order-claim-payment-collection.d.ts.map +0 -1
- package/dist/definitions/order-claim-payment-collection.js +0 -73
- package/dist/definitions/order-exchange-payment-collection.d.ts +0 -3
- package/dist/definitions/order-exchange-payment-collection.d.ts.map +0 -1
- package/dist/definitions/order-exchange-payment-collection.js +0 -73
- package/dist/definitions/order-fulfillment.d.ts +0 -3
- package/dist/definitions/order-fulfillment.d.ts.map +0 -1
- package/dist/definitions/order-fulfillment.js +0 -66
- package/dist/definitions/order-payment-collection.d.ts +0 -3
- package/dist/definitions/order-payment-collection.d.ts.map +0 -1
- package/dist/definitions/order-payment-collection.js +0 -70
- package/dist/definitions/order-promotion.d.ts.map +0 -1
- package/dist/definitions/product-sales-channel.d.ts.map +0 -1
- package/dist/definitions/product-variant-inventory-item.d.ts.map +0 -1
- package/dist/definitions/product-variant-price-set.d.ts.map +0 -1
- package/dist/definitions/publishable-api-key-sales-channel.d.ts.map +0 -1
- package/dist/definitions/readonly/cart-customer.d.ts.map +0 -1
- package/dist/definitions/readonly/cart-product.d.ts +0 -3
- package/dist/definitions/readonly/cart-product.d.ts.map +0 -1
- package/dist/definitions/readonly/cart-product.js +0 -47
- package/dist/definitions/readonly/cart-region.d.ts.map +0 -1
- package/dist/definitions/readonly/cart-sales-channel.d.ts.map +0 -1
- package/dist/definitions/readonly/index.d.ts +0 -12
- package/dist/definitions/readonly/index.d.ts.map +0 -1
- package/dist/definitions/readonly/index.js +0 -27
- package/dist/definitions/readonly/inventory-level-stock-location.d.ts.map +0 -1
- package/dist/definitions/readonly/line-item-adjustment-promotion.d.ts +0 -3
- package/dist/definitions/readonly/line-item-adjustment-promotion.d.ts.map +0 -1
- package/dist/definitions/readonly/line-item-adjustment-promotion.js +0 -22
- package/dist/definitions/readonly/order-customer.d.ts.map +0 -1
- package/dist/definitions/readonly/order-product.d.ts +0 -3
- package/dist/definitions/readonly/order-product.d.ts.map +0 -1
- package/dist/definitions/readonly/order-product.js +0 -47
- package/dist/definitions/readonly/order-region.d.ts.map +0 -1
- package/dist/definitions/readonly/order-sales-channel.d.ts.map +0 -1
- package/dist/definitions/readonly/order-sales-channel.js +0 -35
- package/dist/definitions/readonly/store-currency.d.ts +0 -3
- package/dist/definitions/readonly/store-currency.d.ts.map +0 -1
- package/dist/definitions/readonly/store-currency.js +0 -22
- package/dist/definitions/region-payment-provider.d.ts.map +0 -1
- package/dist/definitions/sales-channel-location.d.ts.map +0 -1
- package/dist/definitions/shipping-option-price-set.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/initialize/index.d.ts.map +0 -1
- package/dist/initialize/module-definition.d.ts.map +0 -1
- package/dist/loaders/connection.d.ts.map +0 -1
- package/dist/loaders/container.d.ts.map +0 -1
- package/dist/loaders/index.d.ts.map +0 -1
- package/dist/migration/index.d.ts.map +0 -1
- package/dist/repositories/index.d.ts.map +0 -1
- package/dist/repositories/link.d.ts.map +0 -1
- package/dist/services/dynamic-service-class.d.ts.map +0 -1
- package/dist/services/index.d.ts.map +0 -1
- package/dist/services/link-module-service.d.ts.map +0 -1
- package/dist/services/link.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/utils/compose-link-name.d.ts.map +0 -1
- package/dist/utils/generate-entity.d.ts.map +0 -1
- package/dist/utils/generate-schema.d.ts.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
@@ -1,4 +1,3 @@
|
|
1
1
|
import { InternalModuleDeclaration, LoaderOptions, ModuleServiceInitializeCustomDataLayerOptions, ModuleServiceInitializeOptions } from "@medusajs/modules-sdk";
|
2
2
|
import { EntitySchema } from "@mikro-orm/core";
|
3
3
|
export declare function connectionLoader(entity: EntitySchema): ({ options, container, logger, }: LoaderOptions<ModuleServiceInitializeOptions | ModuleServiceInitializeCustomDataLayerOptions>, moduleDeclaration?: InternalModuleDeclaration) => Promise<void>;
|
4
|
-
//# sourceMappingURL=connection.d.ts.map
|
@@ -1,4 +1,3 @@
|
|
1
1
|
import { LoaderOptions } from "@medusajs/modules-sdk";
|
2
2
|
import { InternalModuleDeclaration, ModuleJoinerConfig, ModulesSdkTypes } from "@medusajs/types";
|
3
3
|
export declare function containerLoader(entity: any, joinerConfig: ModuleJoinerConfig): ({ options, container, }: LoaderOptions<ModulesSdkTypes.ModuleServiceInitializeOptions | ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions>, moduleDeclaration?: InternalModuleDeclaration) => Promise<void>;
|
4
|
-
//# sourceMappingURL=container.d.ts.map
|
package/dist/loaders/index.d.ts
CHANGED
@@ -1,4 +1,2 @@
|
|
1
1
|
import { JoinerRelationship, LoaderOptions, ModuleJoinerConfig, ModuleServiceInitializeOptions } from "@medusajs/types";
|
2
2
|
export declare function getMigration(joinerConfig: ModuleJoinerConfig, serviceName: string, primary: JoinerRelationship, foreign: JoinerRelationship): ({ options, logger, }?: Pick<LoaderOptions<ModuleServiceInitializeOptions>, "options" | "logger">) => Promise<void>;
|
3
|
-
export declare function getRevertMigration(joinerConfig: ModuleJoinerConfig, serviceName: string, primary: JoinerRelationship, foreign: JoinerRelationship): ({ options, logger, }?: Pick<LoaderOptions<ModuleServiceInitializeOptions>, "options" | "logger">) => Promise<void>;
|
4
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/migration/index.js
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
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
|
8
|
+
logger ?? (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,9 +13,7 @@ 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
|
17
|
-
.getConnection()
|
18
|
-
.execute(`SELECT 1 FROM "${tableName}" LIMIT 0`);
|
16
|
+
await orm.em.getConnection().execute(`SELECT 1 FROM ${tableName} LIMIT 0`);
|
19
17
|
hasTable = true;
|
20
18
|
}
|
21
19
|
catch { }
|
@@ -35,46 +33,24 @@ function getMigration(joinerConfig, serviceName, primary, foreign) {
|
|
35
33
|
logger.info(`Link module "${serviceName}" migration executed`)
|
36
34
|
} catch (error) {
|
37
35
|
logger.error(
|
38
|
-
`Link module "${serviceName}" migration failed to run - Error: ${error
|
36
|
+
`Link module "${serviceName}" migration failed to run - Error: ${error}`
|
39
37
|
)
|
40
38
|
}
|
41
39
|
} else {
|
42
40
|
logger.info(`Skipping "${tableName}" migration.`)
|
43
41
|
}*/
|
44
|
-
|
45
|
-
// logger.info(
|
46
|
-
// `Link module('${serviceName}'): Table already exists. Write your own migration if needed.`
|
47
|
-
// )
|
42
|
+
logger.info(`Link module "${serviceName}" table update skipped because the table already exists. Please write your own migration if needed.`);
|
48
43
|
}
|
49
44
|
else {
|
50
45
|
try {
|
51
46
|
await generator.createSchema();
|
52
|
-
logger.info(`Link module
|
47
|
+
logger.info(`Link module "${serviceName}" migration executed`);
|
53
48
|
}
|
54
49
|
catch (error) {
|
55
|
-
logger.error(`Link module
|
50
|
+
logger.error(`Link module "${serviceName}" migration failed to run - Error: ${error}`);
|
56
51
|
}
|
57
52
|
}
|
58
53
|
await orm.close();
|
59
54
|
};
|
60
55
|
}
|
61
56
|
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;
|
@@ -14,11 +14,10 @@ export declare function getLinkRepository(model: EntitySchema): {
|
|
14
14
|
find(options?: import("@medusajs/types").FindOptions<object> | undefined, context?: Context | undefined): Promise<object[]>;
|
15
15
|
findAndCount(options?: import("@medusajs/types").FindOptions<object> | undefined, context?: Context | undefined): Promise<[object[], number]>;
|
16
16
|
upsert(data: unknown[], context?: Context | undefined): Promise<object[]>;
|
17
|
-
upsertWithReplace(data: unknown[], config?: import("@medusajs/types").UpsertWithReplaceConfig<object> | undefined, context?: Context | undefined): Promise<
|
18
|
-
|
19
|
-
|
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[]>]>;
|
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[]>]>;
|
22
21
|
restore(idsOrFilter: string[] | {
|
23
22
|
[x: string]: any;
|
24
23
|
}, sharedContext?: Context | undefined): Promise<[object[], Record<string, unknown[]>]>;
|
@@ -36,4 +35,3 @@ export declare function getLinkRepository(model: EntitySchema): {
|
|
36
35
|
serialize<TOutput extends object | object[]>(data: any, options?: any): Promise<TOutput>;
|
37
36
|
};
|
38
37
|
};
|
39
|
-
//# sourceMappingURL=link.d.ts.map
|
@@ -1,17 +1,10 @@
|
|
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");
|
5
4
|
const _services_1 = require(".");
|
6
5
|
function getModuleService(joinerConfig) {
|
7
6
|
const joinerConfig_ = JSON.parse(JSON.stringify(joinerConfig));
|
8
|
-
const databaseConfig = joinerConfig_.databaseConfig;
|
9
7
|
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
|
-
}
|
15
8
|
return class LinkService extends _services_1.LinkModuleService {
|
16
9
|
__joinerConfig() {
|
17
10
|
return joinerConfig_;
|
package/dist/services/index.d.ts
CHANGED
@@ -92,14 +92,16 @@ class LinkModuleService {
|
|
92
92
|
}
|
93
93
|
const links = await this.linkService_.create(data, sharedContext);
|
94
94
|
await this.eventBusModuleService_?.emit(data.map(({ id }) => ({
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
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 },
|
101
104
|
},
|
102
|
-
data: { id },
|
103
105
|
})));
|
104
106
|
return await this.baseRepository_.serialize(links);
|
105
107
|
}
|
@@ -121,14 +123,16 @@ class LinkModuleService {
|
|
121
123
|
await this.linkService_.delete(data, sharedContext);
|
122
124
|
const allData = Array.isArray(data) ? data : [data];
|
123
125
|
await this.eventBusModuleService_?.emit(allData.map(({ id }) => ({
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
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 },
|
130
135
|
},
|
131
|
-
data: { id },
|
132
136
|
})));
|
133
137
|
}
|
134
138
|
async softDelete(data, { returnLinkableKeys } = {}, sharedContext = {}) {
|
@@ -151,14 +155,16 @@ class LinkModuleService {
|
|
151
155
|
});
|
152
156
|
}
|
153
157
|
await this.eventBusModuleService_?.emit(deletedEntities.map(({ id }) => ({
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
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 },
|
160
167
|
},
|
161
|
-
data: { id },
|
162
168
|
})));
|
163
169
|
return mappedCascadedEntitiesMap ? mappedCascadedEntitiesMap : void 0;
|
164
170
|
}
|
@@ -185,14 +191,16 @@ class LinkModuleService {
|
|
185
191
|
});
|
186
192
|
}
|
187
193
|
await this.eventBusModuleService_?.emit(restoredEntities.map(({ id }) => ({
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
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 },
|
194
203
|
},
|
195
|
-
data: { id },
|
196
204
|
})));
|
197
205
|
return mappedCascadedEntitiesMap ? mappedCascadedEntitiesMap : void 0;
|
198
206
|
}
|
package/dist/services/link.d.ts
CHANGED
package/dist/types/index.d.ts
CHANGED
@@ -1,4 +1,3 @@
|
|
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
|
@@ -2,4 +2,3 @@ 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
|
@@ -7,8 +7,7 @@ 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
|
-
|
11
|
-
if (!isReadOnlyLink) {
|
10
|
+
if (!joinerConfig.isReadOnlyLink) {
|
12
11
|
fieldNames = primary.foreignKey.split(",").concat(foreign.foreignKey);
|
13
12
|
entityName = (0, utils_1.toPascalCase)("Link_" +
|
14
13
|
(joinerConfig.databaseConfig?.tableName ??
|
@@ -17,12 +16,12 @@ function generateGraphQLSchema(joinerConfig, primary, foreign, { logger } = { lo
|
|
17
16
|
let typeDef = "";
|
18
17
|
for (const extend of joinerConfig.extends ?? []) {
|
19
18
|
const extendedModule = modules_sdk_1.MedusaModule.getModuleInstance(extend.serviceName);
|
20
|
-
if (!extendedModule) {
|
19
|
+
if (!extendedModule && !extend.relationship.isInternalService) {
|
21
20
|
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.`);
|
22
21
|
}
|
23
22
|
const extJoinerConfig = modules_sdk_1.MedusaModule.getJoinerConfig(extend.relationship.serviceName);
|
24
23
|
let extendedEntityName = extJoinerConfig?.linkableKeys?.[extend.relationship.foreignKey];
|
25
|
-
if (!
|
24
|
+
if (!extendedEntityName && (!primary || !foreign)) {
|
26
25
|
logger.warn(`Link modules schema: No linkable key found for ${extend.relationship.foreignKey} on module ${extend.relationship.serviceName}.`);
|
27
26
|
continue;
|
28
27
|
}
|
@@ -39,7 +38,7 @@ function generateGraphQLSchema(joinerConfig, primary, foreign, { logger } = { lo
|
|
39
38
|
}
|
40
39
|
`;
|
41
40
|
}
|
42
|
-
if (isReadOnlyLink) {
|
41
|
+
if (joinerConfig.isReadOnlyLink) {
|
43
42
|
return typeDef;
|
44
43
|
}
|
45
44
|
// Pivot table fields
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
@@ -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
|
18
|
+
const types_1 = require("@medusajs/types");
|
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 ===
|
23
|
+
return target.moduleDeclaration?.resources === types_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
|
3
|
+
"version": "0.2.12",
|
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": ">=
|
19
|
+
"node": ">=16"
|
20
20
|
},
|
21
21
|
"author": "Medusa",
|
22
22
|
"license": "MIT",
|
@@ -29,18 +29,19 @@
|
|
29
29
|
"test:integration": "jest --passWithNoTests"
|
30
30
|
},
|
31
31
|
"devDependencies": {
|
32
|
-
"@medusajs/types": "1.12.0-snapshot-20240718073308",
|
33
32
|
"cross-env": "^5.2.1",
|
34
|
-
"jest": "^29.
|
33
|
+
"jest": "^29.6.3",
|
35
34
|
"pg-god": "^1.0.12",
|
36
35
|
"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.
|
43
|
-
"@medusajs/
|
42
|
+
"@medusajs/modules-sdk": "^1.12.12",
|
43
|
+
"@medusajs/types": "^1.11.17",
|
44
|
+
"@medusajs/utils": "^1.11.10",
|
44
45
|
"@mikro-orm/core": "5.9.7",
|
45
46
|
"@mikro-orm/postgresql": "5.9.7",
|
46
47
|
"awilix": "^8.0.0"
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"cart-payment-collection.d.ts","sourceRoot":"","sources":["../../src/definitions/cart-payment-collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAGpD,eAAO,MAAM,qBAAqB,EAAE,kBA8DnC,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"cart-promotion.d.ts","sourceRoot":"","sources":["../../src/definitions/cart-promotion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAGpD,eAAO,MAAM,aAAa,EAAE,kBAmD3B,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"fulfillment-set-location.d.ts","sourceRoot":"","sources":["../../src/definitions/fulfillment-set-location.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAGpD,eAAO,MAAM,sBAAsB,EAAE,kBAgEpC,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/definitions/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA;AACzC,cAAc,kBAAkB,CAAA;AAChC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,cAAc,CAAA;AAC5B,cAAc,qBAAqB,CAAA;AACnC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,mBAAmB,CAAA;AACjC,cAAc,yBAAyB,CAAA;AACvC,cAAc,kCAAkC,CAAA;AAChD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,qCAAqC,CAAA;AACnD,cAAc,YAAY,CAAA;AAC1B,cAAc,2BAA2B,CAAA;AACzC,cAAc,0BAA0B,CAAA;AACxC,cAAc,6BAA6B,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"order-cart.d.ts","sourceRoot":"","sources":["../../src/definitions/order-cart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAGpD,eAAO,MAAM,SAAS,EAAE,kBA8DvB,CAAA"}
|
@@ -1,67 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.OrderCart = void 0;
|
4
|
-
const utils_1 = require("@medusajs/utils");
|
5
|
-
exports.OrderCart = {
|
6
|
-
serviceName: utils_1.LINKS.OrderCart,
|
7
|
-
isLink: true,
|
8
|
-
databaseConfig: {
|
9
|
-
tableName: "order_cart",
|
10
|
-
idPrefix: "ordercart",
|
11
|
-
},
|
12
|
-
alias: [
|
13
|
-
{
|
14
|
-
name: ["order_cart", "order_carts"],
|
15
|
-
args: {
|
16
|
-
entity: "LinkOrderCart",
|
17
|
-
},
|
18
|
-
},
|
19
|
-
],
|
20
|
-
primaryKeys: ["id", "order_id", "cart_id"],
|
21
|
-
relationships: [
|
22
|
-
{
|
23
|
-
serviceName: utils_1.Modules.ORDER,
|
24
|
-
primaryKey: "id",
|
25
|
-
foreignKey: "order_id",
|
26
|
-
alias: "order",
|
27
|
-
args: {
|
28
|
-
methodSuffix: "Orders",
|
29
|
-
},
|
30
|
-
},
|
31
|
-
{
|
32
|
-
serviceName: utils_1.Modules.CART,
|
33
|
-
primaryKey: "id",
|
34
|
-
foreignKey: "cart_id",
|
35
|
-
alias: "cart",
|
36
|
-
args: {
|
37
|
-
methodSuffix: "Carts",
|
38
|
-
},
|
39
|
-
},
|
40
|
-
],
|
41
|
-
extends: [
|
42
|
-
{
|
43
|
-
serviceName: utils_1.Modules.ORDER,
|
44
|
-
fieldAlias: {
|
45
|
-
cart: "cart_link.cart",
|
46
|
-
},
|
47
|
-
relationship: {
|
48
|
-
serviceName: utils_1.LINKS.OrderCart,
|
49
|
-
primaryKey: "order_id",
|
50
|
-
foreignKey: "id",
|
51
|
-
alias: "cart_link",
|
52
|
-
},
|
53
|
-
},
|
54
|
-
{
|
55
|
-
serviceName: utils_1.Modules.CART,
|
56
|
-
fieldAlias: {
|
57
|
-
order: "order_link.order",
|
58
|
-
},
|
59
|
-
relationship: {
|
60
|
-
serviceName: utils_1.LINKS.OrderCart,
|
61
|
-
primaryKey: "cart_id",
|
62
|
-
foreignKey: "id",
|
63
|
-
alias: "order_link",
|
64
|
-
},
|
65
|
-
},
|
66
|
-
],
|
67
|
-
};
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"order-claim-payment-collection.d.ts","sourceRoot":"","sources":["../../src/definitions/order-claim-payment-collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAGpD,eAAO,MAAM,2BAA2B,EAAE,kBAoEzC,CAAA"}
|
@@ -1,73 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.OrderClaimPaymentCollection = void 0;
|
4
|
-
const utils_1 = require("@medusajs/utils");
|
5
|
-
exports.OrderClaimPaymentCollection = {
|
6
|
-
serviceName: utils_1.LINKS.OrderClaimPaymentCollection,
|
7
|
-
isLink: true,
|
8
|
-
databaseConfig: {
|
9
|
-
tableName: "order_claim_payment_collection",
|
10
|
-
idPrefix: "claimpay",
|
11
|
-
},
|
12
|
-
alias: [
|
13
|
-
{
|
14
|
-
name: [
|
15
|
-
"order_claim_payment_collection",
|
16
|
-
"order_claim_payment_collections",
|
17
|
-
],
|
18
|
-
args: {
|
19
|
-
entity: "LinkOrderClaimPaymentCollection",
|
20
|
-
},
|
21
|
-
},
|
22
|
-
],
|
23
|
-
primaryKeys: ["id", "claim_id", "payment_collection_id"],
|
24
|
-
relationships: [
|
25
|
-
{
|
26
|
-
serviceName: utils_1.Modules.ORDER,
|
27
|
-
primaryKey: "id",
|
28
|
-
foreignKey: "claim_id",
|
29
|
-
alias: "order",
|
30
|
-
args: {
|
31
|
-
methodSuffix: "OrderClaims",
|
32
|
-
},
|
33
|
-
},
|
34
|
-
{
|
35
|
-
serviceName: utils_1.Modules.PAYMENT,
|
36
|
-
primaryKey: "id",
|
37
|
-
foreignKey: "payment_collection_id",
|
38
|
-
alias: "payment_collection",
|
39
|
-
args: {
|
40
|
-
methodSuffix: "PaymentCollections",
|
41
|
-
},
|
42
|
-
},
|
43
|
-
],
|
44
|
-
extends: [
|
45
|
-
{
|
46
|
-
serviceName: utils_1.Modules.ORDER,
|
47
|
-
fieldAlias: {
|
48
|
-
claim_payment_collections: {
|
49
|
-
path: "claim_payment_collections_link.payment_collection",
|
50
|
-
isList: true,
|
51
|
-
},
|
52
|
-
},
|
53
|
-
relationship: {
|
54
|
-
serviceName: utils_1.LINKS.OrderClaimPaymentCollection,
|
55
|
-
primaryKey: "claim_id",
|
56
|
-
foreignKey: "id",
|
57
|
-
alias: "claim_payment_collections_link",
|
58
|
-
},
|
59
|
-
},
|
60
|
-
{
|
61
|
-
serviceName: utils_1.Modules.PAYMENT,
|
62
|
-
fieldAlias: {
|
63
|
-
claim: "order_claim_link.order",
|
64
|
-
},
|
65
|
-
relationship: {
|
66
|
-
serviceName: utils_1.LINKS.OrderClaimPaymentCollection,
|
67
|
-
primaryKey: "payment_collection_id",
|
68
|
-
foreignKey: "id",
|
69
|
-
alias: "order_claim_link",
|
70
|
-
},
|
71
|
-
},
|
72
|
-
],
|
73
|
-
};
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"order-exchange-payment-collection.d.ts","sourceRoot":"","sources":["../../src/definitions/order-exchange-payment-collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAGpD,eAAO,MAAM,8BAA8B,EAAE,kBAoE5C,CAAA"}
|