@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,204 +1,204 @@
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
- const common_1 = require("@nestjs/common");
10
- const typeorm_1 = require("typeorm");
11
- const rxjs_1 = require("rxjs");
12
- const operators_1 = require("rxjs/operators");
13
- let PrincipalService = class PrincipalService {
14
- constructor(repository, Entidad, nombreRepositorio) {
15
- this.repository = repository;
16
- this.Entidad = Entidad;
17
- this.nombreRepositorio = nombreRepositorio;
18
- }
19
- async find(criterioBusqueda, arregloIds) {
20
- if (arregloIds) {
21
- return await this.repository.findByIds(arregloIds, criterioBusqueda);
22
- }
23
- else {
24
- return await this.repository.findAndCount(criterioBusqueda);
25
- }
26
- }
27
- async findOne(criterioBusqueda, id, esSocket = false) {
28
- if (id) {
29
- const encontroRegistro = await this.repository.findOne(id, criterioBusqueda);
30
- return devolverRespuestaSiExiste(encontroRegistro, esSocket);
31
- }
32
- else {
33
- const encontroRegistro = await this.repository.findOne(criterioBusqueda);
34
- return devolverRespuestaSiExiste(encontroRegistro, esSocket);
35
- }
36
- }
37
- async count(criterioBusqueda) {
38
- return await new Promise((resolve) => {
39
- this.repository
40
- .count(criterioBusqueda)
41
- .then((respuesta) => {
42
- resolve({ registros: respuesta });
43
- }, (error) => {
44
- console.error('Error', error);
45
- resolve({ error: '500', mensaje: 'Error del servidor' });
46
- });
47
- });
48
- }
49
- async create(registro) {
50
- const registroACrearse = this.repository.create(registro);
51
- return await this.repository.save(registroACrearse);
52
- }
53
- async update(criterio, datosAActualizar) {
54
- return await this.repository.update(criterio, datosAActualizar);
55
- }
56
- async findOneByIdAndUpdate(id, datosAActualizar, esSocket = false) {
57
- const registroEncontrado = await this.repository.findOne(id);
58
- return devolverRespuestaSiExiste(registroEncontrado, esSocket, true, datosAActualizar, this);
59
- }
60
- delete(criterio, esSocket = false) {
61
- return rxjs_1.from(this.repository.delete(criterio))
62
- .pipe(operators_1.mergeMap((deleteResponse) => {
63
- if (deleteResponse.raw) {
64
- if (deleteResponse.raw.affectedRows === 1 && (typeof criterio === 'number' || typeof criterio === 'string')) {
65
- const id = criterio;
66
- return rxjs_1.from(new Promise((resolve) => {
67
- resolve({ mensaje: `Registro ${id} eliminado` });
68
- }));
69
- }
70
- else {
71
- if (deleteResponse.raw.affectedRows === 0) {
72
- if (esSocket) {
73
- return rxjs_1.from(new Promise((resolve) => {
74
- resolve({ error: 404, mensaje: 'No se encontro ningun registro' });
75
- }));
76
- }
77
- else {
78
- throw new common_1.NotFoundException('No se elimino ningun registro');
79
- }
80
- }
81
- else {
82
- return rxjs_1.from(new Promise((resolve) => {
83
- resolve(deleteResponse);
84
- }));
85
- }
86
- }
87
- }
88
- else {
89
- return rxjs_1.from(new Promise((resolve) => {
90
- resolve(deleteResponse);
91
- }));
92
- }
93
- }));
94
- }
95
- async deleteMany(criterio) {
96
- return await this.repository.delete(criterio);
97
- }
98
- queryBuilder(alias, queryRunner) {
99
- return this.repository.createQueryBuilder(alias, queryRunner);
100
- }
101
- async findWhereOr(camposABuscar, skip, take, relations) {
102
- if (this.Entidad && this.nombreRepositorio) {
103
- const entidad = new this.Entidad();
104
- const atributos = Object
105
- .keys(entidad);
106
- const todosCamposExisten = camposABuscar
107
- .every((campo) => {
108
- return atributos.some((atributo) => atributo === campo.campo);
109
- });
110
- if (todosCamposExisten) {
111
- let query = '';
112
- const objeto = {};
113
- camposABuscar
114
- .forEach((campo) => {
115
- if (query === '') {
116
- query = query + `entidad.${campo.campo} Like :${campo.campo}`;
117
- objeto[campo.campo] = campo.valor;
118
- }
119
- else {
120
- query = query + ` OR entidad.${campo.campo} Like :${campo.campo}`;
121
- objeto[campo.campo] = campo.valor;
122
- }
123
- });
124
- let respuesta = typeorm_1.getRepository(this.Entidad, this.nombreRepositorio)
125
- .createQueryBuilder('entidad')
126
- .where(query, objeto);
127
- if (relations) {
128
- relations.forEach((relacion) => {
129
- const parametros = ['entidad.' + relacion.entidad, relacion.entidad];
130
- if (relacion.query) {
131
- let queryRelacion = '';
132
- const objetoRelacion = {};
133
- relacion.query
134
- .forEach((campoRelacion) => {
135
- if (queryRelacion === '') {
136
- queryRelacion = queryRelacion + `${relacion.key}.${campoRelacion.campo} = :${campoRelacion.campo}`;
137
- objetoRelacion[campoRelacion.campo] = campoRelacion.valor;
138
- }
139
- else {
140
- queryRelacion = queryRelacion + ` AND ${relacion.key}.${campoRelacion.campo} = :${campoRelacion.campo}`;
141
- objetoRelacion[campoRelacion.campo] = campoRelacion.valor;
142
- }
143
- });
144
- parametros.push(queryRelacion);
145
- parametros.push(objetoRelacion);
146
- respuesta = respuesta.innerJoinAndSelect(...parametros);
147
- }
148
- else {
149
- respuesta = respuesta.innerJoinAndSelect(...parametros);
150
- }
151
- });
152
- }
153
- const respuestaFinal = await respuesta
154
- .skip(skip)
155
- .take(take)
156
- .getManyAndCount();
157
- return new Promise(r => r(respuestaFinal));
158
- }
159
- else {
160
- return new Promise(r => r({ error: 400, mensaje: 'No envia parametros' }));
161
- }
162
- }
163
- else {
164
- return new Promise(r => r({ error: 400, mensaje: 'No envia parametros' }));
165
- }
166
- }
167
- };
168
- PrincipalService = __decorate([
169
- common_1.Injectable()
170
- ], PrincipalService);
171
- exports.PrincipalService = PrincipalService;
172
- function devolverRespuestaSiExiste(encontroRegistro, esSocket = false, esActualizado = false, datosAActualizar, contexto) {
173
- return new Promise((resolve, reject) => {
174
- if (encontroRegistro) {
175
- if (esActualizado) {
176
- contexto.update(encontroRegistro, datosAActualizar)
177
- .then(() => {
178
- if (esActualizado) {
179
- Object
180
- .keys(datosAActualizar)
181
- .map(propiedadActualizada => {
182
- encontroRegistro[propiedadActualizada] = datosAActualizar[propiedadActualizada];
183
- });
184
- }
185
- resolve(encontroRegistro);
186
- })
187
- .catch((e) => { reject(e); });
188
- }
189
- else {
190
- resolve(encontroRegistro);
191
- }
192
- }
193
- else {
194
- if (esSocket) {
195
- resolve({ error: 404, mensaje: 'No se encontro ningun registro' });
196
- }
197
- else {
198
- throw new common_1.NotFoundException('No se encontro ningun registro');
199
- }
200
- }
201
- });
202
- }
203
- exports.devolverRespuestaSiExiste = devolverRespuestaSiExiste;
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
+ const common_1 = require("@nestjs/common");
10
+ const typeorm_1 = require("typeorm");
11
+ const rxjs_1 = require("rxjs");
12
+ const operators_1 = require("rxjs/operators");
13
+ let PrincipalService = class PrincipalService {
14
+ constructor(repository, Entidad, nombreRepositorio) {
15
+ this.repository = repository;
16
+ this.Entidad = Entidad;
17
+ this.nombreRepositorio = nombreRepositorio;
18
+ }
19
+ async find(criterioBusqueda, arregloIds) {
20
+ if (arregloIds) {
21
+ return await this.repository.findByIds(arregloIds, criterioBusqueda);
22
+ }
23
+ else {
24
+ return await this.repository.findAndCount(criterioBusqueda);
25
+ }
26
+ }
27
+ async findOne(criterioBusqueda, id, esSocket = false) {
28
+ if (id) {
29
+ const encontroRegistro = await this.repository.findOne(id, criterioBusqueda);
30
+ return devolverRespuestaSiExiste(encontroRegistro, esSocket);
31
+ }
32
+ else {
33
+ const encontroRegistro = await this.repository.findOne(criterioBusqueda);
34
+ return devolverRespuestaSiExiste(encontroRegistro, esSocket);
35
+ }
36
+ }
37
+ async count(criterioBusqueda) {
38
+ return await new Promise((resolve) => {
39
+ this.repository
40
+ .count(criterioBusqueda)
41
+ .then((respuesta) => {
42
+ resolve({ registros: respuesta });
43
+ }, (error) => {
44
+ console.error('Error', error);
45
+ resolve({ error: '500', mensaje: 'Error del servidor' });
46
+ });
47
+ });
48
+ }
49
+ async create(registro) {
50
+ const registroACrearse = this.repository.create(registro);
51
+ return await this.repository.save(registroACrearse);
52
+ }
53
+ async update(criterio, datosAActualizar) {
54
+ return await this.repository.update(criterio, datosAActualizar);
55
+ }
56
+ async findOneByIdAndUpdate(id, datosAActualizar, esSocket = false) {
57
+ const registroEncontrado = await this.repository.findOne(id);
58
+ return devolverRespuestaSiExiste(registroEncontrado, esSocket, true, datosAActualizar, this);
59
+ }
60
+ delete(criterio, esSocket = false) {
61
+ return rxjs_1.from(this.repository.delete(criterio))
62
+ .pipe(operators_1.mergeMap((deleteResponse) => {
63
+ if (deleteResponse.raw) {
64
+ if (deleteResponse.raw.affectedRows === 1 && (typeof criterio === 'number' || typeof criterio === 'string')) {
65
+ const id = criterio;
66
+ return rxjs_1.from(new Promise((resolve) => {
67
+ resolve({ mensaje: `Registro ${id} eliminado` });
68
+ }));
69
+ }
70
+ else {
71
+ if (deleteResponse.raw.affectedRows === 0) {
72
+ if (esSocket) {
73
+ return rxjs_1.from(new Promise((resolve) => {
74
+ resolve({ error: 404, mensaje: 'No se encontro ningun registro' });
75
+ }));
76
+ }
77
+ else {
78
+ throw new common_1.NotFoundException('No se elimino ningun registro');
79
+ }
80
+ }
81
+ else {
82
+ return rxjs_1.from(new Promise((resolve) => {
83
+ resolve(deleteResponse);
84
+ }));
85
+ }
86
+ }
87
+ }
88
+ else {
89
+ return rxjs_1.from(new Promise((resolve) => {
90
+ resolve(deleteResponse);
91
+ }));
92
+ }
93
+ }));
94
+ }
95
+ async deleteMany(criterio) {
96
+ return await this.repository.delete(criterio);
97
+ }
98
+ queryBuilder(alias, queryRunner) {
99
+ return this.repository.createQueryBuilder(alias, queryRunner);
100
+ }
101
+ async findWhereOr(camposABuscar, skip, take, relations) {
102
+ if (this.Entidad && this.nombreRepositorio) {
103
+ const entidad = new this.Entidad();
104
+ const atributos = Object
105
+ .keys(entidad);
106
+ const todosCamposExisten = camposABuscar
107
+ .every((campo) => {
108
+ return atributos.some((atributo) => atributo === campo.campo);
109
+ });
110
+ if (todosCamposExisten) {
111
+ let query = '';
112
+ const objeto = {};
113
+ camposABuscar
114
+ .forEach((campo) => {
115
+ if (query === '') {
116
+ query = query + `entidad.${campo.campo} Like :${campo.campo}`;
117
+ objeto[campo.campo] = campo.valor;
118
+ }
119
+ else {
120
+ query = query + ` OR entidad.${campo.campo} Like :${campo.campo}`;
121
+ objeto[campo.campo] = campo.valor;
122
+ }
123
+ });
124
+ let respuesta = typeorm_1.getRepository(this.Entidad, this.nombreRepositorio)
125
+ .createQueryBuilder('entidad')
126
+ .where(query, objeto);
127
+ if (relations) {
128
+ relations.forEach((relacion) => {
129
+ const parametros = ['entidad.' + relacion.entidad, relacion.entidad];
130
+ if (relacion.query) {
131
+ let queryRelacion = '';
132
+ const objetoRelacion = {};
133
+ relacion.query
134
+ .forEach((campoRelacion) => {
135
+ if (queryRelacion === '') {
136
+ queryRelacion = queryRelacion + `${relacion.key}.${campoRelacion.campo} = :${campoRelacion.campo}`;
137
+ objetoRelacion[campoRelacion.campo] = campoRelacion.valor;
138
+ }
139
+ else {
140
+ queryRelacion = queryRelacion + ` AND ${relacion.key}.${campoRelacion.campo} = :${campoRelacion.campo}`;
141
+ objetoRelacion[campoRelacion.campo] = campoRelacion.valor;
142
+ }
143
+ });
144
+ parametros.push(queryRelacion);
145
+ parametros.push(objetoRelacion);
146
+ respuesta = respuesta.innerJoinAndSelect(...parametros);
147
+ }
148
+ else {
149
+ respuesta = respuesta.innerJoinAndSelect(...parametros);
150
+ }
151
+ });
152
+ }
153
+ const respuestaFinal = await respuesta
154
+ .skip(skip)
155
+ .take(take)
156
+ .getManyAndCount();
157
+ return new Promise(r => r(respuestaFinal));
158
+ }
159
+ else {
160
+ return new Promise(r => r({ error: 400, mensaje: 'No envia parametros' }));
161
+ }
162
+ }
163
+ else {
164
+ return new Promise(r => r({ error: 400, mensaje: 'No envia parametros' }));
165
+ }
166
+ }
167
+ };
168
+ PrincipalService = __decorate([
169
+ common_1.Injectable()
170
+ ], PrincipalService);
171
+ exports.PrincipalService = PrincipalService;
172
+ function devolverRespuestaSiExiste(encontroRegistro, esSocket = false, esActualizado = false, datosAActualizar, contexto) {
173
+ return new Promise((resolve, reject) => {
174
+ if (encontroRegistro) {
175
+ if (esActualizado) {
176
+ contexto.update(encontroRegistro, datosAActualizar)
177
+ .then(() => {
178
+ if (esActualizado) {
179
+ Object
180
+ .keys(datosAActualizar)
181
+ .map(propiedadActualizada => {
182
+ encontroRegistro[propiedadActualizada] = datosAActualizar[propiedadActualizada];
183
+ });
184
+ }
185
+ resolve(encontroRegistro);
186
+ })
187
+ .catch((e) => { reject(e); });
188
+ }
189
+ else {
190
+ resolve(encontroRegistro);
191
+ }
192
+ }
193
+ else {
194
+ if (esSocket) {
195
+ resolve({ error: 404, mensaje: 'No se encontro ningun registro' });
196
+ }
197
+ else {
198
+ throw new common_1.NotFoundException('No se encontro ningun registro');
199
+ }
200
+ }
201
+ });
202
+ }
203
+ exports.devolverRespuestaSiExiste = devolverRespuestaSiExiste;
204
204
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpbmNpcGFsLnNlcnZpY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvbGliL3ByaW5jaXBhbC5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7O0FBQUEsMkNBQStEO0FBQy9ELHFDQUFxRTtBQU9yRSwrQkFBd0M7QUFDeEMsOENBQTBDO0FB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WdDLEVBQUUsQ0FBQyxDQUFDO2FBQ3RFO2lCQUNJO2dCQUNELE1BQU0sSUFBSSwwQkFBaUIsQ0FBQyxnQ0FBZ0MsQ0FBQyxDQUFDO2FBQ2pFO1NBQ0o7SUFDTCxDQUFDLENBQUMsQ0FBQztBQUNQLENBQUM7QUE5QkQsOERBOEJDIn0=
@@ -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,17 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const rxjs_1 = require("rxjs");
4
- const operators_1 = require("rxjs/operators");
5
- const funciones_1 = require("./funciones");
6
- function aplicarPoliticasDeSeguridad(tipoPoliticaSeguridad, objetoPoliticasDeSeguridad, contexto) {
7
- const arregloSeguridad$ = rxjs_1.of(objetoPoliticasDeSeguridad.funciones);
8
- return arregloSeguridad$
9
- .pipe(operators_1.switchMap((arregloFunciones) => {
10
- const arregloObservables = funciones_1.convertirArregloEnArregloDeObservables(arregloFunciones, tipoPoliticaSeguridad, contexto);
11
- const funcionesDeSeguridad$ = rxjs_1.of(...arregloObservables);
12
- return funcionesDeSeguridad$
13
- .pipe(operators_1.mergeMap((solucionObservable) => solucionObservable), operators_1.every((solucion) => funciones_1.tieneAccesoPermitido(solucion, tipoPoliticaSeguridad, contexto)));
14
- }));
15
- }
16
- exports.aplicarPoliticasDeSeguridad = aplicarPoliticasDeSeguridad;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const rxjs_1 = require("rxjs");
4
+ const operators_1 = require("rxjs/operators");
5
+ const funciones_1 = require("./funciones");
6
+ function aplicarPoliticasDeSeguridad(tipoPoliticaSeguridad, objetoPoliticasDeSeguridad, contexto) {
7
+ const arregloSeguridad$ = rxjs_1.of(objetoPoliticasDeSeguridad.funciones);
8
+ return arregloSeguridad$
9
+ .pipe(operators_1.switchMap((arregloFunciones) => {
10
+ const arregloObservables = funciones_1.convertirArregloEnArregloDeObservables(arregloFunciones, tipoPoliticaSeguridad, contexto);
11
+ const funcionesDeSeguridad$ = rxjs_1.of(...arregloObservables);
12
+ return funcionesDeSeguridad$
13
+ .pipe(operators_1.mergeMap((solucionObservable) => solucionObservable), operators_1.every((solucion) => funciones_1.tieneAccesoPermitido(solucion, tipoPoliticaSeguridad, contexto)));
14
+ }));
15
+ }
16
+ exports.aplicarPoliticasDeSeguridad = aplicarPoliticasDeSeguridad;
17
17
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBsaWNhci1wb2xpdGljYXMtZGUtc2VndXJpZGFkLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL2xpYi9zZWd1cmlkYWQvYXBsaWNhci1wb2xpdGljYXMtZGUtc2VndXJpZGFkLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsK0JBQXNDO0FBQ3RDLDhDQUE0RDtBQUM1RCwyQ0FBMkY7QUFJM0YscUNBQ0kscUJBQTJDLEVBQzNDLDBCQUFxRCxFQUNyRCxRQUFhO0lBQ2IsTUFBTSxpQkFBaUIsR0FBRyxTQUFFLENBQUMsMEJBQTBCLENBQUMsU0FBUyxDQUFDLENBQUM7SUFDbkUsT0FBTyxpQkFBaUI7U0FDbkIsSUFBSSxDQUNELHFCQUFTLENBQUMsQ0FBQyxnQkFBdUIsRUFBRSxFQUFFO1FBQ2xDLE1BQU0sa0JBQWtCLEdBQUcsa0RBQXNDLENBQUMsZ0JBQWdCLEVBQUUscUJBQXFCLEVBQUUsUUFBUSxDQUFDLENBQUM7UUFDckgsTUFBTSxxQkFBcUIsR0FBRyxTQUFFLENBQUMsR0FBRyxrQkFBa0IsQ0FBQyxDQUFDO1FBQ3hELE9BQU8scUJBQXFCO2FBQ3ZCLElBQUksQ0FDRCxvQkFBUSxDQUFDLENBQUMsa0JBQWtCLEVBQUUsRUFBRSxDQUFDLGtCQUFrQixDQUFDLEVBQ3BELGlCQUFLLENBQUMsQ0FBQyxRQUFhLEVBQUUsRUFBRSxDQUFDLGdDQUFvQixDQUFDLFFBQVEsRUFBRSxxQkFBcUIsRUFBRSxRQUFRLENBQUMsQ0FBQyxDQUM1RixDQUFDO0lBQ1YsQ0FBQyxDQUFDLENBQ0wsQ0FBQztBQUNWLENBQUM7QUFqQkQsa0VBaUJDIn0=
@@ -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,27 +1,27 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const rxjs_1 = require("rxjs");
4
- function convertirArregloEnArregloDeObservables(arregloFunciones, tipoPoliticaSeguridad, contexto) {
5
- const arregloObservables = [];
6
- arregloFunciones.forEach((funcion) => {
7
- const esFuncion = typeof funcion === 'function';
8
- if (esFuncion) {
9
- const esPromesa = typeof funcion(tipoPoliticaSeguridad, contexto).then === 'function';
10
- if (esPromesa) {
11
- const promesa = funcion(tipoPoliticaSeguridad, contexto);
12
- arregloObservables.push(rxjs_1.from(promesa));
13
- }
14
- else {
15
- const respuesta = funcion(tipoPoliticaSeguridad, contexto);
16
- arregloObservables.push(rxjs_1.of(respuesta));
17
- }
18
- }
19
- const esObservable = funcion instanceof rxjs_1.Observable;
20
- if (esObservable) {
21
- arregloObservables.push(funcion);
22
- }
23
- });
24
- return arregloObservables;
25
- }
26
- exports.convertirArregloEnArregloDeObservables = convertirArregloEnArregloDeObservables;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const rxjs_1 = require("rxjs");
4
+ function convertirArregloEnArregloDeObservables(arregloFunciones, tipoPoliticaSeguridad, contexto) {
5
+ const arregloObservables = [];
6
+ arregloFunciones.forEach((funcion) => {
7
+ const esFuncion = typeof funcion === 'function';
8
+ if (esFuncion) {
9
+ const esPromesa = typeof funcion(tipoPoliticaSeguridad, contexto).then === 'function';
10
+ if (esPromesa) {
11
+ const promesa = funcion(tipoPoliticaSeguridad, contexto);
12
+ arregloObservables.push(rxjs_1.from(promesa));
13
+ }
14
+ else {
15
+ const respuesta = funcion(tipoPoliticaSeguridad, contexto);
16
+ arregloObservables.push(rxjs_1.of(respuesta));
17
+ }
18
+ }
19
+ const esObservable = funcion instanceof rxjs_1.Observable;
20
+ if (esObservable) {
21
+ arregloObservables.push(funcion);
22
+ }
23
+ });
24
+ return arregloObservables;
25
+ }
26
+ exports.convertirArregloEnArregloDeObservables = convertirArregloEnArregloDeObservables;
27
27
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udmVydGlyLWFycmVnbG8tZW4tYXJyZWdsby1kZS1vYnNlcnZhYmxlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi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0FBQyxDQUFDO1NBQ3BDO0lBQ0wsQ0FBQyxDQUFDLENBQUM7SUFFSCxPQUFPLGtCQUFrQixDQUFDO0FBQzlCLENBQUM7QUF0QkQsd0ZBc0JDIn0=
@@ -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 };