@medusajs/link-modules 0.2.12-snapshot-20240719133408 → 0.2.12-snapshot-20240723115023
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/initialize/index.d.ts +12 -4
- package/dist/initialize/index.d.ts.map +1 -1
- package/dist/initialize/index.js +15 -17
- package/dist/initialize/module-definition.js +1 -2
- package/dist/loaders/connection.d.ts.map +1 -1
- package/dist/loaders/connection.js +1 -2
- package/dist/loaders/container.d.ts.map +1 -1
- package/dist/loaders/container.js +1 -2
- package/dist/loaders/index.js +1 -2
- package/dist/migration/index.d.ts +84 -3
- package/dist/migration/index.d.ts.map +1 -1
- package/dist/migration/index.js +290 -67
- package/dist/repositories/link.d.ts +14 -16
- package/dist/repositories/link.d.ts.map +1 -1
- package/dist/repositories/link.js +1 -2
- package/dist/services/dynamic-service-class.js +2 -3
- package/dist/utils/generate-entity.js +1 -2
- package/dist/utils/generate-schema.js +1 -2
- package/dist/utils/index.js +2 -3
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,2BAA2B,CAAA"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,2BAA2B,CAAA"}
|
package/dist/index.js
CHANGED
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
15
|
};
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
17
|
__exportStar(require("./initialize"), exports);
|
18
|
+
__exportStar(require("./migration"), exports);
|
18
19
|
__exportStar(require("./types"), exports);
|
19
20
|
__exportStar(require("./loaders"), exports);
|
20
21
|
__exportStar(require("./services"), exports);
|
@@ -1,9 +1,17 @@
|
|
1
1
|
import { InternalModuleDeclaration } from "@medusajs/modules-sdk";
|
2
|
-
import { ExternalModuleDeclaration, ILinkModule,
|
2
|
+
import { ExternalModuleDeclaration, ILinkModule, ModuleJoinerConfig, ModuleServiceInitializeCustomDataLayerOptions, ModuleServiceInitializeOptions } from "@medusajs/types";
|
3
|
+
import { MigrationsExecutionPlanner } from "../migration";
|
3
4
|
import { InitializeModuleInjectableDependencies } from "../types";
|
4
|
-
export declare const initialize: (options?: ModuleServiceInitializeOptions | ModuleServiceInitializeCustomDataLayerOptions | ExternalModuleDeclaration | InternalModuleDeclaration,
|
5
|
+
export declare const initialize: (options?: ModuleServiceInitializeOptions | ModuleServiceInitializeCustomDataLayerOptions | ExternalModuleDeclaration | InternalModuleDeclaration, pluginLinksDefinitions?: ModuleJoinerConfig[], injectedDependencies?: InitializeModuleInjectableDependencies) => Promise<{
|
5
6
|
[link: string]: ILinkModule;
|
6
7
|
}>;
|
7
|
-
|
8
|
-
|
8
|
+
/**
|
9
|
+
* Prepare an execution plan and run the migrations accordingly.
|
10
|
+
* It includes creating, updating, deleting the tables according to the execution plan.
|
11
|
+
* If any unsafe sql is identified then we will notify the user to act manually.
|
12
|
+
*
|
13
|
+
* @param options
|
14
|
+
* @param pluginLinksDefinition
|
15
|
+
*/
|
16
|
+
export declare function getMigrationPlanner(options: ModuleServiceInitializeOptions, pluginLinksDefinition?: ModuleJoinerConfig[]): MigrationsExecutionPlanner;
|
9
17
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/initialize/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EAI1B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,yBAAyB,EACzB,WAAW,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/initialize/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EAI1B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,yBAAyB,EACzB,WAAW,EAGX,kBAAkB,EAClB,6CAA6C,EAC7C,8BAA8B,EAC/B,MAAM,iBAAiB,CAAA;AAUxB,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,EAAE,sCAAsC,EAAE,MAAM,UAAU,CAAA;AAQjE,eAAO,MAAM,UAAU,aAEjB,8BAA8B,GAC9B,6CAA6C,GAC7C,yBAAyB,GACzB,yBAAyB,2BACJ,kBAAkB,EAAE,yBACtB,sCAAsC,KAC5D,OAAO,CAAC;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAA;CAAE,CAgJzC,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,8BAA8B,EACvC,qBAAqB,CAAC,EAAE,kBAAkB,EAAE,8BAgD7C"}
|
package/dist/initialize/index.js
CHANGED
@@ -23,17 +23,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
23
|
return result;
|
24
24
|
};
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
-
exports.
|
26
|
+
exports.initialize = void 0;
|
27
|
+
exports.getMigrationPlanner = getMigrationPlanner;
|
27
28
|
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
28
29
|
const utils_1 = require("@medusajs/utils");
|
29
30
|
const linkDefinitions = __importStar(require("../definitions"));
|
30
31
|
const migration_1 = require("../migration");
|
31
32
|
const utils_2 = require("../utils");
|
32
33
|
const module_definition_1 = require("./module-definition");
|
33
|
-
const initialize = async (options,
|
34
|
+
const initialize = async (options, pluginLinksDefinitions, injectedDependencies) => {
|
34
35
|
const allLinks = {};
|
35
36
|
const modulesLoadedKeys = modules_sdk_1.MedusaModule.getLoadedModules().map((mod) => Object.keys(mod)[0]);
|
36
|
-
const allLinksToLoad = Object.values(linkDefinitions).concat(
|
37
|
+
const allLinksToLoad = Object.values(linkDefinitions).concat(pluginLinksDefinitions ?? []);
|
37
38
|
for (const linkDefinition of allLinksToLoad) {
|
38
39
|
const definition = JSON.parse(JSON.stringify(linkDefinition));
|
39
40
|
const [primary, foreign] = definition.relationships ?? [];
|
@@ -116,9 +117,17 @@ const initialize = async (options, modulesDefinition, injectedDependencies) => {
|
|
116
117
|
return allLinks;
|
117
118
|
};
|
118
119
|
exports.initialize = initialize;
|
119
|
-
|
120
|
+
/**
|
121
|
+
* Prepare an execution plan and run the migrations accordingly.
|
122
|
+
* It includes creating, updating, deleting the tables according to the execution plan.
|
123
|
+
* If any unsafe sql is identified then we will notify the user to act manually.
|
124
|
+
*
|
125
|
+
* @param options
|
126
|
+
* @param pluginLinksDefinition
|
127
|
+
*/
|
128
|
+
function getMigrationPlanner(options, pluginLinksDefinition) {
|
120
129
|
const modulesLoadedKeys = modules_sdk_1.MedusaModule.getLoadedModules().map((mod) => Object.keys(mod)[0]);
|
121
|
-
const allLinksToLoad = Object.values(linkDefinitions).concat(
|
130
|
+
const allLinksToLoad = Object.values(linkDefinitions).concat(pluginLinksDefinition ?? []);
|
122
131
|
const allLinks = new Set();
|
123
132
|
for (const definition of allLinksToLoad) {
|
124
133
|
if (definition.isReadOnlyLink) {
|
@@ -138,17 +147,6 @@ async function applyMigrationUpOrDown({ options, logger, }, modulesDefinition, r
|
|
138
147
|
!modulesLoadedKeys.includes(foreign.serviceName)) {
|
139
148
|
continue;
|
140
149
|
}
|
141
|
-
const migrate = revert
|
142
|
-
? (0, migration_1.getRevertMigration)(definition, serviceKey, primary, foreign)
|
143
|
-
: (0, migration_1.getMigration)(definition, serviceKey, primary, foreign);
|
144
|
-
await migrate({ options, logger });
|
145
150
|
}
|
151
|
+
return new migration_1.MigrationsExecutionPlanner(allLinksToLoad, options);
|
146
152
|
}
|
147
|
-
async function runMigrations({ options, logger, }, modulesDefinition) {
|
148
|
-
await applyMigrationUpOrDown({ options, logger }, modulesDefinition);
|
149
|
-
}
|
150
|
-
exports.runMigrations = runMigrations;
|
151
|
-
async function revertMigrations({ options, logger, }, modulesDefinition) {
|
152
|
-
await applyMigrationUpOrDown({ options, logger }, modulesDefinition, true);
|
153
|
-
}
|
154
|
-
exports.revertMigrations = revertMigrations;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getLinkModuleDefinition =
|
3
|
+
exports.getLinkModuleDefinition = getLinkModuleDefinition;
|
4
4
|
const _services_1 = require("../services");
|
5
5
|
const loaders_1 = require("../loaders");
|
6
6
|
function getLinkModuleDefinition(joinerConfig, primary, foreign) {
|
@@ -15,4 +15,3 @@ function getLinkModuleDefinition(joinerConfig, primary, foreign) {
|
|
15
15
|
}),
|
16
16
|
};
|
17
17
|
}
|
18
|
-
exports.getLinkModuleDefinition = getLinkModuleDefinition;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/loaders/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,aAAa,EACb,6CAA6C,EAC7C,8BAA8B,EAC/B,MAAM,uBAAuB,CAAA;AAG9B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,qCAM9C,
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/loaders/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,aAAa,EACb,6CAA6C,EAC7C,8BAA8B,EAC/B,MAAM,uBAAuB,CAAA;AAG9B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,qCAM9C,aAAa,CACZ,8BAA8B,GAC9B,6CAA6C,CAChD,sBACmB,yBAAyB,KAC5C,OAAO,CAAC,IAAI,CAAC,CAajB"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.connectionLoader =
|
3
|
+
exports.connectionLoader = connectionLoader;
|
4
4
|
const utils_1 = require("@medusajs/utils");
|
5
5
|
function connectionLoader(entity) {
|
6
6
|
return async ({ options, container, logger, }, moduleDeclaration) => {
|
@@ -16,4 +16,3 @@ function connectionLoader(entity) {
|
|
16
16
|
});
|
17
17
|
};
|
18
18
|
}
|
19
|
-
exports.connectionLoader = connectionLoader;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/loaders/container.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,eAAe,EAChB,MAAM,iBAAiB,CAAA;AAKxB,wBAAgB,eAAe,CAAC,MAAM,KAAA,EAAE,YAAY,EAAE,kBAAkB,6BAKjE,
|
1
|
+
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/loaders/container.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,eAAe,EAChB,MAAM,iBAAiB,CAAA;AAKxB,wBAAgB,eAAe,CAAC,MAAM,KAAA,EAAE,YAAY,EAAE,kBAAkB,6BAKjE,aAAa,CACZ,eAAe,CAAC,8BAA8B,GAC9C,eAAe,CAAC,6CAA6C,CAChE,sBACmB,yBAAyB,KAC5C,OAAO,CAAC,IAAI,CAAC,CA2CjB"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.containerLoader =
|
3
|
+
exports.containerLoader = containerLoader;
|
4
4
|
const _repositories_1 = require("../repositories");
|
5
5
|
const _services_1 = require("../services");
|
6
6
|
const utils_1 = require("@medusajs/utils");
|
@@ -30,4 +30,3 @@ function containerLoader(entity, joinerConfig) {
|
|
30
30
|
});
|
31
31
|
};
|
32
32
|
}
|
33
|
-
exports.containerLoader = containerLoader;
|
package/dist/loaders/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getLoaders =
|
3
|
+
exports.getLoaders = getLoaders;
|
4
4
|
const utils_1 = require("../utils");
|
5
5
|
const connection_1 = require("./connection");
|
6
6
|
const container_1 = require("./container");
|
@@ -11,4 +11,3 @@ function getLoaders({ joinerConfig, primary, foreign, }) {
|
|
11
11
|
const entity = (0, utils_1.generateEntity)(joinerConfig, primary, foreign);
|
12
12
|
return [(0, connection_1.connectionLoader)(entity), (0, container_1.containerLoader)(entity, joinerConfig)];
|
13
13
|
}
|
14
|
-
exports.getLoaders = getLoaders;
|
@@ -1,4 +1,85 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
1
|
+
import { ILinkMigrationsPlanner, LinkMigrationsPlannerAction, ModuleJoinerConfig, ModuleServiceInitializeOptions, PlannerActionLinkDescriptor } from "@medusajs/types";
|
2
|
+
import { EntitySchema, MikroORM } from "@mikro-orm/core";
|
3
|
+
import { PostgreSqlDriver } from "@mikro-orm/postgresql";
|
4
|
+
/**
|
5
|
+
* The migrations execution planner creates a plan of SQL queries
|
6
|
+
* to be executed to keep link modules database state in sync
|
7
|
+
* with the links defined inside the user application.
|
8
|
+
*/
|
9
|
+
export declare class MigrationsExecutionPlanner implements ILinkMigrationsPlanner {
|
10
|
+
#private;
|
11
|
+
/**
|
12
|
+
* The table that keeps a track of tables generated by the link
|
13
|
+
* module.
|
14
|
+
*/
|
15
|
+
protected tableName: string;
|
16
|
+
constructor(joinerConfig: ModuleJoinerConfig[], options?: ModuleServiceInitializeOptions);
|
17
|
+
/**
|
18
|
+
* Initializes the ORM using the normalized dbConfig and set
|
19
|
+
* of provided entities
|
20
|
+
*/
|
21
|
+
protected createORM(entities?: EntitySchema[]): Promise<MikroORM<PostgreSqlDriver>>;
|
22
|
+
/**
|
23
|
+
* Ensure the table to track link modules migrations
|
24
|
+
* exists.
|
25
|
+
*
|
26
|
+
* @param orm MikroORM
|
27
|
+
*/
|
28
|
+
protected ensureMigrationsTable(orm: MikroORM<PostgreSqlDriver>): Promise<void>;
|
29
|
+
/**
|
30
|
+
* Ensure the migrations table is in sync
|
31
|
+
*
|
32
|
+
* @param orm
|
33
|
+
* @protected
|
34
|
+
*/
|
35
|
+
protected ensureMigrationsTableUpToDate(orm: MikroORM<PostgreSqlDriver>): Promise<void>;
|
36
|
+
/**
|
37
|
+
* Insert tuple to the migrations table and create the link table
|
38
|
+
*
|
39
|
+
* @param orm
|
40
|
+
* @param action
|
41
|
+
* @protected
|
42
|
+
*/
|
43
|
+
protected createLinkTable(orm: MikroORM<PostgreSqlDriver>, action: LinkMigrationsPlannerAction & {
|
44
|
+
linkDescriptor: PlannerActionLinkDescriptor;
|
45
|
+
sql: string;
|
46
|
+
}): Promise<void>;
|
47
|
+
/**
|
48
|
+
* Drops the link table and untracks it from the "link_modules_migrations"
|
49
|
+
* table.
|
50
|
+
*/
|
51
|
+
protected dropLinkTable(orm: MikroORM<PostgreSqlDriver>, tableName: string): Promise<void>;
|
52
|
+
/**
|
53
|
+
* Returns an array of table names that have been tracked during
|
54
|
+
* the last run. In short, these tables were created by the
|
55
|
+
* link modules migrations runner.
|
56
|
+
*
|
57
|
+
* @param orm MikroORM
|
58
|
+
*/
|
59
|
+
protected getTrackedLinksTables(orm: MikroORM<PostgreSqlDriver>): Promise<{
|
60
|
+
table_name: string;
|
61
|
+
link_descriptor: PlannerActionLinkDescriptor;
|
62
|
+
}[]>;
|
63
|
+
/**
|
64
|
+
* Returns the migration plan for a specific link entity.
|
65
|
+
*/
|
66
|
+
protected getEntityMigrationPlan(linkDescriptor: PlannerActionLinkDescriptor, entity: EntitySchema, trackedLinksTables: string[]): Promise<LinkMigrationsPlannerAction>;
|
67
|
+
/**
|
68
|
+
* Creates a plan to executed in order to keep the database state in
|
69
|
+
* sync with the user-defined links.
|
70
|
+
*
|
71
|
+
* This method only creates a plan and does not change the database
|
72
|
+
* state. You must call the "executePlan" method for that.
|
73
|
+
*/
|
74
|
+
createPlan(): Promise<LinkMigrationsPlannerAction[]>;
|
75
|
+
/**
|
76
|
+
* Executes the actionsPlan actions where the action is one of 'create' | 'update' | 'delete'.
|
77
|
+
* 'noop' and 'notify' actions are implicitly ignored. If a notify action needs to be
|
78
|
+
* executed, you can mutate its action to 'update', in that scenario it means that an unsafe
|
79
|
+
* update sql (from our point of view) will be executed and some data could be lost.
|
80
|
+
*
|
81
|
+
* @param actionPlan
|
82
|
+
*/
|
83
|
+
executePlan(actionPlan: LinkMigrationsPlannerAction[]): Promise<void>;
|
84
|
+
}
|
4
85
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,2BAA2B,EAC3B,kBAAkB,EAClB,8BAA8B,EAC9B,2BAA2B,EAC5B,MAAM,iBAAiB,CAAA;AAGxB,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAkB,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAQxE;;;;GAIG;AACH,qBAAa,0BAA2B,YAAW,sBAAsB;;IAoBvE;;;OAGG;IACH,SAAS,CAAC,SAAS,SAA2B;gBAG5C,YAAY,EAAE,kBAAkB,EAAE,EAClC,OAAO,CAAC,EAAE,8BAA8B;IAyB1C;;;OAGG;cACa,SAAS,CAAC,QAAQ,GAAE,YAAY,EAAO;IAIvD;;;;;OAKG;cACa,qBAAqB,CACnC,GAAG,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAC9B,OAAO,CAAC,IAAI,CAAC;IAWhB;;;;;OAKG;cACa,6BAA6B,CAC3C,GAAG,EAAE,QAAQ,CAAC,gBAAgB,CAAC;IAmDjC;;;;;;OAMG;cACa,eAAe,CAC7B,GAAG,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAC/B,MAAM,EAAE,2BAA2B,GAAG;QACpC,cAAc,EAAE,2BAA2B,CAAA;QAC3C,GAAG,EAAE,MAAM,CAAA;KACZ;IAgBH;;;OAGG;cACa,aAAa,CAC3B,GAAG,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAC/B,SAAS,EAAE,MAAM;IAQnB;;;;;;OAMG;cACa,qBAAqB,CACnC,GAAG,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAC9B,OAAO,CACR;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,2BAA2B,CAAA;KAAE,EAAE,CACvE;IAgBD;;OAEG;cACa,sBAAsB,CACpC,cAAc,EAAE,2BAA2B,EAC3C,MAAM,EAAE,YAAY,EACpB,kBAAkB,EAAE,MAAM,EAAE,GAC3B,OAAO,CAAC,2BAA2B,CAAC;IAyEvC;;;;;;OAMG;IACG,UAAU;IAkDhB;;;;;;;OAOG;IACG,WAAW,CAAC,UAAU,EAAE,2BAA2B,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAkB5E"}
|
package/dist/migration/index.js
CHANGED
@@ -1,80 +1,303 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
7
|
+
};
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
12
|
+
};
|
13
|
+
var _MigrationsExecutionPlanner_dbConfig, _MigrationsExecutionPlanner_unsafeSQLCommands, _MigrationsExecutionPlanner_linksEntities;
|
2
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
15
|
+
exports.MigrationsExecutionPlanner = void 0;
|
4
16
|
const utils_1 = require("../utils");
|
17
|
+
const postgresql_1 = require("@mikro-orm/postgresql");
|
5
18
|
const utils_2 = require("@medusajs/utils");
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
19
|
+
/**
|
20
|
+
* The migrations execution planner creates a plan of SQL queries
|
21
|
+
* to be executed to keep link modules database state in sync
|
22
|
+
* with the links defined inside the user application.
|
23
|
+
*/
|
24
|
+
class MigrationsExecutionPlanner {
|
25
|
+
constructor(joinerConfig, options) {
|
26
|
+
/**
|
27
|
+
* Database options for the module service
|
28
|
+
*/
|
29
|
+
_MigrationsExecutionPlanner_dbConfig.set(this, void 0);
|
30
|
+
/**
|
31
|
+
* The set of commands that are unsafe to execute automatically when
|
32
|
+
* performing "alter table"
|
33
|
+
*/
|
34
|
+
_MigrationsExecutionPlanner_unsafeSQLCommands.set(this, ["alter column", "drop column"]
|
35
|
+
/**
|
36
|
+
* On-the-fly computed set of entities for the user provided joinerConfig and the link it is coming from
|
37
|
+
*/
|
38
|
+
);
|
39
|
+
/**
|
40
|
+
* On-the-fly computed set of entities for the user provided joinerConfig and the link it is coming from
|
41
|
+
*/
|
42
|
+
_MigrationsExecutionPlanner_linksEntities.set(this, void 0);
|
43
|
+
/**
|
44
|
+
* The table that keeps a track of tables generated by the link
|
45
|
+
* module.
|
46
|
+
*/
|
47
|
+
this.tableName = "link_module_migrations";
|
48
|
+
__classPrivateFieldSet(this, _MigrationsExecutionPlanner_dbConfig, utils_2.ModulesSdkUtils.loadDatabaseConfig("link_modules", options), "f");
|
49
|
+
__classPrivateFieldSet(this, _MigrationsExecutionPlanner_linksEntities, joinerConfig
|
50
|
+
.map((config) => {
|
51
|
+
if (config.isReadOnlyLink) {
|
52
|
+
return;
|
53
|
+
}
|
54
|
+
const [primary, foreign] = config.relationships ?? [];
|
55
|
+
const linkDescriptor = {
|
56
|
+
fromModule: primary.serviceName,
|
57
|
+
toModule: foreign.serviceName,
|
58
|
+
fromModel: primary.alias,
|
59
|
+
toModel: foreign.alias,
|
60
|
+
};
|
61
|
+
return {
|
62
|
+
entity: (0, utils_1.generateEntity)(config, primary, foreign),
|
63
|
+
linkDescriptor,
|
64
|
+
};
|
65
|
+
})
|
66
|
+
.filter((item) => !!item), "f");
|
67
|
+
}
|
68
|
+
/**
|
69
|
+
* Initializes the ORM using the normalized dbConfig and set
|
70
|
+
* of provided entities
|
71
|
+
*/
|
72
|
+
async createORM(entities = []) {
|
73
|
+
return await utils_2.DALUtils.mikroOrmCreateConnection(__classPrivateFieldGet(this, _MigrationsExecutionPlanner_dbConfig, "f"), entities, "");
|
74
|
+
}
|
75
|
+
/**
|
76
|
+
* Ensure the table to track link modules migrations
|
77
|
+
* exists.
|
78
|
+
*
|
79
|
+
* @param orm MikroORM
|
80
|
+
*/
|
81
|
+
async ensureMigrationsTable(orm) {
|
82
|
+
await orm.em.getDriver().getConnection().execute(`
|
83
|
+
CREATE TABLE IF NOT EXISTS "${this.tableName}" (
|
84
|
+
id SERIAL PRIMARY KEY,
|
85
|
+
table_name VARCHAR(255) NOT NULL UNIQUE,
|
86
|
+
link_descriptor JSONB NOT NULL DEFAULT '{}'::jsonb,
|
87
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
88
|
+
)
|
89
|
+
`);
|
90
|
+
}
|
91
|
+
/**
|
92
|
+
* Ensure the migrations table is in sync
|
93
|
+
*
|
94
|
+
* @param orm
|
95
|
+
* @protected
|
96
|
+
*/
|
97
|
+
async ensureMigrationsTableUpToDate(orm) {
|
98
|
+
const existingTables = (await orm.em
|
99
|
+
.getDriver()
|
100
|
+
.getConnection()
|
101
|
+
.execute(`
|
102
|
+
SELECT table_name
|
103
|
+
FROM information_schema.tables;
|
104
|
+
`))
|
105
|
+
.map(({ table_name }) => table_name)
|
106
|
+
.filter((tableName) => __classPrivateFieldGet(this, _MigrationsExecutionPlanner_linksEntities, "f").some(({ entity }) => entity.meta.collection === tableName));
|
107
|
+
if (!existingTables.length) {
|
108
|
+
return;
|
109
|
+
}
|
110
|
+
const orderedDescriptors = existingTables.map((tableName) => {
|
111
|
+
return __classPrivateFieldGet(this, _MigrationsExecutionPlanner_linksEntities, "f").find(({ entity }) => entity.meta.collection === tableName).linkDescriptor;
|
112
|
+
});
|
113
|
+
const positionalArgs = new Array(existingTables.length)
|
114
|
+
.fill("(?, ?)")
|
115
|
+
.join(", ");
|
116
|
+
await orm.em
|
117
|
+
.getDriver()
|
118
|
+
.getConnection()
|
119
|
+
.execute(`
|
120
|
+
INSERT INTO ${this.tableName} (table_name, link_descriptor) VALUES ${positionalArgs} ON CONFLICT DO NOTHING;
|
121
|
+
`, existingTables.flatMap((tableName, index) => [
|
122
|
+
tableName,
|
123
|
+
JSON.stringify(orderedDescriptors[index]),
|
124
|
+
]));
|
125
|
+
}
|
126
|
+
/**
|
127
|
+
* Insert tuple to the migrations table and create the link table
|
128
|
+
*
|
129
|
+
* @param orm
|
130
|
+
* @param action
|
131
|
+
* @protected
|
132
|
+
*/
|
133
|
+
async createLinkTable(orm, action) {
|
134
|
+
const { tableName, linkDescriptor, sql } = action;
|
135
|
+
await orm.em
|
136
|
+
.getDriver()
|
137
|
+
.getConnection()
|
138
|
+
.execute(`
|
139
|
+
INSERT INTO "${this.tableName}" (table_name, link_descriptor) VALUES (?, ?);
|
140
|
+
${sql}
|
141
|
+
`, [tableName, linkDescriptor]);
|
142
|
+
}
|
143
|
+
/**
|
144
|
+
* Drops the link table and untracks it from the "link_modules_migrations"
|
145
|
+
* table.
|
146
|
+
*/
|
147
|
+
async dropLinkTable(orm, tableName) {
|
148
|
+
await orm.em.getDriver().getConnection().execute(`
|
149
|
+
DROP TABLE IF EXISTS "${tableName}";
|
150
|
+
DELETE FROM "${this.tableName}" WHERE table_name = '${tableName}';
|
151
|
+
`);
|
152
|
+
}
|
153
|
+
/**
|
154
|
+
* Returns an array of table names that have been tracked during
|
155
|
+
* the last run. In short, these tables were created by the
|
156
|
+
* link modules migrations runner.
|
157
|
+
*
|
158
|
+
* @param orm MikroORM
|
159
|
+
*/
|
160
|
+
async getTrackedLinksTables(orm) {
|
161
|
+
const results = await orm.em.getDriver().getConnection().execute(`
|
162
|
+
SELECT table_name, link_descriptor from "${this.tableName}"
|
163
|
+
`);
|
164
|
+
return results.map((tuple) => ({
|
165
|
+
table_name: tuple.table_name,
|
166
|
+
link_descriptor: tuple.link_descriptor,
|
167
|
+
}));
|
168
|
+
}
|
169
|
+
/**
|
170
|
+
* Returns the migration plan for a specific link entity.
|
171
|
+
*/
|
172
|
+
async getEntityMigrationPlan(linkDescriptor, entity, trackedLinksTables) {
|
13
173
|
const tableName = entity.meta.collection;
|
14
|
-
|
174
|
+
const orm = await this.createORM([entity]);
|
175
|
+
const generator = orm.getSchemaGenerator();
|
176
|
+
const platform = orm.em.getPlatform();
|
177
|
+
const connection = orm.em.getConnection();
|
178
|
+
const schemaName = __classPrivateFieldGet(this, _MigrationsExecutionPlanner_dbConfig, "f").schema || "public";
|
179
|
+
/**
|
180
|
+
* If the table name for the entity has not been
|
181
|
+
* managed by us earlier, then we should create
|
182
|
+
* it.
|
183
|
+
*/
|
184
|
+
if (!trackedLinksTables.includes(tableName)) {
|
185
|
+
return {
|
186
|
+
action: "create",
|
187
|
+
linkDescriptor,
|
188
|
+
tableName,
|
189
|
+
sql: await generator.getCreateSchemaSQL(),
|
190
|
+
};
|
191
|
+
}
|
192
|
+
/**
|
193
|
+
* Pre-fetching information schema from the database and using that
|
194
|
+
* as the way to compute the update diff.
|
195
|
+
*
|
196
|
+
* @note
|
197
|
+
* The "loadInformationSchema" mutates the "dbSchema" argument provided
|
198
|
+
* to it as the first argument.
|
199
|
+
*/
|
200
|
+
const dbSchema = new postgresql_1.DatabaseSchema(platform, schemaName);
|
201
|
+
await platform
|
202
|
+
.getSchemaHelper?.()
|
203
|
+
?.loadInformationSchema(dbSchema, connection, [
|
204
|
+
{
|
205
|
+
table_name: tableName,
|
206
|
+
schema_name: schemaName,
|
207
|
+
},
|
208
|
+
]);
|
209
|
+
const updateSQL = await generator.getUpdateSchemaSQL({
|
210
|
+
fromSchema: dbSchema,
|
211
|
+
});
|
212
|
+
/**
|
213
|
+
* Entity is upto-date and hence we do not have to perform
|
214
|
+
* any updates on it.
|
215
|
+
*/
|
216
|
+
if (!updateSQL.length) {
|
217
|
+
return {
|
218
|
+
action: "noop",
|
219
|
+
linkDescriptor,
|
220
|
+
tableName,
|
221
|
+
};
|
222
|
+
}
|
223
|
+
const usesUnsafeCommands = __classPrivateFieldGet(this, _MigrationsExecutionPlanner_unsafeSQLCommands, "f").some((fragment) => {
|
224
|
+
return updateSQL.match(new RegExp(`${fragment}`, "ig"));
|
225
|
+
});
|
15
226
|
try {
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
227
|
+
return {
|
228
|
+
action: usesUnsafeCommands ? "notify" : "update",
|
229
|
+
linkDescriptor,
|
230
|
+
tableName,
|
231
|
+
sql: updateSQL,
|
232
|
+
};
|
20
233
|
}
|
21
|
-
|
22
|
-
|
23
|
-
if (hasTable) {
|
24
|
-
/* const updateSql = await generator.getUpdateSchemaSQL()
|
25
|
-
const entityUpdates = updateSql
|
26
|
-
.split(";")
|
27
|
-
.map((sql) => sql.trim())
|
28
|
-
.filter((sql) =>
|
29
|
-
sql.toLowerCase().includes(`alter table "${tableName.toLowerCase()}"`)
|
30
|
-
)
|
31
|
-
|
32
|
-
if (entityUpdates.length > 0) {
|
33
|
-
try {
|
34
|
-
await generator.execute(entityUpdates.join(";"))
|
35
|
-
logger.info(`Link module "${serviceName}" migration executed`)
|
36
|
-
} catch (error) {
|
37
|
-
logger.error(
|
38
|
-
`Link module "${serviceName}" migration failed to run - Error: ${error.errros ?? error}`
|
39
|
-
)
|
40
|
-
}
|
41
|
-
} else {
|
42
|
-
logger.info(`Skipping "${tableName}" migration.`)
|
43
|
-
}*/
|
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
|
-
// )
|
234
|
+
finally {
|
235
|
+
await orm.close(true);
|
48
236
|
}
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
237
|
+
}
|
238
|
+
/**
|
239
|
+
* Creates a plan to executed in order to keep the database state in
|
240
|
+
* sync with the user-defined links.
|
241
|
+
*
|
242
|
+
* This method only creates a plan and does not change the database
|
243
|
+
* state. You must call the "executePlan" method for that.
|
244
|
+
*/
|
245
|
+
async createPlan() {
|
246
|
+
const orm = await this.createORM();
|
247
|
+
await this.ensureMigrationsTable(orm);
|
248
|
+
const executionActions = [];
|
249
|
+
await this.ensureMigrationsTableUpToDate(orm);
|
250
|
+
const trackedTables = await this.getTrackedLinksTables(orm);
|
251
|
+
const trackedTablesNames = trackedTables.map(({ table_name }) => table_name);
|
252
|
+
/**
|
253
|
+
* Looping through the new set of entities and generating
|
254
|
+
* execution plan for them
|
255
|
+
*/
|
256
|
+
for (let { entity, linkDescriptor } of __classPrivateFieldGet(this, _MigrationsExecutionPlanner_linksEntities, "f")) {
|
257
|
+
executionActions.push(await this.getEntityMigrationPlan(linkDescriptor, entity, trackedTablesNames));
|
57
258
|
}
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
259
|
+
const linksTableNames = __classPrivateFieldGet(this, _MigrationsExecutionPlanner_linksEntities, "f").map(({ entity }) => entity.meta.collection);
|
260
|
+
/**
|
261
|
+
* Finding the tables to be removed
|
262
|
+
*/
|
263
|
+
const tablesToRemove = (0, utils_2.arrayDifference)(trackedTablesNames, linksTableNames);
|
264
|
+
tablesToRemove.forEach((tableToRemove) => {
|
265
|
+
executionActions.push({
|
266
|
+
action: "delete",
|
267
|
+
tableName: tableToRemove,
|
268
|
+
linkDescriptor: trackedTables.find(({ table_name }) => tableToRemove === table_name).link_descriptor,
|
269
|
+
});
|
270
|
+
});
|
69
271
|
try {
|
70
|
-
|
71
|
-
await migrator.down();
|
72
|
-
logger.info(`Link module "${serviceName}" migration executed`);
|
272
|
+
return executionActions;
|
73
273
|
}
|
74
|
-
|
75
|
-
|
274
|
+
finally {
|
275
|
+
await orm.close(true);
|
76
276
|
}
|
77
|
-
|
78
|
-
|
277
|
+
}
|
278
|
+
/**
|
279
|
+
* Executes the actionsPlan actions where the action is one of 'create' | 'update' | 'delete'.
|
280
|
+
* 'noop' and 'notify' actions are implicitly ignored. If a notify action needs to be
|
281
|
+
* executed, you can mutate its action to 'update', in that scenario it means that an unsafe
|
282
|
+
* update sql (from our point of view) will be executed and some data could be lost.
|
283
|
+
*
|
284
|
+
* @param actionPlan
|
285
|
+
*/
|
286
|
+
async executePlan(actionPlan) {
|
287
|
+
const orm = await this.createORM();
|
288
|
+
await (0, utils_2.promiseAll)(actionPlan.map(async (action) => {
|
289
|
+
switch (action.action) {
|
290
|
+
case "delete":
|
291
|
+
return await this.dropLinkTable(orm, action.tableName);
|
292
|
+
case "create":
|
293
|
+
return await this.createLinkTable(orm, action);
|
294
|
+
case "update":
|
295
|
+
return await orm.em.getDriver().getConnection().execute(action.sql);
|
296
|
+
default:
|
297
|
+
return;
|
298
|
+
}
|
299
|
+
})).finally(() => orm.close(true));
|
300
|
+
}
|
79
301
|
}
|
80
|
-
exports.
|
302
|
+
exports.MigrationsExecutionPlanner = MigrationsExecutionPlanner;
|
303
|
+
_MigrationsExecutionPlanner_dbConfig = new WeakMap(), _MigrationsExecutionPlanner_unsafeSQLCommands = new WeakMap(), _MigrationsExecutionPlanner_linksEntities = new WeakMap();
|
@@ -10,29 +10,27 @@ export declare function getLinkRepository(model: EntitySchema): {
|
|
10
10
|
update(data: {
|
11
11
|
entity: any;
|
12
12
|
update: any;
|
13
|
-
}[], context?: Context
|
14
|
-
find(options?: import("@medusajs/types").FindOptions<object> | undefined, context?: Context
|
15
|
-
findAndCount(options?: import("@medusajs/types").FindOptions<object> | undefined, context?: Context
|
16
|
-
upsert(data: unknown[], context?: Context
|
17
|
-
upsertWithReplace(data: unknown[], config?: import("@medusajs/types").UpsertWithReplaceConfig<object> | undefined, context?: Context
|
13
|
+
}[], context?: Context): Promise<object[]>;
|
14
|
+
find(options?: import("@medusajs/types").FindOptions<object> | undefined, context?: Context): Promise<object[]>;
|
15
|
+
findAndCount(options?: import("@medusajs/types").FindOptions<object> | undefined, context?: Context): Promise<[object[], number]>;
|
16
|
+
upsert(data: unknown[], context?: Context): Promise<object[]>;
|
17
|
+
upsertWithReplace(data: unknown[], config?: import("@medusajs/types").UpsertWithReplaceConfig<object> | undefined, context?: Context): Promise<{
|
18
18
|
entities: object[];
|
19
19
|
performedActions: import("@medusajs/types").PerformedActions;
|
20
20
|
}>;
|
21
|
-
softDelete(filters: string | string[] | (object & import("@medusajs/types").BaseFilterable<object>) | (object & import("@medusajs/types").BaseFilterable<object>)[], sharedContext?: Context
|
22
|
-
restore(idsOrFilter: string[] |
|
23
|
-
[x: string]: any;
|
24
|
-
}, sharedContext?: Context | undefined): Promise<[object[], Record<string, unknown[]>]>;
|
21
|
+
softDelete(filters: string | string[] | (object & import("@medusajs/types").BaseFilterable<object>) | (object & import("@medusajs/types").BaseFilterable<object>)[], sharedContext?: Context): Promise<[object[], Record<string, unknown[]>]>;
|
22
|
+
restore(idsOrFilter: string[] | import("@medusajs/types").FilterQuery, sharedContext?: Context): Promise<[object[], Record<string, unknown[]>]>;
|
25
23
|
applyFreeTextSearchFilters<T>(findOptions: import("@medusajs/types").FindOptions<T & {
|
26
|
-
q?: string
|
24
|
+
q?: string;
|
27
25
|
}>, retrieveConstraintsToApply: (q: string) => any[]): void;
|
28
26
|
readonly manager_: any;
|
29
27
|
getFreshManager<TManager = unknown>(): TManager;
|
30
|
-
getActiveManager<
|
31
|
-
transaction<
|
32
|
-
isolationLevel?: string
|
33
|
-
enableNestedTransactions?: boolean
|
34
|
-
transaction?:
|
35
|
-
}
|
28
|
+
getActiveManager<TManager = unknown>({ transactionManager, manager, }?: Context): TManager;
|
29
|
+
transaction<TManager = unknown>(task: (transactionManager: TManager) => Promise<any>, options?: {
|
30
|
+
isolationLevel?: string;
|
31
|
+
enableNestedTransactions?: boolean;
|
32
|
+
transaction?: TManager;
|
33
|
+
}): Promise<any>;
|
36
34
|
serialize<TOutput extends object | object[]>(data: any, options?: any): Promise<TOutput>;
|
37
35
|
};
|
38
36
|
};
|
@@ -1 +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,
|
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,OAAO,CAAC,IAAI,CAAC;qBAY1C,MAAM,EAAE,YAAW,OAAO,GAAQ,OAAO,CAAC,MAAM,EAAE,CAAC;;;;;;;;;;;;;;;aAkBmsC,CAAC;;;;;;0BA5BnvC,CAAC;oCAEb,CAAA;uBAA8B,CAAC;;;;EAyB7C"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getLinkRepository =
|
3
|
+
exports.getLinkRepository = getLinkRepository;
|
4
4
|
const utils_1 = require("@medusajs/utils");
|
5
5
|
function getLinkRepository(model) {
|
6
6
|
return class LinkRepository extends (0, utils_1.mikroOrmBaseRepositoryFactory)(model) {
|
@@ -31,4 +31,3 @@ function getLinkRepository(model) {
|
|
31
31
|
}
|
32
32
|
};
|
33
33
|
}
|
34
|
-
exports.getLinkRepository = getLinkRepository;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.getModuleService = getModuleService;
|
4
|
+
exports.getReadOnlyModuleService = getReadOnlyModuleService;
|
4
5
|
const utils_1 = require("@medusajs/utils");
|
5
6
|
const _services_1 = require(".");
|
6
7
|
function getModuleService(joinerConfig) {
|
@@ -18,7 +19,6 @@ function getModuleService(joinerConfig) {
|
|
18
19
|
}
|
19
20
|
};
|
20
21
|
}
|
21
|
-
exports.getModuleService = getModuleService;
|
22
22
|
function getReadOnlyModuleService(joinerConfig) {
|
23
23
|
return class ReadOnlyLinkService {
|
24
24
|
__joinerConfig() {
|
@@ -26,4 +26,3 @@ function getReadOnlyModuleService(joinerConfig) {
|
|
26
26
|
}
|
27
27
|
};
|
28
28
|
}
|
29
|
-
exports.getReadOnlyModuleService = getReadOnlyModuleService;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.generateEntity =
|
3
|
+
exports.generateEntity = generateEntity;
|
4
4
|
const utils_1 = require("@medusajs/utils");
|
5
5
|
const core_1 = require("@mikro-orm/core");
|
6
6
|
const compose_link_name_1 = require("./compose-link-name");
|
@@ -90,4 +90,3 @@ function generateEntity(joinerConfig, primary, foreign) {
|
|
90
90
|
],
|
91
91
|
});
|
92
92
|
}
|
93
|
-
exports.generateEntity = generateEntity;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.generateGraphQLSchema =
|
3
|
+
exports.generateGraphQLSchema = generateGraphQLSchema;
|
4
4
|
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
5
5
|
const utils_1 = require("@medusajs/utils");
|
6
6
|
const compose_link_name_1 = require("./compose-link-name");
|
@@ -76,7 +76,6 @@ function generateGraphQLSchema(joinerConfig, primary, foreign, { logger } = { lo
|
|
76
76
|
`;
|
77
77
|
return typeDef;
|
78
78
|
}
|
79
|
-
exports.generateGraphQLSchema = generateGraphQLSchema;
|
80
79
|
function getGraphQLType(type) {
|
81
80
|
const typeDef = {
|
82
81
|
numeric: "Float",
|
package/dist/utils/index.js
CHANGED
@@ -14,7 +14,8 @@ 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
|
-
exports.
|
17
|
+
exports.shouldForceTransaction = shouldForceTransaction;
|
18
|
+
exports.doNotForceTransaction = doNotForceTransaction;
|
18
19
|
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
19
20
|
__exportStar(require("./compose-link-name"), exports);
|
20
21
|
__exportStar(require("./generate-entity"), exports);
|
@@ -22,8 +23,6 @@ __exportStar(require("./generate-schema"), exports);
|
|
22
23
|
function shouldForceTransaction(target) {
|
23
24
|
return target.moduleDeclaration?.resources === modules_sdk_1.MODULE_RESOURCE_TYPE.ISOLATED;
|
24
25
|
}
|
25
|
-
exports.shouldForceTransaction = shouldForceTransaction;
|
26
26
|
function doNotForceTransaction() {
|
27
27
|
return false;
|
28
28
|
}
|
29
|
-
exports.doNotForceTransaction = doNotForceTransaction;
|
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-20240723115023",
|
4
4
|
"description": "Medusa Default Link Modules Package and Definitions",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -26,21 +26,21 @@
|
|
26
26
|
"prepare": "cross-env NODE_ENV=production yarn run build",
|
27
27
|
"build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json",
|
28
28
|
"test": "jest --passWithNoTests --runInBand --bail --forceExit -- src",
|
29
|
-
"test:integration": "jest --
|
29
|
+
"test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts"
|
30
30
|
},
|
31
31
|
"devDependencies": {
|
32
|
-
"@medusajs/types": "1.12.0-snapshot-
|
32
|
+
"@medusajs/types": "1.12.0-snapshot-20240723115023",
|
33
33
|
"cross-env": "^5.2.1",
|
34
34
|
"jest": "^29.7.0",
|
35
35
|
"pg-god": "^1.0.12",
|
36
36
|
"rimraf": "^5.0.1",
|
37
37
|
"ts-node": "^10.9.1",
|
38
38
|
"tsc-alias": "^1.8.6",
|
39
|
-
"typescript": "^5.
|
39
|
+
"typescript": "^5.5.0"
|
40
40
|
},
|
41
41
|
"dependencies": {
|
42
|
-
"@medusajs/modules-sdk": "1.13.0-snapshot-
|
43
|
-
"@medusajs/utils": "1.12.0-snapshot-
|
42
|
+
"@medusajs/modules-sdk": "1.13.0-snapshot-20240723115023",
|
43
|
+
"@medusajs/utils": "1.12.0-snapshot-20240723115023",
|
44
44
|
"@mikro-orm/core": "5.9.7",
|
45
45
|
"@mikro-orm/postgresql": "5.9.7",
|
46
46
|
"awilix": "^8.0.0"
|