nestjs-mongo 0.11.4 → 0.13.2
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/constants.d.ts +1 -4
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -5
- package/dist/constants.js.map +1 -1
- package/dist/entity/decorators.d.ts +2 -0
- package/dist/entity/decorators.d.ts.map +1 -0
- package/dist/entity/decorators.js +8 -0
- package/dist/entity/decorators.js.map +1 -0
- package/dist/entity/entity.d.ts +11 -0
- package/dist/entity/entity.d.ts.map +1 -0
- package/dist/{entity.js → entity/entity.js} +11 -11
- package/dist/entity/entity.js.map +1 -0
- package/dist/{classes → entity}/filter.d.ts +2 -2
- package/dist/entity/filter.d.ts.map +1 -0
- package/dist/{classes → entity}/filter.js +13 -13
- package/dist/entity/filter.js.map +1 -0
- package/dist/entity/index.d.ts +9 -0
- package/dist/entity/index.d.ts.map +1 -0
- package/dist/entity/index.js +21 -0
- package/dist/entity/index.js.map +1 -0
- package/dist/entity/interfaces.d.ts +10 -0
- package/dist/entity/interfaces.d.ts.map +1 -0
- package/dist/{interfaces/entity.js → entity/interfaces.js} +1 -1
- package/dist/entity/interfaces.js.map +1 -0
- package/dist/entity/manager.d.ts +55 -0
- package/dist/entity/manager.d.ts.map +1 -0
- package/dist/{manager.js → entity/manager.js} +106 -142
- package/dist/entity/manager.js.map +1 -0
- package/dist/entity/paginated.d.ts +8 -0
- package/dist/entity/paginated.d.ts.map +1 -0
- package/dist/{classes → entity}/paginated.js +2 -2
- package/dist/entity/paginated.js.map +1 -0
- package/dist/entity/repository.d.ts +25 -0
- package/dist/entity/repository.d.ts.map +1 -0
- package/dist/{repository.js → entity/repository.js} +15 -37
- package/dist/entity/repository.js.map +1 -0
- package/dist/entity/service.d.ts +22 -0
- package/dist/entity/service.d.ts.map +1 -0
- package/dist/{entity.service.js → entity/service.js} +23 -48
- package/dist/entity/service.js.map +1 -0
- package/dist/event/event.d.ts +4 -0
- package/dist/event/event.d.ts.map +1 -0
- package/dist/{interfaces → event}/event.js +0 -0
- package/dist/{interfaces → event}/event.js.map +1 -1
- package/dist/event/index.d.ts +2 -0
- package/dist/event/index.d.ts.map +1 -0
- package/dist/event/index.js +14 -0
- package/dist/event/index.js.map +1 -0
- package/dist/helpers.d.ts +0 -6
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +1 -24
- package/dist/helpers.js.map +1 -1
- package/dist/{classes → history}/history.action.d.ts +0 -0
- package/dist/{classes → history}/history.action.d.ts.map +1 -1
- package/dist/{classes → history}/history.action.js +2 -2
- package/dist/{classes → history}/history.action.js.map +1 -1
- package/dist/{classes → history}/history.d.ts +0 -0
- package/dist/history/history.d.ts.map +1 -0
- package/dist/{classes → history}/history.js +4 -4
- package/dist/history/history.js.map +1 -0
- package/dist/history/index.d.ts +3 -0
- package/dist/history/index.d.ts.map +1 -0
- package/dist/history/index.js +15 -0
- package/dist/history/index.js.map +1 -0
- package/dist/index.d.ts +7 -31
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -33
- package/dist/index.js.map +1 -1
- package/dist/indexs/decorators.d.ts +3 -0
- package/dist/indexs/decorators.d.ts.map +1 -0
- package/dist/{indexes → indexs}/decorators.js +1 -1
- package/dist/indexs/decorators.js.map +1 -0
- package/dist/indexs/index.d.ts +3 -0
- package/dist/indexs/index.d.ts.map +1 -0
- package/dist/indexs/index.js +15 -0
- package/dist/indexs/index.js.map +1 -0
- package/dist/indexs/metadata.d.ts +9 -0
- package/dist/indexs/metadata.d.ts.map +1 -0
- package/dist/indexs/metadata.js +27 -0
- package/dist/indexs/metadata.js.map +1 -0
- package/dist/module/core.d.ts +11 -0
- package/dist/module/core.d.ts.map +1 -0
- package/dist/module/core.js +126 -0
- package/dist/module/core.js.map +1 -0
- package/dist/module/feature.d.ts +9 -0
- package/dist/module/feature.d.ts.map +1 -0
- package/dist/module/feature.js +67 -0
- package/dist/module/feature.js.map +1 -0
- package/dist/module/index.d.ts +4 -0
- package/dist/module/index.d.ts.map +1 -0
- package/dist/module/index.js +16 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/injection.d.ts +10 -0
- package/dist/module/injection.d.ts.map +1 -0
- package/dist/module/injection.js +38 -0
- package/dist/module/injection.js.map +1 -0
- package/dist/module/interfaces.d.ts +28 -0
- package/dist/module/interfaces.d.ts.map +1 -0
- package/dist/{interfaces/exception.js → module/interfaces.js} +1 -1
- package/dist/module/interfaces.js.map +1 -0
- package/dist/relationship/constraint.d.ts +3 -3
- package/dist/relationship/constraint.d.ts.map +1 -1
- package/dist/relationship/constraint.js +8 -9
- package/dist/relationship/constraint.js.map +1 -1
- package/dist/relationship/decorators.d.ts +6 -6
- package/dist/relationship/decorators.d.ts.map +1 -1
- package/dist/relationship/decorators.js +25 -13
- package/dist/relationship/decorators.js.map +1 -1
- package/dist/relationship/index.d.ts +6 -0
- package/dist/relationship/index.d.ts.map +1 -0
- package/dist/relationship/index.js +18 -0
- package/dist/relationship/index.js.map +1 -0
- package/dist/relationship/interfaces.d.ts +36 -0
- package/dist/relationship/interfaces.d.ts.map +1 -0
- package/dist/relationship/interfaces.js +8 -0
- package/dist/relationship/interfaces.js.map +1 -0
- package/dist/relationship/metadata.d.ts +8 -43
- package/dist/relationship/metadata.d.ts.map +1 -1
- package/dist/relationship/metadata.js +56 -56
- package/dist/relationship/metadata.js.map +1 -1
- package/dist/relationship/pipes/index.d.ts +3 -0
- package/dist/relationship/pipes/index.d.ts.map +1 -0
- package/dist/relationship/pipes/index.js +15 -0
- package/dist/relationship/pipes/index.js.map +1 -0
- package/dist/relationship/pipes/relationship.d.ts +8 -0
- package/dist/relationship/pipes/relationship.d.ts.map +1 -0
- package/dist/{validation → relationship}/pipes/relationship.js +8 -8
- package/dist/relationship/pipes/relationship.js.map +1 -0
- package/dist/{validation → relationship}/pipes/required.relationship.d.ts +1 -1
- package/dist/relationship/pipes/required.relationship.d.ts.map +1 -0
- package/dist/{validation → relationship}/pipes/required.relationship.js +1 -1
- package/dist/relationship/pipes/required.relationship.js.map +1 -0
- package/dist/serializer/decorators.d.ts +2 -0
- package/dist/serializer/decorators.d.ts.map +1 -0
- package/dist/serializer/decorators.js +12 -0
- package/dist/serializer/decorators.js.map +1 -0
- package/dist/serializer/index.d.ts +4 -0
- package/dist/serializer/index.d.ts.map +1 -0
- package/dist/serializer/index.js +16 -0
- package/dist/serializer/index.js.map +1 -0
- package/dist/serializer/interfaces.d.ts +5 -0
- package/dist/serializer/interfaces.d.ts.map +1 -0
- package/dist/{interfaces/async.options.js → serializer/interfaces.js} +1 -1
- package/dist/serializer/interfaces.js.map +1 -0
- package/dist/serializer/serializer.d.ts +3 -0
- package/dist/serializer/serializer.d.ts.map +1 -0
- package/dist/serializer/serializer.js +22 -0
- package/dist/serializer/serializer.js.map +1 -0
- package/dist/session/middleware.js +3 -3
- package/dist/session/middleware.js.map +1 -1
- package/dist/session/service.d.ts.map +1 -1
- package/dist/session/service.js +9 -11
- package/dist/session/service.js.map +1 -1
- package/dist/transformer/index.d.ts +4 -0
- package/dist/transformer/index.d.ts.map +1 -0
- package/dist/transformer/index.js +16 -0
- package/dist/transformer/index.js.map +1 -0
- package/dist/transformer/objectId/index.d.ts +6 -0
- package/dist/transformer/objectId/index.d.ts.map +1 -0
- package/dist/transformer/objectId/index.js +54 -0
- package/dist/transformer/objectId/index.js.map +1 -0
- package/dist/{transformers/objectid.d.ts → transformer/objectId/objectid.pipe.d.ts} +2 -2
- package/dist/transformer/objectId/objectid.pipe.d.ts.map +1 -0
- package/dist/{transformers/objectid.js → transformer/objectId/objectid.pipe.js} +5 -5
- package/dist/transformer/objectId/objectid.pipe.js.map +1 -0
- package/dist/transformer/slug.d.ts +18 -0
- package/dist/transformer/slug.d.ts.map +1 -0
- package/dist/transformer/slug.js +31 -0
- package/dist/transformer/slug.js.map +1 -0
- package/dist/transformer/utils.d.ts +7 -0
- package/dist/transformer/utils.d.ts.map +1 -0
- package/dist/transformer/utils.js +23 -0
- package/dist/transformer/utils.js.map +1 -0
- package/dist/validation/index.d.ts +2 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +14 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/unique/constraint.d.ts +2 -2
- package/dist/validation/unique/constraint.d.ts.map +1 -1
- package/dist/validation/unique/constraint.js +4 -4
- package/dist/validation/unique/constraint.js.map +1 -1
- package/dist/validation/unique/decorator.d.ts +1 -1
- package/dist/validation/unique/decorator.d.ts.map +1 -1
- package/dist/validation/unique/decorator.js +13 -13
- package/dist/validation/unique/decorator.js.map +1 -1
- package/dist/validation/unique/index.d.ts +3 -0
- package/dist/validation/unique/index.d.ts.map +1 -0
- package/dist/validation/unique/index.js +15 -0
- package/dist/validation/unique/index.js.map +1 -0
- package/package.json +37 -38
- package/dist/classes/filter.d.ts.map +0 -1
- package/dist/classes/filter.js.map +0 -1
- package/dist/classes/history.d.ts.map +0 -1
- package/dist/classes/history.js.map +0 -1
- package/dist/classes/paginated.d.ts +0 -8
- package/dist/classes/paginated.d.ts.map +0 -1
- package/dist/classes/paginated.js.map +0 -1
- package/dist/dataloader/data.d.ts +0 -6
- package/dist/dataloader/data.d.ts.map +0 -1
- package/dist/dataloader/data.js +0 -11
- package/dist/dataloader/data.js.map +0 -1
- package/dist/dataloader/middleware.d.ts +0 -14
- package/dist/dataloader/middleware.d.ts.map +0 -1
- package/dist/dataloader/middleware.js +0 -56
- package/dist/dataloader/middleware.js.map +0 -1
- package/dist/dataloader/service.d.ts +0 -17
- package/dist/dataloader/service.d.ts.map +0 -1
- package/dist/dataloader/service.js +0 -92
- package/dist/dataloader/service.js.map +0 -1
- package/dist/decorators.d.ts +0 -25
- package/dist/decorators.d.ts.map +0 -1
- package/dist/decorators.js +0 -91
- package/dist/decorators.js.map +0 -1
- package/dist/entity.d.ts +0 -11
- package/dist/entity.d.ts.map +0 -1
- package/dist/entity.js.map +0 -1
- package/dist/entity.service.d.ts +0 -22
- package/dist/entity.service.d.ts.map +0 -1
- package/dist/entity.service.js.map +0 -1
- package/dist/indexes/decorators.d.ts +0 -3
- package/dist/indexes/decorators.d.ts.map +0 -1
- package/dist/indexes/decorators.js.map +0 -1
- package/dist/indexes/metadata.d.ts +0 -13
- package/dist/indexes/metadata.d.ts.map +0 -1
- package/dist/indexes/metadata.js +0 -70
- package/dist/indexes/metadata.js.map +0 -1
- package/dist/interfaces/async.options.d.ts +0 -8
- package/dist/interfaces/async.options.d.ts.map +0 -1
- package/dist/interfaces/async.options.js.map +0 -1
- package/dist/interfaces/entity.d.ts +0 -10
- package/dist/interfaces/entity.d.ts.map +0 -1
- package/dist/interfaces/entity.js.map +0 -1
- package/dist/interfaces/event.d.ts +0 -6
- package/dist/interfaces/event.d.ts.map +0 -1
- package/dist/interfaces/exception.d.ts +0 -3
- package/dist/interfaces/exception.d.ts.map +0 -1
- package/dist/interfaces/exception.js.map +0 -1
- package/dist/interfaces/execution.options.d.ts +0 -5
- package/dist/interfaces/execution.options.d.ts.map +0 -1
- package/dist/interfaces/execution.options.js +0 -3
- package/dist/interfaces/execution.options.js.map +0 -1
- package/dist/interfaces/feature.options.d.ts +0 -5
- package/dist/interfaces/feature.options.d.ts.map +0 -1
- package/dist/interfaces/feature.options.js +0 -3
- package/dist/interfaces/feature.options.js.map +0 -1
- package/dist/interfaces/module.options.d.ts +0 -7
- package/dist/interfaces/module.options.d.ts.map +0 -1
- package/dist/interfaces/module.options.factory.d.ts +0 -5
- package/dist/interfaces/module.options.factory.d.ts.map +0 -1
- package/dist/interfaces/module.options.factory.js +0 -3
- package/dist/interfaces/module.options.factory.js.map +0 -1
- package/dist/interfaces/module.options.js +0 -3
- package/dist/interfaces/module.options.js.map +0 -1
- package/dist/manager.d.ts +0 -80
- package/dist/manager.d.ts.map +0 -1
- package/dist/manager.js.map +0 -1
- package/dist/module.core.d.ts +0 -13
- package/dist/module.core.d.ts.map +0 -1
- package/dist/module.core.js +0 -173
- package/dist/module.core.js.map +0 -1
- package/dist/module.d.ts +0 -8
- package/dist/module.d.ts.map +0 -1
- package/dist/module.js +0 -33
- package/dist/module.js.map +0 -1
- package/dist/repository.d.ts +0 -37
- package/dist/repository.d.ts.map +0 -1
- package/dist/repository.js.map +0 -1
- package/dist/serializer.d.ts +0 -7
- package/dist/serializer.d.ts.map +0 -1
- package/dist/serializer.js +0 -30
- package/dist/serializer.js.map +0 -1
- package/dist/transformers/objectid.d.ts.map +0 -1
- package/dist/transformers/objectid.js.map +0 -1
- package/dist/transformers/utils.d.ts +0 -6
- package/dist/transformers/utils.d.ts.map +0 -1
- package/dist/transformers/utils.js +0 -14
- package/dist/transformers/utils.js.map +0 -1
- package/dist/validation/pipes/relationship.d.ts +0 -8
- package/dist/validation/pipes/relationship.d.ts.map +0 -1
- package/dist/validation/pipes/relationship.js.map +0 -1
- package/dist/validation/pipes/required.relationship.d.ts.map +0 -1
- package/dist/validation/pipes/required.relationship.js.map +0 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import Debug from 'debug';
|
|
2
|
+
import { ChangeStreamDocument, ObjectId, WithId } from 'mongodb';
|
|
3
|
+
import { EventCallback } from '../event/event';
|
|
4
|
+
import { Filter } from './filter';
|
|
5
|
+
import { EntityInterface } from './interfaces';
|
|
6
|
+
import { PaginatedData } from './paginated';
|
|
7
|
+
import { EntityRepository } from './repository';
|
|
8
|
+
export declare abstract class EntityService<Model extends EntityInterface, Repository extends EntityRepository<Model> = EntityRepository<Model>> {
|
|
9
|
+
protected repository: Repository;
|
|
10
|
+
protected log: Debug.Debugger;
|
|
11
|
+
constructor();
|
|
12
|
+
addHistory<Obj extends EntityInterface>(item: Obj, action: string, date?: Date): this;
|
|
13
|
+
getRepository(): Repository;
|
|
14
|
+
create(data: any, save?: boolean, ...rest: any[]): Promise<WithId<Model> | Model>;
|
|
15
|
+
get(itemId: ObjectId, ...rest: any[]): Promise<WithId<Model>>;
|
|
16
|
+
list(filter: Filter, ResponseType: any, ...rest: any[]): Promise<PaginatedData<Model>>;
|
|
17
|
+
update(itemId: ObjectId, data: any, save?: boolean, ...rest: any[]): Promise<WithId<Model> | Model>;
|
|
18
|
+
delete(itemId: ObjectId, ...rest: any[]): Promise<void>;
|
|
19
|
+
subscribe(onData: EventCallback<WithId<Model>>): import("mongodb").ChangeStream<WithId<Model>>;
|
|
20
|
+
protected readonly onData: (change: ChangeStreamDocument<WithId<Model>>, onData: EventCallback<WithId<Model>>) => Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/entity/service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,oBAAoB,EAAyB,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGxF,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,8BACsB,aAAa,CAC/B,KAAK,SAAS,eAAe,EAC7B,UAAU,SAAS,gBAAgB,CAAC,KAAK,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC;IAEpE,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC;IACjC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC;;IAM9B,UAAU,CAAC,GAAG,SAAS,eAAe,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI;IAQ9E,aAAa,IAAI,UAAU;IAIrB,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,UAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;IAQ/E,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAU7D,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAmBtF,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,UAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;IASjG,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAS7D,SAAS,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAU9C,SAAS,CAAC,QAAQ,CAAC,MAAM,WACb,qBAAqB,OAAO,KAAK,CAAC,CAAC,UACnC,cAAc,OAAO,KAAK,CAAC,CAAC,mBActC;CACL"}
|
|
@@ -26,56 +26,30 @@ const common_1 = require("@nestjs/common");
|
|
|
26
26
|
const class_validator_1 = require("class-validator");
|
|
27
27
|
const debug_1 = __importDefault(require("debug"));
|
|
28
28
|
const lodash_1 = require("lodash");
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const constants_1 = require("./constants");
|
|
29
|
+
const constants_1 = require("../constants");
|
|
30
|
+
const history_1 = require("../history");
|
|
32
31
|
let EntityService = class EntityService {
|
|
33
32
|
constructor() {
|
|
34
33
|
this.onData = (change, onData) => __awaiter(this, void 0, void 0, function* () {
|
|
35
34
|
try {
|
|
36
35
|
const em = this.repository.getEm();
|
|
37
36
|
const classType = this.repository.getClassType();
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
if (operationType === 'insert') {
|
|
41
|
-
operation = 'create';
|
|
42
|
-
}
|
|
43
|
-
else if (operationType === 'replace' ||
|
|
44
|
-
operationType === 'update') {
|
|
45
|
-
operation = 'update';
|
|
46
|
-
}
|
|
47
|
-
else if (operationType === 'delete') {
|
|
48
|
-
operation = 'delete';
|
|
49
|
-
}
|
|
50
|
-
if (operation === undefined) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
if (!['create', 'update', 'delete'].includes(operation)) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
const changeCast = change;
|
|
57
|
-
let fullDocument;
|
|
37
|
+
const eventName = (0, lodash_1.camelCase)(`on_${change.operationType}_${classType.name}`);
|
|
38
|
+
this.log('Event:%s for %s:%s', eventName, classType.name, change.documentKey);
|
|
58
39
|
if (change.fullDocument !== undefined) {
|
|
59
|
-
fullDocument = change.fullDocument;
|
|
60
|
-
}
|
|
61
|
-
const eventName = lodash_1.camelCase(`on_${operation}_${classType.name}`);
|
|
62
|
-
this.log('Event:%s for %s:%s', eventName, classType.name, changeCast.documentKey._id);
|
|
63
|
-
if (operation === 'delete') {
|
|
64
|
-
onData(eventName, operation, changeCast.documentKey._id, changeCast);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
onData(eventName, operation, em.fromPlain(classType, fullDocument), changeCast);
|
|
40
|
+
change.fullDocument = em.fromPlain(classType, change.fullDocument);
|
|
68
41
|
}
|
|
42
|
+
onData(eventName, change);
|
|
69
43
|
}
|
|
70
44
|
catch (e) {
|
|
71
45
|
this.log('Entity listener error: %s', e.message);
|
|
72
46
|
}
|
|
73
47
|
});
|
|
74
|
-
this.log = debug_1.default(constants_1.DEBUG + '_' + this.constructor.name);
|
|
48
|
+
this.log = (0, debug_1.default)(constants_1.DEBUG + '_' + this.constructor.name);
|
|
75
49
|
}
|
|
76
50
|
addHistory(item, action, date) {
|
|
77
51
|
if (item.history instanceof history_1.HistoryActions) {
|
|
78
|
-
const historyAction = new
|
|
52
|
+
const historyAction = new history_1.HistoryAction(action, date !== undefined ? date : new Date());
|
|
79
53
|
item.history.add(historyAction);
|
|
80
54
|
}
|
|
81
55
|
return this;
|
|
@@ -94,7 +68,9 @@ let EntityService = class EntityService {
|
|
|
94
68
|
}
|
|
95
69
|
get(itemId, ...rest) {
|
|
96
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
-
const
|
|
71
|
+
const filter = {};
|
|
72
|
+
filter._id = itemId;
|
|
73
|
+
const item = yield this.repository.findOne(filter, ...rest);
|
|
98
74
|
if (item === undefined) {
|
|
99
75
|
throw new common_1.NotFoundException();
|
|
100
76
|
}
|
|
@@ -103,14 +79,13 @@ let EntityService = class EntityService {
|
|
|
103
79
|
}
|
|
104
80
|
list(filter, ResponseType, ...rest) {
|
|
105
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
.
|
|
109
|
-
if (!class_validator_1.isEmpty(filter.orderBy)) {
|
|
110
|
-
items = items.sort(filter.getSort());
|
|
82
|
+
const cursor = yield this.repository.find(filter.toQuery());
|
|
83
|
+
if (!(0, class_validator_1.isEmpty)(filter.orderBy)) {
|
|
84
|
+
cursor.sort(filter.getSort());
|
|
111
85
|
}
|
|
112
|
-
const count = yield
|
|
113
|
-
|
|
86
|
+
const count = yield cursor.count();
|
|
87
|
+
cursor.skip(filter.skip).limit(filter.limit);
|
|
88
|
+
const data = yield cursor.toArray();
|
|
114
89
|
const res = new ResponseType();
|
|
115
90
|
res.count = count;
|
|
116
91
|
res.data = data;
|
|
@@ -129,10 +104,10 @@ let EntityService = class EntityService {
|
|
|
129
104
|
}
|
|
130
105
|
delete(itemId, ...rest) {
|
|
131
106
|
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
}, ...rest);
|
|
135
|
-
if (
|
|
107
|
+
const filter = {};
|
|
108
|
+
filter._id = itemId;
|
|
109
|
+
const { deletedCount } = yield this.repository.deleteOne(filter, ...rest);
|
|
110
|
+
if (deletedCount !== 1) {
|
|
136
111
|
throw new common_1.NotFoundException();
|
|
137
112
|
}
|
|
138
113
|
});
|
|
@@ -148,8 +123,8 @@ let EntityService = class EntityService {
|
|
|
148
123
|
}
|
|
149
124
|
};
|
|
150
125
|
EntityService = __decorate([
|
|
151
|
-
common_1.Injectable(),
|
|
126
|
+
(0, common_1.Injectable)(),
|
|
152
127
|
__metadata("design:paramtypes", [])
|
|
153
128
|
], EntityService);
|
|
154
129
|
exports.EntityService = EntityService;
|
|
155
|
-
//# sourceMappingURL=
|
|
130
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/entity/service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA+D;AAC/D,qDAA0C;AAC1C,kDAA0B;AAC1B,mCAAmC;AAGnC,4CAAqC;AAErC,wCAA2D;AAO3D,IAAsB,aAAa,GAAnC,MAAsB,aAAa;IAO/B;QAiFmB,WAAM,GAAG,CACxB,MAA2C,EAC3C,MAAoC,EACtC,EAAE;YACA,IAAI;gBACA,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;gBACnC,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC;gBACjD,MAAM,SAAS,GAAG,IAAA,kBAAS,EAAC,MAAM,MAAM,CAAC,aAAa,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;gBAC5E,IAAI,CAAC,GAAG,CAAC,oBAAoB,EAAE,SAAS,EAAE,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;gBAC9E,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS,EAAE;oBACnC,MAAM,CAAC,YAAY,GAAG,EAAE,CAAC,SA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,EAAE,GAAG,IAAI,CAAC,CAAC;aACpD;YACD,OAAO,IAAI,CAAC;QAChB,CAAC;KAAA;IAEK,MAAM,CAAC,MAAgB,EAAE,GAAG,IAAW;;YACzC,MAAM,MAAM,GAAuB,EAAE,CAAC;YACtC,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC;YACpB,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;YAC1E,IAAI,YAAY,KAAK,CAAC,EAAE;gBACpB,MAAM,IAAI,0BAAiB,EAAE,CAAC;aACjC;QACL,CAAC;KAAA;IAED,SAAS,CAAC,MAAoC;QAC1C,OAAO,IAAI,CAAC,UAAU;aACjB,KAAK,CAAC,EAAE,EAAE,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;aAC3C,EAAE,CAAC,QAAQ,EAAE,CAAC,MAA2C,EAAE,EAAE;YAC1D,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;gBACpC,MAAM,CAAC,CAAC;YACZ,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACX,CAAC;CAmBJ,CAAA;AAzGqB,aAAa;IADlC,IAAA,mBAAU,GAAE;;GACS,aAAa,CAyGlC;AAzGqB,sCAAa"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ChangeStreamDocument } from 'mongodb';
|
|
2
|
+
import { EntityInterface } from '../entity/interfaces';
|
|
3
|
+
export declare type EventCallback<Model extends EntityInterface> = (eventName: string, change: ChangeStreamDocument<Model>) => void;
|
|
4
|
+
//# sourceMappingURL=event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/event/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAMvD,oBAAY,aAAa,CAAC,KAAK,SAAS,eAAe,IAAI,CACvD,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,oBAAoB,CAAC,KAAK,CAAC,KAGlC,IAAI,CAAC"}
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../src/event/event.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/event/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./event"), exports);
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/event/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAwB"}
|
package/dist/helpers.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
export { ObjectId } from 'mongodb';
|
|
2
1
|
export declare const isClass: (fn: any) => boolean;
|
|
3
|
-
export declare function getRepositoryToken(model: string, connectionName?: string): string;
|
|
4
|
-
export declare function getDataloaderToken(model: string, connectionName?: string): string;
|
|
5
|
-
export declare function getConfigToken(connectionName?: string): string;
|
|
6
|
-
export declare function getConnectionToken(connectionName?: string): string;
|
|
7
|
-
export declare function getManagerToken(connectionName?: string): string;
|
|
8
2
|
export declare function getObjectName(o: Object): string;
|
|
9
3
|
//# sourceMappingURL=helpers.d.ts.map
|
package/dist/helpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,OAAQ,GAAG,YAAoC,CAAC;AAEpE,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE/C"}
|
package/dist/helpers.js
CHANGED
|
@@ -1,31 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getObjectName = exports.
|
|
4
|
-
const constants_1 = require("./constants");
|
|
5
|
-
var mongodb_1 = require("mongodb");
|
|
6
|
-
Object.defineProperty(exports, "ObjectId", { enumerable: true, get: function () { return mongodb_1.ObjectId; } });
|
|
3
|
+
exports.getObjectName = exports.isClass = void 0;
|
|
7
4
|
const isClass = (fn) => /^\s*class/.test(fn.toString());
|
|
8
5
|
exports.isClass = isClass;
|
|
9
|
-
function getRepositoryToken(model, connectionName = constants_1.DEFAULT_CONNECTION_NAME) {
|
|
10
|
-
return `${connectionName}_${model}Repository`;
|
|
11
|
-
}
|
|
12
|
-
exports.getRepositoryToken = getRepositoryToken;
|
|
13
|
-
function getDataloaderToken(model, connectionName = constants_1.DEFAULT_CONNECTION_NAME) {
|
|
14
|
-
return `${connectionName}_${model}Dataloader`;
|
|
15
|
-
}
|
|
16
|
-
exports.getDataloaderToken = getDataloaderToken;
|
|
17
|
-
function getConfigToken(connectionName = constants_1.DEFAULT_CONNECTION_NAME) {
|
|
18
|
-
return `${connectionName}_MongoConfig`;
|
|
19
|
-
}
|
|
20
|
-
exports.getConfigToken = getConfigToken;
|
|
21
|
-
function getConnectionToken(connectionName = constants_1.DEFAULT_CONNECTION_NAME) {
|
|
22
|
-
return `${connectionName}_MongoConnection`;
|
|
23
|
-
}
|
|
24
|
-
exports.getConnectionToken = getConnectionToken;
|
|
25
|
-
function getManagerToken(connectionName = constants_1.DEFAULT_CONNECTION_NAME) {
|
|
26
|
-
return `${connectionName}_MongoManager`;
|
|
27
|
-
}
|
|
28
|
-
exports.getManagerToken = getManagerToken;
|
|
29
6
|
function getObjectName(o) {
|
|
30
7
|
return o.constructor.name;
|
|
31
8
|
}
|
package/dist/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;AAAO,MAAM,OAAO,GAAG,CAAC,EAAO,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;AAAvD,QAAA,OAAO,WAAgD;AAEpE,SAAgB,aAAa,CAAC,CAAS;IACnC,OAAO,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC;AAC9B,CAAC;AAFD,sCAEC"}
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history.action.d.ts","sourceRoot":"","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"history.action.d.ts","sourceRoot":"","sources":["../../src/history/history.action.ts"],"names":[],"mappings":"AAEA,qBAAa,aAAa;IAEtB,MAAM,EAAE,MAAM,CAAC;IAGf,IAAI,EAAE,IAAI,CAAC;gBAEC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI;CAIzC"}
|
|
@@ -18,11 +18,11 @@ class HistoryAction {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
__decorate([
|
|
21
|
-
class_validator_1.IsString(),
|
|
21
|
+
(0, class_validator_1.IsString)(),
|
|
22
22
|
__metadata("design:type", String)
|
|
23
23
|
], HistoryAction.prototype, "action", void 0);
|
|
24
24
|
__decorate([
|
|
25
|
-
class_validator_1.IsDate(),
|
|
25
|
+
(0, class_validator_1.IsDate)(),
|
|
26
26
|
__metadata("design:type", Date)
|
|
27
27
|
], HistoryAction.prototype, "date", void 0);
|
|
28
28
|
exports.HistoryAction = HistoryAction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history.action.js","sourceRoot":"","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"history.action.js","sourceRoot":"","sources":["../../src/history/history.action.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAmD;AAEnD,MAAa,aAAa;IAOtB,YAAY,MAAc,EAAE,IAAU;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;CACJ;AATG;IADC,IAAA,0BAAQ,GAAE;;6CACI;AAGf;IADC,IAAA,wBAAM,GAAE;8BACH,IAAI;2CAAC;AALf,sCAWC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/history/history.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,qBAAa,cAAc;IAGvB,OAAO,EAAE,aAAa,EAAE,CAAM;IAE9B,GAAG,CAAC,aAAa,EAAE,aAAa;IAIhC,KAAK;IAIL,UAAU;CAGb"}
|
|
@@ -10,9 +10,9 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.HistoryActions = void 0;
|
|
13
|
-
const history_action_1 = require("./history.action");
|
|
14
|
-
const class_validator_1 = require("class-validator");
|
|
15
13
|
const class_transformer_1 = require("class-transformer");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
const history_action_1 = require("./history.action");
|
|
16
16
|
class HistoryActions {
|
|
17
17
|
constructor() {
|
|
18
18
|
this.actions = [];
|
|
@@ -28,8 +28,8 @@ class HistoryActions {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
__decorate([
|
|
31
|
-
class_validator_1.IsArray(),
|
|
32
|
-
class_transformer_1.Type(() => history_action_1.HistoryAction),
|
|
31
|
+
(0, class_validator_1.IsArray)(),
|
|
32
|
+
(0, class_transformer_1.Type)(() => history_action_1.HistoryAction),
|
|
33
33
|
__metadata("design:type", Array)
|
|
34
34
|
], HistoryActions.prototype, "actions", void 0);
|
|
35
35
|
exports.HistoryActions = HistoryActions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/history/history.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyC;AACzC,qDAA0C;AAE1C,qDAAiD;AAEjD,MAAa,cAAc;IAA3B;QAGI,YAAO,GAAoB,EAAE,CAAC;IAalC,CAAC;IAXG,GAAG,CAAC,aAA4B;QAC5B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACrC,CAAC;IAED,KAAK;QACD,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACtB,CAAC;IAED,UAAU;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;CACJ;AAbG;IAFC,IAAA,yBAAO,GAAE;IACT,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,8BAAa,CAAC;;+CACI;AAHlC,wCAgBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/history/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./history.action"), exports);
|
|
14
|
+
__exportStar(require("./history"), exports);
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/history/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAiC;AACjC,4CAA0B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,39 +1,15 @@
|
|
|
1
|
-
export { Cursor } from 'mongodb';
|
|
2
|
-
export * from './classes/filter';
|
|
3
|
-
export * from './classes/history';
|
|
4
|
-
export * from './classes/history.action';
|
|
5
|
-
export * from './classes/paginated';
|
|
6
1
|
export * from './constants';
|
|
7
|
-
export * from './dataloader/data';
|
|
8
|
-
export * from './dataloader/service';
|
|
9
2
|
export * from './session/middleware';
|
|
10
3
|
export * from './session/service';
|
|
11
4
|
export * from './session/utils';
|
|
12
|
-
export * from './decorators';
|
|
13
|
-
export * from './entity';
|
|
14
|
-
export * from './entity.service';
|
|
15
5
|
export * from './helpers';
|
|
16
|
-
export * from './
|
|
17
|
-
export * from './interfaces/entity';
|
|
18
|
-
export * from './interfaces/exception';
|
|
19
|
-
export * from './interfaces/execution.options';
|
|
20
|
-
export * from './interfaces/feature.options';
|
|
21
|
-
export * from './interfaces/module.options';
|
|
22
|
-
export * from './interfaces/module.options.factory';
|
|
23
|
-
export * from './interfaces/event';
|
|
24
|
-
export * from './manager';
|
|
6
|
+
export * from './event';
|
|
25
7
|
export * from './module';
|
|
26
|
-
export * from './relationship
|
|
27
|
-
export * from './
|
|
28
|
-
export * from './relationship/metadata';
|
|
29
|
-
export * from './repository';
|
|
8
|
+
export * from './relationship';
|
|
9
|
+
export * from './entity';
|
|
30
10
|
export * from './serializer';
|
|
31
|
-
export * from './
|
|
32
|
-
export * from './
|
|
33
|
-
export * from './
|
|
34
|
-
export * from './
|
|
35
|
-
export * from './validation/unique/constraint';
|
|
36
|
-
export * from './validation/unique/decorator';
|
|
37
|
-
export * from './indexes/decorators';
|
|
38
|
-
export * from './indexes/metadata';
|
|
11
|
+
export * from './transformer';
|
|
12
|
+
export * from './validation';
|
|
13
|
+
export * from './indexs';
|
|
14
|
+
export * from './history';
|
|
39
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -10,44 +10,18 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.Cursor = void 0;
|
|
14
|
-
var mongodb_1 = require("mongodb");
|
|
15
|
-
Object.defineProperty(exports, "Cursor", { enumerable: true, get: function () { return mongodb_1.Cursor; } });
|
|
16
|
-
__exportStar(require("./classes/filter"), exports);
|
|
17
|
-
__exportStar(require("./classes/history"), exports);
|
|
18
|
-
__exportStar(require("./classes/history.action"), exports);
|
|
19
|
-
__exportStar(require("./classes/paginated"), exports);
|
|
20
13
|
__exportStar(require("./constants"), exports);
|
|
21
|
-
__exportStar(require("./dataloader/data"), exports);
|
|
22
|
-
__exportStar(require("./dataloader/service"), exports);
|
|
23
14
|
__exportStar(require("./session/middleware"), exports);
|
|
24
15
|
__exportStar(require("./session/service"), exports);
|
|
25
16
|
__exportStar(require("./session/utils"), exports);
|
|
26
|
-
__exportStar(require("./decorators"), exports);
|
|
27
|
-
__exportStar(require("./entity"), exports);
|
|
28
|
-
__exportStar(require("./entity.service"), exports);
|
|
29
17
|
__exportStar(require("./helpers"), exports);
|
|
30
|
-
__exportStar(require("./
|
|
31
|
-
__exportStar(require("./interfaces/entity"), exports);
|
|
32
|
-
__exportStar(require("./interfaces/exception"), exports);
|
|
33
|
-
__exportStar(require("./interfaces/execution.options"), exports);
|
|
34
|
-
__exportStar(require("./interfaces/feature.options"), exports);
|
|
35
|
-
__exportStar(require("./interfaces/module.options"), exports);
|
|
36
|
-
__exportStar(require("./interfaces/module.options.factory"), exports);
|
|
37
|
-
__exportStar(require("./interfaces/event"), exports);
|
|
38
|
-
__exportStar(require("./manager"), exports);
|
|
18
|
+
__exportStar(require("./event"), exports);
|
|
39
19
|
__exportStar(require("./module"), exports);
|
|
40
|
-
__exportStar(require("./relationship
|
|
41
|
-
__exportStar(require("./
|
|
42
|
-
__exportStar(require("./relationship/metadata"), exports);
|
|
43
|
-
__exportStar(require("./repository"), exports);
|
|
20
|
+
__exportStar(require("./relationship"), exports);
|
|
21
|
+
__exportStar(require("./entity"), exports);
|
|
44
22
|
__exportStar(require("./serializer"), exports);
|
|
45
|
-
__exportStar(require("./
|
|
46
|
-
__exportStar(require("./
|
|
47
|
-
__exportStar(require("./
|
|
48
|
-
__exportStar(require("./
|
|
49
|
-
__exportStar(require("./validation/unique/constraint"), exports);
|
|
50
|
-
__exportStar(require("./validation/unique/decorator"), exports);
|
|
51
|
-
__exportStar(require("./indexes/decorators"), exports);
|
|
52
|
-
__exportStar(require("./indexes/metadata"), exports);
|
|
23
|
+
__exportStar(require("./transformer"), exports);
|
|
24
|
+
__exportStar(require("./validation"), exports);
|
|
25
|
+
__exportStar(require("./indexs"), exports);
|
|
26
|
+
__exportStar(require("./history"), exports);
|
|
53
27
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAA4B;AAC5B,uDAAqC;AACrC,oDAAkC;AAClC,kDAAgC;AAChC,4CAA0B;AAC1B,0CAAwB;AACxB,2CAAyB;AACzB,iDAA+B;AAC/B,2CAAyB;AACzB,+CAA6B;AAC7B,gDAA8B;AAC9B,+CAA6B;AAC7B,2CAAyB;AACzB,4CAA0B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/indexs/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAKjE,wBAAgB,KAAK,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,oBAAoB,YACpD,GAAG,YAAY,MAAM,UAGjD"}
|
|
@@ -4,7 +4,7 @@ exports.Index = void 0;
|
|
|
4
4
|
const metadata_1 = require("./metadata");
|
|
5
5
|
function Index(metadata) {
|
|
6
6
|
return function (target, property) {
|
|
7
|
-
metadata_1.setIndexMetadata(target, property, metadata
|
|
7
|
+
(0, metadata_1.setIndexMetadata)(target, { property, description: metadata !== null && metadata !== void 0 ? metadata : {} });
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
exports.Index = Index;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/indexs/decorators.ts"],"names":[],"mappings":";;;AAEA,yCAA8C;AAG9C,SAAgB,KAAK,CAAC,QAA2D;IAC7E,OAAO,UAAU,MAAW,EAAE,QAAgB;QAC1C,IAAA,2BAAgB,EAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,EAAE,CAAC,CAAC;IACxE,CAAC,CAAC;AACN,CAAC;AAJD,sBAIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/indexs/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./metadata"), exports);
|
|
14
|
+
__exportStar(require("./decorators"), exports);
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/indexs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA2B;AAC3B,+CAA6B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CreateIndexesOptions, IndexDescription } from 'mongodb';
|
|
2
|
+
export interface IndexMetadata {
|
|
3
|
+
property: string;
|
|
4
|
+
description?: Partial<IndexDescription> & CreateIndexesOptions;
|
|
5
|
+
}
|
|
6
|
+
export declare function setIndexMetadata(target: any, metadata: IndexMetadata): void;
|
|
7
|
+
export declare function getIndexMetadatas(target: any): IndexMetadata[];
|
|
8
|
+
export declare function getIndexMetadata(target: any, property: string): IndexMetadata | undefined;
|
|
9
|
+
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/indexs/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAIjE,MAAM,WAAW,aAAa;IAC1B,QAAQ,EAAE,MAAM,CAAC;IAEjB,WAAW,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,oBAAoB,CAAC;CAClE;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,aAAa,QASpE;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,GAAG,GAAG,aAAa,EAAE,CAK9D;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAEzF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getIndexMetadata = exports.getIndexMetadatas = exports.setIndexMetadata = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
function setIndexMetadata(target, metadata) {
|
|
6
|
+
const constructorName = target.constructor.name;
|
|
7
|
+
const metadataName = `${constants_1.INDEX_METADATA_NAME}:${constructorName}`;
|
|
8
|
+
let targetMetadata = Reflect.getMetadata(metadataName, target.constructor);
|
|
9
|
+
if (targetMetadata === undefined) {
|
|
10
|
+
targetMetadata = [];
|
|
11
|
+
}
|
|
12
|
+
targetMetadata.push(metadata);
|
|
13
|
+
Reflect.defineMetadata(metadataName, targetMetadata, target.constructor);
|
|
14
|
+
}
|
|
15
|
+
exports.setIndexMetadata = setIndexMetadata;
|
|
16
|
+
function getIndexMetadatas(target) {
|
|
17
|
+
const metadataKeys = Reflect.getMetadataKeys(target).filter((p) => p.startsWith(constants_1.INDEX_METADATA_NAME));
|
|
18
|
+
return metadataKeys.reduce((previous, current) => {
|
|
19
|
+
return previous.concat(Reflect.getMetadata(current, target));
|
|
20
|
+
}, []);
|
|
21
|
+
}
|
|
22
|
+
exports.getIndexMetadatas = getIndexMetadatas;
|
|
23
|
+
function getIndexMetadata(target, property) {
|
|
24
|
+
return getIndexMetadatas(target).find((metadata) => metadata.property === property);
|
|
25
|
+
}
|
|
26
|
+
exports.getIndexMetadata = getIndexMetadata;
|
|
27
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
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-0,0 +1,11 @@
|
|
|
1
|
+
import { DynamicModule, OnModuleDestroy } from '@nestjs/common';
|
|
2
|
+
import { EntityManager } from '../entity/manager';
|
|
3
|
+
import { MongoFeatureOptions, MongoModuleAsyncOptions } from './interfaces';
|
|
4
|
+
export declare class MongoModule implements OnModuleDestroy {
|
|
5
|
+
private readonly em;
|
|
6
|
+
constructor(em: EntityManager);
|
|
7
|
+
onModuleDestroy(): Promise<void>;
|
|
8
|
+
static forRootAsync(options: MongoModuleAsyncOptions): Promise<DynamicModule>;
|
|
9
|
+
static forFeature(options: MongoFeatureOptions): DynamicModule;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/module/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAkB,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAKhF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAMlD,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAsB,MAAM,cAAc,CAAC;AAEhG,qBAEa,WAAY,YAAW,eAAe;IACZ,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,aAAa;IAE/D,eAAe;WAIR,YAAY,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,aAAa,CAAC;IAgFnF,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,mBAAmB,GAAG,aAAa;CAGjE"}
|