@campxdev/server-shared 1.2.33 → 1.2.34

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.
@@ -1,5 +1,4 @@
1
1
  export * from './config/mongo.config';
2
- export * from './databases/mongoose.repository';
3
2
  export * from './decorators/request.decorators';
4
3
  export * from './decorators/time-validation.decorator';
5
4
  export * from './filters/unhandled-exception.filter';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,wCAAwC,CAAC;AACvD,cAAc,sCAAsC,CAAC;AACrD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oCAAoC,CAAC;AACnD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,wCAAwC,CAAC;AACvD,cAAc,sCAAsC,CAAC;AACrD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oCAAoC,CAAC;AACnD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC"}
@@ -15,7 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./config/mongo.config"), exports);
18
- __exportStar(require("./databases/mongoose.repository"), exports);
19
18
  __exportStar(require("./decorators/request.decorators"), exports);
20
19
  __exportStar(require("./decorators/time-validation.decorator"), exports);
21
20
  __exportStar(require("./filters/unhandled-exception.filter"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,kEAAgD;AAChD,kEAAgD;AAChD,yEAAuD;AACvD,uEAAqD;AACrD,iDAA+B;AAC/B,qEAAmD;AACnD,iEAA+C;AAC/C,wDAAsC;AACtC,uDAAqC;AACrC,4DAA0C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,kEAAgD;AAChD,yEAAuD;AACvD,uEAAqD;AACrD,iDAA+B;AAC/B,qEAAmD;AACnD,iEAA+C;AAC/C,wDAAsC;AACtC,uDAAqC;AACrC,4DAA0C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@campxdev/server-shared",
3
- "version": "1.2.33",
3
+ "version": "1.2.34",
4
4
  "description": "Campx server shared files",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",
@@ -1,41 +0,0 @@
1
- /// <reference types="mongoose/types/aggregate" />
2
- /// <reference types="mongoose/types/callback" />
3
- /// <reference types="mongoose/types/collection" />
4
- /// <reference types="mongoose/types/connection" />
5
- /// <reference types="mongoose/types/cursor" />
6
- /// <reference types="mongoose/types/document" />
7
- /// <reference types="mongoose/types/error" />
8
- /// <reference types="mongoose/types/expressions" />
9
- /// <reference types="mongoose/types/helpers" />
10
- /// <reference types="mongoose/types/middlewares" />
11
- /// <reference types="mongoose/types/indexes" />
12
- /// <reference types="mongoose/types/models" />
13
- /// <reference types="mongoose/types/mongooseoptions" />
14
- /// <reference types="mongoose/types/pipelinestage" />
15
- /// <reference types="mongoose/types/populate" />
16
- /// <reference types="mongoose/types/query" />
17
- /// <reference types="mongoose/types/schemaoptions" />
18
- /// <reference types="mongoose/types/schematypes" />
19
- /// <reference types="mongoose/types/session" />
20
- /// <reference types="mongoose/types/types" />
21
- /// <reference types="mongoose/types/utility" />
22
- /// <reference types="mongoose/types/validation" />
23
- /// <reference types="mongoose/types/virtuals" />
24
- /// <reference types="mongoose/types/inferschematype" />
25
- import { AggregateOptions, Document, FilterQuery, Model, PipelineStage, ProjectionType, UpdateQuery } from 'mongoose';
26
- export declare abstract class MongooseRepository<T extends Document> {
27
- protected readonly schemaModel: Model<T>;
28
- constructor(schemaModel: Model<T>);
29
- instance(data: unknown): import("mongoose").IfAny<T, any, Document<unknown, {}, T> & import("mongoose").Require_id<T>>;
30
- save(entity: T): Promise<T>;
31
- create(createEntityData: unknown): Promise<T>;
32
- findOne(entityFilterQuery: FilterQuery<T>, projection?: Record<string, unknown>): Promise<import("mongoose").IfAny<T, any, Document<unknown, {}, T> & import("mongoose").Require_id<T>>>;
33
- findById(id: string, projection?: Record<string, unknown>): Promise<import("mongoose").IfAny<T, any, Document<unknown, {}, T> & import("mongoose").Require_id<T>>>;
34
- find(entityFilterQuery: FilterQuery<T>, projection?: ProjectionType<T>): import("mongoose").Query<import("mongoose").IfAny<T, any, Document<unknown, {}, T> & import("mongoose").Require_id<T>>[], import("mongoose").IfAny<T, any, Document<unknown, {}, T> & import("mongoose").Require_id<T>>, {}, T, "find">;
35
- countDocuments(entityFilterQuery: FilterQuery<T>): Promise<number>;
36
- findOneAndUpdate(entityFilterQuery: FilterQuery<T>, updateEntityData: UpdateQuery<unknown>): Promise<import("mongoose").IfAny<T, any, Document<unknown, {}, T> & import("mongoose").Require_id<T>>>;
37
- deleteMany(entityFilterQuery: FilterQuery<T>): Promise<boolean>;
38
- deleteById(id: string): Promise<import("mongoose").IfAny<T, any, Document<unknown, {}, T> & import("mongoose").Require_id<T>>>;
39
- aggregate(pipelines: PipelineStage[], options?: AggregateOptions): Promise<any[]>;
40
- }
41
- //# sourceMappingURL=mongoose.repository.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mongoose.repository.d.ts","sourceRoot":"","sources":["../../../src/common/databases/mongoose.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EACL,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,KAAK,EACL,aAAa,EACb,cAAc,EACd,WAAW,EACZ,MAAM,UAAU,CAAC;AAIlB,8BAAsB,kBAAkB,CAAC,CAAC,SAAS,QAAQ;IAC7C,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;gBAArB,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;IAEpD,QAAQ,CAAC,IAAI,EAAE,OAAO;IAIhB,IAAI,CAAC,MAAM,EAAE,CAAC;IAWd,MAAM,CAAC,gBAAgB,EAAE,OAAO;IAKhC,OAAO,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAW/E,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAW/D,IAAI,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC;IAOhE,cAAc,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC,CAAC;IAQhD,gBAAgB,CACpB,iBAAiB,EAAE,WAAW,CAAC,CAAC,CAAC,EACjC,gBAAgB,EAAE,WAAW,CAAC,OAAO,CAAC;IAYlC,UAAU,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAS/D,UAAU,CAAC,EAAE,EAAE,MAAM;IAQrB,SAAS,CAAC,SAAS,EAAE,aAAa,EAAE,EAAE,OAAO,CAAC,EAAE,gBAAgB;CAMvE"}
@@ -1,95 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MongooseRepository = void 0;
4
- const request_store_1 = require("../store/request-store");
5
- const utils_1 = require("../../utils");
6
- class MongooseRepository {
7
- schemaModel;
8
- constructor(schemaModel) {
9
- this.schemaModel = schemaModel;
10
- }
11
- instance(data) {
12
- return new this.schemaModel(data);
13
- }
14
- async save(entity) {
15
- entity.set('tenantId', (0, request_store_1.getTenantDetails)()._id);
16
- const res = await this.schemaModel.exists({ _id: entity._id });
17
- if (res) {
18
- entity.set('updatedBy', (0, request_store_1.getUserData)()?.userId);
19
- }
20
- else {
21
- entity.set('createdBy', (0, request_store_1.getUserData)()?.userId);
22
- }
23
- return entity.save();
24
- }
25
- async create(createEntityData) {
26
- const entity = new this.schemaModel(createEntityData);
27
- return this.save(entity);
28
- }
29
- async findOne(entityFilterQuery, projection) {
30
- return this.schemaModel
31
- .findOne(entityFilterQuery, {
32
- __v: 0,
33
- ...projection,
34
- })
35
- .where('tenantId')
36
- .equals((0, request_store_1.getTenantDetails)()._id)
37
- .exec();
38
- }
39
- async findById(id, projection) {
40
- return this.schemaModel
41
- .findById(id, {
42
- __v: 0,
43
- ...projection,
44
- })
45
- .where('tenantId')
46
- .equals((0, request_store_1.getTenantDetails)()._id)
47
- .exec();
48
- }
49
- find(entityFilterQuery, projection) {
50
- return this.schemaModel
51
- .find(entityFilterQuery, projection)
52
- .where('tenantId')
53
- .equals((0, request_store_1.getTenantDetails)()._id);
54
- }
55
- async countDocuments(entityFilterQuery) {
56
- return this.schemaModel
57
- .countDocuments(entityFilterQuery)
58
- .where('tenantId')
59
- .equals((0, request_store_1.getTenantDetails)()._id)
60
- .exec();
61
- }
62
- async findOneAndUpdate(entityFilterQuery, updateEntityData) {
63
- updateEntityData.set('updatedBy', (0, request_store_1.getUserData)()?.userId);
64
- return this.schemaModel
65
- .findOneAndUpdate(entityFilterQuery, updateEntityData, {
66
- new: true,
67
- })
68
- .where('tenantId')
69
- .equals((0, request_store_1.getTenantDetails)()._id)
70
- .exec();
71
- }
72
- async deleteMany(entityFilterQuery) {
73
- const deleteResult = await this.schemaModel
74
- .deleteMany(entityFilterQuery)
75
- .where('tenantId')
76
- .equals((0, request_store_1.getTenantDetails)()._id)
77
- .exec();
78
- return deleteResult.deletedCount >= 1;
79
- }
80
- async deleteById(id) {
81
- return this.schemaModel
82
- .findByIdAndDelete(id)
83
- .where('tenantId')
84
- .equals((0, request_store_1.getTenantDetails)()._id)
85
- .exec();
86
- }
87
- async aggregate(pipelines, options) {
88
- pipelines.unshift({
89
- $match: { tenantId: (0, utils_1.getObjectId)((0, request_store_1.getTenantDetails)()._id) },
90
- });
91
- return this.schemaModel.aggregate(pipelines, options).exec();
92
- }
93
- }
94
- exports.MongooseRepository = MongooseRepository;
95
- //# sourceMappingURL=mongoose.repository.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mongoose.repository.js","sourceRoot":"","sources":["../../../src/common/databases/mongoose.repository.ts"],"names":[],"mappings":";;;AASA,0DAAuE;AACvE,uCAA0C;AAE1C,MAAsB,kBAAkB;IACP;IAA/B,YAA+B,WAAqB;QAArB,gBAAW,GAAX,WAAW,CAAU;IAAG,CAAC;IAExD,QAAQ,CAAC,IAAa;QACpB,OAAO,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,MAAS;QAClB,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,IAAA,gCAAgB,GAAE,CAAC,GAAG,CAAC,CAAC;QAC/C,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;QAC/D,IAAI,GAAG,EAAE;YACP,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,IAAA,2BAAW,GAAE,EAAE,MAAM,CAAC,CAAC;SAChD;aAAM;YACL,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,IAAA,2BAAW,GAAE,EAAE,MAAM,CAAC,CAAC;SAChD;QACD,OAAO,MAAM,CAAC,IA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