@medusajs/link-modules 0.2.12-snapshot-20240531102054 → 0.2.12-snapshot-20240607093839
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/definitions/index.d.ts +2 -2
- package/dist/definitions/index.js +2 -2
- package/dist/definitions/order-cart.d.ts +2 -0
- package/dist/definitions/order-cart.js +62 -0
- package/dist/initialize/index.js +11 -1
- package/dist/repositories/link.d.ts +4 -1
- package/dist/services/dynamic-service-class.js +7 -0
- package/package.json +4 -4
@@ -1,6 +1,8 @@
|
|
1
1
|
export * from "./cart-payment-collection";
|
2
2
|
export * from "./cart-promotion";
|
3
3
|
export * from "./fulfillment-set-location";
|
4
|
+
export * from "./order-cart";
|
5
|
+
export * from "./order-fulfillment";
|
4
6
|
export * from "./order-payment-collection";
|
5
7
|
export * from "./order-promotion";
|
6
8
|
export * from "./product-sales-channel";
|
@@ -8,8 +10,6 @@ export * from "./product-variant-inventory-item";
|
|
8
10
|
export * from "./product-variant-price-set";
|
9
11
|
export * from "./publishable-api-key-sales-channel";
|
10
12
|
export * from "./readonly";
|
11
|
-
export * from "./order-fulfillment";
|
12
13
|
export * from "./region-payment-provider";
|
13
14
|
export * from "./sales-channel-location";
|
14
15
|
export * from "./shipping-option-price-set";
|
15
|
-
export * from "./order-fulfillment";
|
@@ -17,6 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./cart-payment-collection"), exports);
|
18
18
|
__exportStar(require("./cart-promotion"), exports);
|
19
19
|
__exportStar(require("./fulfillment-set-location"), exports);
|
20
|
+
__exportStar(require("./order-cart"), exports);
|
21
|
+
__exportStar(require("./order-fulfillment"), exports);
|
20
22
|
__exportStar(require("./order-payment-collection"), exports);
|
21
23
|
__exportStar(require("./order-promotion"), exports);
|
22
24
|
__exportStar(require("./product-sales-channel"), exports);
|
@@ -24,8 +26,6 @@ __exportStar(require("./product-variant-inventory-item"), exports);
|
|
24
26
|
__exportStar(require("./product-variant-price-set"), exports);
|
25
27
|
__exportStar(require("./publishable-api-key-sales-channel"), exports);
|
26
28
|
__exportStar(require("./readonly"), exports);
|
27
|
-
__exportStar(require("./order-fulfillment"), exports);
|
28
29
|
__exportStar(require("./region-payment-provider"), exports);
|
29
30
|
__exportStar(require("./sales-channel-location"), exports);
|
30
31
|
__exportStar(require("./shipping-option-price-set"), exports);
|
31
|
-
__exportStar(require("./order-fulfillment"), exports);
|
@@ -0,0 +1,62 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.OrderCart = void 0;
|
4
|
+
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
5
|
+
const utils_1 = require("@medusajs/utils");
|
6
|
+
exports.OrderCart = {
|
7
|
+
serviceName: utils_1.LINKS.OrderCart,
|
8
|
+
isLink: true,
|
9
|
+
databaseConfig: {
|
10
|
+
tableName: "order_cart",
|
11
|
+
idPrefix: "ordercart",
|
12
|
+
},
|
13
|
+
alias: [
|
14
|
+
{
|
15
|
+
name: ["order_cart", "order_carts"],
|
16
|
+
args: {
|
17
|
+
entity: "LinkOrderCart",
|
18
|
+
},
|
19
|
+
},
|
20
|
+
],
|
21
|
+
primaryKeys: ["id", "order_id", "cart_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.CART,
|
31
|
+
primaryKey: "id",
|
32
|
+
foreignKey: "cart_id",
|
33
|
+
alias: "cart",
|
34
|
+
},
|
35
|
+
],
|
36
|
+
extends: [
|
37
|
+
{
|
38
|
+
serviceName: modules_sdk_1.Modules.ORDER,
|
39
|
+
fieldAlias: {
|
40
|
+
cart: "cart_link.cart",
|
41
|
+
},
|
42
|
+
relationship: {
|
43
|
+
serviceName: utils_1.LINKS.OrderCart,
|
44
|
+
primaryKey: "order_id",
|
45
|
+
foreignKey: "id",
|
46
|
+
alias: "cart_link",
|
47
|
+
},
|
48
|
+
},
|
49
|
+
{
|
50
|
+
serviceName: modules_sdk_1.Modules.CART,
|
51
|
+
fieldAlias: {
|
52
|
+
order: "order_link.order",
|
53
|
+
},
|
54
|
+
relationship: {
|
55
|
+
serviceName: utils_1.LINKS.OrderCart,
|
56
|
+
primaryKey: "cart_id",
|
57
|
+
foreignKey: "id",
|
58
|
+
alias: "order_link",
|
59
|
+
},
|
60
|
+
},
|
61
|
+
],
|
62
|
+
};
|
package/dist/initialize/index.js
CHANGED
@@ -44,6 +44,14 @@ const initialize = async (options, modulesDefinition, injectedDependencies) => {
|
|
44
44
|
!definition.isReadOnlyLink) {
|
45
45
|
throw new Error(`Foreign key cannot be a composed key.`);
|
46
46
|
}
|
47
|
+
if (Array.isArray(definition.extraDataFields)) {
|
48
|
+
const extraDataFields = definition.extraDataFields;
|
49
|
+
const definedDbFields = Object.keys(definition.databaseConfig?.extraFields || {});
|
50
|
+
const difference = (0, utils_1.arrayDifference)(extraDataFields, definedDbFields);
|
51
|
+
if (difference.length) {
|
52
|
+
throw new Error(`extraDataFields (fieldNames: ${difference.join(",")}) need to be configured under databaseConfig (serviceName: ${definition.serviceName}).`);
|
53
|
+
}
|
54
|
+
}
|
47
55
|
const serviceKey = !definition.isReadOnlyLink
|
48
56
|
? (0, utils_1.lowerCaseFirst)(definition.serviceName ??
|
49
57
|
(0, utils_2.composeLinkName)(primary.serviceName, primary.foreignKey, foreign.serviceName, foreign.foreignKey))
|
@@ -75,7 +83,9 @@ const initialize = async (options, modulesDefinition, injectedDependencies) => {
|
|
75
83
|
definition.schema = (0, utils_2.generateGraphQLSchema)(definition, primary, foreign, {
|
76
84
|
logger,
|
77
85
|
});
|
78
|
-
definition.alias
|
86
|
+
if (!Array.isArray(definition.alias)) {
|
87
|
+
definition.alias = definition.alias ? [definition.alias] : [];
|
88
|
+
}
|
79
89
|
for (const alias of definition.alias) {
|
80
90
|
alias.args ??= {};
|
81
91
|
alias.args.entity = (0, utils_1.toPascalCase)("Link_" +
|
@@ -14,7 +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<
|
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
|
+
}>;
|
18
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[]>]>;
|
19
22
|
restore(idsOrFilter: string[] | {
|
20
23
|
[x: string]: any;
|
@@ -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_;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@medusajs/link-modules",
|
3
|
-
"version": "0.2.12-snapshot-
|
3
|
+
"version": "0.2.12-snapshot-20240607093839",
|
4
4
|
"description": "Medusa Default Link Modules Package and Definitions",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -29,7 +29,7 @@
|
|
29
29
|
"test:integration": "jest --passWithNoTests"
|
30
30
|
},
|
31
31
|
"devDependencies": {
|
32
|
-
"@medusajs/types": "1.12.0-snapshot-
|
32
|
+
"@medusajs/types": "1.12.0-snapshot-20240607093839",
|
33
33
|
"cross-env": "^5.2.1",
|
34
34
|
"jest": "^29.6.3",
|
35
35
|
"pg-god": "^1.0.12",
|
@@ -40,8 +40,8 @@
|
|
40
40
|
"typescript": "^5.1.6"
|
41
41
|
},
|
42
42
|
"dependencies": {
|
43
|
-
"@medusajs/modules-sdk": "1.13.0-snapshot-
|
44
|
-
"@medusajs/utils": "1.12.0-snapshot-
|
43
|
+
"@medusajs/modules-sdk": "1.13.0-snapshot-20240607093839",
|
44
|
+
"@medusajs/utils": "1.12.0-snapshot-20240607093839",
|
45
45
|
"@mikro-orm/core": "5.9.7",
|
46
46
|
"@mikro-orm/postgresql": "5.9.7",
|
47
47
|
"awilix": "^8.0.0"
|