@eventista/ticketing-common 1.0.2 → 1.0.4
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/package.json +6 -3
- package/dist/cluster/config/cluster.config.d.ts +0 -8
- package/dist/cluster/config/cluster.config.js +0 -8
- package/dist/cluster/config/cluster.config.js.map +0 -1
- package/dist/cluster/index.d.ts +0 -2
- package/dist/cluster/index.js +0 -19
- package/dist/cluster/index.js.map +0 -1
- package/dist/cluster/modules/cluster.module.d.ts +0 -2
- package/dist/cluster/modules/cluster.module.js +0 -22
- package/dist/cluster/modules/cluster.module.js.map +0 -1
- package/dist/cluster/services/cluster.service.d.ts +0 -7
- package/dist/cluster/services/cluster.service.js +0 -63
- package/dist/cluster/services/cluster.service.js.map +0 -1
- package/dist/database/index.d.ts +0 -2
- package/dist/database/index.js +0 -19
- package/dist/database/index.js.map +0 -1
- package/dist/database/mongodb/index.d.ts +0 -2
- package/dist/database/mongodb/index.js +0 -19
- package/dist/database/mongodb/index.js.map +0 -1
- package/dist/database/mongodb/mongodb.module.d.ts +0 -2
- package/dist/database/mongodb/mongodb.module.js +0 -50
- package/dist/database/mongodb/mongodb.module.js.map +0 -1
- package/dist/database/mongodb/mongodb.service.d.ts +0 -29
- package/dist/database/mongodb/mongodb.service.js +0 -114
- package/dist/database/mongodb/mongodb.service.js.map +0 -1
- package/dist/database/redis/index.d.ts +0 -2
- package/dist/database/redis/index.js +0 -19
- package/dist/database/redis/index.js.map +0 -1
- package/dist/database/redis/redis.module.d.ts +0 -2
- package/dist/database/redis/redis.module.js +0 -52
- package/dist/database/redis/redis.module.js.map +0 -1
- package/dist/database/redis/redis.service.d.ts +0 -26
- package/dist/database/redis/redis.service.js +0 -126
- package/dist/database/redis/redis.service.js.map +0 -1
- package/dist/exception/exception.filter.d.ts +0 -4
- package/dist/exception/exception.filter.js +0 -35
- package/dist/exception/exception.filter.js.map +0 -1
- package/dist/generic-repository/index.d.ts +0 -4
- package/dist/generic-repository/index.js +0 -21
- package/dist/generic-repository/index.js.map +0 -1
- package/dist/generic-repository/repositories/base.repository.d.ts +0 -39
- package/dist/generic-repository/repositories/base.repository.interface.d.ts +0 -36
- package/dist/generic-repository/repositories/base.repository.interface.js +0 -3
- package/dist/generic-repository/repositories/base.repository.interface.js.map +0 -1
- package/dist/generic-repository/repositories/base.repository.js +0 -96
- package/dist/generic-repository/repositories/base.repository.js.map +0 -1
- package/dist/generic-repository/services/base.service.d.ts +0 -42
- package/dist/generic-repository/services/base.service.interface.d.ts +0 -36
- package/dist/generic-repository/services/base.service.interface.js +0 -3
- package/dist/generic-repository/services/base.service.interface.js.map +0 -1
- package/dist/generic-repository/services/base.service.js +0 -57
- package/dist/generic-repository/services/base.service.js.map +0 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.js +0 -24
- package/dist/index.js.map +0 -1
- package/dist/logger/custom.logger.d.ts +0 -14
- package/dist/logger/custom.logger.js +0 -76
- package/dist/logger/custom.logger.js.map +0 -1
- package/dist/logger/index.d.ts +0 -2
- package/dist/logger/index.js +0 -19
- package/dist/logger/index.js.map +0 -1
- package/dist/logger/logger.module.d.ts +0 -2
- package/dist/logger/logger.module.js +0 -27
- package/dist/logger/logger.module.js.map +0 -1
- package/dist/pipes/custom-validation.pipe.d.ts +0 -7
- package/dist/pipes/custom-validation.pipe.js +0 -69
- package/dist/pipes/custom-validation.pipe.js.map +0 -1
- package/dist/response/response.interceptor.d.ts +0 -5
- package/dist/response/response.interceptor.js +0 -29
- package/dist/response/response.interceptor.js.map +0 -1
- package/dist/schemas/base.schema.d.ts +0 -11
- package/dist/schemas/base.schema.js +0 -29
- package/dist/schemas/base.schema.js.map +0 -1
- package/dist/schemas/event/event.interfaces.d.ts +0 -69
- package/dist/schemas/event/event.interfaces.js +0 -9
- package/dist/schemas/event/event.interfaces.js.map +0 -1
- package/dist/schemas/event/event.schema.d.ts +0 -70
- package/dist/schemas/event/event.schema.js +0 -242
- package/dist/schemas/event/event.schema.js.map +0 -1
- package/dist/schemas/index.d.ts +0 -14
- package/dist/schemas/index.js +0 -31
- package/dist/schemas/index.js.map +0 -1
- package/dist/schemas/order/order.interfaces.d.ts +0 -72
- package/dist/schemas/order/order.interfaces.js +0 -31
- package/dist/schemas/order/order.interfaces.js.map +0 -1
- package/dist/schemas/order/order.schema.d.ts +0 -39
- package/dist/schemas/order/order.schema.js +0 -162
- package/dist/schemas/order/order.schema.js.map +0 -1
- package/dist/schemas/promotions/promotions.interfaces.d.ts +0 -30
- package/dist/schemas/promotions/promotions.interfaces.js +0 -14
- package/dist/schemas/promotions/promotions.interfaces.js.map +0 -1
- package/dist/schemas/promotions/promotions.schema.d.ts +0 -25
- package/dist/schemas/promotions/promotions.schema.js +0 -92
- package/dist/schemas/promotions/promotions.schema.js.map +0 -1
- package/dist/schemas/rows/rows.interfaces.d.ts +0 -14
- package/dist/schemas/rows/rows.interfaces.js +0 -3
- package/dist/schemas/rows/rows.interfaces.js.map +0 -1
- package/dist/schemas/rows/rows.schema.d.ts +0 -22
- package/dist/schemas/rows/rows.schema.js +0 -65
- package/dist/schemas/rows/rows.schema.js.map +0 -1
- package/dist/schemas/schema.helper.d.ts +0 -4
- package/dist/schemas/schema.helper.js +0 -84
- package/dist/schemas/schema.helper.js.map +0 -1
- package/dist/schemas/ticket-classes/ticket-classes.interfaces.d.ts +0 -18
- package/dist/schemas/ticket-classes/ticket-classes.interfaces.js +0 -3
- package/dist/schemas/ticket-classes/ticket-classes.interfaces.js.map +0 -1
- package/dist/schemas/ticket-classes/ticket-classes.schemas.d.ts +0 -26
- package/dist/schemas/ticket-classes/ticket-classes.schemas.js +0 -75
- package/dist/schemas/ticket-classes/ticket-classes.schemas.js.map +0 -1
- package/dist/schemas/ticket-summary/ticket-summary.interfaces.d.ts +0 -19
- package/dist/schemas/ticket-summary/ticket-summary.interfaces.js +0 -9
- package/dist/schemas/ticket-summary/ticket-summary.interfaces.js.map +0 -1
- package/dist/schemas/ticket-summary/ticket-summary.schema.d.ts +0 -23
- package/dist/schemas/ticket-summary/ticket-summary.schema.js +0 -65
- package/dist/schemas/ticket-summary/ticket-summary.schema.js.map +0 -1
- package/dist/schemas/user-fanpass/user-fanpass.interfaces.d.ts +0 -26
- package/dist/schemas/user-fanpass/user-fanpass.interfaces.js +0 -9
- package/dist/schemas/user-fanpass/user-fanpass.interfaces.js.map +0 -1
- package/dist/schemas/user-fanpass/user-fanpass.schemas.d.ts +0 -29
- package/dist/schemas/user-fanpass/user-fanpass.schemas.js +0 -113
- package/dist/schemas/user-fanpass/user-fanpass.schemas.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/cluster/config/cluster.config.ts +0 -6
- package/src/cluster/index.ts +0 -2
- package/src/cluster/modules/cluster.module.ts +0 -9
- package/src/cluster/services/cluster.service.ts +0 -76
- package/src/database/index.ts +0 -2
- package/src/database/mongodb/index.ts +0 -2
- package/src/database/mongodb/mongodb.module.ts +0 -42
- package/src/database/mongodb/mongodb.service.ts +0 -111
- package/src/database/redis/index.ts +0 -2
- package/src/database/redis/redis.module.ts +0 -45
- package/src/database/redis/redis.service.ts +0 -142
- package/src/exception/exception.filter.ts +0 -36
- package/src/generic-repository/index.ts +0 -7
- package/src/generic-repository/repositories/base.repository.interface.ts +0 -78
- package/src/generic-repository/repositories/base.repository.ts +0 -199
- package/src/generic-repository/services/base.service.interface.ts +0 -78
- package/src/generic-repository/services/base.service.ts +0 -165
- package/src/index.ts +0 -11
- package/src/logger/custom.logger.ts +0 -83
- package/src/logger/index.ts +0 -2
- package/src/logger/logger.module.ts +0 -14
- package/src/pipes/custom-validation.pipe.ts +0 -61
- package/src/response/response.interceptor.ts +0 -26
- package/src/schemas/base.schema.ts +0 -19
- package/src/schemas/event/event.interfaces.ts +0 -74
- package/src/schemas/event/event.schema.ts +0 -195
- package/src/schemas/index.ts +0 -16
- package/src/schemas/order/order.interfaces.ts +0 -78
- package/src/schemas/order/order.schema.ts +0 -120
- package/src/schemas/promotions/promotions.interfaces.ts +0 -34
- package/src/schemas/promotions/promotions.schema.ts +0 -71
- package/src/schemas/rows/rows.interfaces.ts +0 -14
- package/src/schemas/rows/rows.schema.ts +0 -47
- package/src/schemas/schema.helper.ts +0 -103
- package/src/schemas/ticket-classes/ticket-classes.interfaces.ts +0 -18
- package/src/schemas/ticket-classes/ticket-classes.schemas.ts +0 -51
- package/src/schemas/ticket-summary/ticket-summary.interfaces.ts +0 -20
- package/src/schemas/ticket-summary/ticket-summary.schema.ts +0 -46
- package/src/schemas/user-fanpass/user-fanpass.interfaces.ts +0 -28
- package/src/schemas/user-fanpass/user-fanpass.schemas.ts +0 -86
- package/tsconfig.json +0 -17
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.RedisService = void 0;
|
|
16
|
-
const common_1 = require("@nestjs/common");
|
|
17
|
-
const ioredis_1 = require("ioredis");
|
|
18
|
-
let RedisService = class RedisService {
|
|
19
|
-
constructor(redis) {
|
|
20
|
-
this.redis = redis;
|
|
21
|
-
}
|
|
22
|
-
getClient() {
|
|
23
|
-
return this.redis;
|
|
24
|
-
}
|
|
25
|
-
async get(key) {
|
|
26
|
-
return this.redis.get(key);
|
|
27
|
-
}
|
|
28
|
-
async set(key, value, ttl) {
|
|
29
|
-
if (ttl) {
|
|
30
|
-
return this.redis.set(key, value, 'EX', ttl);
|
|
31
|
-
}
|
|
32
|
-
return this.redis.set(key, value);
|
|
33
|
-
}
|
|
34
|
-
async del(key) {
|
|
35
|
-
return this.redis.del(key);
|
|
36
|
-
}
|
|
37
|
-
async incr(key) {
|
|
38
|
-
return this.redis.incr(key);
|
|
39
|
-
}
|
|
40
|
-
async decr(key) {
|
|
41
|
-
return this.redis.decr(key);
|
|
42
|
-
}
|
|
43
|
-
async incrby(key, increment) {
|
|
44
|
-
return this.redis.incrby(key, increment);
|
|
45
|
-
}
|
|
46
|
-
async decrby(key, decrement) {
|
|
47
|
-
return this.redis.decrby(key, decrement);
|
|
48
|
-
}
|
|
49
|
-
async pipeline(commands) {
|
|
50
|
-
const pipeline = this.redis.pipeline();
|
|
51
|
-
for (const [command, ...args] of commands) {
|
|
52
|
-
pipeline[command](...args);
|
|
53
|
-
}
|
|
54
|
-
return pipeline.exec();
|
|
55
|
-
}
|
|
56
|
-
async executeScript(script, keys, args) {
|
|
57
|
-
const scriptHash = require('crypto').createHash('sha1').update(script).digest('hex');
|
|
58
|
-
try {
|
|
59
|
-
return await this.redis.evalsha(scriptHash, keys.length, ...keys, ...args);
|
|
60
|
-
}
|
|
61
|
-
catch (err) {
|
|
62
|
-
if (err.message.includes('NOSCRIPT')) {
|
|
63
|
-
return this.redis.eval(script, keys.length, ...keys, ...args);
|
|
64
|
-
}
|
|
65
|
-
throw err;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
async releaseLock(lockKey, value) {
|
|
69
|
-
const script = `
|
|
70
|
-
if redis.call("get", KEYS[1]) == ARGV[1] then
|
|
71
|
-
return redis.call("del", KEYS[1])
|
|
72
|
-
else
|
|
73
|
-
return 0
|
|
74
|
-
end
|
|
75
|
-
`;
|
|
76
|
-
const result = await this.redis.eval(script, 1, lockKey, value);
|
|
77
|
-
return result === 1;
|
|
78
|
-
}
|
|
79
|
-
async zadd(key, ...args) {
|
|
80
|
-
return this.redis.zadd(key, ...args);
|
|
81
|
-
}
|
|
82
|
-
async zrevrange(key, start, stop, withScores) {
|
|
83
|
-
if (withScores) {
|
|
84
|
-
return this.redis.zrevrange(key, start, stop, 'WITHSCORES');
|
|
85
|
-
}
|
|
86
|
-
return this.redis.zrevrange(key, start, stop);
|
|
87
|
-
}
|
|
88
|
-
async zrange(key, start, stop, withScores) {
|
|
89
|
-
if (withScores) {
|
|
90
|
-
return this.redis.zrange(key, start, stop, 'WITHSCORES');
|
|
91
|
-
}
|
|
92
|
-
return this.redis.zrange(key, start, stop);
|
|
93
|
-
}
|
|
94
|
-
async zrem(key, ...members) {
|
|
95
|
-
return this.redis.zrem(key, ...members);
|
|
96
|
-
}
|
|
97
|
-
async zscore(key, member) {
|
|
98
|
-
return this.redis.zscore(key, member);
|
|
99
|
-
}
|
|
100
|
-
async hmset(key, hash) {
|
|
101
|
-
return this.redis.hmset(key, hash);
|
|
102
|
-
}
|
|
103
|
-
async hgetall(key) {
|
|
104
|
-
return this.redis.hgetall(key);
|
|
105
|
-
}
|
|
106
|
-
async mget(...keys) {
|
|
107
|
-
try {
|
|
108
|
-
const client = this.getClient();
|
|
109
|
-
const values = await client.mget(keys);
|
|
110
|
-
return values;
|
|
111
|
-
}
|
|
112
|
-
catch (error) {
|
|
113
|
-
return Array(keys.length).fill(null);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
onModuleDestroy() {
|
|
117
|
-
this.redis.disconnect();
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
exports.RedisService = RedisService;
|
|
121
|
-
exports.RedisService = RedisService = __decorate([
|
|
122
|
-
(0, common_1.Injectable)(),
|
|
123
|
-
__param(0, (0, common_1.Inject)('REDIS_CLIENT')),
|
|
124
|
-
__metadata("design:paramtypes", [ioredis_1.Redis])
|
|
125
|
-
], RedisService);
|
|
126
|
-
//# sourceMappingURL=redis.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"redis.service.js","sourceRoot":"","sources":["../../../src/database/redis/redis.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAqE;AACrE,qCAAgC;AAGzB,IAAM,YAAY,GAAlB,MAAM,YAAY;IACvB,YAEmB,KAAY;QAAZ,UAAK,GAAL,KAAK,CAAO;IAC5B,CAAC;IAEJ,SAAS;QACP,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,GAAY;QAChD,IAAI,GAAG,EAAE,CAAC;YACR,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,GAAW;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,GAAW;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAW,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c;QACtC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;IAGD,KAAK,CAAC,KAAK,CAAC,GAAW,EAAE,IAA4B;QACnD,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAW;QACvB,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IAOD,KAAK,CAAC,IAAI,CAAC,GAAG,IAAc;QAC1B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;YAChC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACvC,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAEf,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED,eAAe;QACb,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;IAC1B,CAAC;CACF,CAAA;AAzIY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,eAAM,EAAC,cAAc,CAAC,CAAA;qCACC,eAAK;GAHpB,YAAY,CAyIxB"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.GlobalExceptionFilter = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
let GlobalExceptionFilter = class GlobalExceptionFilter {
|
|
12
|
-
catch(exception, host) {
|
|
13
|
-
const ctx = host.switchToHttp();
|
|
14
|
-
const response = ctx.getResponse();
|
|
15
|
-
const request = ctx.getRequest();
|
|
16
|
-
const status = exception instanceof common_1.HttpException
|
|
17
|
-
? exception.getStatus()
|
|
18
|
-
: common_1.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
19
|
-
const errorResponse = {
|
|
20
|
-
errorCode: exception instanceof common_1.HttpException
|
|
21
|
-
? exception.getResponse()['code']
|
|
22
|
-
: status,
|
|
23
|
-
message: exception.message || 'Internal Server Error',
|
|
24
|
-
data: exception instanceof common_1.HttpException ? exception.getResponse()['data'] : null,
|
|
25
|
-
path: request.url,
|
|
26
|
-
timestamp: new Date().toISOString(),
|
|
27
|
-
};
|
|
28
|
-
response.status(status).send(errorResponse);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
exports.GlobalExceptionFilter = GlobalExceptionFilter;
|
|
32
|
-
exports.GlobalExceptionFilter = GlobalExceptionFilter = __decorate([
|
|
33
|
-
(0, common_1.Catch)()
|
|
34
|
-
], GlobalExceptionFilter);
|
|
35
|
-
//# sourceMappingURL=exception.filter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exception.filter.js","sourceRoot":"","sources":["../../src/exception/exception.filter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAMwB;AAGjB,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAChC,KAAK,CAAC,SAAc,EAAE,IAAmB;QACvC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC;QAEjC,MAAM,MAAM,GACV,SAAS,YAAY,sBAAa;YAChC,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE;YACvB,CAAC,CAAC,mBAAU,CAAC,qBAAqB,CAAC;QAEvC,MAAM,aAAa,GAAG;YACpB,SAAS,EACP,SAAS,YAAY,sBAAa;gBAChC,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC;gBACjC,CAAC,CAAC,MAAM;YACZ,OAAO,EAAE,SAAS,CAAC,OAAO,IAAI,uBAAuB;YACrD,IAAI,EAAE,SAAS,YAAY,sBAAa,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI;YAEjF,IAAI,EAAE,OAAO,CAAC,GAAG;YACjB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC;QAGF,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC9C,CAAC;CACF,CAAA;AA1BY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,cAAK,GAAE;GACK,qBAAqB,CA0BjC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./repositories/base.repository.interface"), exports);
|
|
18
|
-
__exportStar(require("./repositories/base.repository"), exports);
|
|
19
|
-
__exportStar(require("./services/base.service.interface"), exports);
|
|
20
|
-
__exportStar(require("./services/base.service"), exports);
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generic-repository/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,2EAAyD;AACzD,iEAA+C;AAG/C,oEAAkD;AAClD,0DAAwC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Document, FilterQuery, Model, UpdateQuery, QueryOptions, PipelineStage } from 'mongoose';
|
|
2
|
-
import { IBaseRepository } from './base.repository.interface';
|
|
3
|
-
export declare class BaseRepository<T extends Document> implements IBaseRepository<T> {
|
|
4
|
-
protected readonly model: Model<T>;
|
|
5
|
-
constructor(model: Model<T>);
|
|
6
|
-
findOne(filterQuery: FilterQuery<T>, projection?: Record<string, unknown>, options?: QueryOptions): Promise<T | null>;
|
|
7
|
-
findOneOrFail(filterQuery: FilterQuery<T>, projection?: Record<string, unknown>, options?: QueryOptions): Promise<T>;
|
|
8
|
-
find(filterQuery: FilterQuery<T>, projection?: Record<string, unknown>, options?: QueryOptions): Promise<T[]>;
|
|
9
|
-
create(createDto: Partial<T>): Promise<T>;
|
|
10
|
-
createMany(createDtos: Partial<T>[]): Promise<T[]>;
|
|
11
|
-
findOneAndUpdate(filterQuery: FilterQuery<T>, updateQuery: UpdateQuery<T>, options?: QueryOptions): Promise<T | null>;
|
|
12
|
-
findOneAndUpdateOrFail(filterQuery: FilterQuery<T>, updateQuery: UpdateQuery<T>, options?: QueryOptions): Promise<T>;
|
|
13
|
-
updateMany(filterQuery: FilterQuery<T>, updateQuery: UpdateQuery<T>): Promise<{
|
|
14
|
-
matchedCount: number;
|
|
15
|
-
modifiedCount: number;
|
|
16
|
-
}>;
|
|
17
|
-
findOneAndDelete(filterQuery: FilterQuery<T>, options?: QueryOptions): Promise<T | null>;
|
|
18
|
-
findOneAndDeleteOrFail(filterQuery: FilterQuery<T>, options?: QueryOptions): Promise<T>;
|
|
19
|
-
deleteMany(filterQuery: FilterQuery<T>): Promise<{
|
|
20
|
-
deletedCount: number;
|
|
21
|
-
}>;
|
|
22
|
-
count(filterQuery: FilterQuery<T>): Promise<number>;
|
|
23
|
-
exists(filterQuery: FilterQuery<T>): Promise<boolean>;
|
|
24
|
-
aggregate(pipeline: PipelineStage[]): Promise<any[]>;
|
|
25
|
-
paginate(filterQuery: FilterQuery<T>, options?: {
|
|
26
|
-
page?: number;
|
|
27
|
-
limit?: number;
|
|
28
|
-
sort?: Record<string, 1 | -1>;
|
|
29
|
-
projection?: Record<string, unknown>;
|
|
30
|
-
}): Promise<{
|
|
31
|
-
data: T[];
|
|
32
|
-
pagination: {
|
|
33
|
-
total: number;
|
|
34
|
-
page: number;
|
|
35
|
-
limit: number;
|
|
36
|
-
pages: number;
|
|
37
|
-
};
|
|
38
|
-
}>;
|
|
39
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Document, FilterQuery, UpdateQuery, QueryOptions, PipelineStage } from 'mongoose';
|
|
2
|
-
export interface IBaseRepository<T extends Document> {
|
|
3
|
-
findOne(filterQuery: FilterQuery<T>, projection?: Record<string, unknown>, options?: QueryOptions): Promise<T | null>;
|
|
4
|
-
findOneOrFail(filterQuery: FilterQuery<T>, projection?: Record<string, unknown>, options?: QueryOptions): Promise<T>;
|
|
5
|
-
find(filterQuery: FilterQuery<T>, projection?: Record<string, unknown>, options?: QueryOptions): Promise<T[]>;
|
|
6
|
-
create(createDto: Partial<T>): Promise<T>;
|
|
7
|
-
createMany(createDtos: Partial<T>[]): Promise<T[]>;
|
|
8
|
-
findOneAndUpdate(filterQuery: FilterQuery<T>, updateQuery: UpdateQuery<T>, options?: QueryOptions): Promise<T | null>;
|
|
9
|
-
findOneAndUpdateOrFail(filterQuery: FilterQuery<T>, updateQuery: UpdateQuery<T>, options?: QueryOptions): Promise<T>;
|
|
10
|
-
updateMany(filterQuery: FilterQuery<T>, updateQuery: UpdateQuery<T>): Promise<{
|
|
11
|
-
matchedCount: number;
|
|
12
|
-
modifiedCount: number;
|
|
13
|
-
}>;
|
|
14
|
-
findOneAndDelete(filterQuery: FilterQuery<T>, options?: QueryOptions): Promise<T | null>;
|
|
15
|
-
findOneAndDeleteOrFail(filterQuery: FilterQuery<T>, options?: QueryOptions): Promise<T>;
|
|
16
|
-
deleteMany(filterQuery: FilterQuery<T>): Promise<{
|
|
17
|
-
deletedCount: number;
|
|
18
|
-
}>;
|
|
19
|
-
count(filterQuery: FilterQuery<T>): Promise<number>;
|
|
20
|
-
exists(filterQuery: FilterQuery<T>): Promise<boolean>;
|
|
21
|
-
aggregate(pipeline: PipelineStage[]): Promise<any[]>;
|
|
22
|
-
paginate(filterQuery: FilterQuery<T>, options?: {
|
|
23
|
-
page?: number;
|
|
24
|
-
limit?: number;
|
|
25
|
-
sort?: Record<string, 1 | -1>;
|
|
26
|
-
projection?: Record<string, unknown>;
|
|
27
|
-
}): Promise<{
|
|
28
|
-
data: T[];
|
|
29
|
-
pagination: {
|
|
30
|
-
total: number;
|
|
31
|
-
page: number;
|
|
32
|
-
limit: number;
|
|
33
|
-
pages: number;
|
|
34
|
-
};
|
|
35
|
-
}>;
|
|
36
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.repository.interface.js","sourceRoot":"","sources":["../../../src/generic-repository/repositories/base.repository.interface.ts"],"names":[],"mappings":""}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseRepository = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
class BaseRepository {
|
|
6
|
-
constructor(model) {
|
|
7
|
-
this.model = model;
|
|
8
|
-
}
|
|
9
|
-
async findOne(filterQuery, projection, options) {
|
|
10
|
-
return this.model.findOne(filterQuery, projection, options).exec();
|
|
11
|
-
}
|
|
12
|
-
async findOneOrFail(filterQuery, projection, options) {
|
|
13
|
-
const document = await this.findOne(filterQuery, projection, options);
|
|
14
|
-
if (!document) {
|
|
15
|
-
throw new common_1.NotFoundException(`${this.model.modelName} not found`);
|
|
16
|
-
}
|
|
17
|
-
return document;
|
|
18
|
-
}
|
|
19
|
-
async find(filterQuery, projection, options) {
|
|
20
|
-
return this.model.find(filterQuery, projection, options).exec();
|
|
21
|
-
}
|
|
22
|
-
async create(createDto) {
|
|
23
|
-
const newDocument = new this.model(createDto);
|
|
24
|
-
return newDocument.save();
|
|
25
|
-
}
|
|
26
|
-
async createMany(createDtos) {
|
|
27
|
-
const result = await this.model.insertMany(createDtos);
|
|
28
|
-
return result;
|
|
29
|
-
}
|
|
30
|
-
async findOneAndUpdate(filterQuery, updateQuery, options = { new: true }) {
|
|
31
|
-
return this.model.findOneAndUpdate(filterQuery, updateQuery, options).exec();
|
|
32
|
-
}
|
|
33
|
-
async findOneAndUpdateOrFail(filterQuery, updateQuery, options = { new: true }) {
|
|
34
|
-
const document = await this.findOneAndUpdate(filterQuery, updateQuery, options);
|
|
35
|
-
if (!document) {
|
|
36
|
-
throw new common_1.NotFoundException(`${this.model.modelName} not found`);
|
|
37
|
-
}
|
|
38
|
-
return document;
|
|
39
|
-
}
|
|
40
|
-
async updateMany(filterQuery, updateQuery) {
|
|
41
|
-
const result = await this.model.updateMany(filterQuery, updateQuery).exec();
|
|
42
|
-
return {
|
|
43
|
-
matchedCount: result.matchedCount,
|
|
44
|
-
modifiedCount: result.modifiedCount,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
async findOneAndDelete(filterQuery, options) {
|
|
48
|
-
return this.model.findOneAndDelete(filterQuery, options).exec();
|
|
49
|
-
}
|
|
50
|
-
async findOneAndDeleteOrFail(filterQuery, options) {
|
|
51
|
-
const document = await this.findOneAndDelete(filterQuery, options);
|
|
52
|
-
if (!document) {
|
|
53
|
-
throw new common_1.NotFoundException(`${this.model.modelName} not found`);
|
|
54
|
-
}
|
|
55
|
-
return document;
|
|
56
|
-
}
|
|
57
|
-
async deleteMany(filterQuery) {
|
|
58
|
-
const result = await this.model.deleteMany(filterQuery).exec();
|
|
59
|
-
return { deletedCount: result.deletedCount || 0 };
|
|
60
|
-
}
|
|
61
|
-
async count(filterQuery) {
|
|
62
|
-
return this.model.countDocuments(filterQuery).exec();
|
|
63
|
-
}
|
|
64
|
-
async exists(filterQuery) {
|
|
65
|
-
const count = await this.count(filterQuery);
|
|
66
|
-
return count > 0;
|
|
67
|
-
}
|
|
68
|
-
async aggregate(pipeline) {
|
|
69
|
-
return this.model.aggregate(pipeline).exec();
|
|
70
|
-
}
|
|
71
|
-
async paginate(filterQuery, options = {}) {
|
|
72
|
-
const page = options.page || 1;
|
|
73
|
-
const limit = options.limit || 10;
|
|
74
|
-
const skip = (page - 1) * limit;
|
|
75
|
-
const [data, total] = await Promise.all([
|
|
76
|
-
this.model
|
|
77
|
-
.find(filterQuery, options.projection)
|
|
78
|
-
.sort(options.sort)
|
|
79
|
-
.skip(skip)
|
|
80
|
-
.limit(limit)
|
|
81
|
-
.exec(),
|
|
82
|
-
this.count(filterQuery),
|
|
83
|
-
]);
|
|
84
|
-
return {
|
|
85
|
-
data,
|
|
86
|
-
pagination: {
|
|
87
|
-
total,
|
|
88
|
-
page,
|
|
89
|
-
limit,
|
|
90
|
-
pages: Math.ceil(total / limit),
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
exports.BaseRepository = BaseRepository;
|
|
96
|
-
//# sourceMappingURL=base.repository.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.repository.js","sourceRoot":"","sources":["../../../src/generic-repository/repositories/base.repository.ts"],"names":[],"mappings":";;;AACA,2CAAmD;AAGnD,MAAa,cAAc;IACzB,YAA+B,KAAe;QAAf,UAAK,GAAL,KAAK,CAAU;IAAG,CAAC;IAKlD,KAAK,CAAC,OAAO,CACX,WAA2B,EAC3B,UAAoC,EACpC,OAAsB;QAEtB,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;IACrE,CAAC;IAKD,KAAK,CAAC,aAAa,CACjB,WAA2B,EAC3B,UAAoC,EACpC,OAAsB;QAEtB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QACtE,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,0BAAiB,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,YAAY,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAKD,KAAK,CAAC,IAAI,CACR,WAA2B,EAC3B,UAAoC,EACpC,OAAsB;QAEtB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;IAClE,CAAC;IAKD,KAAK,CAAC,MAAM,CAAC,SAAqB;QAChC,MAAM,WAAW,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAC9C,OAAO,WAAW,CAAC,IAAI,EAAE,CAAC;IAC5B,CAAC;IAKD,KAAK,CAAC,UAAU,CAAC,UAAwB;QACvC,MAAM,MAA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iBACP,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,UAAU,CAAC;iBACrC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;iBAClB,IAAI,CAAC,IAAI,CAAC;iBACV,KAAK,CAAC,KAAK,CAAC;iBACZ,IAAI,EAAE;YACT,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;SACxB,CAAC,CAAC;QAEH,OAAO;YACL,IAAI;YACJ,UAAU,EAAE;gBACV,KAAK;gBACL,IAAI;gBACJ,KAAK;gBACL,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;aAChC;SACF,CAAC;IACJ,CAAC;CACF;AAlMD,wCAkMC"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Document, FilterQuery, UpdateQuery, QueryOptions, PipelineStage } from 'mongoose';
|
|
2
|
-
import { IBaseRepository } from '../repositories/base.repository.interface';
|
|
3
|
-
import { Logger } from '@nestjs/common';
|
|
4
|
-
import { IBaseService } from './base.service.interface';
|
|
5
|
-
export declare class BaseService<T extends Document> implements IBaseService<T> {
|
|
6
|
-
protected readonly repository: IBaseRepository<T>;
|
|
7
|
-
protected readonly logger: Logger;
|
|
8
|
-
constructor(repository: IBaseRepository<T>, context?: string);
|
|
9
|
-
findOne(filterQuery: FilterQuery<T>, projection?: Record<string, unknown>, options?: QueryOptions): Promise<T | null>;
|
|
10
|
-
findOneOrFail(filterQuery: FilterQuery<T>, projection?: Record<string, unknown>, options?: QueryOptions): Promise<T>;
|
|
11
|
-
find(filterQuery: FilterQuery<T>, projection?: Record<string, unknown>, options?: QueryOptions): Promise<T[]>;
|
|
12
|
-
create(createDto: Partial<T>): Promise<T>;
|
|
13
|
-
createMany(createDtos: Partial<T>[]): Promise<T[]>;
|
|
14
|
-
update(filterQuery: FilterQuery<T>, updateQuery: UpdateQuery<T>, options?: QueryOptions): Promise<T | null>;
|
|
15
|
-
updateOrFail(filterQuery: FilterQuery<T>, updateQuery: UpdateQuery<T>, options?: QueryOptions): Promise<T>;
|
|
16
|
-
updateMany(filterQuery: FilterQuery<T>, updateQuery: UpdateQuery<T>): Promise<{
|
|
17
|
-
matchedCount: number;
|
|
18
|
-
modifiedCount: number;
|
|
19
|
-
}>;
|
|
20
|
-
delete(filterQuery: FilterQuery<T>, options?: QueryOptions): Promise<T | null>;
|
|
21
|
-
deleteOrFail(filterQuery: FilterQuery<T>, options?: QueryOptions): Promise<T>;
|
|
22
|
-
deleteMany(filterQuery: FilterQuery<T>): Promise<{
|
|
23
|
-
deletedCount: number;
|
|
24
|
-
}>;
|
|
25
|
-
count(filterQuery: FilterQuery<T>): Promise<number>;
|
|
26
|
-
exists(filterQuery: FilterQuery<T>): Promise<boolean>;
|
|
27
|
-
aggregate(pipeline: PipelineStage[]): Promise<any[]>;
|
|
28
|
-
paginate(filterQuery: FilterQuery<T>, options?: {
|
|
29
|
-
page?: number;
|
|
30
|
-
limit?: number;
|
|
31
|
-
sort?: Record<string, 1 | -1>;
|
|
32
|
-
projection?: Record<string, unknown>;
|
|
33
|
-
}): Promise<{
|
|
34
|
-
data: T[];
|
|
35
|
-
pagination: {
|
|
36
|
-
total: number;
|
|
37
|
-
page: number;
|
|
38
|
-
limit: number;
|
|
39
|
-
pages: number;
|
|
40
|
-
};
|
|
41
|
-
}>;
|
|
42
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Document, FilterQuery, UpdateQuery, QueryOptions, PipelineStage } from 'mongoose';
|
|
2
|
-
export interface IBaseService<T extends Document> {
|
|
3
|
-
findOne(filterQuery: FilterQuery<T>, projection?: Record<string, unknown>, options?: QueryOptions): Promise<T | null>;
|
|
4
|
-
findOneOrFail(filterQuery: FilterQuery<T>, projection?: Record<string, unknown>, options?: QueryOptions): Promise<T>;
|
|
5
|
-
find(filterQuery: FilterQuery<T>, projection?: Record<string, unknown>, options?: QueryOptions): Promise<T[]>;
|
|
6
|
-
create(createDto: Partial<T>): Promise<T>;
|
|
7
|
-
createMany(createDtos: Partial<T>[]): Promise<T[]>;
|
|
8
|
-
update(filterQuery: FilterQuery<T>, updateQuery: UpdateQuery<T>, options?: QueryOptions): Promise<T | null>;
|
|
9
|
-
updateOrFail(filterQuery: FilterQuery<T>, updateQuery: UpdateQuery<T>, options?: QueryOptions): Promise<T>;
|
|
10
|
-
updateMany(filterQuery: FilterQuery<T>, updateQuery: UpdateQuery<T>): Promise<{
|
|
11
|
-
matchedCount: number;
|
|
12
|
-
modifiedCount: number;
|
|
13
|
-
}>;
|
|
14
|
-
delete(filterQuery: FilterQuery<T>, options?: QueryOptions): Promise<T | null>;
|
|
15
|
-
deleteOrFail(filterQuery: FilterQuery<T>, options?: QueryOptions): Promise<T>;
|
|
16
|
-
deleteMany(filterQuery: FilterQuery<T>): Promise<{
|
|
17
|
-
deletedCount: number;
|
|
18
|
-
}>;
|
|
19
|
-
count(filterQuery: FilterQuery<T>): Promise<number>;
|
|
20
|
-
exists(filterQuery: FilterQuery<T>): Promise<boolean>;
|
|
21
|
-
aggregate(pipeline: PipelineStage[]): Promise<any[]>;
|
|
22
|
-
paginate(filterQuery: FilterQuery<T>, options?: {
|
|
23
|
-
page?: number;
|
|
24
|
-
limit?: number;
|
|
25
|
-
sort?: Record<string, 1 | -1>;
|
|
26
|
-
projection?: Record<string, unknown>;
|
|
27
|
-
}): Promise<{
|
|
28
|
-
data: T[];
|
|
29
|
-
pagination: {
|
|
30
|
-
total: number;
|
|
31
|
-
page: number;
|
|
32
|
-
limit: number;
|
|
33
|
-
pages: number;
|
|
34
|
-
};
|
|
35
|
-
}>;
|
|
36
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.service.interface.js","sourceRoot":"","sources":["../../../src/generic-repository/services/base.service.interface.ts"],"names":[],"mappings":""}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseService = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
class BaseService {
|
|
6
|
-
constructor(repository, context) {
|
|
7
|
-
this.repository = repository;
|
|
8
|
-
this.logger = new common_1.Logger(context || this.constructor.name);
|
|
9
|
-
}
|
|
10
|
-
async findOne(filterQuery, projection, options) {
|
|
11
|
-
return this.repository.findOne(filterQuery, projection, options);
|
|
12
|
-
}
|
|
13
|
-
async findOneOrFail(filterQuery, projection, options) {
|
|
14
|
-
return this.repository.findOneOrFail(filterQuery, projection, options);
|
|
15
|
-
}
|
|
16
|
-
async find(filterQuery, projection, options) {
|
|
17
|
-
return this.repository.find(filterQuery, projection, options);
|
|
18
|
-
}
|
|
19
|
-
async create(createDto) {
|
|
20
|
-
return this.repository.create(createDto);
|
|
21
|
-
}
|
|
22
|
-
async createMany(createDtos) {
|
|
23
|
-
return this.repository.createMany(createDtos);
|
|
24
|
-
}
|
|
25
|
-
async update(filterQuery, updateQuery, options = { new: true }) {
|
|
26
|
-
return this.repository.findOneAndUpdate(filterQuery, updateQuery, options);
|
|
27
|
-
}
|
|
28
|
-
async updateOrFail(filterQuery, updateQuery, options = { new: true }) {
|
|
29
|
-
return this.repository.findOneAndUpdateOrFail(filterQuery, updateQuery, options);
|
|
30
|
-
}
|
|
31
|
-
async updateMany(filterQuery, updateQuery) {
|
|
32
|
-
return this.repository.updateMany(filterQuery, updateQuery);
|
|
33
|
-
}
|
|
34
|
-
async delete(filterQuery, options) {
|
|
35
|
-
return this.repository.findOneAndDelete(filterQuery, options);
|
|
36
|
-
}
|
|
37
|
-
async deleteOrFail(filterQuery, options) {
|
|
38
|
-
return this.repository.findOneAndDeleteOrFail(filterQuery, options);
|
|
39
|
-
}
|
|
40
|
-
async deleteMany(filterQuery) {
|
|
41
|
-
return this.repository.deleteMany(filterQuery);
|
|
42
|
-
}
|
|
43
|
-
async count(filterQuery) {
|
|
44
|
-
return this.repository.count(filterQuery);
|
|
45
|
-
}
|
|
46
|
-
async exists(filterQuery) {
|
|
47
|
-
return this.repository.exists(filterQuery);
|
|
48
|
-
}
|
|
49
|
-
async aggregate(pipeline) {
|
|
50
|
-
return this.repository.aggregate(pipeline);
|
|
51
|
-
}
|
|
52
|
-
async paginate(filterQuery, options = {}) {
|
|
53
|
-
return this.repository.paginate(filterQuery, options);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
exports.BaseService = BaseService;
|
|
57
|
-
//# sourceMappingURL=base.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.service.js","sourceRoot":"","sources":["../../../src/generic-repository/services/base.service.ts"],"names":[],"mappings":";;;AAEA,2CAAwC;AAGxC,MAAa,WAAW;IAGtB,YACqB,UAA8B,EACjD,OAAgB;QADG,eAAU,GAAV,UAAU,CAAoB;QAGjD,IAAI,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC,OAAO,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC7D,CAAC;IAKD,KAAK,CAAC,OAAO,CACX,WAA2B,EAC3B,UAAoC,EACpC,OAAsB;QAEtB,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC;IAKD,KAAK,CAAC,aAAa,CACjB,WAA2B,EAC3B,UAAoC,EACpC,OAAsB;QAEtB,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;IAKD,KAAK,CAAC,IAAI,CACR,WAA2B,EAC3B,UAAoC,EACpC,OAAsB;QAEtB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;IAKD,KAAK,CAAC,MAAM,CAAC,SAAqB;QAChC,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC3C,CAAC;IAKD,KAAK,CAAC,U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CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC7C,CAAC;IAKD,KAAK,CAAC,SAAS,CAAC,QAAyB;QACvC,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAKD,KAAK,CAAC,QAAQ,CACZ,WAA2B,EAC3B,UAKI,EAAE;QAUN,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;CACF;AA/JD,kCA+JC"}
|
package/dist/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from './database';
|
|
2
|
-
export * from './exception/exception.filter';
|
|
3
|
-
export * from './generic-repository';
|
|
4
|
-
export * from './logger';
|
|
5
|
-
export * from './pipes/custom-validation.pipe';
|
|
6
|
-
export * from './response/response.interceptor';
|
|
7
|
-
export * from './schemas';
|
package/dist/index.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./database"), exports);
|
|
18
|
-
__exportStar(require("./exception/exception.filter"), exports);
|
|
19
|
-
__exportStar(require("./generic-repository"), exports);
|
|
20
|
-
__exportStar(require("./logger"), exports);
|
|
21
|
-
__exportStar(require("./pipes/custom-validation.pipe"), exports);
|
|
22
|
-
__exportStar(require("./response/response.interceptor"), exports);
|
|
23
|
-
__exportStar(require("./schemas"), exports);
|
|
24
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,6CAA2B;AAC3B,+DAA6C;AAC7C,uDAAqC;AAErC,2CAAyB;AAEzB,iEAA+C;AAC/C,kEAA+C;AAE/C,4CAA0B"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { LoggerService } from '@nestjs/common';
|
|
2
|
-
export declare class CustomLogger implements LoggerService {
|
|
3
|
-
private readonly context?;
|
|
4
|
-
private readonly isProduction;
|
|
5
|
-
constructor(context?: string);
|
|
6
|
-
private getTimestamp;
|
|
7
|
-
private formatMessage;
|
|
8
|
-
private colorize;
|
|
9
|
-
log(message: string, context?: string): void;
|
|
10
|
-
error(message: string, metadata?: any): void;
|
|
11
|
-
warn(message: string, context?: string): void;
|
|
12
|
-
debug(message: string, context?: string): void;
|
|
13
|
-
verbose(message: string, context?: string): void;
|
|
14
|
-
}
|