@smartsoft001/mongo 1.1.91 → 1.2.0
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/.eslintrc +13 -0
- package/jest.config.ts +27 -0
- package/package.json +2 -26
- package/project.json +48 -0
- package/src/index.ts +3 -0
- package/src/lib/mongo.config.ts +10 -0
- package/src/lib/mongo.module.ts +28 -0
- package/src/lib/mongo.unitofwork.spec.ts +84 -0
- package/src/lib/mongo.unitofwork.ts +58 -0
- package/src/lib/mongo.utils.spec.ts +54 -0
- package/src/lib/mongo.utils.ts +17 -0
- package/src/lib/repositories/attachment.repository.spec.ts +249 -0
- package/src/lib/repositories/attachment.repository.ts +113 -0
- package/src/lib/repositories/interfaces.ts +28 -0
- package/src/lib/repositories/item.repository.spec.ts +1269 -0
- package/src/lib/repositories/item.repository.ts +582 -0
- package/tsconfig.json +13 -0
- package/tsconfig.lib.json +11 -0
- package/tsconfig.spec.json +20 -0
- package/src/index.d.ts +0 -3
- package/src/index.js +0 -7
- package/src/index.js.map +0 -1
- package/src/lib/mongo.config.d.ts +0 -9
- package/src/lib/mongo.config.js +0 -7
- package/src/lib/mongo.config.js.map +0 -1
- package/src/lib/mongo.module.d.ts +0 -5
- package/src/lib/mongo.module.js +0 -25
- package/src/lib/mongo.module.js.map +0 -1
- package/src/lib/mongo.unitofwork.d.ts +0 -12
- package/src/lib/mongo.unitofwork.js +0 -56
- package/src/lib/mongo.unitofwork.js.map +0 -1
- package/src/lib/mongo.utils.d.ts +0 -2
- package/src/lib/mongo.utils.js +0 -13
- package/src/lib/mongo.utils.js.map +0 -1
- package/src/lib/repositories/attachment.repository.d.ts +0 -28
- package/src/lib/repositories/attachment.repository.js +0 -88
- package/src/lib/repositories/attachment.repository.js.map +0 -1
- package/src/lib/repositories/item.repository.d.ts +0 -51
- package/src/lib/repositories/item.repository.js +0 -411
- package/src/lib/repositories/item.repository.js.map +0 -1
- package/test-setup.js +0 -1
- package/test-setup.js.map +0 -1
- /package/{test-setup.d.ts → test-setup.ts} +0 -0
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ClientSession } from "mongodb";
|
|
2
|
-
import { ITransaction, IUnitOfWork } from "@smartsoft001/domain-core";
|
|
3
|
-
import { MongoConfig } from "./mongo.config";
|
|
4
|
-
export interface IMongoTransaction extends ITransaction {
|
|
5
|
-
session: ClientSession;
|
|
6
|
-
}
|
|
7
|
-
export declare class MongoUnitOfWork extends IUnitOfWork {
|
|
8
|
-
private config;
|
|
9
|
-
constructor(config: MongoConfig);
|
|
10
|
-
scope(definition: (transaction: ITransaction) => Promise<void>): Promise<void>;
|
|
11
|
-
private getUrl;
|
|
12
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MongoUnitOfWork = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const mongodb_1 = require("mongodb");
|
|
6
|
-
const common_1 = require("@nestjs/common");
|
|
7
|
-
const domain_core_1 = require("@smartsoft001/domain-core");
|
|
8
|
-
const mongo_config_1 = require("./mongo.config");
|
|
9
|
-
const mongo_utils_1 = require("./mongo.utils");
|
|
10
|
-
let MongoUnitOfWork = exports.MongoUnitOfWork = class MongoUnitOfWork extends domain_core_1.IUnitOfWork {
|
|
11
|
-
constructor(config) {
|
|
12
|
-
super();
|
|
13
|
-
this.config = config;
|
|
14
|
-
}
|
|
15
|
-
scope(definition) {
|
|
16
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
const client = yield mongodb_1.MongoClient.connect(this.getUrl());
|
|
18
|
-
// Step 1: Start a Client Session
|
|
19
|
-
const session = client.startSession();
|
|
20
|
-
// Step 2: Optional. Define options to use for the transaction
|
|
21
|
-
const transactionOptions = {
|
|
22
|
-
readPreference: 'primary',
|
|
23
|
-
readConcern: { level: 'local' },
|
|
24
|
-
writeConcern: { w: 'majority' }
|
|
25
|
-
};
|
|
26
|
-
// Step 3: Use withTransaction to start a transaction, execute the callback, and commit (or abort on error)
|
|
27
|
-
// Note: The callback for withTransaction MUST be async and/or return a Promise.
|
|
28
|
-
let error = null;
|
|
29
|
-
try {
|
|
30
|
-
yield session.withTransaction(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
yield definition({
|
|
32
|
-
session,
|
|
33
|
-
connection: client
|
|
34
|
-
});
|
|
35
|
-
}), transactionOptions);
|
|
36
|
-
}
|
|
37
|
-
catch (e) {
|
|
38
|
-
error = e;
|
|
39
|
-
}
|
|
40
|
-
finally {
|
|
41
|
-
yield session.endSession();
|
|
42
|
-
yield client.close();
|
|
43
|
-
}
|
|
44
|
-
if (error)
|
|
45
|
-
throw error;
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
getUrl() {
|
|
49
|
-
return (0, mongo_utils_1.getMongoUrl)(this.config);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
exports.MongoUnitOfWork = MongoUnitOfWork = tslib_1.__decorate([
|
|
53
|
-
(0, common_1.Injectable)(),
|
|
54
|
-
tslib_1.__metadata("design:paramtypes", [mongo_config_1.MongoConfig])
|
|
55
|
-
], MongoUnitOfWork);
|
|
56
|
-
//# sourceMappingURL=mongo.unitofwork.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mongo.unitofwork.js","sourceRoot":"","sources":["../../../../../../libs/shared/mongo/src/lib/mongo.unitofwork.ts"],"names":[],"mappings":";;;;AAAA,qCAAuE;AACvE,2CAA0C;AAE1C,2DAAoE;AAEpE,iDAA2C;AAC3C,+CAA0C;AAOnC,IAAM,eAAe,6BAArB,MAAM,eAAgB,SAAQ,yBAAW;IAC5C,YAAoB,MAAmB;QACnC,KAAK,EAAE,CAAC;QADQ,WAAM,GAAN,MAAM,CAAa;IAEvC,CAAC;IAEK,KAAK,CAAC,UAAwD;;YAChE,MAAM,MAAM,GAAG,MAAO,qBAAW,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;YAEzD,iCAAiC;YACjC,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;YAEtC,8DAA8D;YAC9D,MAAM,kBAAkB,GAAuB;gBAC3C,cAAc,EAAE,SAAS;gBACzB,WAAW,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;gBAC/B,YAAY,EAAE,EAAE,CAAC,EAAE,UAAU,EAAE;aAClC,CAAC;YAEF,2GAA2G;YAC3G,gFAAgF;YAEhF,IAAI,KAAK,GAAG,IAAI,CAAC;YACjB,IAAI;gBACA,MAAM,OAAO,CAAC,eAAe,CAAC,GAAS,EAAE;oBACrC,MAAM,UAAU,CAAC;wBACb,OAAO;wBACP,UAAU,EAAE,MAAM;qBACA,CAAC,CAAC;gBAC5B,CAAC,CAAA,EAAE,kBAAkB,CAAC,CAAC;aAC1B;YAAC,OAAO,CAAC,EAAE;gBACR,KAAK,GAAG,CAAC,CAAC;aACb;oBAAU;gBACP,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;gBAC3B,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;aACxB;YAED,IAAI,KAAK;gBAAE,MAAM,KAAK,CAAC;QAC3B,CAAC;KAAA;IAEO,MAAM;QACV,OAAO,IAAA,yBAAW,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;CACJ,CAAA;0BA1CY,eAAe;IAD3B,IAAA,mBAAU,GAAE;6CAEmB,0BAAW;GAD9B,eAAe,CA0C3B"}
|
package/src/lib/mongo.utils.d.ts
DELETED
package/src/lib/mongo.utils.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMongoUrl = void 0;
|
|
4
|
-
function getMongoUrl(config) {
|
|
5
|
-
let url;
|
|
6
|
-
if (config.username && config.password)
|
|
7
|
-
url = `mongodb://${config.username}:${config.password}@${config.host}:${config.port}`;
|
|
8
|
-
else
|
|
9
|
-
url = `mongodb://${config.host}:${config.port}`;
|
|
10
|
-
return url + "?authSource=" + config.database;
|
|
11
|
-
}
|
|
12
|
-
exports.getMongoUrl = getMongoUrl;
|
|
13
|
-
//# sourceMappingURL=mongo.utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mongo.utils.js","sourceRoot":"","sources":["../../../../../../libs/shared/mongo/src/lib/mongo.utils.ts"],"names":[],"mappings":";;;AAEA,SAAgB,WAAW,CAAC,MAAmB;IAC3C,IAAI,GAAG,CAAC;IACR,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ;QAClC,GAAG,GAAG,aAAa,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;;QACrF,GAAG,GAAG,aAAa,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;IAErD,OAAO,GAAG,GAAG,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC;AAClD,CAAC;AAPD,kCAOC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Readable, Stream } from "stream";
|
|
3
|
-
import { IEntity, IAttachmentRepository } from "@smartsoft001/domain-core";
|
|
4
|
-
import { MongoConfig } from "../mongo.config";
|
|
5
|
-
export declare class MongoAttachmentRepository<T extends IEntity<string>> extends IAttachmentRepository<T> {
|
|
6
|
-
private config;
|
|
7
|
-
constructor(config: MongoConfig);
|
|
8
|
-
upload(data: {
|
|
9
|
-
id: string;
|
|
10
|
-
fileName: string;
|
|
11
|
-
stream: Stream;
|
|
12
|
-
mimeType: string;
|
|
13
|
-
encoding: string;
|
|
14
|
-
}, options?: {
|
|
15
|
-
streamCallback?: (r: any) => void;
|
|
16
|
-
}): Promise<void>;
|
|
17
|
-
getInfo(id: string): Promise<{
|
|
18
|
-
fileName: string;
|
|
19
|
-
contentType: string;
|
|
20
|
-
length: number;
|
|
21
|
-
}>;
|
|
22
|
-
getStream(id: string, options: {
|
|
23
|
-
start: number;
|
|
24
|
-
end: number;
|
|
25
|
-
} | undefined): Promise<Readable>;
|
|
26
|
-
delete(id: string): Promise<void>;
|
|
27
|
-
private getUrl;
|
|
28
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MongoAttachmentRepository = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const common_1 = require("@nestjs/common");
|
|
6
|
-
const mongodb_1 = require("mongodb");
|
|
7
|
-
const mongo = require("mongodb");
|
|
8
|
-
const domain_core_1 = require("@smartsoft001/domain-core");
|
|
9
|
-
const mongo_config_1 = require("../mongo.config");
|
|
10
|
-
const mongo_utils_1 = require("../mongo.utils");
|
|
11
|
-
let MongoAttachmentRepository = exports.MongoAttachmentRepository = class MongoAttachmentRepository extends domain_core_1.IAttachmentRepository {
|
|
12
|
-
constructor(config) {
|
|
13
|
-
super();
|
|
14
|
-
this.config = config;
|
|
15
|
-
}
|
|
16
|
-
upload(data, options) {
|
|
17
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
const client = yield mongodb_1.MongoClient.connect(this.getUrl());
|
|
19
|
-
return yield new Promise((res, rej) => {
|
|
20
|
-
const db = client.db(this.config.database);
|
|
21
|
-
const bucket = new mongo.GridFSBucket(db, {
|
|
22
|
-
bucketName: this.config.collection
|
|
23
|
-
});
|
|
24
|
-
const writeStream = bucket.openUploadStreamWithId(data.id, data.fileName, {
|
|
25
|
-
contentType: data.mimeType,
|
|
26
|
-
});
|
|
27
|
-
if (options === null || options === void 0 ? void 0 : options.streamCallback)
|
|
28
|
-
options.streamCallback(writeStream);
|
|
29
|
-
data.stream.pipe(writeStream);
|
|
30
|
-
writeStream.on('error', error => {
|
|
31
|
-
rej(error);
|
|
32
|
-
});
|
|
33
|
-
writeStream.on("finish", () => {
|
|
34
|
-
res();
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
getInfo(id) {
|
|
40
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
const client = yield mongodb_1.MongoClient.connect(this.getUrl());
|
|
42
|
-
const db = client.db(this.config.database);
|
|
43
|
-
const bucket = new mongo.GridFSBucket(db, {
|
|
44
|
-
bucketName: this.config.collection
|
|
45
|
-
});
|
|
46
|
-
const items = yield bucket.find({
|
|
47
|
-
_id: id
|
|
48
|
-
}).toArray();
|
|
49
|
-
yield client;
|
|
50
|
-
if (!items[0])
|
|
51
|
-
return null;
|
|
52
|
-
return {
|
|
53
|
-
fileName: items[0].filename,
|
|
54
|
-
contentType: items[0].contentType,
|
|
55
|
-
length: items[0].length
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
getStream(id, options) {
|
|
60
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
const client = yield mongodb_1.MongoClient.connect(this.getUrl());
|
|
62
|
-
const db = client.db(this.config.database);
|
|
63
|
-
const bucket = new mongo.GridFSBucket(db, {
|
|
64
|
-
bucketName: this.config.collection
|
|
65
|
-
});
|
|
66
|
-
return bucket.openDownloadStream(id, options);
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
delete(id) {
|
|
70
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
const client = yield mongodb_1.MongoClient.connect(this.getUrl());
|
|
72
|
-
const db = client.db(this.config.database);
|
|
73
|
-
const bucket = new mongo.GridFSBucket(db, {
|
|
74
|
-
bucketName: this.config.collection
|
|
75
|
-
});
|
|
76
|
-
yield bucket.delete(id);
|
|
77
|
-
yield client.close();
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
getUrl() {
|
|
81
|
-
return (0, mongo_utils_1.getMongoUrl)(this.config);
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
exports.MongoAttachmentRepository = MongoAttachmentRepository = tslib_1.__decorate([
|
|
85
|
-
(0, common_1.Injectable)(),
|
|
86
|
-
tslib_1.__metadata("design:paramtypes", [mongo_config_1.MongoConfig])
|
|
87
|
-
], MongoAttachmentRepository);
|
|
88
|
-
//# sourceMappingURL=attachment.repository.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attachment.repository.js","sourceRoot":"","sources":["../../../../../../../libs/shared/mongo/src/lib/repositories/attachment.repository.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { Collection, Db } from 'mongodb';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { IEntity, IItemRepository, IItemRepositoryOptions, ISpecification } from '@smartsoft001/domain-core';
|
|
4
|
-
import { IUser } from '@smartsoft001/users';
|
|
5
|
-
import { ItemChangedData } from '@smartsoft001/crud-shell-dtos';
|
|
6
|
-
import { MongoConfig } from '../mongo.config';
|
|
7
|
-
export declare class MongoItemRepository<T extends IEntity<string>> extends IItemRepository<T> {
|
|
8
|
-
protected config: MongoConfig;
|
|
9
|
-
constructor(config: MongoConfig);
|
|
10
|
-
create(item: T, user: IUser, repoOptions?: IItemRepositoryOptions): Promise<void>;
|
|
11
|
-
clear(user: IUser, repoOptions?: IItemRepositoryOptions): Promise<void>;
|
|
12
|
-
createMany(list: T[], user: IUser, repoOptions?: IItemRepositoryOptions): Promise<void>;
|
|
13
|
-
update(item: T, user: IUser, repoOptions?: IItemRepositoryOptions): Promise<void>;
|
|
14
|
-
updatePartial(item: Partial<T> & {
|
|
15
|
-
id: string;
|
|
16
|
-
}, user: IUser, repoOptions?: IItemRepositoryOptions): Promise<void>;
|
|
17
|
-
updatePartialManyByCriteria(criteria: any, set: Partial<T>, user: IUser, repoOptions?: IItemRepositoryOptions): Promise<void>;
|
|
18
|
-
updatePartialManyBySpecification(spec: ISpecification, set: Partial<T>, user: IUser, repoOptions?: IItemRepositoryOptions): Promise<void>;
|
|
19
|
-
delete(id: string, user: IUser, repoOptions?: IItemRepositoryOptions): Promise<void>;
|
|
20
|
-
getById(id: string, repoOptions?: IItemRepositoryOptions): Promise<T>;
|
|
21
|
-
getByCriteria(criteria: any, options?: any): Promise<{
|
|
22
|
-
data: T[];
|
|
23
|
-
totalCount: number;
|
|
24
|
-
}>;
|
|
25
|
-
getBySpecification(spec: ISpecification, options?: any): Promise<{
|
|
26
|
-
data: T[];
|
|
27
|
-
totalCount: number;
|
|
28
|
-
}>;
|
|
29
|
-
countByCriteria(criteria: any): Promise<number>;
|
|
30
|
-
countBySpecification(spec: ISpecification): Promise<number>;
|
|
31
|
-
changesByCriteria(criteria: {
|
|
32
|
-
id?: string;
|
|
33
|
-
}): Observable<ItemChangedData>;
|
|
34
|
-
protected getContext<TResult>(handler: (db: Db) => Promise<TResult>): Promise<TResult>;
|
|
35
|
-
protected getCount(criteria: any, collection: any): Promise<any>;
|
|
36
|
-
protected getInfo(id: string, collection: Collection<any>): Promise<any>;
|
|
37
|
-
protected getModelToCreate(item: T, user: IUser): T;
|
|
38
|
-
protected mapChangeType(dbType: string): any;
|
|
39
|
-
protected getModelToUpdate(item: {
|
|
40
|
-
id: string;
|
|
41
|
-
}, user: IUser, info: any): {
|
|
42
|
-
id: string;
|
|
43
|
-
};
|
|
44
|
-
protected getModelToResult(item: T): T;
|
|
45
|
-
protected getUrl(): string;
|
|
46
|
-
protected logChange(type: any, item: any, options: any, user: any, error: any): Promise<void>;
|
|
47
|
-
protected generateSearch(criteria: any): void;
|
|
48
|
-
protected convertIdInCriteria(criteria: any): void;
|
|
49
|
-
protected convertRegex(val: string): string;
|
|
50
|
-
protected collectionContext<T>(callback: (collection: Collection) => Promise<any>, repoOptions?: IItemRepositoryOptions): Promise<any>;
|
|
51
|
-
}
|