@runnerpro/backend 1.13.40 → 1.14.1
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/lib/cjs/chat/api/conversation.js +41 -0
- package/lib/cjs/db/index.js +158 -55
- package/lib/cjs/index.js +4 -1
- package/lib/cjs/types/chat/api/conversation.d.ts.map +1 -1
- package/lib/cjs/types/db/index.d.ts +12 -3
- package/lib/cjs/types/db/index.d.ts.map +1 -1
- package/lib/cjs/types/index.d.ts +2 -2
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -56,6 +56,8 @@ const conversationRoute = (_a) => {
|
|
|
56
56
|
router.get('/conversation/thumbnail/:id', (req, res, next) => getConversationThumbnail(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
|
|
57
57
|
router.get('/conversation/file/:id', (req, res, next) => getConversationFile(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
|
|
58
58
|
router.post('/conversation/send', (req, res, next) => sendMessage(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
|
|
59
|
+
router.post('/conversation/send-emoji', (req, res, next) => sendEmoji(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
|
|
60
|
+
router.delete('/conversation/emoji/:id', (req, res, next) => deleteEmoji(req, res).catch((error) => (0, index_1.err)(req, res, error, next)));
|
|
59
61
|
router.post('/conversation/send-file', uploadFile.single('file'), (req, res, next) => sendFile(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
|
|
60
62
|
router.post('/conversation/read', (req, res, next) => readMessage(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
|
|
61
63
|
};
|
|
@@ -72,6 +74,9 @@ const getConversation = (req, res, { isClient }) => __awaiter(void 0, void 0, vo
|
|
|
72
74
|
WHERE [CHAT MESSAGE].[ID CLIENTE] = ? AND (${isClient} = FALSE OR [CHAT MESSAGE].[SHOW CLIENT] = TRUE)
|
|
73
75
|
ORDER BY [CHAT MESSAGE].[DATE] DESC
|
|
74
76
|
LIMIT 100`, [idCliente]);
|
|
77
|
+
const [reacciones] = yield (0, index_1.query)('SELECT [EMOJI], [ID CHAT], [ID SENDER] FROM [CHAT MESSAGE REACCION] WHERE [ID CHAT] IN (?)', [
|
|
78
|
+
messages.map((m) => m.id),
|
|
79
|
+
]);
|
|
75
80
|
messages = messages.reverse();
|
|
76
81
|
// Si el cliente no habla español, se muestran los mensajes en el idioma del cliente. El entrenador siempre ve los mensajes en español que están en la columna [TEXT]
|
|
77
82
|
if (header.preferredLanguage !== common_1.LANGUAGES.ES && isClient) {
|
|
@@ -82,6 +87,7 @@ const getConversation = (req, res, { isClient }) => __awaiter(void 0, void 0, vo
|
|
|
82
87
|
message.reply = messages.find((m) => m.id === message.replyMessageId);
|
|
83
88
|
if (message.workoutTitlePreferredLanguage)
|
|
84
89
|
message.workoutTitle = message.workoutTitlePreferredLanguage;
|
|
90
|
+
fillReacciones(message, reacciones);
|
|
85
91
|
return message;
|
|
86
92
|
});
|
|
87
93
|
}
|
|
@@ -89,6 +95,7 @@ const getConversation = (req, res, { isClient }) => __awaiter(void 0, void 0, vo
|
|
|
89
95
|
messages = messages.map((message) => {
|
|
90
96
|
if (message.replyMessageId)
|
|
91
97
|
message.reply = messages.find((m) => m.id === message.replyMessageId);
|
|
98
|
+
fillReacciones(message, reacciones);
|
|
92
99
|
return message;
|
|
93
100
|
});
|
|
94
101
|
}
|
|
@@ -97,6 +104,9 @@ const getConversation = (req, res, { isClient }) => __awaiter(void 0, void 0, vo
|
|
|
97
104
|
if (isClient)
|
|
98
105
|
yield markReadMessage({ isClient, idCliente });
|
|
99
106
|
});
|
|
107
|
+
const fillReacciones = (message, reacciones) => {
|
|
108
|
+
message.reacciones = reacciones.filter((r) => Number(r.idChat) === Number(message.id));
|
|
109
|
+
};
|
|
100
110
|
const deleteConversationMessage = (req, res, { isClient }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
101
111
|
const { id } = req.params;
|
|
102
112
|
if (!(yield canEditOrDeleteMessage({ idMessage: id, isClient, userid: req.session.userid })))
|
|
@@ -260,6 +270,37 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, isClient }
|
|
|
260
270
|
// }
|
|
261
271
|
}
|
|
262
272
|
});
|
|
273
|
+
const sendEmoji = (req, res, { sendNotification, firebaseMessaging, isClient }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
274
|
+
const { emoji, messageId } = req.body;
|
|
275
|
+
const { userid } = req.session;
|
|
276
|
+
const idCliente = isClient ? userid : req.body.idCliente;
|
|
277
|
+
const [isClientMessage] = yield (0, index_1.query)('SELECT [ID CLIENTE] FROM [CHAT MESSAGE] WHERE [ID] = ?', [messageId]);
|
|
278
|
+
if (isClientMessage.idCliente !== idCliente)
|
|
279
|
+
return res.send({ idReaction: null });
|
|
280
|
+
const [reaction] = yield (0, index_1.query)(`INSERT INTO [CHAT MESSAGE REACCION] ([EMOJI], [ID CHAT], [ID SENDER]) VALUES (?, ?, ?) RETURNING [ID]`, [
|
|
281
|
+
emoji,
|
|
282
|
+
messageId,
|
|
283
|
+
userid,
|
|
284
|
+
]);
|
|
285
|
+
res.send({ idReaction: reaction.id });
|
|
286
|
+
if (!isClient) {
|
|
287
|
+
sendNotification({
|
|
288
|
+
firebaseMessaging,
|
|
289
|
+
idCliente,
|
|
290
|
+
body: `Rubén ha reaccionado a un mensaje '${emoji}'`,
|
|
291
|
+
screen: common_1.NOTIFICATION_SCREEN_TYPES.CHAT,
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
const deleteEmoji = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
296
|
+
const { id } = req.params;
|
|
297
|
+
const { userid } = req.session;
|
|
298
|
+
const [isUserReaction] = yield (0, index_1.query)('SELECT [ID SENDER] FROM [CHAT MESSAGE REACCION] WHERE [ID] = ?', [id]);
|
|
299
|
+
if (isUserReaction.idSender !== userid)
|
|
300
|
+
return res.send({ status: 'ok' });
|
|
301
|
+
yield (0, index_1.query)('DELETE FROM [CHAT MESSAGE REACCION] WHERE [ID] = ?', [id]);
|
|
302
|
+
res.send({ status: 'ok' });
|
|
303
|
+
});
|
|
263
304
|
const getPreferredLanguageForChat = ({ text, idCliente, isClient }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
264
305
|
const [{ preferredLanguage }] = yield (0, index_1.query)('SELECT [PREFERRED LANGUAGE] FROM [CLIENTE] WHERE [ID] = ?', [idCliente]);
|
|
265
306
|
if (preferredLanguage === common_1.LANGUAGES.ES)
|
package/lib/cjs/db/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.pool = exports.toPgArray = exports.batchQuery = exports.query = void 0;
|
|
15
|
+
exports.pool = exports.toPgArray = exports.batchQuery = exports.longRunningQuery = exports.transaction = exports.queryWithClient = exports.query = void 0;
|
|
16
16
|
const pg_1 = __importDefault(require("pg"));
|
|
17
17
|
const { Pool } = pg_1.default;
|
|
18
18
|
const pool = new Pool({
|
|
@@ -23,28 +23,52 @@ const pool = new Pool({
|
|
|
23
23
|
port: 5432,
|
|
24
24
|
max: 10,
|
|
25
25
|
idleTimeoutMillis: 30000,
|
|
26
|
-
connectionTimeoutMillis:
|
|
26
|
+
connectionTimeoutMillis: 30000, // Aumentado a 30 segundos
|
|
27
27
|
keepAlive: true,
|
|
28
|
+
keepAliveInitialDelayMillis: 0,
|
|
29
|
+
statement_timeout: 30000, // Timeout para queries
|
|
30
|
+
query_timeout: 30000,
|
|
28
31
|
});
|
|
29
32
|
exports.pool = pool;
|
|
30
33
|
pool.on('error', (err, client) => {
|
|
31
|
-
var _a;
|
|
32
|
-
// eslint-disable-next-line no-console
|
|
33
34
|
console.error('PG pool error', err);
|
|
34
|
-
|
|
35
|
-
(_a = client.release) === null || _a === void 0 ? void 0 : _a.call(client);
|
|
35
|
+
// El pool se encarga automáticamente del manejo
|
|
36
36
|
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const text = getParseQuery(queryText, values);
|
|
37
|
+
// ✅ FUNCIÓN PRINCIPAL - queryDirect (recomendada para 90% de casos)
|
|
38
|
+
const query = (queryText, values = []) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
39
|
try {
|
|
41
|
-
|
|
40
|
+
const text = getParseQuery(queryText, values);
|
|
41
|
+
const result = (yield pool.query({
|
|
42
|
+
text,
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
values: values.flat(),
|
|
45
|
+
}));
|
|
46
|
+
return (result.rows || []).map((row) => {
|
|
47
|
+
const json = Object.keys(row);
|
|
48
|
+
const aux = {};
|
|
49
|
+
json.forEach((key) => {
|
|
50
|
+
aux[camelize(key)] = row[key];
|
|
51
|
+
});
|
|
52
|
+
return aux;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
console.error('PG query error', error);
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
exports.query = query;
|
|
61
|
+
// ✅ Para casos especiales que requieren control manual de conexiones
|
|
62
|
+
const queryWithClient = (queryText, values = [], _retry = false) => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
+
let client;
|
|
64
|
+
let released = false;
|
|
65
|
+
try {
|
|
66
|
+
client = yield pool.connect();
|
|
67
|
+
const text = getParseQuery(queryText, values);
|
|
42
68
|
const result = (yield client.query({
|
|
43
69
|
text,
|
|
44
|
-
// @ts-ignore — mezcla de tipos que TS no infiere bien
|
|
45
70
|
values: values.flat(),
|
|
46
71
|
}));
|
|
47
|
-
// @ts-ignore — rows existe en runtime pero no está en el tipo Submittable
|
|
48
72
|
return (result.rows || []).map((row) => {
|
|
49
73
|
const json = Object.keys(row);
|
|
50
74
|
const aux = {};
|
|
@@ -55,30 +79,96 @@ const query = (queryText, values = [], _retry = false) => __awaiter(void 0, void
|
|
|
55
79
|
});
|
|
56
80
|
}
|
|
57
81
|
catch (error) {
|
|
58
|
-
// eslint-disable-next-line no-console
|
|
59
82
|
console.error('PG query error', error);
|
|
60
|
-
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
83
|
+
// Liberar conexión como rota si es necesario
|
|
84
|
+
if (['EPIPE', 'ECONNRESET', '57P01', 'ECONNREFUSED'].includes(error.code)) {
|
|
85
|
+
if (client) {
|
|
86
|
+
client.release(true);
|
|
87
|
+
released = true;
|
|
88
|
+
}
|
|
89
|
+
if (!_retry) {
|
|
90
|
+
yield sleep(500);
|
|
91
|
+
return queryWithClient(queryText, values, true);
|
|
92
|
+
}
|
|
67
93
|
}
|
|
68
|
-
if (!forced)
|
|
69
|
-
client.release();
|
|
70
94
|
return [];
|
|
71
95
|
}
|
|
72
96
|
finally {
|
|
97
|
+
if (client && !released) {
|
|
98
|
+
try {
|
|
99
|
+
client.release();
|
|
100
|
+
}
|
|
101
|
+
catch (releaseError) {
|
|
102
|
+
console.error('Error releasing client:', releaseError);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
exports.queryWithClient = queryWithClient;
|
|
108
|
+
// ✅ Para transacciones - función helper
|
|
109
|
+
const transaction = (callback) => __awaiter(void 0, void 0, void 0, function* () {
|
|
110
|
+
const client = yield pool.connect();
|
|
111
|
+
try {
|
|
112
|
+
yield client.query('BEGIN');
|
|
113
|
+
const result = yield callback(client);
|
|
114
|
+
yield client.query('COMMIT');
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
yield client.query('ROLLBACK');
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
client.release();
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
exports.transaction = transaction;
|
|
126
|
+
// ✅ Batch queries optimizado con queryDirect
|
|
127
|
+
const batchQuery = (queries, batchSize = 5) => __awaiter(void 0, void 0, void 0, function* () {
|
|
128
|
+
const results = [];
|
|
129
|
+
for (let i = 0; i < queries.length; i += batchSize) {
|
|
130
|
+
const batch = queries.slice(i, i + batchSize);
|
|
131
|
+
const promises = batch.map((q) => query(q.query, q.values));
|
|
73
132
|
try {
|
|
74
|
-
|
|
133
|
+
const batchResults = yield Promise.all(promises);
|
|
134
|
+
// @ts-ignore
|
|
135
|
+
results.push(...batchResults);
|
|
75
136
|
}
|
|
76
|
-
catch (
|
|
77
|
-
|
|
137
|
+
catch (error) {
|
|
138
|
+
console.error('Batch query error:', error);
|
|
139
|
+
// Continuar con el siguiente batch
|
|
78
140
|
}
|
|
79
141
|
}
|
|
142
|
+
return results;
|
|
80
143
|
});
|
|
81
|
-
exports.
|
|
144
|
+
exports.batchQuery = batchQuery;
|
|
145
|
+
// ✅ Para queries que pueden exceder el timeout normal
|
|
146
|
+
const longRunningQuery = (queryText, values = [], timeoutMs = 300000 // 5 minutos por defecto
|
|
147
|
+
) => __awaiter(void 0, void 0, void 0, function* () {
|
|
148
|
+
const client = yield pool.connect();
|
|
149
|
+
try {
|
|
150
|
+
yield client.query(`SET statement_timeout = ${timeoutMs}`);
|
|
151
|
+
const text = getParseQuery(queryText, values);
|
|
152
|
+
const result = (yield client.query({
|
|
153
|
+
text,
|
|
154
|
+
// @ts-ignore
|
|
155
|
+
values: values.flat(),
|
|
156
|
+
}));
|
|
157
|
+
return (result.rows || []).map((row) => {
|
|
158
|
+
const json = Object.keys(row);
|
|
159
|
+
const aux = {};
|
|
160
|
+
json.forEach((key) => {
|
|
161
|
+
aux[camelize(key)] = row[key];
|
|
162
|
+
});
|
|
163
|
+
return aux;
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
finally {
|
|
167
|
+
client.release();
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
exports.longRunningQuery = longRunningQuery;
|
|
171
|
+
// ✅ Funciones auxiliares sin cambios
|
|
82
172
|
const toPgArray = (arr) => {
|
|
83
173
|
if (!Array.isArray(arr) || arr.length === 0)
|
|
84
174
|
return '{}';
|
|
@@ -117,37 +207,50 @@ function camelize(str) {
|
|
|
117
207
|
})
|
|
118
208
|
.replace(/\s+/g, '');
|
|
119
209
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
210
|
+
function sleep(ms) {
|
|
211
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
212
|
+
}
|
|
213
|
+
// ✅ Manejo de cierre mejorado
|
|
214
|
+
const gracefulShutdown = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
215
|
+
console.log('Cerrando pool de conexiones...');
|
|
216
|
+
try {
|
|
217
|
+
yield pool.end();
|
|
218
|
+
console.log('PG pool cerrado correctamente');
|
|
219
|
+
}
|
|
220
|
+
catch (e) {
|
|
221
|
+
console.error('Error cerrando PG pool', e);
|
|
128
222
|
}
|
|
129
|
-
yield Promise.all(promises);
|
|
130
223
|
});
|
|
131
|
-
|
|
132
|
-
['SIGTERM', 'SIGINT', 'beforeExit'].forEach((signal) => {
|
|
133
|
-
// eslint-disable-next-line no-undef
|
|
224
|
+
['SIGTERM', 'SIGINT'].forEach((signal) => {
|
|
134
225
|
process.on(signal, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
// eslint-disable-next-line no-console
|
|
138
|
-
console.log('PG pool closed');
|
|
139
|
-
}
|
|
140
|
-
catch (e) {
|
|
141
|
-
// eslint-disable-next-line no-console
|
|
142
|
-
console.error('Error closing PG pool', e);
|
|
143
|
-
}
|
|
144
|
-
finally {
|
|
145
|
-
if (signal !== 'beforeExit')
|
|
146
|
-
process.exit(0);
|
|
147
|
-
}
|
|
226
|
+
yield gracefulShutdown();
|
|
227
|
+
process.exit(0);
|
|
148
228
|
}));
|
|
149
229
|
});
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
230
|
+
process.on('beforeExit', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
231
|
+
yield gracefulShutdown();
|
|
232
|
+
}));
|
|
233
|
+
/*
|
|
234
|
+
GUÍA DE USO:
|
|
235
|
+
|
|
236
|
+
✅ Para la mayoría de casos (90%):
|
|
237
|
+
const usuarios = await query('SELECT * FROM usuarios WHERE active = ?', [true]);
|
|
238
|
+
|
|
239
|
+
✅ Para transacciones:
|
|
240
|
+
const resultado = await transaction(async (client) => {
|
|
241
|
+
await client.query('INSERT INTO pedidos VALUES ($1, $2)', [userId, total]);
|
|
242
|
+
await client.query('UPDATE inventario SET stock = stock - $1', [cantidad]);
|
|
243
|
+
return { success: true };
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
✅ Para queries pesadas:
|
|
247
|
+
const reporte = await longRunningQuery('SELECT * FROM generate_report(?)', [month], 600000);
|
|
248
|
+
|
|
249
|
+
✅ Para lotes:
|
|
250
|
+
const results = await batchQuery([
|
|
251
|
+
{ query: 'SELECT * FROM tabla1 WHERE id = ?', values: [1] },
|
|
252
|
+
{ query: 'SELECT * FROM tabla2 WHERE name = ?', values: ['test'] }
|
|
253
|
+
]);
|
|
254
|
+
|
|
255
|
+
❌ Evitar queryWithClient a menos que sea absolutamente necesario
|
|
256
|
+
*/
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendPrompt = exports.saveResponseTime = exports.sendMessageChatToClient = exports.saveWorkoutAplication = exports.getPlanificacionPrueba7dias = exports.sendWorkoutToWatch = exports.getDefaultWorkoutImage = exports.generateShareMap = exports.reduceSizeImage = exports.getLetter = exports.getNumberByLetter = exports.appendSheet = exports.writeSheet = exports.findCellByValue = exports.readSheet = exports.NOTION_DATABASES_ID = exports.notionEditPage = exports.notionAddPage = exports.notionGetDatabase = exports.notionGetUsers = exports.getCountNotificaciones = exports.chatExposed = exports.chatApi = exports.chat = exports.getExerciseTranslatedDescription = exports.useTranslation = exports.LANGUAGES = exports.translate = exports.CHANNEL_SLACK = exports.notifySlack = exports.fetchIA = exports.err = exports.sendMail = exports.pool = exports.toPgArray = exports.batchQuery = exports.query = exports.sleep = exports.sendNotification = void 0;
|
|
3
|
+
exports.sendPrompt = exports.saveResponseTime = exports.sendMessageChatToClient = exports.saveWorkoutAplication = exports.getPlanificacionPrueba7dias = exports.sendWorkoutToWatch = exports.getDefaultWorkoutImage = exports.generateShareMap = exports.reduceSizeImage = exports.getLetter = exports.getNumberByLetter = exports.appendSheet = exports.writeSheet = exports.findCellByValue = exports.readSheet = exports.NOTION_DATABASES_ID = exports.notionEditPage = exports.notionAddPage = exports.notionGetDatabase = exports.notionGetUsers = exports.getCountNotificaciones = exports.chatExposed = exports.chatApi = exports.chat = exports.getExerciseTranslatedDescription = exports.useTranslation = exports.LANGUAGES = exports.translate = exports.CHANNEL_SLACK = exports.notifySlack = exports.fetchIA = exports.err = exports.sendMail = exports.pool = exports.toPgArray = exports.batchQuery = exports.longRunningQuery = exports.transaction = exports.queryWithClient = exports.query = exports.sleep = exports.sendNotification = void 0;
|
|
4
4
|
const sendNotification_1 = require("./sendNotification");
|
|
5
5
|
Object.defineProperty(exports, "sendNotification", { enumerable: true, get: function () { return sendNotification_1.sendNotification; } });
|
|
6
6
|
const sleep_1 = require("./sleep");
|
|
7
7
|
Object.defineProperty(exports, "sleep", { enumerable: true, get: function () { return sleep_1.sleep; } });
|
|
8
8
|
const db_1 = require("./db");
|
|
9
9
|
Object.defineProperty(exports, "query", { enumerable: true, get: function () { return db_1.query; } });
|
|
10
|
+
Object.defineProperty(exports, "queryWithClient", { enumerable: true, get: function () { return db_1.queryWithClient; } });
|
|
11
|
+
Object.defineProperty(exports, "transaction", { enumerable: true, get: function () { return db_1.transaction; } });
|
|
12
|
+
Object.defineProperty(exports, "longRunningQuery", { enumerable: true, get: function () { return db_1.longRunningQuery; } });
|
|
10
13
|
Object.defineProperty(exports, "batchQuery", { enumerable: true, get: function () { return db_1.batchQuery; } });
|
|
11
14
|
Object.defineProperty(exports, "toPgArray", { enumerable: true, get: function () { return db_1.toPgArray; } });
|
|
12
15
|
Object.defineProperty(exports, "pool", { enumerable: true, get: function () { return db_1.pool; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAyBpD,CAAC;AAgfF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import postgresql from 'pg';
|
|
2
2
|
declare const pool: postgresql.Pool;
|
|
3
|
-
declare const query: (queryText: string, values?: (string | number | boolean)[]
|
|
3
|
+
declare const query: (queryText: string, values?: (string | number | boolean)[]) => Promise<any>;
|
|
4
|
+
declare const queryWithClient: (queryText: string, values?: (string | number | boolean)[], _retry?: boolean) => any;
|
|
5
|
+
declare const transaction: (callback: (client: any) => Promise<any>) => Promise<any>;
|
|
6
|
+
declare const batchQuery: (queries: any[], batchSize?: number) => Promise<any[]>;
|
|
7
|
+
declare const longRunningQuery: (queryText: string, values?: (string | number | boolean)[], timeoutMs?: number) => Promise<any>;
|
|
4
8
|
declare const toPgArray: (arr: string[]) => string;
|
|
5
|
-
|
|
6
|
-
|
|
9
|
+
export { query, // ⭐ Función principal (queryDirect)
|
|
10
|
+
queryWithClient, // Para casos especiales
|
|
11
|
+
transaction, // Para transacciones
|
|
12
|
+
longRunningQuery, // Para queries pesadas
|
|
13
|
+
batchQuery, // Para lotes
|
|
14
|
+
toPgArray, // Utilidad
|
|
15
|
+
pool, };
|
|
7
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/db/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,IAAI,CAAC;AAI5B,QAAA,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/db/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,IAAI,CAAC;AAI5B,QAAA,MAAM,IAAI,iBAaR,CAAC;AAQH,QAAA,MAAM,KAAK,cAAqB,MAAM,WAAU,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,iBAsB5E,CAAC;AAGF,QAAA,MAAM,eAAe,cAAqB,MAAM,WAAU,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,0BA+CtF,CAAC;AAGF,QAAA,MAAM,WAAW,sBAA6B,GAAG,KAAK,QAAQ,GAAG,CAAC,iBAajE,CAAC;AAGF,QAAA,MAAM,UAAU,YAAmB,GAAG,EAAE,uCAkBvC,CAAC;AAGF,QAAA,MAAM,gBAAgB,cACT,MAAM,WACT,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,qCAyBtC,CAAC;AAGF,QAAA,MAAM,SAAS,QAAS,MAAM,EAAE,WAM/B,CAAC;AA0DF,OAAO,EACL,KAAK,EAAE,oCAAoC;AAC3C,eAAe,EAAE,wBAAwB;AACzC,WAAW,EAAE,qBAAqB;AAClC,gBAAgB,EAAE,uBAAuB;AACzC,UAAU,EAAE,aAAa;AACzB,SAAS,EAAE,WAAW;AACtB,IAAI,GACL,CAAC"}
|
package/lib/cjs/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { sendNotification } from './sendNotification';
|
|
2
2
|
import { sleep } from './sleep';
|
|
3
|
-
import { query, batchQuery, toPgArray, pool } from './db';
|
|
3
|
+
import { query, queryWithClient, transaction, longRunningQuery, batchQuery, toPgArray, pool } from './db';
|
|
4
4
|
import { sendMail } from './sendMail';
|
|
5
5
|
import { err } from './err';
|
|
6
6
|
import { fetchIA } from './fetch/fetchIA';
|
|
@@ -18,5 +18,5 @@ import { saveWorkoutAplication } from './workout/saveWorkoutAplication';
|
|
|
18
18
|
import { sendMessageChatToClient } from './chat/sendMessageChatToClient';
|
|
19
19
|
import { saveResponseTime } from './chat/saveResponseTime';
|
|
20
20
|
import { sendPrompt } from './prompt';
|
|
21
|
-
export { sendNotification, sleep, query, batchQuery, toPgArray, pool, sendMail, err, fetchIA, notifySlack, CHANNEL_SLACK, translate, LANGUAGES, useTranslation, getExerciseTranslatedDescription, chat, chatApi, chatExposed, getCountNotificaciones, notionGetUsers, notionGetDatabase, notionAddPage, notionEditPage, NOTION_DATABASES_ID, readSheet, findCellByValue, writeSheet, appendSheet, getNumberByLetter, getLetter, reduceSizeImage, generateShareMap, getDefaultWorkoutImage, sendWorkoutToWatch, getPlanificacionPrueba7dias, saveWorkoutAplication, sendMessageChatToClient, saveResponseTime, sendPrompt, };
|
|
21
|
+
export { sendNotification, sleep, query, queryWithClient, transaction, longRunningQuery, batchQuery, toPgArray, pool, sendMail, err, fetchIA, notifySlack, CHANNEL_SLACK, translate, LANGUAGES, useTranslation, getExerciseTranslatedDescription, chat, chatApi, chatExposed, getCountNotificaciones, notionGetUsers, notionGetDatabase, notionAddPage, notionEditPage, NOTION_DATABASES_ID, readSheet, findCellByValue, writeSheet, appendSheet, getNumberByLetter, getLetter, reduceSizeImage, generateShareMap, getDefaultWorkoutImage, sendWorkoutToWatch, getPlanificacionPrueba7dias, saveWorkoutAplication, sendMessageChatToClient, saveResponseTime, sendPrompt, };
|
|
22
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../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