@manticore-labs/nest 0.0.17 → 0.0.18

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.
Files changed (143) hide show
  1. package/.circleci/config.yml +47 -47
  2. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  3. package/.idea/modules.xml +8 -0
  4. package/.idea/npm.iml +12 -0
  5. package/.idea/vcs.xml +6 -0
  6. package/.idea/workspace.xml +293 -0
  7. package/LICENSE +8 -8
  8. package/README.1.md +116 -116
  9. package/build/main/index.d.ts +10 -9
  10. package/build/main/index.js +13 -12
  11. package/build/main/lib/funciones-util/buscar-registro.d.ts +1 -1
  12. package/build/main/lib/funciones-util/buscar-registro.js +146 -146
  13. package/build/main/lib/funciones-util/buscar-un-registro-por-id.d.ts +1 -1
  14. package/build/main/lib/funciones-util/buscar-un-registro-por-id.js +25 -25
  15. package/build/main/lib/funciones-util/buscar-where-or.d.ts +1 -1
  16. package/build/main/lib/funciones-util/buscar-where-or.js +31 -31
  17. package/build/main/lib/funciones-util/contar-registros.d.ts +1 -1
  18. package/build/main/lib/funciones-util/contar-registros.js +41 -41
  19. package/build/main/lib/funciones-util/crear-un-registro.d.ts +1 -1
  20. package/build/main/lib/funciones-util/crear-un-registro.js +24 -24
  21. package/build/main/lib/funciones-util/editar-un-registro.d.ts +1 -1
  22. package/build/main/lib/funciones-util/editar-un-registro.js +24 -24
  23. package/build/main/lib/funciones-util/eliminar-uno.d.ts +1 -1
  24. package/build/main/lib/funciones-util/eliminar-uno.js +35 -35
  25. package/build/main/lib/funciones-util/typeorm/valor-esta-dentro-del-arreglo.d.ts +2 -0
  26. package/build/main/lib/funciones-util/typeorm/valor-esta-dentro-del-arreglo.js +24 -0
  27. package/build/main/lib/interfaces-util/arreglo-funciones-booleanas.d.ts +4 -4
  28. package/build/main/lib/interfaces-util/arreglo-funciones-booleanas.js +2 -2
  29. package/build/main/lib/interfaces-util/broadcast-join.gateway.d.ts +14 -14
  30. package/build/main/lib/interfaces-util/broadcast-join.gateway.js +2 -2
  31. package/build/main/lib/interfaces-util/delete-service.d.ts +12 -12
  32. package/build/main/lib/interfaces-util/delete-service.js +2 -2
  33. package/build/main/lib/interfaces-util/dto.d.ts +4 -4
  34. package/build/main/lib/interfaces-util/dto.js +2 -2
  35. package/build/main/lib/interfaces-util/find-where-relations.d.ts +8 -8
  36. package/build/main/lib/interfaces-util/find-where-relations.js +2 -2
  37. package/build/main/lib/interfaces-util/funciones-seguridad.d.ts +13 -13
  38. package/build/main/lib/interfaces-util/funciones-seguridad.js +2 -2
  39. package/build/main/lib/interfaces-util/funciones.gateway.d.ts +5 -5
  40. package/build/main/lib/interfaces-util/funciones.gateway.js +2 -2
  41. package/build/main/lib/interfaces-util/mensajes-controller.d.ts +6 -6
  42. package/build/main/lib/interfaces-util/mensajes-controller.js +2 -2
  43. package/build/main/lib/interfaces-util/politicas-de-seguridad.d.ts +17 -17
  44. package/build/main/lib/interfaces-util/politicas-de-seguridad.js +2 -2
  45. package/build/main/lib/interfaces-util/respuesta-general.gateway.d.ts +5 -5
  46. package/build/main/lib/interfaces-util/respuesta-general.gateway.js +2 -2
  47. package/build/main/lib/principal.controller.d.ts +20 -20
  48. package/build/main/lib/principal.controller.js +309 -309
  49. package/build/main/lib/principal.dto.d.ts +5 -5
  50. package/build/main/lib/principal.dto.js +21 -21
  51. package/build/main/lib/principal.entity.d.ts +7 -7
  52. package/build/main/lib/principal.entity.js +42 -42
  53. package/build/main/lib/principal.find-many-options.d.ts +14 -14
  54. package/build/main/lib/principal.find-many-options.js +48 -48
  55. package/build/main/lib/principal.find-many-where-or.d.ts +10 -10
  56. package/build/main/lib/principal.find-many-where-or.js +28 -28
  57. package/build/main/lib/principal.gateway.d.ts +35 -35
  58. package/build/main/lib/principal.gateway.js +399 -399
  59. package/build/main/lib/principal.id.d.ts +3 -3
  60. package/build/main/lib/principal.id.js +16 -16
  61. package/build/main/lib/principal.resolver.d.ts +20 -20
  62. package/build/main/lib/principal.resolver.js +343 -343
  63. package/build/main/lib/principal.service.d.ts +35 -35
  64. package/build/main/lib/principal.service.js +203 -203
  65. package/build/main/lib/seguridad/aplicar-politicas-de-seguridad.d.ts +4 -4
  66. package/build/main/lib/seguridad/aplicar-politicas-de-seguridad.js +16 -16
  67. package/build/main/lib/seguridad/funciones/convertir-arreglo-en-arreglo-de-observables.d.ts +3 -3
  68. package/build/main/lib/seguridad/funciones/convertir-arreglo-en-arreglo-de-observables.js +26 -26
  69. package/build/main/lib/seguridad/funciones/index.d.ts +6 -6
  70. package/build/main/lib/seguridad/funciones/index.js +12 -12
  71. package/build/main/lib/seguridad/funciones/obtener-reflector-seguridad.d.ts +1 -1
  72. package/build/main/lib/seguridad/funciones/obtener-reflector-seguridad.js +6 -6
  73. package/build/main/lib/seguridad/funciones/obtener-request.d.ts +1 -1
  74. package/build/main/lib/seguridad/funciones/obtener-request.js +6 -6
  75. package/build/main/lib/seguridad/funciones/obtener-response.d.ts +1 -1
  76. package/build/main/lib/seguridad/funciones/obtener-response.js +6 -6
  77. package/build/main/lib/seguridad/funciones/tiene-acceso-permitido.d.ts +2 -2
  78. package/build/main/lib/seguridad/funciones/tiene-acceso-permitido.js +13 -13
  79. package/build/main/lib/seguridad/seguridad.decorator.d.ts +1 -1
  80. package/build/main/lib/seguridad/seguridad.decorator.js +4 -4
  81. package/build/module/index.d.ts +10 -9
  82. package/build/module/index.js +8 -7
  83. package/build/module/lib/funciones-util/buscar-registro.d.ts +1 -1
  84. package/build/module/lib/funciones-util/buscar-registro.js +143 -143
  85. package/build/module/lib/funciones-util/buscar-un-registro-por-id.d.ts +1 -1
  86. package/build/module/lib/funciones-util/buscar-un-registro-por-id.js +22 -22
  87. package/build/module/lib/funciones-util/buscar-where-or.d.ts +1 -1
  88. package/build/module/lib/funciones-util/buscar-where-or.js +28 -28
  89. package/build/module/lib/funciones-util/contar-registros.d.ts +1 -1
  90. package/build/module/lib/funciones-util/contar-registros.js +38 -38
  91. package/build/module/lib/funciones-util/crear-un-registro.d.ts +1 -1
  92. package/build/module/lib/funciones-util/crear-un-registro.js +21 -21
  93. package/build/module/lib/funciones-util/editar-un-registro.d.ts +1 -1
  94. package/build/module/lib/funciones-util/editar-un-registro.js +21 -21
  95. package/build/module/lib/funciones-util/eliminar-uno.d.ts +1 -1
  96. package/build/module/lib/funciones-util/eliminar-uno.js +32 -32
  97. package/build/module/lib/funciones-util/typeorm/valor-esta-dentro-del-arreglo.d.ts +2 -0
  98. package/build/module/lib/funciones-util/typeorm/valor-esta-dentro-del-arreglo.js +21 -0
  99. package/build/module/lib/interfaces-util/arreglo-funciones-booleanas.d.ts +4 -4
  100. package/build/module/lib/interfaces-util/broadcast-join.gateway.d.ts +14 -14
  101. package/build/module/lib/interfaces-util/delete-service.d.ts +12 -12
  102. package/build/module/lib/interfaces-util/dto.d.ts +4 -4
  103. package/build/module/lib/interfaces-util/find-where-relations.d.ts +8 -8
  104. package/build/module/lib/interfaces-util/funciones-seguridad.d.ts +13 -13
  105. package/build/module/lib/interfaces-util/funciones.gateway.d.ts +5 -5
  106. package/build/module/lib/interfaces-util/mensajes-controller.d.ts +6 -6
  107. package/build/module/lib/interfaces-util/politicas-de-seguridad.d.ts +17 -17
  108. package/build/module/lib/interfaces-util/respuesta-general.gateway.d.ts +5 -5
  109. package/build/module/lib/principal.controller.d.ts +20 -20
  110. package/build/module/lib/principal.controller.js +306 -306
  111. package/build/module/lib/principal.dto.d.ts +5 -5
  112. package/build/module/lib/principal.dto.js +18 -18
  113. package/build/module/lib/principal.entity.d.ts +7 -7
  114. package/build/module/lib/principal.entity.js +39 -39
  115. package/build/module/lib/principal.find-many-options.d.ts +14 -14
  116. package/build/module/lib/principal.find-many-options.js +45 -45
  117. package/build/module/lib/principal.find-many-where-or.d.ts +10 -10
  118. package/build/module/lib/principal.find-many-where-or.js +25 -25
  119. package/build/module/lib/principal.gateway.d.ts +35 -35
  120. package/build/module/lib/principal.gateway.js +396 -396
  121. package/build/module/lib/principal.id.d.ts +3 -3
  122. package/build/module/lib/principal.id.js +13 -13
  123. package/build/module/lib/principal.resolver.d.ts +20 -20
  124. package/build/module/lib/principal.resolver.js +340 -340
  125. package/build/module/lib/principal.service.d.ts +35 -35
  126. package/build/module/lib/principal.service.js +200 -200
  127. package/build/module/lib/seguridad/aplicar-politicas-de-seguridad.d.ts +4 -4
  128. package/build/module/lib/seguridad/aplicar-politicas-de-seguridad.js +13 -13
  129. package/build/module/lib/seguridad/funciones/convertir-arreglo-en-arreglo-de-observables.d.ts +3 -3
  130. package/build/module/lib/seguridad/funciones/convertir-arreglo-en-arreglo-de-observables.js +23 -23
  131. package/build/module/lib/seguridad/funciones/index.d.ts +6 -6
  132. package/build/module/lib/seguridad/funciones/index.js +6 -6
  133. package/build/module/lib/seguridad/funciones/obtener-reflector-seguridad.d.ts +1 -1
  134. package/build/module/lib/seguridad/funciones/obtener-reflector-seguridad.js +3 -3
  135. package/build/module/lib/seguridad/funciones/obtener-request.d.ts +1 -1
  136. package/build/module/lib/seguridad/funciones/obtener-request.js +3 -3
  137. package/build/module/lib/seguridad/funciones/obtener-response.d.ts +1 -1
  138. package/build/module/lib/seguridad/funciones/obtener-response.js +3 -3
  139. package/build/module/lib/seguridad/funciones/tiene-acceso-permitido.d.ts +2 -2
  140. package/build/module/lib/seguridad/funciones/tiene-acceso-permitido.js +10 -10
  141. package/build/module/lib/seguridad/seguridad.decorator.d.ts +1 -1
  142. package/build/module/lib/seguridad/seguridad.decorator.js +2 -2
  143. package/package.json +1 -1
@@ -1,35 +1,35 @@
1
- import { FindManyOptions, Repository } from 'typeorm';
2
- import { ObjectID } from 'typeorm/driver/mongodb/typings';
3
- import { FindOneOptions } from 'typeorm/find-options/FindOneOptions';
4
- import { FindConditions } from 'typeorm/find-options/FindConditions';
5
- import { QueryRunner } from 'typeorm/query-runner/QueryRunner';
6
- import { SelectQueryBuilder } from 'typeorm/query-builder/SelectQueryBuilder';
7
- import { DeleteResult } from 'typeorm/query-builder/result/DeleteResult';
8
- import { Observable } from 'rxjs';
9
- import { FindWhereRelations } from './interfaces-util/find-where-relations';
10
- export declare class PrincipalService<T, G, F> {
11
- protected readonly repository: Repository<T>;
12
- private Entidad?;
13
- private nombreRepositorio?;
14
- constructor(repository: Repository<T>, Entidad?: any, nombreRepositorio?: string);
15
- find(criterioBusqueda?: FindManyOptions<T>, arregloIds?: number[]): Promise<T[] | [T[], number]>;
16
- findOne(criterioBusqueda?: FindOneOptions<T>, id?: string | number | Date | ObjectID, esSocket?: boolean): Promise<T | ErrorServicioInterface> | undefined;
17
- count(criterioBusqueda: FindManyOptions<T>): Promise<{
18
- registros: number;
19
- } | {
20
- mensaje: string;
21
- error: string;
22
- } | any>;
23
- create(registro: G): Promise<any>;
24
- update(criterio: T, datosAActualizar: F): Promise<any>;
25
- findOneByIdAndUpdate(id: string | number | Date | ObjectID, datosAActualizar: F, esSocket?: boolean): Promise<T | ErrorServicioInterface>;
26
- delete(criterio?: string | string[] | number | number[] | Date | Date[] | ObjectID | ObjectID[] | FindConditions<T>, esSocket?: boolean): Observable<ErrorServicioInterface | DeleteResult>;
27
- deleteMany(criterio?: string | string[] | number | number[] | Date | Date[] | ObjectID | ObjectID[] | FindConditions<T>): Promise<DeleteResult>;
28
- queryBuilder(alias?: string, queryRunner?: QueryRunner): SelectQueryBuilder<T>;
29
- findWhereOr(camposABuscar: any[], skip: number, take: number, relations?: FindWhereRelations[]): Promise<{}>;
30
- }
31
- export declare function devolverRespuestaSiExiste(encontroRegistro: any, esSocket?: boolean, esActualizado?: boolean, datosAActualizar?: any, contexto?: any): Promise<{}>;
32
- export interface ErrorServicioInterface {
33
- mensaje?: string;
34
- error?: number;
35
- }
1
+ import { FindManyOptions, Repository } from 'typeorm';
2
+ import { ObjectID } from 'typeorm/driver/mongodb/typings';
3
+ import { FindOneOptions } from 'typeorm/find-options/FindOneOptions';
4
+ import { FindConditions } from 'typeorm/find-options/FindConditions';
5
+ import { QueryRunner } from 'typeorm/query-runner/QueryRunner';
6
+ import { SelectQueryBuilder } from 'typeorm/query-builder/SelectQueryBuilder';
7
+ import { DeleteResult } from 'typeorm/query-builder/result/DeleteResult';
8
+ import { Observable } from 'rxjs';
9
+ import { FindWhereRelations } from './interfaces-util/find-where-relations';
10
+ export declare class PrincipalService<T, G, F> {
11
+ protected readonly repository: Repository<T>;
12
+ private Entidad?;
13
+ private nombreRepositorio?;
14
+ constructor(repository: Repository<T>, Entidad?: any, nombreRepositorio?: string);
15
+ find(criterioBusqueda?: FindManyOptions<T>, arregloIds?: number[]): Promise<T[] | [T[], number]>;
16
+ findOne(criterioBusqueda?: FindOneOptions<T>, id?: string | number | Date | ObjectID, esSocket?: boolean): Promise<T | ErrorServicioInterface> | undefined;
17
+ count(criterioBusqueda: FindManyOptions<T>): Promise<{
18
+ registros: number;
19
+ } | {
20
+ mensaje: string;
21
+ error: string;
22
+ } | any>;
23
+ create(registro: G): Promise<any>;
24
+ update(criterio: T, datosAActualizar: F): Promise<any>;
25
+ findOneByIdAndUpdate(id: string | number | Date | ObjectID, datosAActualizar: F, esSocket?: boolean): Promise<T | ErrorServicioInterface>;
26
+ delete(criterio?: string | string[] | number | number[] | Date | Date[] | ObjectID | ObjectID[] | FindConditions<T>, esSocket?: boolean): Observable<ErrorServicioInterface | DeleteResult>;
27
+ deleteMany(criterio?: string | string[] | number | number[] | Date | Date[] | ObjectID | ObjectID[] | FindConditions<T>): Promise<DeleteResult>;
28
+ queryBuilder(alias?: string, queryRunner?: QueryRunner): SelectQueryBuilder<T>;
29
+ findWhereOr(camposABuscar: any[], skip: number, take: number, relations?: FindWhereRelations[]): Promise<{}>;
30
+ }
31
+ export declare function devolverRespuestaSiExiste(encontroRegistro: any, esSocket?: boolean, esActualizado?: boolean, datosAActualizar?: any, contexto?: any): Promise<{}>;
32
+ export interface ErrorServicioInterface {
33
+ mensaje?: string;
34
+ error?: number;
35
+ }
@@ -1,201 +1,201 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- 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;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { Injectable, NotFoundException } from '@nestjs/common';
8
- import { getRepository } from 'typeorm';
9
- import { from } from 'rxjs';
10
- import { mergeMap } from 'rxjs/operators';
11
- let PrincipalService = class PrincipalService {
12
- constructor(repository, Entidad, nombreRepositorio) {
13
- this.repository = repository;
14
- this.Entidad = Entidad;
15
- this.nombreRepositorio = nombreRepositorio;
16
- }
17
- async find(criterioBusqueda, arregloIds) {
18
- if (arregloIds) {
19
- return await this.repository.findByIds(arregloIds, criterioBusqueda);
20
- }
21
- else {
22
- return await this.repository.findAndCount(criterioBusqueda);
23
- }
24
- }
25
- async findOne(criterioBusqueda, id, esSocket = false) {
26
- if (id) {
27
- const encontroRegistro = await this.repository.findOne(id, criterioBusqueda);
28
- return devolverRespuestaSiExiste(encontroRegistro, esSocket);
29
- }
30
- else {
31
- const encontroRegistro = await this.repository.findOne(criterioBusqueda);
32
- return devolverRespuestaSiExiste(encontroRegistro, esSocket);
33
- }
34
- }
35
- async count(criterioBusqueda) {
36
- return await new Promise((resolve) => {
37
- this.repository
38
- .count(criterioBusqueda)
39
- .then((respuesta) => {
40
- resolve({ registros: respuesta });
41
- }, (error) => {
42
- console.error('Error', error);
43
- resolve({ error: '500', mensaje: 'Error del servidor' });
44
- });
45
- });
46
- }
47
- async create(registro) {
48
- const registroACrearse = this.repository.create(registro);
49
- return await this.repository.save(registroACrearse);
50
- }
51
- async update(criterio, datosAActualizar) {
52
- return await this.repository.update(criterio, datosAActualizar);
53
- }
54
- async findOneByIdAndUpdate(id, datosAActualizar, esSocket = false) {
55
- const registroEncontrado = await this.repository.findOne(id);
56
- return devolverRespuestaSiExiste(registroEncontrado, esSocket, true, datosAActualizar, this);
57
- }
58
- delete(criterio, esSocket = false) {
59
- return from(this.repository.delete(criterio))
60
- .pipe(mergeMap((deleteResponse) => {
61
- if (deleteResponse.raw) {
62
- if (deleteResponse.raw.affectedRows === 1 && (typeof criterio === 'number' || typeof criterio === 'string')) {
63
- const id = criterio;
64
- return from(new Promise((resolve) => {
65
- resolve({ mensaje: `Registro ${id} eliminado` });
66
- }));
67
- }
68
- else {
69
- if (deleteResponse.raw.affectedRows === 0) {
70
- if (esSocket) {
71
- return from(new Promise((resolve) => {
72
- resolve({ error: 404, mensaje: 'No se encontro ningun registro' });
73
- }));
74
- }
75
- else {
76
- throw new NotFoundException('No se elimino ningun registro');
77
- }
78
- }
79
- else {
80
- return from(new Promise((resolve) => {
81
- resolve(deleteResponse);
82
- }));
83
- }
84
- }
85
- }
86
- else {
87
- return from(new Promise((resolve) => {
88
- resolve(deleteResponse);
89
- }));
90
- }
91
- }));
92
- }
93
- async deleteMany(criterio) {
94
- return await this.repository.delete(criterio);
95
- }
96
- queryBuilder(alias, queryRunner) {
97
- return this.repository.createQueryBuilder(alias, queryRunner);
98
- }
99
- async findWhereOr(camposABuscar, skip, take, relations) {
100
- if (this.Entidad && this.nombreRepositorio) {
101
- const entidad = new this.Entidad();
102
- const atributos = Object
103
- .keys(entidad);
104
- const todosCamposExisten = camposABuscar
105
- .every((campo) => {
106
- return atributos.some((atributo) => atributo === campo.campo);
107
- });
108
- if (todosCamposExisten) {
109
- let query = '';
110
- const objeto = {};
111
- camposABuscar
112
- .forEach((campo) => {
113
- if (query === '') {
114
- query = query + `entidad.${campo.campo} Like :${campo.campo}`;
115
- objeto[campo.campo] = campo.valor;
116
- }
117
- else {
118
- query = query + ` OR entidad.${campo.campo} Like :${campo.campo}`;
119
- objeto[campo.campo] = campo.valor;
120
- }
121
- });
122
- let respuesta = getRepository(this.Entidad, this.nombreRepositorio)
123
- .createQueryBuilder('entidad')
124
- .where(query, objeto);
125
- if (relations) {
126
- relations.forEach((relacion) => {
127
- const parametros = ['entidad.' + relacion.entidad, relacion.entidad];
128
- if (relacion.query) {
129
- let queryRelacion = '';
130
- const objetoRelacion = {};
131
- relacion.query
132
- .forEach((campoRelacion) => {
133
- if (queryRelacion === '') {
134
- queryRelacion = queryRelacion + `${relacion.key}.${campoRelacion.campo} = :${campoRelacion.campo}`;
135
- objetoRelacion[campoRelacion.campo] = campoRelacion.valor;
136
- }
137
- else {
138
- queryRelacion = queryRelacion + ` AND ${relacion.key}.${campoRelacion.campo} = :${campoRelacion.campo}`;
139
- objetoRelacion[campoRelacion.campo] = campoRelacion.valor;
140
- }
141
- });
142
- parametros.push(queryRelacion);
143
- parametros.push(objetoRelacion);
144
- respuesta = respuesta.innerJoinAndSelect(...parametros);
145
- }
146
- else {
147
- respuesta = respuesta.innerJoinAndSelect(...parametros);
148
- }
149
- });
150
- }
151
- const respuestaFinal = await respuesta
152
- .skip(skip)
153
- .take(take)
154
- .getManyAndCount();
155
- return new Promise(r => r(respuestaFinal));
156
- }
157
- else {
158
- return new Promise(r => r({ error: 400, mensaje: 'No envia parametros' }));
159
- }
160
- }
161
- else {
162
- return new Promise(r => r({ error: 400, mensaje: 'No envia parametros' }));
163
- }
164
- }
165
- };
166
- PrincipalService = __decorate([
167
- Injectable()
168
- ], PrincipalService);
169
- export { PrincipalService };
170
- export function devolverRespuestaSiExiste(encontroRegistro, esSocket = false, esActualizado = false, datosAActualizar, contexto) {
171
- return new Promise((resolve, reject) => {
172
- if (encontroRegistro) {
173
- if (esActualizado) {
174
- contexto.update(encontroRegistro, datosAActualizar)
175
- .then(() => {
176
- if (esActualizado) {
177
- Object
178
- .keys(datosAActualizar)
179
- .map(propiedadActualizada => {
180
- encontroRegistro[propiedadActualizada] = datosAActualizar[propiedadActualizada];
181
- });
182
- }
183
- resolve(encontroRegistro);
184
- })
185
- .catch((e) => { reject(e); });
186
- }
187
- else {
188
- resolve(encontroRegistro);
189
- }
190
- }
191
- else {
192
- if (esSocket) {
193
- resolve({ error: 404, mensaje: 'No se encontro ningun registro' });
194
- }
195
- else {
196
- throw new NotFoundException('No se encontro ningun registro');
197
- }
198
- }
199
- });
200
- }
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Injectable, NotFoundException } from '@nestjs/common';
8
+ import { getRepository } from 'typeorm';
9
+ import { from } from 'rxjs';
10
+ import { mergeMap } from 'rxjs/operators';
11
+ let PrincipalService = class PrincipalService {
12
+ constructor(repository, Entidad, nombreRepositorio) {
13
+ this.repository = repository;
14
+ this.Entidad = Entidad;
15
+ this.nombreRepositorio = nombreRepositorio;
16
+ }
17
+ async find(criterioBusqueda, arregloIds) {
18
+ if (arregloIds) {
19
+ return await this.repository.findByIds(arregloIds, criterioBusqueda);
20
+ }
21
+ else {
22
+ return await this.repository.findAndCount(criterioBusqueda);
23
+ }
24
+ }
25
+ async findOne(criterioBusqueda, id, esSocket = false) {
26
+ if (id) {
27
+ const encontroRegistro = await this.repository.findOne(id, criterioBusqueda);
28
+ return devolverRespuestaSiExiste(encontroRegistro, esSocket);
29
+ }
30
+ else {
31
+ const encontroRegistro = await this.repository.findOne(criterioBusqueda);
32
+ return devolverRespuestaSiExiste(encontroRegistro, esSocket);
33
+ }
34
+ }
35
+ async count(criterioBusqueda) {
36
+ return await new Promise((resolve) => {
37
+ this.repository
38
+ .count(criterioBusqueda)
39
+ .then((respuesta) => {
40
+ resolve({ registros: respuesta });
41
+ }, (error) => {
42
+ console.error('Error', error);
43
+ resolve({ error: '500', mensaje: 'Error del servidor' });
44
+ });
45
+ });
46
+ }
47
+ async create(registro) {
48
+ const registroACrearse = this.repository.create(registro);
49
+ return await this.repository.save(registroACrearse);
50
+ }
51
+ async update(criterio, datosAActualizar) {
52
+ return await this.repository.update(criterio, datosAActualizar);
53
+ }
54
+ async findOneByIdAndUpdate(id, datosAActualizar, esSocket = false) {
55
+ const registroEncontrado = await this.repository.findOne(id);
56
+ return devolverRespuestaSiExiste(registroEncontrado, esSocket, true, datosAActualizar, this);
57
+ }
58
+ delete(criterio, esSocket = false) {
59
+ return from(this.repository.delete(criterio))
60
+ .pipe(mergeMap((deleteResponse) => {
61
+ if (deleteResponse.raw) {
62
+ if (deleteResponse.raw.affectedRows === 1 && (typeof criterio === 'number' || typeof criterio === 'string')) {
63
+ const id = criterio;
64
+ return from(new Promise((resolve) => {
65
+ resolve({ mensaje: `Registro ${id} eliminado` });
66
+ }));
67
+ }
68
+ else {
69
+ if (deleteResponse.raw.affectedRows === 0) {
70
+ if (esSocket) {
71
+ return from(new Promise((resolve) => {
72
+ resolve({ error: 404, mensaje: 'No se encontro ningun registro' });
73
+ }));
74
+ }
75
+ else {
76
+ throw new NotFoundException('No se elimino ningun registro');
77
+ }
78
+ }
79
+ else {
80
+ return from(new Promise((resolve) => {
81
+ resolve(deleteResponse);
82
+ }));
83
+ }
84
+ }
85
+ }
86
+ else {
87
+ return from(new Promise((resolve) => {
88
+ resolve(deleteResponse);
89
+ }));
90
+ }
91
+ }));
92
+ }
93
+ async deleteMany(criterio) {
94
+ return await this.repository.delete(criterio);
95
+ }
96
+ queryBuilder(alias, queryRunner) {
97
+ return this.repository.createQueryBuilder(alias, queryRunner);
98
+ }
99
+ async findWhereOr(camposABuscar, skip, take, relations) {
100
+ if (this.Entidad && this.nombreRepositorio) {
101
+ const entidad = new this.Entidad();
102
+ const atributos = Object
103
+ .keys(entidad);
104
+ const todosCamposExisten = camposABuscar
105
+ .every((campo) => {
106
+ return atributos.some((atributo) => atributo === campo.campo);
107
+ });
108
+ if (todosCamposExisten) {
109
+ let query = '';
110
+ const objeto = {};
111
+ camposABuscar
112
+ .forEach((campo) => {
113
+ if (query === '') {
114
+ query = query + `entidad.${campo.campo} Like :${campo.campo}`;
115
+ objeto[campo.campo] = campo.valor;
116
+ }
117
+ else {
118
+ query = query + ` OR entidad.${campo.campo} Like :${campo.campo}`;
119
+ objeto[campo.campo] = campo.valor;
120
+ }
121
+ });
122
+ let respuesta = getRepository(this.Entidad, this.nombreRepositorio)
123
+ .createQueryBuilder('entidad')
124
+ .where(query, objeto);
125
+ if (relations) {
126
+ relations.forEach((relacion) => {
127
+ const parametros = ['entidad.' + relacion.entidad, relacion.entidad];
128
+ if (relacion.query) {
129
+ let queryRelacion = '';
130
+ const objetoRelacion = {};
131
+ relacion.query
132
+ .forEach((campoRelacion) => {
133
+ if (queryRelacion === '') {
134
+ queryRelacion = queryRelacion + `${relacion.key}.${campoRelacion.campo} = :${campoRelacion.campo}`;
135
+ objetoRelacion[campoRelacion.campo] = campoRelacion.valor;
136
+ }
137
+ else {
138
+ queryRelacion = queryRelacion + ` AND ${relacion.key}.${campoRelacion.campo} = :${campoRelacion.campo}`;
139
+ objetoRelacion[campoRelacion.campo] = campoRelacion.valor;
140
+ }
141
+ });
142
+ parametros.push(queryRelacion);
143
+ parametros.push(objetoRelacion);
144
+ respuesta = respuesta.innerJoinAndSelect(...parametros);
145
+ }
146
+ else {
147
+ respuesta = respuesta.innerJoinAndSelect(...parametros);
148
+ }
149
+ });
150
+ }
151
+ const respuestaFinal = await respuesta
152
+ .skip(skip)
153
+ .take(take)
154
+ .getManyAndCount();
155
+ return new Promise(r => r(respuestaFinal));
156
+ }
157
+ else {
158
+ return new Promise(r => r({ error: 400, mensaje: 'No envia parametros' }));
159
+ }
160
+ }
161
+ else {
162
+ return new Promise(r => r({ error: 400, mensaje: 'No envia parametros' }));
163
+ }
164
+ }
165
+ };
166
+ PrincipalService = __decorate([
167
+ Injectable()
168
+ ], PrincipalService);
169
+ export { PrincipalService };
170
+ export function devolverRespuestaSiExiste(encontroRegistro, esSocket = false, esActualizado = false, datosAActualizar, contexto) {
171
+ return new Promise((resolve, reject) => {
172
+ if (encontroRegistro) {
173
+ if (esActualizado) {
174
+ contexto.update(encontroRegistro, datosAActualizar)
175
+ .then(() => {
176
+ if (esActualizado) {
177
+ Object
178
+ .keys(datosAActualizar)
179
+ .map(propiedadActualizada => {
180
+ encontroRegistro[propiedadActualizada] = datosAActualizar[propiedadActualizada];
181
+ });
182
+ }
183
+ resolve(encontroRegistro);
184
+ })
185
+ .catch((e) => { reject(e); });
186
+ }
187
+ else {
188
+ resolve(encontroRegistro);
189
+ }
190
+ }
191
+ else {
192
+ if (esSocket) {
193
+ resolve({ error: 404, mensaje: 'No se encontro ningun registro' });
194
+ }
195
+ else {
196
+ throw new NotFoundException('No se encontro ningun registro');
197
+ }
198
+ }
199
+ });
200
+ }
201
201
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpbmNpcGFsLnNlcnZpY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvbGliL3ByaW5jaXBhbC5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUFBLE9BQU8sRUFBRSxVQUFVLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQztBQUMvRCxPQUFPLEVBQStCLGFBQWEsRUFBRSxNQUFNLFNBQVMsQ0FBQztBQU9yRSxPQUFPLEVBQUUsSUFBSSxFQUFjLE1BQU0sTUFBTSxDQUFDO0FBQ3hDLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQztBQUsxQyxJQUFhLGdCQUFnQixHQUE3QjtJQUNJLFlBQStCLFVBQXlCLEVBQVUsT0FBYSxFQUFVLGlCQUEwQjtRQUFwRixlQUFVLEdB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FDO2FBQ2pFO1NBQ0o7SUFDTCxDQUFDLENBQUMsQ0FBQztBQUNQLENBQUMifQ==
@@ -1,4 +1,4 @@
1
- import { Observable } from 'rxjs';
2
- import { PoliticasDeSeguridad } from '../interfaces-util/politicas-de-seguridad';
3
- import { ArregloFuncionesBooleanas } from '../interfaces-util/arreglo-funciones-booleanas';
4
- export declare function aplicarPoliticasDeSeguridad(tipoPoliticaSeguridad: PoliticasDeSeguridad, objetoPoliticasDeSeguridad: ArregloFuncionesBooleanas, contexto: any): Observable<boolean>;
1
+ import { Observable } from 'rxjs';
2
+ import { PoliticasDeSeguridad } from '../interfaces-util/politicas-de-seguridad';
3
+ import { ArregloFuncionesBooleanas } from '../interfaces-util/arreglo-funciones-booleanas';
4
+ export declare function aplicarPoliticasDeSeguridad(tipoPoliticaSeguridad: PoliticasDeSeguridad, objetoPoliticasDeSeguridad: ArregloFuncionesBooleanas, contexto: any): Observable<boolean>;
@@ -1,14 +1,14 @@
1
- import { of } from 'rxjs';
2
- import { mergeMap, switchMap, every } from 'rxjs/operators';
3
- import { convertirArregloEnArregloDeObservables, tieneAccesoPermitido } from './funciones';
4
- export function aplicarPoliticasDeSeguridad(tipoPoliticaSeguridad, objetoPoliticasDeSeguridad, contexto) {
5
- const arregloSeguridad$ = of(objetoPoliticasDeSeguridad.funciones);
6
- return arregloSeguridad$
7
- .pipe(switchMap((arregloFunciones) => {
8
- const arregloObservables = convertirArregloEnArregloDeObservables(arregloFunciones, tipoPoliticaSeguridad, contexto);
9
- const funcionesDeSeguridad$ = of(...arregloObservables);
10
- return funcionesDeSeguridad$
11
- .pipe(mergeMap((solucionObservable) => solucionObservable), every((solucion) => tieneAccesoPermitido(solucion, tipoPoliticaSeguridad, contexto)));
12
- }));
13
- }
1
+ import { of } from 'rxjs';
2
+ import { mergeMap, switchMap, every } from 'rxjs/operators';
3
+ import { convertirArregloEnArregloDeObservables, tieneAccesoPermitido } from './funciones';
4
+ export function aplicarPoliticasDeSeguridad(tipoPoliticaSeguridad, objetoPoliticasDeSeguridad, contexto) {
5
+ const arregloSeguridad$ = of(objetoPoliticasDeSeguridad.funciones);
6
+ return arregloSeguridad$
7
+ .pipe(switchMap((arregloFunciones) => {
8
+ const arregloObservables = convertirArregloEnArregloDeObservables(arregloFunciones, tipoPoliticaSeguridad, contexto);
9
+ const funcionesDeSeguridad$ = of(...arregloObservables);
10
+ return funcionesDeSeguridad$
11
+ .pipe(mergeMap((solucionObservable) => solucionObservable), every((solucion) => tieneAccesoPermitido(solucion, tipoPoliticaSeguridad, contexto)));
12
+ }));
13
+ }
14
14
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBsaWNhci1wb2xpdGljYXMtZGUtc2VndXJpZGFkLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL2xpYi9zZWd1cmlkYWQvYXBsaWNhci1wb2xpdGljYXMtZGUtc2VndXJpZGFkLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxFQUFFLEVBQWMsTUFBTSxNQUFNLENBQUM7QUFDdEMsT0FBTyxFQUFFLFFBQVEsRUFBRSxTQUFTLEVBQUUsS0FBSyxFQUFFLE1BQU0sZ0JBQWdCLENBQUM7QUFDNUQsT0FBTyxFQUFFLHNDQUFzQyxFQUFFLG9CQUFvQixFQUFFLE1BQU0sYUFBYSxDQUFDO0FBSTNGLE1BQU0sc0NBQ0YscUJBQTJDLEVBQzNDLDBCQUFxRCxFQUNyRCxRQUFhO0lBQ2IsTUFBTSxpQkFBaUIsR0FBRyxFQUFFLENBQUMsMEJBQTBCLENBQUMsU0FBUyxDQUFDLENBQUM7SUFDbkUsT0FBTyxpQkFBaUI7U0FDbkIsSUFBSSxDQUNELFNBQVMsQ0FBQyxDQUFDLGdCQUF1QixFQUFFLEVBQUU7UUFDbEMsTUFBTSxrQkFBa0IsR0FBRyxzQ0FBc0MsQ0FBQyxnQkFBZ0IsRUFBRSxxQkFBcUIsRUFBRSxRQUFRLENBQUMsQ0FBQztRQUNySCxNQUFNLHFCQUFxQixHQUFHLEVBQUUsQ0FBQyxHQUFHLGtCQUFrQixDQUFDLENBQUM7UUFDeEQsT0FBTyxxQkFBcUI7YUFDdkIsSUFBSSxDQUNELFFBQVEsQ0FBQyxDQUFDLGtCQUFrQixFQUFFLEVBQUUsQ0FBQyxrQkFBa0IsQ0FBQyxFQUNwRCxLQUFLLENBQUMsQ0FBQyxRQUFhLEVBQUUsRUFBRSxDQUFDLG9CQUFvQixDQUFDLFFBQVEsRUFBRSxxQkFBcUIsRUFBRSxRQUFRLENBQUMsQ0FBQyxDQUM1RixDQUFDO0lBQ1YsQ0FBQyxDQUFDLENBQ0wsQ0FBQztBQUNWLENBQUMifQ==
@@ -1,3 +1,3 @@
1
- import { Observable } from "rxjs";
2
- import { PoliticasDeSeguridad } from "../../interfaces-util/politicas-de-seguridad";
3
- export declare function convertirArregloEnArregloDeObservables(arregloFunciones: any[], tipoPoliticaSeguridad: PoliticasDeSeguridad, contexto: any): Observable<any>[];
1
+ import { Observable } from "rxjs";
2
+ import { PoliticasDeSeguridad } from "../../interfaces-util/politicas-de-seguridad";
3
+ export declare function convertirArregloEnArregloDeObservables(arregloFunciones: any[], tipoPoliticaSeguridad: PoliticasDeSeguridad, contexto: any): Observable<any>[];
@@ -1,24 +1,24 @@
1
- import { Observable, from, of } from "rxjs";
2
- export function convertirArregloEnArregloDeObservables(arregloFunciones, tipoPoliticaSeguridad, contexto) {
3
- const arregloObservables = [];
4
- arregloFunciones.forEach((funcion) => {
5
- const esFuncion = typeof funcion === 'function';
6
- if (esFuncion) {
7
- const esPromesa = typeof funcion(tipoPoliticaSeguridad, contexto).then === 'function';
8
- if (esPromesa) {
9
- const promesa = funcion(tipoPoliticaSeguridad, contexto);
10
- arregloObservables.push(from(promesa));
11
- }
12
- else {
13
- const respuesta = funcion(tipoPoliticaSeguridad, contexto);
14
- arregloObservables.push(of(respuesta));
15
- }
16
- }
17
- const esObservable = funcion instanceof Observable;
18
- if (esObservable) {
19
- arregloObservables.push(funcion);
20
- }
21
- });
22
- return arregloObservables;
23
- }
1
+ import { Observable, from, of } from "rxjs";
2
+ export function convertirArregloEnArregloDeObservables(arregloFunciones, tipoPoliticaSeguridad, contexto) {
3
+ const arregloObservables = [];
4
+ arregloFunciones.forEach((funcion) => {
5
+ const esFuncion = typeof funcion === 'function';
6
+ if (esFuncion) {
7
+ const esPromesa = typeof funcion(tipoPoliticaSeguridad, contexto).then === 'function';
8
+ if (esPromesa) {
9
+ const promesa = funcion(tipoPoliticaSeguridad, contexto);
10
+ arregloObservables.push(from(promesa));
11
+ }
12
+ else {
13
+ const respuesta = funcion(tipoPoliticaSeguridad, contexto);
14
+ arregloObservables.push(of(respuesta));
15
+ }
16
+ }
17
+ const esObservable = funcion instanceof Observable;
18
+ if (esObservable) {
19
+ arregloObservables.push(funcion);
20
+ }
21
+ });
22
+ return arregloObservables;
23
+ }
24
24
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udmVydGlyLWFycmVnbG8tZW4tYXJyZWdsby1kZS1vYnNlcnZhYmxlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy9saWIvc2VndXJpZGFkL2Z1bmNpb25lcy9jb252ZXJ0aXItYXJyZWdsby1lbi1hcnJlZ2xvLWRlLW9ic2VydmFibGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxVQUFVLEVBQUUsSUFBSSxFQUFFLEVBQUUsRUFBRSxNQUFNLE1BQU0sQ0FBQztBQUc1QyxNQUFNLGlEQUFpRCxnQkFBdUIsRUFBRSxxQkFBMkMsRUFBRSxRQUFhO0lBQ3RJLE1BQU0sa0JBQWtCLEdBQUcsRUFBRSxDQUFDO0lBRTlCLGdCQUFnQixDQUFDLE9BQU8sQ0FBQyxDQUFDLE9BQU8sRUFBRSxFQUFFO1FBQ2pDLE1BQU0sU0FBUyxHQUFHLE9BQU8sT0FBTyxLQUFLLFVBQVUsQ0FBQztRQUNoRCxJQUFJLFNBQVMsRUFBRTtZQUNYLE1BQU0sU0FBUyxHQUFHLE9BQU8sT0FBTyxDQUFDLHFCQUFxQixFQUFFLFFBQVEsQ0FBQyxDQUFDLElBQUksS0FBSyxVQUFVLENBQUM7WUFDdEYsSUFBSSxTQUFTLEVBQUU7Z0JBQ1gsTUFBTSxPQUFPLEdBQUcsT0FBTyxDQUFDLHFCQUFxQixFQUFFLFFBQVEsQ0FBQyxDQUFDO2dCQUN6RCxrQkFBa0IsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUE7YUFDekM7aUJBQU07Z0JBQ0gsTUFBTSxTQUFTLEdBQUcsT0FBTyxDQUFDLHFCQUFxQixFQUFFLFFBQVEsQ0FBQyxDQUFBO2dCQUMxRCxrQkFBa0IsQ0FBQyxJQUFJLENBQUMsRUFBRSxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUE7YUFDekM7U0FDSjtRQUNELE1BQU0sWUFBWSxHQUFHLE9BQU8sWUFBWSxVQUFVLENBQUM7UUFDbkQsSUFBSSxZQUFZLEVBQUU7WUFDZCxrQkFBa0IsQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLENBQUM7U0FDcEM7SUFDTCxDQUFDLENBQUMsQ0FBQztJQUVILE9BQU8sa0JBQWtCLENBQUM7QUFDOUIsQ0FBQyJ9
@@ -1,6 +1,6 @@
1
- import { obtenerReflectorSeguridad } from './obtener-reflector-seguridad';
2
- import { convertirArregloEnArregloDeObservables } from './convertir-arreglo-en-arreglo-de-observables';
3
- import { obtenerRequest } from './obtener-request';
4
- import { obtenerResponse } from './obtener-response';
5
- import { tieneAccesoPermitido } from './tiene-acceso-permitido';
6
- export { obtenerReflectorSeguridad, convertirArregloEnArregloDeObservables, obtenerRequest, obtenerResponse, tieneAccesoPermitido };
1
+ import { obtenerReflectorSeguridad } from './obtener-reflector-seguridad';
2
+ import { convertirArregloEnArregloDeObservables } from './convertir-arreglo-en-arreglo-de-observables';
3
+ import { obtenerRequest } from './obtener-request';
4
+ import { obtenerResponse } from './obtener-response';
5
+ import { tieneAccesoPermitido } from './tiene-acceso-permitido';
6
+ export { obtenerReflectorSeguridad, convertirArregloEnArregloDeObservables, obtenerRequest, obtenerResponse, tieneAccesoPermitido };
@@ -1,7 +1,7 @@
1
- import { obtenerReflectorSeguridad } from './obtener-reflector-seguridad';
2
- import { convertirArregloEnArregloDeObservables } from './convertir-arreglo-en-arreglo-de-observables';
3
- import { obtenerRequest } from './obtener-request';
4
- import { obtenerResponse } from './obtener-response';
5
- import { tieneAccesoPermitido } from './tiene-acceso-permitido';
6
- export { obtenerReflectorSeguridad, convertirArregloEnArregloDeObservables, obtenerRequest, obtenerResponse, tieneAccesoPermitido };
1
+ import { obtenerReflectorSeguridad } from './obtener-reflector-seguridad';
2
+ import { convertirArregloEnArregloDeObservables } from './convertir-arreglo-en-arreglo-de-observables';
3
+ import { obtenerRequest } from './obtener-request';
4
+ import { obtenerResponse } from './obtener-response';
5
+ import { tieneAccesoPermitido } from './tiene-acceso-permitido';
6
+ export { obtenerReflectorSeguridad, convertirArregloEnArregloDeObservables, obtenerRequest, obtenerResponse, tieneAccesoPermitido };
7
7
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvbGliL3NlZ3VyaWRhZC9mdW5jaW9uZXMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLHlCQUF5QixFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFDMUUsT0FBTyxFQUFFLHNDQUFzQyxFQUFFLE1BQU0sK0NBQStDLENBQUM7QUFDdkcsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQ25ELE9BQU8sRUFBRSxlQUFlLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUNyRCxPQUFPLEVBQUUsb0JBQW9CLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUVoRSxPQUFPLEVBQUUseUJBQXlCLEVBQUUsc0NBQXNDLEVBQUUsY0FBYyxFQUFFLGVBQWUsRUFBRSxvQkFBb0IsRUFBRSxDQUFBIn0=
@@ -1 +1 @@
1
- export declare function obtenerReflectorSeguridad(variableThis: any, context: any): any;
1
+ export declare function obtenerReflectorSeguridad(variableThis: any, context: any): any;