fiscalia_bo-nest-helpers 0.0.5 → 0.0.6
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/README.md +38 -0
- package/dist/app.controller.d.ts +12 -0
- package/dist/app.controller.js +63 -0
- package/dist/app.controller.js.map +1 -0
- package/dist/app.module.d.ts +2 -0
- package/dist/app.module.js +34 -0
- package/dist/app.module.js.map +1 -0
- package/dist/app.service.d.ts +6 -0
- package/dist/app.service.js +28 -0
- package/dist/app.service.js.map +1 -0
- package/dist/configurations/configuration.d.ts +6 -0
- package/dist/configurations/configuration.js +9 -0
- package/dist/configurations/configuration.js.map +1 -0
- package/dist/helpers/global-exception.filter.d.ts +13 -0
- package/dist/helpers/global-exception.filter.js +68 -0
- package/dist/helpers/global-exception.filter.js.map +1 -0
- package/dist/helpers/package-json.helper.d.ts +1 -0
- package/dist/helpers/package-json.helper.js +8 -0
- package/dist/helpers/package-json.helper.js.map +1 -0
- package/dist/helpers/request.helper.js.map +1 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +1 -0
- package/dist/main.js +42 -0
- package/dist/main.js.map +1 -0
- package/dist/ms-redis/datapass.interceptor.d.ts +11 -0
- package/dist/ms-redis/datapass.interceptor.js +158 -0
- package/dist/ms-redis/datapass.interceptor.js.map +1 -0
- package/dist/ms-redis/dto/cache.dto.d.ts +12 -0
- package/dist/ms-redis/dto/cache.dto.js +87 -0
- package/dist/ms-redis/dto/cache.dto.js.map +1 -0
- package/dist/ms-redis/dto/cache.options.dto.d.ts +6 -0
- package/dist/ms-redis/dto/cache.options.dto.js +7 -0
- package/dist/ms-redis/dto/cache.options.dto.js.map +1 -0
- package/dist/ms-redis/ms-redis.module.d.ts +11 -0
- package/dist/ms-redis/ms-redis.module.js +71 -0
- package/dist/ms-redis/ms-redis.module.js.map +1 -0
- package/dist/ms-redis/ms-redis.service.d.ts +14 -0
- package/dist/ms-redis/ms-redis.service.js +74 -0
- package/dist/ms-redis/ms-redis.service.js.map +1 -0
- package/dist/ms-redis/request.proto +18 -0
- package/dist/ms-seguridad/Seguridad.pb.d.ts +57 -0
- package/dist/ms-seguridad/Seguridad.pb.js +23 -0
- package/dist/ms-seguridad/Seguridad.pb.js.map +1 -0
- package/dist/ms-seguridad/Seguridad.proto +60 -0
- package/dist/ms-seguridad/ms-seguridad.decorator.d.ts +11 -0
- package/dist/ms-seguridad/ms-seguridad.decorator.js +36 -0
- package/dist/ms-seguridad/ms-seguridad.decorator.js.map +1 -0
- package/dist/ms-seguridad/ms-seguridad.module.d.ts +13 -0
- package/dist/ms-seguridad/ms-seguridad.module.js +80 -0
- package/dist/ms-seguridad/ms-seguridad.module.js.map +1 -0
- package/dist/ms-seguridad/ms-seguridad.service.d.ts +15 -0
- package/dist/ms-seguridad/ms-seguridad.service.js +58 -0
- package/dist/ms-seguridad/ms-seguridad.service.js.map +1 -0
- package/dist/ms-seguridad/permision.guard.d.ts +13 -0
- package/dist/ms-seguridad/permision.guard.js +51 -0
- package/dist/ms-seguridad/permision.guard.js.map +1 -0
- package/dist/ms-seguridad/token-auth.guard.d.ts +7 -0
- package/dist/ms-seguridad/token-auth.guard.js +42 -0
- package/dist/ms-seguridad/token-auth.guard.js.map +1 -0
- package/dist/{src/services → services}/ms-files.service.js +1 -2
- package/dist/services/ms-files.service.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/index.js.map +1 -0
- package/dist/{src/types → types}/input.type.js.map +1 -1
- package/dist/types/response.type.js.map +1 -0
- package/package.json +31 -7
- package/dist/src/helpers/request.helper.js.map +0 -1
- package/dist/src/services/ms-files.service.js.map +0 -1
- package/dist/src/types/index.js.map +0 -1
- package/dist/src/types/response.type.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- /package/dist/{src/helpers → helpers}/request.helper.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/request.helper.js +0 -0
- /package/dist/{src/services → services}/ms-files.service.d.ts +0 -0
- /package/dist/{src/types → types}/index.d.ts +0 -0
- /package/dist/{src/types → types}/index.js +0 -0
- /package/dist/{src/types → types}/input.type.d.ts +0 -0
- /package/dist/{src/types → types}/input.type.js +0 -0
- /package/dist/{src/types → types}/response.type.d.ts +0 -0
- /package/dist/{src/types → types}/response.type.js +0 -0
@@ -0,0 +1,87 @@
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.parametersControllerCacheDTO = exports.parametersClientCacheDTO = void 0;
|
13
|
+
const class_transformer_1 = require("class-transformer");
|
14
|
+
const class_validator_1 = require("class-validator");
|
15
|
+
class parametersClientCacheDTO {
|
16
|
+
constructor() {
|
17
|
+
this['noCache'] = false;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
__decorate([
|
21
|
+
(0, class_transformer_1.Type)(() => String),
|
22
|
+
(0, class_validator_1.IsString)(),
|
23
|
+
(0, class_transformer_1.Transform)(({ value }) => {
|
24
|
+
return value === 'true' ? true : false;
|
25
|
+
}),
|
26
|
+
__metadata("design:type", Object)
|
27
|
+
], parametersClientCacheDTO.prototype, "noCache", void 0);
|
28
|
+
__decorate([
|
29
|
+
(0, class_transformer_1.Type)(() => Number),
|
30
|
+
(0, class_validator_1.IsNumber)(),
|
31
|
+
(0, class_transformer_1.Transform)(({ value }) => {
|
32
|
+
let setValue = 0;
|
33
|
+
if (!isNaN(parseFloat(value)) && isFinite(value)) {
|
34
|
+
setValue = parseInt(value);
|
35
|
+
}
|
36
|
+
return setValue;
|
37
|
+
}),
|
38
|
+
__metadata("design:type", Number)
|
39
|
+
], parametersClientCacheDTO.prototype, "ttl", void 0);
|
40
|
+
exports.parametersClientCacheDTO = parametersClientCacheDTO;
|
41
|
+
class parametersControllerCacheDTO {
|
42
|
+
constructor() {
|
43
|
+
this['useKeyUrl'] = false;
|
44
|
+
this['ignoreExceptions'] = false;
|
45
|
+
this.responseHttp = true;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
__decorate([
|
49
|
+
(0, class_validator_1.ValidateIf)((o) => !o.useKeyUrl),
|
50
|
+
(0, class_validator_1.IsDefined)({ message: 'key o useKeyUrl es obligatorio' }),
|
51
|
+
(0, class_transformer_1.Type)(() => String),
|
52
|
+
(0, class_validator_1.IsString)(),
|
53
|
+
__metadata("design:type", String)
|
54
|
+
], parametersControllerCacheDTO.prototype, "key", void 0);
|
55
|
+
__decorate([
|
56
|
+
(0, class_validator_1.IsDefined)({ message: 'TTL es obligatorio' }),
|
57
|
+
(0, class_transformer_1.Type)(() => Number),
|
58
|
+
(0, class_validator_1.IsNumber)(),
|
59
|
+
__metadata("design:type", Number)
|
60
|
+
], parametersControllerCacheDTO.prototype, "ttl", void 0);
|
61
|
+
__decorate([
|
62
|
+
(0, class_validator_1.IsOptional)(),
|
63
|
+
(0, class_transformer_1.Type)(() => String),
|
64
|
+
(0, class_validator_1.IsString)(),
|
65
|
+
__metadata("design:type", String)
|
66
|
+
], parametersControllerCacheDTO.prototype, "keyResponse", void 0);
|
67
|
+
__decorate([
|
68
|
+
(0, class_validator_1.ValidateIf)((o) => !o.key),
|
69
|
+
(0, class_validator_1.IsDefined)({ message: 'key o useKeyUrl es obligatorio' }),
|
70
|
+
(0, class_transformer_1.Type)(() => Boolean),
|
71
|
+
(0, class_validator_1.IsBoolean)(),
|
72
|
+
__metadata("design:type", Object)
|
73
|
+
], parametersControllerCacheDTO.prototype, "useKeyUrl", void 0);
|
74
|
+
__decorate([
|
75
|
+
(0, class_validator_1.IsOptional)(),
|
76
|
+
(0, class_transformer_1.Type)(() => Boolean),
|
77
|
+
(0, class_validator_1.IsBoolean)(),
|
78
|
+
__metadata("design:type", Object)
|
79
|
+
], parametersControllerCacheDTO.prototype, "ignoreExceptions", void 0);
|
80
|
+
__decorate([
|
81
|
+
(0, class_validator_1.IsOptional)(),
|
82
|
+
(0, class_transformer_1.Type)(() => Boolean),
|
83
|
+
(0, class_validator_1.IsBoolean)(),
|
84
|
+
__metadata("design:type", Object)
|
85
|
+
], parametersControllerCacheDTO.prototype, "responseHttp", void 0);
|
86
|
+
exports.parametersControllerCacheDTO = parametersControllerCacheDTO;
|
87
|
+
//# sourceMappingURL=cache.dto.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"cache.dto.js","sourceRoot":"","sources":["../../../src/ms-redis/dto/cache.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAoD;AACpD,qDAAmG;AAEnG,MAAa,wBAAwB;IAArC;QAME,eAAS,GAAG,KAAK,CAAC;IAapB,CAAC;CAAA;AAlBC;IAAC,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,0BAAQ,GAAE;IACV,IAAA,6BAAS,EAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;QACvB,OAAO,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IACzC,CAAC,CAAC;;yDACgB;AAElB;IAAC,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,0BAAQ,GAAE;IACV,IAAA,6BAAS,EAAC,CAAC,EA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E;IACZ,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,OAAO,CAAC;IACnB,IAAA,2BAAS,GAAE;;sEACe;AAE3B;IAAC,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,OAAO,CAAC;IACnB,IAAA,2BAAS,GAAE;;kEACQ;AApCtB,oEAqCC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"cache.options.dto.js","sourceRoot":"","sources":["../../../src/ms-redis/dto/cache.options.dto.ts"],"names":[],"mappings":";;;AAAA,MAAa,eAAe;CAK3B;AALD,0CAKC"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
2
|
+
import { ClientProxy } from '@nestjs/microservices';
|
3
|
+
interface RedisModuleOptions {
|
4
|
+
urlRedisCache: string | undefined;
|
5
|
+
}
|
6
|
+
export declare class MsRedisModule {
|
7
|
+
static client: ClientProxy;
|
8
|
+
static register(options: RedisModuleOptions): DynamicModule;
|
9
|
+
static registerAsync(options: RedisModuleOptions): Promise<DynamicModule>;
|
10
|
+
}
|
11
|
+
export {};
|
@@ -0,0 +1,71 @@
|
|
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 MsRedisModule_1;
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
10
|
+
exports.MsRedisModule = void 0;
|
11
|
+
const common_1 = require("@nestjs/common");
|
12
|
+
const microservices_1 = require("@nestjs/microservices");
|
13
|
+
const path_1 = require("path");
|
14
|
+
const ms_redis_service_1 = require("./ms-redis.service");
|
15
|
+
const datapass_interceptor_1 = require("./datapass.interceptor");
|
16
|
+
const chalk_1 = require("chalk");
|
17
|
+
let MsRedisModule = MsRedisModule_1 = class MsRedisModule {
|
18
|
+
static register(options) {
|
19
|
+
const url = process.env.ENV_GRPC_MS_REDIS_CACHE || (options && options.urlRedisCache);
|
20
|
+
if (!url)
|
21
|
+
console.warn(chalk_1.bold.red(`ENV_GRPC_MS_REDIS_CACHE no definido en variables de entorno`));
|
22
|
+
this.client = microservices_1.ClientProxyFactory.create({
|
23
|
+
transport: microservices_1.Transport.GRPC,
|
24
|
+
options: {
|
25
|
+
url: url.trim(),
|
26
|
+
package: 'request',
|
27
|
+
protoPath: (0, path_1.join)(__dirname, './request.proto'),
|
28
|
+
loader: { keepCase: true },
|
29
|
+
},
|
30
|
+
});
|
31
|
+
return {
|
32
|
+
module: MsRedisModule_1,
|
33
|
+
imports: [],
|
34
|
+
providers: [
|
35
|
+
{ provide: 'RQ_PACKAGE', useValue: this.client },
|
36
|
+
ms_redis_service_1.AppServiceRedisClient,
|
37
|
+
datapass_interceptor_1.DatapassInterceptor,
|
38
|
+
],
|
39
|
+
exports: [ms_redis_service_1.AppServiceRedisClient, 'RQ_PACKAGE'],
|
40
|
+
};
|
41
|
+
}
|
42
|
+
static async registerAsync(options) {
|
43
|
+
const url = process.env.ENV_GRPC_MS_REDIS_CACHE || (options && options.urlRedisCache);
|
44
|
+
if (!url)
|
45
|
+
console.warn(chalk_1.bold.red(`ENV_GRPC_MS_REDIS_CACHE no definido en variables de entorno`));
|
46
|
+
this.client = await microservices_1.ClientProxyFactory.create({
|
47
|
+
transport: microservices_1.Transport.GRPC,
|
48
|
+
options: {
|
49
|
+
url: url.trim(),
|
50
|
+
package: 'request',
|
51
|
+
protoPath: (0, path_1.join)(__dirname, './request.proto'),
|
52
|
+
loader: { keepCase: true },
|
53
|
+
},
|
54
|
+
}).connect();
|
55
|
+
return {
|
56
|
+
module: MsRedisModule_1,
|
57
|
+
imports: [],
|
58
|
+
providers: [
|
59
|
+
{ provide: 'RQ_PACKAGE', useValue: this.client },
|
60
|
+
ms_redis_service_1.AppServiceRedisClient,
|
61
|
+
datapass_interceptor_1.DatapassInterceptor,
|
62
|
+
],
|
63
|
+
exports: [ms_redis_service_1.AppServiceRedisClient, 'RQ_PACKAGE'],
|
64
|
+
};
|
65
|
+
}
|
66
|
+
};
|
67
|
+
MsRedisModule = MsRedisModule_1 = __decorate([
|
68
|
+
(0, common_1.Module)({})
|
69
|
+
], MsRedisModule);
|
70
|
+
exports.MsRedisModule = MsRedisModule;
|
71
|
+
//# sourceMappingURL=ms-redis.module.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ms-redis.module.js","sourceRoot":"","sources":["../../src/ms-redis/ms-redis.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAuD;AACvD,yDAAmF;AACnF,+BAA4B;AAC5B,yDAA2D;AAC3D,iEAA6D;AAC7D,iCAA6B;AAOtB,IAAM,aAAa,qBAAnB,MAAM,aAAa;IAMxB,MAAM,CAAC,QAAQ,CAAC,OAA2B;QACzC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;QACtF,IAAI,CAAC,GAAG;YAAE,OAAO,CAAC,IAAI,CAAC,YAAI,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAC,CAAC;QAEhG,IAAI,CAAC,MAAM,GAAG,kCAAkB,CAAC,MAAM,CAAC;YACtC,SAAS,EAAE,yBAAS,CAAC,IAAI;YACzB,OAAO,EAAE;gBACP,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE;gBACf,OAAO,EAAE,SAAS;gBAClB,SAAS,EAAE,IAAA,WAAI,EAAC,SAAS,EAAE,iBAAiB,CAAC;gBAC7C,M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,eAAM,EAAC,EAAE,CAAC;GACE,aAAa,CA4DzB;AA5DY,sCAAa"}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { ClientGrpc } from '@nestjs/microservices';
|
2
|
+
export declare class AppServiceRedisClient {
|
3
|
+
private readonly client;
|
4
|
+
private cacheService;
|
5
|
+
constructor(client: ClientGrpc);
|
6
|
+
onModuleInit(): void;
|
7
|
+
SetCache(key: string, value: string, ttl: number): Promise<any>;
|
8
|
+
getCacheResponse(key: string): Promise<any>;
|
9
|
+
getCache(key: string): Promise<{
|
10
|
+
cache: any;
|
11
|
+
response: any;
|
12
|
+
}>;
|
13
|
+
DeleteCache(key: string): Promise<any>;
|
14
|
+
}
|
@@ -0,0 +1,74 @@
|
|
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.AppServiceRedisClient = void 0;
|
16
|
+
const common_1 = require("@nestjs/common");
|
17
|
+
let AppServiceRedisClient = class AppServiceRedisClient {
|
18
|
+
constructor(client) {
|
19
|
+
this.client = client;
|
20
|
+
}
|
21
|
+
onModuleInit() {
|
22
|
+
this.cacheService = this.client.getService('RequestService');
|
23
|
+
}
|
24
|
+
async SetCache(key, value, ttl) {
|
25
|
+
try {
|
26
|
+
const dataSetCache = await this.cacheService
|
27
|
+
.SetCache({
|
28
|
+
request: JSON.stringify({ key: key, value: value, ttl: ttl }),
|
29
|
+
})
|
30
|
+
.toPromise();
|
31
|
+
return dataSetCache;
|
32
|
+
}
|
33
|
+
catch (error) {
|
34
|
+
throw error;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
async getCacheResponse(key) {
|
38
|
+
const getCache = await this.cacheService
|
39
|
+
.GetCache({ request: JSON.stringify({ key: key }) })
|
40
|
+
.toPromise();
|
41
|
+
return getCache;
|
42
|
+
}
|
43
|
+
async getCache(key) {
|
44
|
+
try {
|
45
|
+
const dataGetCache = await this.getCacheResponse(key);
|
46
|
+
const parseData = JSON.parse(dataGetCache['response']);
|
47
|
+
return {
|
48
|
+
cache: parseData.foundCache,
|
49
|
+
response: JSON.parse(parseData.response),
|
50
|
+
};
|
51
|
+
}
|
52
|
+
catch (error) {
|
53
|
+
throw error;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
async DeleteCache(key) {
|
57
|
+
try {
|
58
|
+
const dataDeleteCache = await this.cacheService
|
59
|
+
.DeleteCache({ request: JSON.stringify({ key: key }) })
|
60
|
+
.toPromise();
|
61
|
+
return dataDeleteCache;
|
62
|
+
}
|
63
|
+
catch (error) {
|
64
|
+
throw error;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
};
|
68
|
+
AppServiceRedisClient = __decorate([
|
69
|
+
(0, common_1.Injectable)(),
|
70
|
+
__param(0, (0, common_1.Inject)('RQ_PACKAGE')),
|
71
|
+
__metadata("design:paramtypes", [Object])
|
72
|
+
], AppServiceRedisClient);
|
73
|
+
exports.AppServiceRedisClient = AppServiceRedisClient;
|
74
|
+
//# sourceMappingURL=ms-redis.service.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ms-redis.service.js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E,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC;aACzC,CAAC;SACH;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,KAAK,CAAC;SACb;IACH,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,GAAW;QAC3B,IAAI;YACF,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,YAAY;iBAC5C,WAAW,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;iBACtD,SAAS,EAAE,CAAC;YACf,OAAO,eAAe,CAAC;SACxB;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,KAAK,CAAC;SACb;IACH,CAAC;CACF,CAAA;AAnDY,qBAAqB;IADjC,IAAA,mBAAU,GAAE;IAGE,WAAA,IAAA,eAAM,EAAC,YAAY,CAAC,CAAA;;GAFtB,qBAAqB,CAmDjC;AAnDY,sDAAqB"}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
syntax = "proto3";
|
2
|
+
|
3
|
+
package request;
|
4
|
+
|
5
|
+
service RequestService {
|
6
|
+
rpc GetCache (Request) returns (Response);
|
7
|
+
rpc SetCache (Request) returns (Response);
|
8
|
+
rpc DeleteCache (Request) returns (Response);
|
9
|
+
rpc DeleteAllCache (Request) returns (Response);
|
10
|
+
}
|
11
|
+
|
12
|
+
message Request {
|
13
|
+
string request = 1;
|
14
|
+
}
|
15
|
+
|
16
|
+
message Response {
|
17
|
+
string response = 1;
|
18
|
+
}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import { Observable } from "rxjs";
|
2
|
+
export declare const protobufPackage = "seguridad.Seguridad";
|
3
|
+
export interface TokenBody {
|
4
|
+
token: string;
|
5
|
+
}
|
6
|
+
export interface ResponseListPermissions {
|
7
|
+
error: boolean;
|
8
|
+
message: string;
|
9
|
+
status: number;
|
10
|
+
response: ResponseListPermissions_ResponseListPermisoMsn | undefined;
|
11
|
+
}
|
12
|
+
export interface ResponseListPermissions_ResponseListPermisoMsn {
|
13
|
+
data: ResponseListPermissions_Response | undefined;
|
14
|
+
validationErrors: string;
|
15
|
+
suggestions: string;
|
16
|
+
}
|
17
|
+
export interface ResponseListPermissions_Response {
|
18
|
+
permisos: string[];
|
19
|
+
total: number;
|
20
|
+
}
|
21
|
+
export interface ResponseValidToken {
|
22
|
+
error: boolean;
|
23
|
+
message: string;
|
24
|
+
status: number;
|
25
|
+
response: ResponseValidToken_ResponseValidTokenMsn | undefined;
|
26
|
+
}
|
27
|
+
export interface ResponseValidToken_ResponseValidTokenMsn {
|
28
|
+
data: boolean;
|
29
|
+
validationErrors: string;
|
30
|
+
suggestions: string;
|
31
|
+
}
|
32
|
+
export interface ResponseUserData {
|
33
|
+
error: boolean;
|
34
|
+
message: string;
|
35
|
+
status: number;
|
36
|
+
response: ResponseUserData_UserPayload | undefined;
|
37
|
+
}
|
38
|
+
export interface ResponseUserData_UserPayload {
|
39
|
+
ci: string;
|
40
|
+
idAplicacion: number;
|
41
|
+
idFuncionario: number;
|
42
|
+
idPersona: number;
|
43
|
+
usuarioId: number;
|
44
|
+
}
|
45
|
+
export declare const SEGURIDAD__SEGURIDAD_PACKAGE_NAME = "seguridad.Seguridad";
|
46
|
+
export interface SeguridadControllerClient {
|
47
|
+
listPermissions(request: TokenBody): Observable<ResponseListPermissions>;
|
48
|
+
validToken(request: TokenBody): Observable<ResponseValidToken>;
|
49
|
+
userDataByToken(request: TokenBody): Observable<ResponseUserData>;
|
50
|
+
}
|
51
|
+
export interface SeguridadControllerController {
|
52
|
+
listPermissions(request: TokenBody): Promise<ResponseListPermissions> | Observable<ResponseListPermissions> | ResponseListPermissions;
|
53
|
+
validToken(request: TokenBody): Promise<ResponseValidToken> | Observable<ResponseValidToken> | ResponseValidToken;
|
54
|
+
userDataByToken(request: TokenBody): Promise<ResponseUserData> | Observable<ResponseUserData> | ResponseUserData;
|
55
|
+
}
|
56
|
+
export declare function SeguridadControllerControllerMethods(): (constructor: Function) => void;
|
57
|
+
export declare const SEGURIDAD_CONTROLLER_SERVICE_NAME = "SeguridadController";
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.SEGURIDAD_CONTROLLER_SERVICE_NAME = exports.SeguridadControllerControllerMethods = exports.SEGURIDAD__SEGURIDAD_PACKAGE_NAME = exports.protobufPackage = void 0;
|
4
|
+
const microservices_1 = require("@nestjs/microservices");
|
5
|
+
exports.protobufPackage = "seguridad.Seguridad";
|
6
|
+
exports.SEGURIDAD__SEGURIDAD_PACKAGE_NAME = "seguridad.Seguridad";
|
7
|
+
function SeguridadControllerControllerMethods() {
|
8
|
+
return function (constructor) {
|
9
|
+
const grpcMethods = ["listPermissions", "validToken", "userDataByToken"];
|
10
|
+
for (const method of grpcMethods) {
|
11
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
12
|
+
(0, microservices_1.GrpcMethod)("SeguridadController", method)(constructor.prototype[method], method, descriptor);
|
13
|
+
}
|
14
|
+
const grpcStreamMethods = [];
|
15
|
+
for (const method of grpcStreamMethods) {
|
16
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
17
|
+
(0, microservices_1.GrpcStreamMethod)("SeguridadController", method)(constructor.prototype[method], method, descriptor);
|
18
|
+
}
|
19
|
+
};
|
20
|
+
}
|
21
|
+
exports.SeguridadControllerControllerMethods = SeguridadControllerControllerMethods;
|
22
|
+
exports.SEGURIDAD_CONTROLLER_SERVICE_NAME = "SeguridadController";
|
23
|
+
//# sourceMappingURL=Seguridad.pb.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Seguridad.pb.js","sourceRoot":"","sources":["../../src/ms-seguridad/Seguridad.pb.ts"],"names":[],"mappings":";;;AACA,yDAAqE;AAGxD,QAAA,eAAe,GAAG,qBAAqB,CAAC;AAoDxC,QAAA,iCAAiC,GAAG,qBAAqB,CAAC;AAwBvE,SAAgB,oCAAoC;IAClD,OAAO,UAAU,WAAqB;QACpC,MAAM,WAAW,GAAa,CAAC,iBAAiB,EAAE,YAAY,EAAE,iBAAiB,CAAC,CAAC;QACnF,KAAK,MAAM,MAAM,IAAI,WAAW,EAAE;YAChC,MAAM,UAAU,GAAQ,OAAO,CAAC,wBAAwB,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YACxF,IAAA,0BAAU,EAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;SAC9F;QACD,MAAM,iBAAiB,GAAa,EAAE,CAAC;QACvC,KAAK,MAAM,MAAM,IAAI,iBAAiB,EAAE;YACtC,MAAM,UAAU,GAAQ,OAAO,CAAC,wBAAwB,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YACxF,IAAA,gCAAgB,EAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;SACpG;IACH,CAAC,CAAC;AACJ,CAAC;AAbD,oFAaC;AAEY,QAAA,iCAAiC,GAAG,qBAAqB,CAAC"}
|
@@ -0,0 +1,60 @@
|
|
1
|
+
syntax = "proto3";
|
2
|
+
|
3
|
+
package seguridad.Seguridad;
|
4
|
+
|
5
|
+
// Inicio AuthAplicaciones
|
6
|
+
service SeguridadController {
|
7
|
+
rpc ListPermissions (TokenBody) returns (ResponseListPermissions) {}
|
8
|
+
rpc ValidToken (TokenBody) returns (ResponseValidToken) {}
|
9
|
+
rpc UserDataByToken (TokenBody) returns (ResponseUserData) {}
|
10
|
+
}
|
11
|
+
|
12
|
+
message TokenBody {
|
13
|
+
string token = 1;
|
14
|
+
}
|
15
|
+
|
16
|
+
message ResponseListPermissions {
|
17
|
+
bool error = 1;
|
18
|
+
string message = 2;
|
19
|
+
int32 status = 3;
|
20
|
+
ResponseListPermisoMsn response = 4;
|
21
|
+
|
22
|
+
message ResponseListPermisoMsn {
|
23
|
+
Response data = 1;
|
24
|
+
string validationErrors = 2;
|
25
|
+
string suggestions = 3;
|
26
|
+
}
|
27
|
+
message Response{
|
28
|
+
repeated string permisos = 1;
|
29
|
+
int32 total = 2;
|
30
|
+
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
message ResponseValidToken {
|
35
|
+
bool error = 1;
|
36
|
+
string message = 2;
|
37
|
+
int32 status = 3;
|
38
|
+
ResponseValidTokenMsn response = 4;
|
39
|
+
|
40
|
+
message ResponseValidTokenMsn {
|
41
|
+
bool data = 1;
|
42
|
+
string validationErrors = 3;
|
43
|
+
string suggestions = 4;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
message ResponseUserData {
|
48
|
+
bool error = 1;
|
49
|
+
string message = 2;
|
50
|
+
int32 status = 3;
|
51
|
+
UserPayload response = 4;
|
52
|
+
|
53
|
+
message UserPayload {
|
54
|
+
string ci = 1;
|
55
|
+
int32 idAplicacion= 2;
|
56
|
+
int32 idFuncionario= 3;
|
57
|
+
int32 idPersona= 4;
|
58
|
+
int32 usuarioId= 5;
|
59
|
+
}
|
60
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
export declare const BearerAuthPermision: (permissions?: string[]) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
2
|
+
export declare class UserPayload {
|
3
|
+
ci: string;
|
4
|
+
idAplicacion: number;
|
5
|
+
idFuncionario: number;
|
6
|
+
idPersona: number;
|
7
|
+
usuarioId: number;
|
8
|
+
}
|
9
|
+
export declare const AuthUser: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
10
|
+
export declare const AuthToken: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
11
|
+
export declare const AuthPermissions: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
@@ -0,0 +1,36 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.AuthPermissions = exports.AuthToken = exports.AuthUser = exports.UserPayload = exports.BearerAuthPermision = void 0;
|
4
|
+
const common_1 = require("@nestjs/common");
|
5
|
+
const swagger_1 = require("@nestjs/swagger");
|
6
|
+
const token_auth_guard_1 = require("./token-auth.guard");
|
7
|
+
const permision_guard_1 = require("./permision.guard");
|
8
|
+
const BearerAuthPermision = (permissions) => {
|
9
|
+
const decorators = [(0, swagger_1.ApiBearerAuth)(), (0, common_1.UseGuards)(token_auth_guard_1.TokenAuthGuard, permision_guard_1.PermissionsGuard)];
|
10
|
+
if (permissions && permissions.length > 0) {
|
11
|
+
decorators.push((0, permision_guard_1.RequiredPermissions)(...permissions));
|
12
|
+
}
|
13
|
+
return (0, common_1.applyDecorators)(...decorators);
|
14
|
+
};
|
15
|
+
exports.BearerAuthPermision = BearerAuthPermision;
|
16
|
+
class UserPayload {
|
17
|
+
}
|
18
|
+
exports.UserPayload = UserPayload;
|
19
|
+
exports.AuthUser = (0, common_1.createParamDecorator)((data, context) => {
|
20
|
+
const request = context.switchToHttp().getRequest();
|
21
|
+
return request.userHeader;
|
22
|
+
});
|
23
|
+
exports.AuthToken = (0, common_1.createParamDecorator)((data, context) => {
|
24
|
+
const request = context.switchToHttp().getRequest();
|
25
|
+
const authHeader = request.headers.authorization;
|
26
|
+
if (!authHeader)
|
27
|
+
return null;
|
28
|
+
const [bearer, token] = authHeader.split(' ');
|
29
|
+
return token !== null && token !== void 0 ? token : bearer;
|
30
|
+
});
|
31
|
+
exports.AuthPermissions = (0, common_1.createParamDecorator)((data, context) => {
|
32
|
+
var _a;
|
33
|
+
const request = context.switchToHttp().getRequest();
|
34
|
+
return (_a = request.permissions) !== null && _a !== void 0 ? _a : [];
|
35
|
+
});
|
36
|
+
//# sourceMappingURL=ms-seguridad.decorator.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":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B,CAAC,CACF,CAAC;AAEW,QAAA,eAAe,GAAG,IAAA,6BAAoB,EACjD,CAAC,IAAa,EAAE,OAAyB,EAAU,EAAE;;IACnD,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IACpD,OAAO,MAAA,OAAO,CAAC,WAAW,mCAAI,EAAE,CAAC;AACnC,CAAC,CACF,CAAC"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
2
|
+
import { ClientProxy } from '@nestjs/microservices';
|
3
|
+
interface SeguridadModuleOptions {
|
4
|
+
urlSeguridad: string | undefined;
|
5
|
+
urlRedisCache: string | undefined;
|
6
|
+
}
|
7
|
+
export declare class MsSeguridadModule {
|
8
|
+
static client: ClientProxy;
|
9
|
+
static register(options: SeguridadModuleOptions): DynamicModule;
|
10
|
+
static registerAsync(options: SeguridadModuleOptions): Promise<DynamicModule>;
|
11
|
+
private static showError;
|
12
|
+
}
|
13
|
+
export {};
|
@@ -0,0 +1,80 @@
|
|
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 MsSeguridadModule_1;
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
10
|
+
exports.MsSeguridadModule = void 0;
|
11
|
+
const common_1 = require("@nestjs/common");
|
12
|
+
const microservices_1 = require("@nestjs/microservices");
|
13
|
+
const ms_seguridad_service_1 = require("./ms-seguridad.service");
|
14
|
+
const ms_redis_module_1 = require("../ms-redis/ms-redis.module");
|
15
|
+
const path_1 = require("path");
|
16
|
+
const chalk_1 = require("chalk");
|
17
|
+
let MsSeguridadModule = MsSeguridadModule_1 = class MsSeguridadModule {
|
18
|
+
static register(options) {
|
19
|
+
const urlSeguridad = process.env.ENV_GRPC_MS_SEGURIDAD || (options && options.urlSeguridad);
|
20
|
+
const urlRedisCache = process.env.ENV_GRPC_MS_REDIS_CACHE || (options && options.urlRedisCache);
|
21
|
+
if (!urlSeguridad)
|
22
|
+
this.showError('ENV_GRPC_MS_SEGURIDAD');
|
23
|
+
if (!urlRedisCache)
|
24
|
+
this.showError('ENV_GRPC_MS_REDIS_CACHE');
|
25
|
+
this.client = microservices_1.ClientProxyFactory.create({
|
26
|
+
transport: microservices_1.Transport.GRPC,
|
27
|
+
options: {
|
28
|
+
url: urlSeguridad.trim(),
|
29
|
+
package: 'seguridad.Seguridad',
|
30
|
+
protoPath: (0, path_1.join)(__dirname, './Seguridad.proto'),
|
31
|
+
loader: { keepCase: true },
|
32
|
+
},
|
33
|
+
});
|
34
|
+
return {
|
35
|
+
module: MsSeguridadModule_1,
|
36
|
+
imports: [ms_redis_module_1.MsRedisModule.register({ urlRedisCache })],
|
37
|
+
providers: [
|
38
|
+
{ provide: 'PROVIDER_NAME_MS_SEGURIDAD', useValue: this.client },
|
39
|
+
ms_seguridad_service_1.MsSeguridadService,
|
40
|
+
],
|
41
|
+
exports: [ms_seguridad_service_1.MsSeguridadService, 'PROVIDER_NAME_MS_SEGURIDAD'],
|
42
|
+
};
|
43
|
+
}
|
44
|
+
static async registerAsync(options) {
|
45
|
+
const urlSeguridad = process.env.ENV_GRPC_MS_SEGURIDAD || (options && options.urlSeguridad);
|
46
|
+
const urlRedisCache = process.env.ENV_GRPC_MS_REDIS_CACHE || (options && options.urlRedisCache);
|
47
|
+
if (!urlSeguridad)
|
48
|
+
this.showError('ENV_GRPC_MS_SEGURIDAD');
|
49
|
+
if (!urlRedisCache)
|
50
|
+
this.showError('ENV_GRPC_MS_REDIS_CACHE');
|
51
|
+
this.client = await microservices_1.ClientProxyFactory.create({
|
52
|
+
transport: microservices_1.Transport.GRPC,
|
53
|
+
options: {
|
54
|
+
url: urlSeguridad.trim(),
|
55
|
+
package: 'seguridad.Seguridad',
|
56
|
+
protoPath: (0, path_1.join)(__dirname, './Seguridad.proto'),
|
57
|
+
loader: { keepCase: true },
|
58
|
+
},
|
59
|
+
}).connect();
|
60
|
+
return {
|
61
|
+
module: MsSeguridadModule_1,
|
62
|
+
imports: [ms_redis_module_1.MsRedisModule.register({ urlRedisCache })],
|
63
|
+
providers: [
|
64
|
+
{ provide: 'PROVIDER_NAME_MS_SEGURIDAD', useValue: this.client },
|
65
|
+
ms_seguridad_service_1.MsSeguridadService,
|
66
|
+
],
|
67
|
+
exports: [ms_seguridad_service_1.MsSeguridadService, 'PROVIDER_NAME_MS_SEGURIDAD'],
|
68
|
+
};
|
69
|
+
}
|
70
|
+
static showError(text) {
|
71
|
+
console.warn(chalk_1.bold.red(`${text} no definido en variables de entorno`));
|
72
|
+
}
|
73
|
+
};
|
74
|
+
MsSeguridadModule = MsSeguridadModule_1 = __decorate([
|
75
|
+
(0, common_1.Module)({
|
76
|
+
providers: [ms_seguridad_service_1.MsSeguridadService],
|
77
|
+
})
|
78
|
+
], MsSeguridadModule);
|
79
|
+
exports.MsSeguridadModule = MsSeguridadModule;
|
80
|
+
//# sourceMappingURL=ms-seguridad.module.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ms-seguridad.module.js","sourceRoot":"","sources":["../../src/ms-seguridad/ms-seguridad.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAuD;AACvD,yDAAmF;AACnF,iEAA4D;AAC5D,iEAA6D;AAC7D,+BAA4B;AAC5B,iCAA6B;AAUtB,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAM5B,MAAM,CAAC,QAAQ,CAAC,OAA+B;QAC7C,MAAM,YAAY,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seguridad.pb';
|
3
|
+
import { UserPayload } from './ms-seguridad.decorator';
|
4
|
+
import { AppServiceRedisClient } from 'src/ms-redis/ms-redis.service';
|
5
|
+
export declare class MsSeguridadService {
|
6
|
+
private readonly client;
|
7
|
+
private readonly redisCache;
|
8
|
+
private seguridadService;
|
9
|
+
constructor(client: ClientGrpc, redisCache: AppServiceRedisClient);
|
10
|
+
private onModuleInit;
|
11
|
+
listPermissions(user: UserPayload, tokenBody: TokenBody): Promise<ResponseListPermissions_ResponseListPermisoMsn>;
|
12
|
+
validToken(tokenBody: TokenBody): Promise<import("./Seguridad.pb").ResponseValidToken>;
|
13
|
+
userData(tokenBody: TokenBody): Promise<import("./Seguridad.pb").ResponseUserData>;
|
14
|
+
private saveInRedisCache;
|
15
|
+
}
|