fpavon-ee-shared 1.0.59 → 1.0.60
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/dist/documentos/application/streamConversor.js +14 -0
- package/dist/expediente-electronico/infrastructure/repositories/expediente-electronico.sql.repository.js +0 -10
- package/dist/infrastructure/bd/connection.sql.js +0 -1
- package/dist/infrastructure/fileServer/fileServer.connection.d.ts +8 -0
- package/dist/infrastructure/fileServer/fileServer.connection.js +94 -0
- package/dist/infrastructure/middlewares/middleware.deslogueo.d.ts +0 -0
- package/dist/infrastructure/middlewares/middleware.deslogueo.js +1 -0
- package/expediente-electronico/infrastructure/repositories/expediente-electronico.sql.repository.ts +4 -10
- package/infrastructure/bd/connection.sql.ts +0 -1
- package/package.json +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertFileToStream = convertFileToStream;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
function convertFileToStream(file) {
|
|
6
|
+
console.log(`[MULTI-DOC] Convirtiendo file a stream: ${file.originalFilename || 'unknown'}`);
|
|
7
|
+
// Caso 1: File tiene path (multiparty)
|
|
8
|
+
if (file.path && typeof file.path === 'string') {
|
|
9
|
+
console.log(`[MULTI-DOC] Usando path del file: ${file.path}`);
|
|
10
|
+
return (0, fs_1.createReadStream)(file.path, {
|
|
11
|
+
highWaterMark: 128 * 1024 // Buffer más pequeño para múltiples archivos
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -186,7 +186,6 @@ class ExpedienteElectronicoSqlRepository {
|
|
|
186
186
|
fechaModificacion = SYSDATETIME()
|
|
187
187
|
WHERE id = @id;
|
|
188
188
|
`;
|
|
189
|
-
console.log('QUERY SHARED -> ', query);
|
|
190
189
|
const result = yield request.query(query);
|
|
191
190
|
if (result.rowsAffected[0] === 0) {
|
|
192
191
|
throw new Error("No se actualizó el expediente.");
|
|
@@ -237,7 +236,6 @@ class ExpedienteElectronicoSqlRepository {
|
|
|
237
236
|
baseQuery += ` AND JSON_VALUE(estado, '$.nombre') IN (${estados}) `;
|
|
238
237
|
}
|
|
239
238
|
if (filtro) {
|
|
240
|
-
console.log("filtro -> ", typeof filtro);
|
|
241
239
|
const consultaEscapada = escapeSQL(filtro.toLowerCase()); // Convertir a minúsculas para la búsqueda
|
|
242
240
|
const consultaCondition = `AND (
|
|
243
241
|
LOWER(CAST(titulo AS NVARCHAR(MAX))) LIKE '%${consultaEscapada}%' OR
|
|
@@ -354,7 +352,6 @@ class ExpedienteElectronicoSqlRepository {
|
|
|
354
352
|
WHERE ${baseQuery};
|
|
355
353
|
`;
|
|
356
354
|
// Ejecutar ambas consultas (expedientes y total de registros)
|
|
357
|
-
console.log("sql -> ", query);
|
|
358
355
|
const response = yield (0, connection_sql_1.getConnection)(query); // Consulta de expedientes
|
|
359
356
|
const countResponse = yield (0, connection_sql_1.getConnection)(countQuery); // Consulta de total_records
|
|
360
357
|
if (response.recordset && response.recordset.length > 0) {
|
|
@@ -659,7 +656,6 @@ class ExpedienteElectronicoSqlRepository {
|
|
|
659
656
|
baseQuery += ` AND (JSON_VALUE(EE.estado, '$.nombre') = 'finalizado') AND (JSON_VALUE(EE.estado, '$.exito') = 'false')`;
|
|
660
657
|
let query = `SELECT * ${baseQuery} ORDER BY tipo DESC OFFSET ${offset} ROWS ${limitClause}`;
|
|
661
658
|
query += ` SELECT COUNT(*) AS total_records ${baseQuery};`;
|
|
662
|
-
// console.log("QUERY getExpRechazadosRepo=> ", query);
|
|
663
659
|
const response = yield (0, connection_sql_1.getConnection)(query);
|
|
664
660
|
if (response.recordset && response.recordset.length > 0) {
|
|
665
661
|
let expedientes = response.recordset.map((expediente) => {
|
|
@@ -707,7 +703,6 @@ class ExpedienteElectronicoSqlRepository {
|
|
|
707
703
|
baseQuery += ` AND (JSON_VALUE(EE.estado, '$.nombre') = 'finalizado') AND (JSON_VALUE(EE.estado, '$.exito') = 'true')`;
|
|
708
704
|
let query = `SELECT * ${baseQuery} ORDER BY tipo DESC OFFSET ${offset} ROWS ${limitClause}`;
|
|
709
705
|
query += ` SELECT COUNT(*) AS total_records ${baseQuery};`;
|
|
710
|
-
// console.log("QUERY getExpAprobadosRepo=> ", query);
|
|
711
706
|
const response = yield (0, connection_sql_1.getConnection)(query);
|
|
712
707
|
if (response.recordset && response.recordset.length > 0) {
|
|
713
708
|
let expedientes = response.recordset.map((expediente) => {
|
|
@@ -751,7 +746,6 @@ class ExpedienteElectronicoSqlRepository {
|
|
|
751
746
|
.map((elemento) => "'" + elemento + "'")
|
|
752
747
|
.join(", ");
|
|
753
748
|
baseQuery += ` value IN (${unidades}) `;
|
|
754
|
-
// console.log("QUERY getExpTotalesRepo=> ", baseQuery);
|
|
755
749
|
const response = yield (0, connection_sql_1.getConnection)(baseQuery);
|
|
756
750
|
if (response.recordset && response.recordset.length > 0) {
|
|
757
751
|
const totalExpedientes = response.recordset[0].totalExpedientes;
|
|
@@ -782,7 +776,6 @@ class ExpedienteElectronicoSqlRepository {
|
|
|
782
776
|
)
|
|
783
777
|
)
|
|
784
778
|
)`;
|
|
785
|
-
// console.log("QUERY getExpCantidadPendientesRepo => ", baseQuery);
|
|
786
779
|
const response = yield (0, connection_sql_1.getConnection)(baseQuery);
|
|
787
780
|
if (response.recordset && response.recordset.length > 0) {
|
|
788
781
|
const totalExpedientes = response.recordset[0].totalExpedientes;
|
|
@@ -805,7 +798,6 @@ class ExpedienteElectronicoSqlRepository {
|
|
|
805
798
|
.join(", ");
|
|
806
799
|
baseQuery += ` value IN (${unidades}) `;
|
|
807
800
|
baseQuery += `AND (JSON_VALUE(EE.estado, '$.nombre') = 'finalizado' AND JSON_VALUE(EE.estado, '$.exito') = 'true')`;
|
|
808
|
-
// console.log("QUERY getExpCantidadAprobadosRepo=> ", baseQuery);
|
|
809
801
|
const response = yield (0, connection_sql_1.getConnection)(baseQuery);
|
|
810
802
|
if (response.recordset && response.recordset.length > 0) {
|
|
811
803
|
const totalExpedientes = response.recordset[0].totalExpedientes;
|
|
@@ -828,7 +820,6 @@ class ExpedienteElectronicoSqlRepository {
|
|
|
828
820
|
.join(", ");
|
|
829
821
|
baseQuery += ` value IN (${unidades}) `;
|
|
830
822
|
baseQuery += `) AND (JSON_VALUE(EE.estado, '$.nombre') = 'finalizado' AND JSON_VALUE(EE.estado, '$.exito') = 'false')`;
|
|
831
|
-
// console.log("QUERY getExpCantidadRechazadosRepo=> ", baseQuery);
|
|
832
823
|
const response = yield (0, connection_sql_1.getConnection)(baseQuery);
|
|
833
824
|
if (response.recordset && response.recordset.length > 0) {
|
|
834
825
|
const totalExpedientes = response.recordset[0].totalExpedientes;
|
|
@@ -844,7 +835,6 @@ class ExpedienteElectronicoSqlRepository {
|
|
|
844
835
|
}
|
|
845
836
|
getUnidadesPref() {
|
|
846
837
|
let query = `SELECT * FROM CodigosDeUbicacion`;
|
|
847
|
-
// console.log(query);
|
|
848
838
|
return (0, connection_sql_1.getConnection)(query).then((response) => {
|
|
849
839
|
if (response.recordset.length > 0) {
|
|
850
840
|
let res = response.recordset;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class FtpConnection {
|
|
2
|
+
private client;
|
|
3
|
+
constructor();
|
|
4
|
+
connect(host: string, user: string, password: string): Promise<void>;
|
|
5
|
+
uploadFile(localPath: string, remotePath: string): Promise<void>;
|
|
6
|
+
downloadFile(remotePath: string, localPath: string): Promise<void>;
|
|
7
|
+
disconnect(): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.FtpConnection = void 0;
|
|
27
|
+
const fs = __importStar(require("fs"));
|
|
28
|
+
class FtpConnection {
|
|
29
|
+
constructor() {
|
|
30
|
+
let Client = require('ftp');
|
|
31
|
+
this.client = new Client();
|
|
32
|
+
this.client.on('error', (err) => {
|
|
33
|
+
console.error('Error en la conexión FTP:', err);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
connect(host, user, password) {
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
this.client.on('ready', () => {
|
|
39
|
+
console.log('Conexión FTP exitosa');
|
|
40
|
+
this.client.list((err, list) => {
|
|
41
|
+
if (err)
|
|
42
|
+
throw err;
|
|
43
|
+
// console.log(list);
|
|
44
|
+
this.client.end();
|
|
45
|
+
});
|
|
46
|
+
resolve();
|
|
47
|
+
});
|
|
48
|
+
this.client.connect({
|
|
49
|
+
host: host,
|
|
50
|
+
user: user,
|
|
51
|
+
password: password
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
uploadFile(localPath, remotePath) {
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
|
+
this.client.put(localPath, remotePath, (err) => {
|
|
58
|
+
if (err) {
|
|
59
|
+
console.error('Error al subir el archivo:', err);
|
|
60
|
+
reject(err);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
console.log('Archivo subido exitosamente');
|
|
64
|
+
resolve();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
downloadFile(remotePath, localPath) {
|
|
70
|
+
console.log('Descargando..');
|
|
71
|
+
return new Promise((resolve, reject) => {
|
|
72
|
+
this.client.get(remotePath, function (err, stream) {
|
|
73
|
+
if (err) {
|
|
74
|
+
console.error('Error al descargar el archivo:');
|
|
75
|
+
reject(err);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
stream.once('close', () => {
|
|
79
|
+
console.log('Archivo descargado exitosamente');
|
|
80
|
+
stream.pipe(fs.createWriteStream(localPath));
|
|
81
|
+
resolve();
|
|
82
|
+
});
|
|
83
|
+
stream.once('end', () => {
|
|
84
|
+
console.log('La conexión se cerró sin errores.');
|
|
85
|
+
resolve();
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
disconnect() {
|
|
91
|
+
this.client.end();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.FtpConnection = FtpConnection;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/expediente-electronico/infrastructure/repositories/expediente-electronico.sql.repository.ts
CHANGED
|
@@ -223,7 +223,6 @@ export class ExpedienteElectronicoSqlRepository implements IExpedienteElectronic
|
|
|
223
223
|
fechaModificacion = SYSDATETIME()
|
|
224
224
|
WHERE id = @id;
|
|
225
225
|
`;
|
|
226
|
-
console.log('QUERY SHARED -> ', query)
|
|
227
226
|
const result = await request.query(query);
|
|
228
227
|
|
|
229
228
|
if (result.rowsAffected[0] === 0) {
|
|
@@ -298,7 +297,6 @@ export class ExpedienteElectronicoSqlRepository implements IExpedienteElectronic
|
|
|
298
297
|
}
|
|
299
298
|
|
|
300
299
|
if (filtro) {
|
|
301
|
-
console.log("filtro -> ", typeof filtro);
|
|
302
300
|
const consultaEscapada = escapeSQL(filtro.toLowerCase()); // Convertir a minúsculas para la búsqueda
|
|
303
301
|
const consultaCondition = `AND (
|
|
304
302
|
LOWER(CAST(titulo AS NVARCHAR(MAX))) LIKE '%${consultaEscapada}%' OR
|
|
@@ -440,7 +438,6 @@ export class ExpedienteElectronicoSqlRepository implements IExpedienteElectronic
|
|
|
440
438
|
`;
|
|
441
439
|
|
|
442
440
|
// Ejecutar ambas consultas (expedientes y total de registros)
|
|
443
|
-
console.log("sql -> ", query);
|
|
444
441
|
const response = await getConnection(query); // Consulta de expedientes
|
|
445
442
|
const countResponse = await getConnection(countQuery); // Consulta de total_records
|
|
446
443
|
|
|
@@ -806,7 +803,6 @@ export class ExpedienteElectronicoSqlRepository implements IExpedienteElectronic
|
|
|
806
803
|
let query = `SELECT * ${baseQuery} ORDER BY tipo DESC OFFSET ${offset} ROWS ${limitClause}`;
|
|
807
804
|
query += ` SELECT COUNT(*) AS total_records ${baseQuery};`;
|
|
808
805
|
|
|
809
|
-
// console.log("QUERY getExpRechazadosRepo=> ", query);
|
|
810
806
|
const response = await getConnection(query);
|
|
811
807
|
if (response.recordset && response.recordset.length > 0) {
|
|
812
808
|
let expedientes = response.recordset.map((expediente) => {
|
|
@@ -871,7 +867,6 @@ export class ExpedienteElectronicoSqlRepository implements IExpedienteElectronic
|
|
|
871
867
|
let query = `SELECT * ${baseQuery} ORDER BY tipo DESC OFFSET ${offset} ROWS ${limitClause}`;
|
|
872
868
|
query += ` SELECT COUNT(*) AS total_records ${baseQuery};`;
|
|
873
869
|
|
|
874
|
-
// console.log("QUERY getExpAprobadosRepo=> ", query);
|
|
875
870
|
const response = await getConnection(query);
|
|
876
871
|
if (response.recordset && response.recordset.length > 0) {
|
|
877
872
|
let expedientes = response.recordset.map((expediente) => {
|
|
@@ -927,7 +922,7 @@ export class ExpedienteElectronicoSqlRepository implements IExpedienteElectronic
|
|
|
927
922
|
.map((elemento) => "'" + elemento + "'")
|
|
928
923
|
.join(", ");
|
|
929
924
|
baseQuery += ` value IN (${unidades}) `;
|
|
930
|
-
|
|
925
|
+
|
|
931
926
|
const response = await getConnection(baseQuery);
|
|
932
927
|
if (response.recordset && response.recordset.length > 0) {
|
|
933
928
|
const totalExpedientes = response.recordset[0].totalExpedientes;
|
|
@@ -956,7 +951,7 @@ export class ExpedienteElectronicoSqlRepository implements IExpedienteElectronic
|
|
|
956
951
|
)
|
|
957
952
|
)
|
|
958
953
|
)`;
|
|
959
|
-
|
|
954
|
+
|
|
960
955
|
const response = await getConnection(baseQuery);
|
|
961
956
|
if (response.recordset && response.recordset.length > 0) {
|
|
962
957
|
const totalExpedientes = response.recordset[0].totalExpedientes;
|
|
@@ -979,7 +974,6 @@ export class ExpedienteElectronicoSqlRepository implements IExpedienteElectronic
|
|
|
979
974
|
|
|
980
975
|
baseQuery += `AND (JSON_VALUE(EE.estado, '$.nombre') = 'finalizado' AND JSON_VALUE(EE.estado, '$.exito') = 'true')`;
|
|
981
976
|
|
|
982
|
-
// console.log("QUERY getExpCantidadAprobadosRepo=> ", baseQuery);
|
|
983
977
|
const response = await getConnection(baseQuery);
|
|
984
978
|
if (response.recordset && response.recordset.length > 0) {
|
|
985
979
|
const totalExpedientes = response.recordset[0].totalExpedientes;
|
|
@@ -1000,7 +994,7 @@ export class ExpedienteElectronicoSqlRepository implements IExpedienteElectronic
|
|
|
1000
994
|
.join(", ");
|
|
1001
995
|
baseQuery += ` value IN (${unidades}) `;
|
|
1002
996
|
baseQuery += `) AND (JSON_VALUE(EE.estado, '$.nombre') = 'finalizado' AND JSON_VALUE(EE.estado, '$.exito') = 'false')`;
|
|
1003
|
-
|
|
997
|
+
|
|
1004
998
|
const response = await getConnection(baseQuery);
|
|
1005
999
|
if (response.recordset && response.recordset.length > 0) {
|
|
1006
1000
|
const totalExpedientes = response.recordset[0].totalExpedientes;
|
|
@@ -1018,7 +1012,7 @@ export class ExpedienteElectronicoSqlRepository implements IExpedienteElectronic
|
|
|
1018
1012
|
|
|
1019
1013
|
getUnidadesPref() {
|
|
1020
1014
|
let query = `SELECT * FROM CodigosDeUbicacion`;
|
|
1021
|
-
|
|
1015
|
+
|
|
1022
1016
|
return getConnection(query).then((response) => {
|
|
1023
1017
|
if (response.recordset.length > 0) {
|
|
1024
1018
|
let res = response.recordset;
|