@medusajs/link-modules 0.2.6 → 0.2.7-next-20240124093206
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/repositories/link.d.ts +12 -12
- package/dist/repositories/link.js +5 -26
- package/package.json +4 -4
|
@@ -1,28 +1,26 @@
|
|
|
1
|
-
import { Context,
|
|
1
|
+
import { Context, ModuleJoinerConfig } from "@medusajs/types";
|
|
2
2
|
import { EntitySchema } from "@mikro-orm/core";
|
|
3
|
-
import { SqlEntityManager } from "@mikro-orm/postgresql";
|
|
4
3
|
export declare function getLinkRepository(model: EntitySchema): {
|
|
5
|
-
new ({
|
|
6
|
-
manager: SqlEntityManager;
|
|
4
|
+
new ({ joinerConfig }: {
|
|
7
5
|
joinerConfig: ModuleJoinerConfig;
|
|
8
6
|
}): {
|
|
9
|
-
readonly manager_: SqlEntityManager;
|
|
10
|
-
readonly model_: EntitySchema;
|
|
11
7
|
readonly joinerConfig_: ModuleJoinerConfig;
|
|
12
|
-
find(findOptions?: FindOptions<unknown>, context?: Context): Promise<unknown[]>;
|
|
13
|
-
findAndCount(findOptions?: FindOptions<object>, context?: Context): Promise<[object[], number]>;
|
|
14
8
|
delete(data: any, context?: Context): Promise<void>;
|
|
15
9
|
create(data: object[], context?: Context): Promise<object[]>;
|
|
16
|
-
update(data:
|
|
10
|
+
update(data: any[], context?: Context | undefined): Promise<any[]>;
|
|
11
|
+
find(options?: import("@medusajs/types").FindOptions<any> | undefined, context?: Context | undefined): Promise<any[]>;
|
|
12
|
+
findAndCount(findOptions?: import("@medusajs/types").FindOptions<any> | undefined, context?: Context | undefined): Promise<[any[], number]>;
|
|
13
|
+
upsert(data: any[], context?: Context | undefined): Promise<any[]>;
|
|
17
14
|
softDelete(idsOrFilter: string[] | {
|
|
18
15
|
[x: string]: any;
|
|
19
|
-
}, { transactionManager: manager }?: Context | undefined): Promise<[
|
|
16
|
+
}, { transactionManager: manager }?: Context | undefined): Promise<[any[], Record<string, unknown[]>]>;
|
|
20
17
|
restore(idsOrFilter: string[] | {
|
|
21
18
|
[x: string]: any;
|
|
22
|
-
}, { transactionManager: manager }?: Context | undefined): Promise<[
|
|
23
|
-
applyFreeTextSearchFilters<T>(findOptions: FindOptions<T & {
|
|
19
|
+
}, { transactionManager: manager }?: Context | undefined): Promise<[any[], Record<string, unknown[]>]>;
|
|
20
|
+
applyFreeTextSearchFilters<T>(findOptions: import("@medusajs/types").FindOptions<T & {
|
|
24
21
|
q?: string | undefined;
|
|
25
22
|
}>, retrieveConstraintsToApply: (q: string) => any[]): void;
|
|
23
|
+
readonly manager_: any;
|
|
26
24
|
getFreshManager<TManager = unknown>(): TManager;
|
|
27
25
|
getActiveManager<TManager_1 = unknown>({ transactionManager, manager }?: Context | undefined): TManager_1;
|
|
28
26
|
transaction<TManager_2 = unknown>(task: (transactionManager: TManager_2) => Promise<any>, options?: {
|
|
@@ -32,4 +30,6 @@ export declare function getLinkRepository(model: EntitySchema): {
|
|
|
32
30
|
} | undefined): Promise<any>;
|
|
33
31
|
serialize<TOutput extends object | object[]>(data: any, options?: any): Promise<TOutput>;
|
|
34
32
|
};
|
|
33
|
+
buildUniqueCompositeKeyValue(keys: string[], data: object): string;
|
|
34
|
+
retrievePrimaryKeys(entity: EntitySchema<any, never> | import("@mikro-orm/core").EntityClass<any>): string[];
|
|
35
35
|
};
|
|
@@ -1,35 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getLinkRepository = void 0;
|
|
4
|
-
const core_1 = require("@mikro-orm/core");
|
|
5
4
|
const utils_1 = require("@medusajs/utils");
|
|
6
5
|
function getLinkRepository(model) {
|
|
7
|
-
return class LinkRepository extends utils_1.
|
|
8
|
-
constructor({
|
|
6
|
+
return class LinkRepository extends (0, utils_1.mikroOrmBaseRepositoryFactory)(model) {
|
|
7
|
+
constructor({ joinerConfig }) {
|
|
9
8
|
// @ts-ignore
|
|
10
9
|
super(...arguments);
|
|
11
|
-
this.manager_ = manager;
|
|
12
|
-
this.model_ = model;
|
|
13
10
|
this.joinerConfig_ = joinerConfig;
|
|
14
11
|
}
|
|
15
|
-
async find(findOptions = { where: {} }, context = {}) {
|
|
16
|
-
const manager = this.getActiveManager(context);
|
|
17
|
-
const findOptions_ = { ...findOptions };
|
|
18
|
-
findOptions_.options ?? (findOptions_.options = {});
|
|
19
|
-
Object.assign(findOptions_.options, {
|
|
20
|
-
strategy: core_1.LoadStrategy.SELECT_IN,
|
|
21
|
-
});
|
|
22
|
-
return await manager.find(this.model_, findOptions_.where, findOptions_.options);
|
|
23
|
-
}
|
|
24
|
-
async findAndCount(findOptions = { where: {} }, context = {}) {
|
|
25
|
-
const manager = this.getActiveManager(context);
|
|
26
|
-
const findOptions_ = { ...findOptions };
|
|
27
|
-
findOptions_.options ?? (findOptions_.options = {});
|
|
28
|
-
Object.assign(findOptions_.options, {
|
|
29
|
-
strategy: core_1.LoadStrategy.SELECT_IN,
|
|
30
|
-
});
|
|
31
|
-
return await manager.findAndCount(this.model_, findOptions_.where, findOptions_.options);
|
|
32
|
-
}
|
|
33
12
|
async delete(data, context = {}) {
|
|
34
13
|
const filter = {};
|
|
35
14
|
for (const key in data) {
|
|
@@ -38,15 +17,15 @@ function getLinkRepository(model) {
|
|
|
38
17
|
};
|
|
39
18
|
}
|
|
40
19
|
const manager = this.getActiveManager(context);
|
|
41
|
-
await manager.nativeDelete(
|
|
20
|
+
await manager.nativeDelete(model, data, {});
|
|
42
21
|
}
|
|
43
22
|
async create(data, context = {}) {
|
|
44
23
|
const manager = this.getActiveManager(context);
|
|
45
24
|
const links = data.map((link) => {
|
|
46
25
|
link.id = (0, utils_1.generateEntityId)(link.id, this.joinerConfig_.databaseConfig?.idPrefix ?? "link");
|
|
47
|
-
return manager.create(
|
|
26
|
+
return manager.create(model, link);
|
|
48
27
|
});
|
|
49
|
-
await manager.upsertMany(
|
|
28
|
+
await manager.upsertMany(model, links);
|
|
50
29
|
return links;
|
|
51
30
|
}
|
|
52
31
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/link-modules",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7-next-20240124093206",
|
|
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": "
|
|
43
|
-
"@medusajs/types": "
|
|
44
|
-
"@medusajs/utils": "
|
|
42
|
+
"@medusajs/modules-sdk": "1.12.7-next-20240124093206",
|
|
43
|
+
"@medusajs/types": "1.11.11-next-20240124093206",
|
|
44
|
+
"@medusajs/utils": "1.11.4-next-20240124093206",
|
|
45
45
|
"@mikro-orm/core": "5.9.7",
|
|
46
46
|
"@mikro-orm/postgresql": "5.9.7",
|
|
47
47
|
"awilix": "^8.0.0"
|