@runnerpro/backend 1.6.6 → 1.6.8

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.
@@ -50,19 +50,18 @@ const conversationRoute = (_a) => {
50
50
  router.post('/conversation/send', (req, res, next) => sendMessage(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
51
51
  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)));
52
52
  router.post('/conversation/read', (req, res, next) => readMessage(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
53
- router.post('/conversation/read-feelings', (req, res, next) => readFeelings(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
54
53
  };
55
54
  exports.conversationRoute = conversationRoute;
56
55
  const getConversation = (req, res, { query, isClient }) => __awaiter(void 0, void 0, void 0, function* () {
57
56
  const idCliente = isClient ? req.session.userid : req.query.id;
58
57
  const [header] = yield query('SELECT [NAME], [PREFERRED LANGUAGE] FROM [CLIENTE] WHERE [ID] = ?', [idCliente]);
59
- let messages = yield query(`SELECT [CHAT MESSAGE].*,
60
- [WORKOUT].[DATE] AS [WORKOUT DATE], [WORKOUT].[TYPE] AS [WORKOUT TYPE], [WORKOUT].[TITLE] AS [WORKOUT TITLE],
61
- [WORKOUT].[PHOTO URL SHARE] AS [WORKOUT PHOTO URL SHARE], [FEELINGS], [FEELINGS DESCRIPTION]
62
- FROM [CHAT MESSAGE]
63
- LEFT JOIN [WORKOUT] ON [WORKOUT].[ID] = [CHAT MESSAGE].[ID WORKOUT]
64
- WHERE [CHAT MESSAGE].[ID CLIENTE] = ? AND (${isClient} = FALSE OR [CHAT MESSAGE].[SHOW CLIENT] = TRUE)
65
- ORDER BY [CHAT MESSAGE].[DATE] DESC
58
+ let messages = yield query(`SELECT [CHAT MESSAGE].*,
59
+ [WORKOUT].[DATE] AS [WORKOUT DATE], [WORKOUT].[TYPE] AS [WORKOUT TYPE], [WORKOUT].[TITLE] AS [WORKOUT TITLE],
60
+ [WORKOUT].[PHOTO URL SHARE] AS [WORKOUT PHOTO URL SHARE], [FEELINGS], [FEELINGS DESCRIPTION]
61
+ FROM [CHAT MESSAGE]
62
+ LEFT JOIN [WORKOUT] ON [WORKOUT].[ID] = [CHAT MESSAGE].[ID WORKOUT]
63
+ WHERE [CHAT MESSAGE].[ID CLIENTE] = ? AND (${isClient} = FALSE OR [CHAT MESSAGE].[SHOW CLIENT] = TRUE)
64
+ ORDER BY [CHAT MESSAGE].[DATE] DESC
66
65
  LIMIT 100`, [idCliente]);
67
66
  messages = messages.reverse();
68
67
  // 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]
@@ -294,13 +293,6 @@ const orientationImage = (data, filePath, image = null, mimetype) => __awaiter(v
294
293
  }
295
294
  return image.getBufferAsync(jimp_1.default.MIME_JPEG);
296
295
  });
297
- const readFeelings = (req, res, { query, isClient }) => __awaiter(void 0, void 0, void 0, function* () {
298
- const { id } = req.body;
299
- if (!isClient) {
300
- yield query('UPDATE [CHAT MESSAGE] SET [READ FEELINGS] = TRUE WHERE [ID] = ?', [id]);
301
- }
302
- res.send({ status: 'ok' });
303
- });
304
296
  const saveResponseTime = ({ query, isClient, idCliente }) => __awaiter(void 0, void 0, void 0, function* () {
305
297
  if (isClient)
306
298
  return;
@@ -308,11 +300,11 @@ const saveResponseTime = ({ query, isClient, idCliente }) => __awaiter(void 0, v
308
300
  let firstNotReadMessage;
309
301
  // eslint-disable-next-line no-constant-condition
310
302
  while (true) {
311
- const [lastMessage] = yield query(`
312
- SELECT * FROM [CHAT MESSAGE]
313
- WHERE [ID CLIENTE] = ? AND [ID] < ?
314
- ORDER BY [DATE] DESC
315
- LIMIT 1
303
+ const [lastMessage] = yield query(`
304
+ SELECT * FROM [CHAT MESSAGE]
305
+ WHERE [ID CLIENTE] = ? AND [ID] < ?
306
+ ORDER BY [DATE] DESC
307
+ LIMIT 1
316
308
  `, [idCliente, (lastNotReadMessage === null || lastNotReadMessage === void 0 ? void 0 : lastNotReadMessage.id) || 2147483646]);
317
309
  // Si no hay más mensajes || el mensaje no es del cliente || ya tiene tiempo de respuesta => salimos del bucle
318
310
  if (!lastMessage || (lastMessage.idSender && lastMessage.idCliente !== lastMessage.idSender) || lastMessage.tiempoRespuesta)
@@ -32,18 +32,18 @@ const getList = (req, res, { query, isClient }) => __awaiter(void 0, void 0, voi
32
32
  else {
33
33
  const { page } = req.query;
34
34
  const limit = 20;
35
- const list = yield query(`
36
- SELECT [C].[ID], [C].[NAME],
37
- [CM].[DATE], [CM].[TEXT],
38
- CASE WHEN [CM].[READ] = FALSE AND [CM].[ID SENDER] = [CM].[ID CLIENTE] THEN 0
39
- ELSE 1 END AS [READ]
40
- FROM [CLIENTE] AS [C]
41
- LEFT JOIN (
42
- SELECT *, ROW_NUMBER() OVER (PARTITION BY [ID CLIENTE] ORDER BY [DATE] DESC) AS [ROW]
43
- FROM [CHAT MESSAGE]
44
- ) AS [CM] ON [CM].[ID CLIENTE] = [C].[ID] AND [CM].[ROW] = 1
45
- ORDER BY CASE WHEN [CM].[DATE] IS NULL THEN 1 ELSE 0 END, [CM].[DATE] DESC
46
- LIMIT ? OFFSET ?
35
+ const list = yield query(`
36
+ SELECT [C].[ID], [C].[NAME],
37
+ [CM].[DATE], [CM].[TEXT],
38
+ CASE WHEN [CM].[READ] = FALSE AND [CM].[ID SENDER] = [CM].[ID CLIENTE] THEN 0
39
+ ELSE 1 END AS [READ]
40
+ FROM [CLIENTE] AS [C]
41
+ LEFT JOIN (
42
+ SELECT *, ROW_NUMBER() OVER (PARTITION BY [ID CLIENTE] ORDER BY [DATE] DESC) AS [ROW]
43
+ FROM [CHAT MESSAGE]
44
+ ) AS [CM] ON [CM].[ID CLIENTE] = [C].[ID] AND [CM].[ROW] = 1
45
+ ORDER BY CASE WHEN [CM].[DATE] IS NULL THEN 1 ELSE 0 END, [CM].[DATE] DESC
46
+ LIMIT ? OFFSET ?
47
47
  `, [limit, limit * page]);
48
48
  res.send(list);
49
49
  }
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.sendChatMessage = exports.getCountNotificaciones = exports.chatExposed = exports.chatApi = exports.chat = void 0;
6
+ exports.getCountNotificaciones = exports.chatExposed = exports.chatApi = exports.chat = void 0;
7
7
  const socket_io_1 = __importDefault(require("socket.io"));
8
8
  const axios_1 = __importDefault(require("axios"));
9
9
  const getRoom_1 = require("./utils/getRoom");
@@ -14,8 +14,6 @@ const exposed_1 = require("./exposed");
14
14
  Object.defineProperty(exports, "chatExposed", { enumerable: true, get: function () { return exposed_1.chatExposed; } });
15
15
  const getCountNotificaciones_1 = require("./utils/getCountNotificaciones");
16
16
  Object.defineProperty(exports, "getCountNotificaciones", { enumerable: true, get: function () { return getCountNotificaciones_1.getCountNotificaciones; } });
17
- const sendChatMessage_1 = require("./utils/sendChatMessage");
18
- Object.defineProperty(exports, "sendChatMessage", { enumerable: true, get: function () { return sendChatMessage_1.sendChatMessage; } });
19
17
  const chat = ({ server, app, verify_access_token, tokenExposed, backendExtremeUrl, frontendUrl, isClient }) => {
20
18
  // @ts-ignore
21
19
  const io = (0, socket_io_1.default)(server, {
@@ -12,22 +12,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getCountNotificaciones = void 0;
13
13
  const getCountNotificaciones = ({ query, isClient, idClient }) => __awaiter(void 0, void 0, void 0, function* () {
14
14
  if (isClient) {
15
- const [{ chat }] = yield query(`
16
- SELECT COUNT([ID]) AS [CHAT]
17
- FROM [CHAT MESSAGE]
18
- WHERE [ID CLIENTE] = ? AND [READ] = FALSE AND [ID SENDER] != [ID CLIENTE]
15
+ const [{ chat }] = yield query(`
16
+ SELECT COUNT([ID]) AS [CHAT]
17
+ FROM [CHAT MESSAGE]
18
+ WHERE [ID CLIENTE] = ? AND [READ] = FALSE AND [ID SENDER] != [ID CLIENTE]
19
19
  `, [idClient]);
20
20
  return chat;
21
21
  }
22
22
  else {
23
- const [{ chat }] = yield query(`
24
- SELECT COUNT([C].[ID]) AS [CHAT]
25
- FROM [CLIENTE] AS [C]
26
- LEFT JOIN (
27
- SELECT *, ROW_NUMBER() OVER (PARTITION BY [ID CLIENTE] ORDER BY [DATE] DESC) AS [ROW]
28
- FROM [CHAT MESSAGE]
29
- ) AS [CM] ON [CM].[ID CLIENTE] = [C].[ID] AND [CM].[ROW] = 1
30
- WHERE [CM].[READ] = FALSE AND [CM].[ID SENDER] = [CM].[ID CLIENTE]
23
+ const [{ chat }] = yield query(`
24
+ SELECT COUNT([C].[ID]) AS [CHAT]
25
+ FROM [CLIENTE] AS [C]
26
+ LEFT JOIN (
27
+ SELECT *, ROW_NUMBER() OVER (PARTITION BY [ID CLIENTE] ORDER BY [DATE] DESC) AS [ROW]
28
+ FROM [CHAT MESSAGE]
29
+ ) AS [CM] ON [CM].[ID CLIENTE] = [C].[ID] AND [CM].[ROW] = 1
30
+ WHERE [CM].[READ] = FALSE AND [CM].[ID SENDER] = [CM].[ID CLIENTE]
31
31
  `);
32
32
  return chat;
33
33
  }
@@ -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.toPgArray = exports.batchQuery = 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({
@@ -22,7 +22,6 @@ const pool = new Pool({
22
22
  host: process.env.DB_HOST,
23
23
  port: 5432,
24
24
  });
25
- exports.pool = pool;
26
25
  const query = (queryText, values = []) => __awaiter(void 0, void 0, void 0, function* () {
27
26
  const client = yield pool.connect();
28
27
  const text = getParseQuery(queryText, values);
package/lib/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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.sendChatMessage = 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.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.toPgArray = exports.batchQuery = 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");
@@ -9,7 +9,6 @@ const db_1 = require("./db");
9
9
  Object.defineProperty(exports, "query", { enumerable: true, get: function () { return db_1.query; } });
10
10
  Object.defineProperty(exports, "batchQuery", { enumerable: true, get: function () { return db_1.batchQuery; } });
11
11
  Object.defineProperty(exports, "toPgArray", { enumerable: true, get: function () { return db_1.toPgArray; } });
12
- Object.defineProperty(exports, "pool", { enumerable: true, get: function () { return db_1.pool; } });
13
12
  const sendMail_1 = require("./sendMail");
14
13
  Object.defineProperty(exports, "sendMail", { enumerable: true, get: function () { return sendMail_1.sendMail; } });
15
14
  const err_1 = require("./err");
@@ -29,7 +28,6 @@ Object.defineProperty(exports, "chat", { enumerable: true, get: function () { re
29
28
  Object.defineProperty(exports, "chatApi", { enumerable: true, get: function () { return chat_1.chatApi; } });
30
29
  Object.defineProperty(exports, "chatExposed", { enumerable: true, get: function () { return chat_1.chatExposed; } });
31
30
  Object.defineProperty(exports, "getCountNotificaciones", { enumerable: true, get: function () { return chat_1.getCountNotificaciones; } });
32
- Object.defineProperty(exports, "sendChatMessage", { enumerable: true, get: function () { return chat_1.sendChatMessage; } });
33
31
  const notion_1 = require("./notion");
34
32
  Object.defineProperty(exports, "notionGetUsers", { enumerable: true, get: function () { return notion_1.notionGetUsers; } });
35
33
  Object.defineProperty(exports, "notionGetDatabase", { enumerable: true, get: function () { return notion_1.notionGetDatabase; } });
@@ -45,72 +45,72 @@ const sendMail = ({ subject, title, body, to, link, attachments, bcc }) => __awa
45
45
  });
46
46
  exports.sendMail = sendMail;
47
47
  function getBodyHTML(title, body, link) {
48
- return `
49
- <html lang="es">
50
- <head>
51
- <meta charset="UTF-8">
52
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
53
- <title>Correo con estilo</title>
54
- <style>
55
- /* Estilos generales */
56
- body {
57
- margin: 0;
58
- padding: 0;
59
- }
60
-
61
- /* Estilos específicos del botón */
62
- .button {
63
- display: inline-block;
64
- padding: 12px 26px;
65
- font-size: 17px;
66
- text-align: center;
67
- text-decoration: none;
68
- background-color: #ea5b1b;
69
- color: #ffffff !important;
70
- margin: 40px 0 20px 0;
71
- font-family: 'Sofia Sans', 'Roboto', sans-serif;
72
- font-weight: bold;
73
- border-radius: 4px;
74
- border: 2px solid #ea5b1b;
75
- }
76
- </style>
77
- </head>
78
- <body style="background: #f0f0f0; padding: 0 0 40px 0">
79
- <table role="presentation" style="width:100%;border-collapse:collapse;border:0;border-spacing:0;background:#f0f0f0">
80
- <tr>
81
- <td align="center" style="padding:0;">
82
- <table role="presentation" style="width:100%;border-collapse:collapse;border-spacing:0;text-align:left;">
83
- <tr>
84
- <td align="center" style="padding:5px 0 0 0;background:#ea5b1b;">
85
- <img src="cid:logo" alt="" width="220" style="height:auto;display:block;">
86
- </td>
87
- </tr>
88
- <tr>
89
- <td style="padding:20px 24px 0px 24px; max-width: 600px" align="center">
90
- <h1 style="font-size:22px;text-align:center;margin:16px 0 6px 0;font-family:'Sofia Sans', 'Roboto', sans-serif;font-style: italic">
91
- ${title || ''}
92
- </h1>
93
- <p style="text-align:left;margin:0 0 12px 0;font-size:15px;line-height:24px;font-family:'Sofia Sans', 'Roboto', sans-serif;">
94
- ${body.split('\n').join('<br>')}
95
- </p>
48
+ return `
49
+ <html lang="es">
50
+ <head>
51
+ <meta charset="UTF-8">
52
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
53
+ <title>Correo con estilo</title>
54
+ <style>
55
+ /* Estilos generales */
56
+ body {
57
+ margin: 0;
58
+ padding: 0;
59
+ }
60
+
61
+ /* Estilos específicos del botón */
62
+ .button {
63
+ display: inline-block;
64
+ padding: 12px 26px;
65
+ font-size: 17px;
66
+ text-align: center;
67
+ text-decoration: none;
68
+ background-color: #ea5b1b;
69
+ color: #ffffff !important;
70
+ margin: 40px 0 20px 0;
71
+ font-family: 'Sofia Sans', 'Roboto', sans-serif;
72
+ font-weight: bold;
73
+ border-radius: 4px;
74
+ border: 2px solid #ea5b1b;
75
+ }
76
+ </style>
77
+ </head>
78
+ <body style="background: #f0f0f0; padding: 0 0 40px 0">
79
+ <table role="presentation" style="width:100%;border-collapse:collapse;border:0;border-spacing:0;background:#f0f0f0">
80
+ <tr>
81
+ <td align="center" style="padding:0;">
82
+ <table role="presentation" style="width:100%;border-collapse:collapse;border-spacing:0;text-align:left;">
83
+ <tr>
84
+ <td align="center" style="padding:5px 0 0 0;background:#ea5b1b;">
85
+ <img src="cid:logo" alt="" width="220" style="height:auto;display:block;">
86
+ </td>
87
+ </tr>
88
+ <tr>
89
+ <td style="padding:20px 24px 0px 24px; max-width: 600px" align="center">
90
+ <h1 style="font-size:22px;text-align:center;margin:16px 0 6px 0;font-family:'Sofia Sans', 'Roboto', sans-serif;font-style: italic">
91
+ ${title || ''}
92
+ </h1>
93
+ <p style="text-align:left;margin:0 0 12px 0;font-size:15px;line-height:24px;font-family:'Sofia Sans', 'Roboto', sans-serif;">
94
+ ${body.split('\n').join('<br>')}
95
+ </p>
96
96
  ${link
97
- ? `
98
- <table role="presentation" style="width:100%;border-collapse:collapse;border:0;border-spacing:0;background:#f0f0f0;">
99
- <tr>
100
- <td align="center" style="padding:0;">
101
- <a href="${link.external ? '' : process.env.FRONTEND_URL}${link.url}" class="button" style="color:white">${link.text}</a>
102
- </td>
103
- </tr>
104
- </table>
97
+ ? `
98
+ <table role="presentation" style="width:100%;border-collapse:collapse;border:0;border-spacing:0;background:#f0f0f0;">
99
+ <tr>
100
+ <td align="center" style="padding:0;">
101
+ <a href="${link.external ? '' : process.env.FRONTEND_URL}${link.url}" class="button" style="color:white">${link.text}</a>
102
+ </td>
103
+ </tr>
104
+ </table>
105
105
  `
106
- : ''}
107
- </td>
108
- </tr>
109
- </table>
110
- </td>
111
- </tr>
112
- </table>
113
- </body>
114
- </html>
106
+ : ''}
107
+ </td>
108
+ </tr>
109
+ </table>
110
+ </td>
111
+ </tr>
112
+ </table>
113
+ </body>
114
+ </html>
115
115
  `;
116
116
  }
@@ -11,12 +11,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.sendNotification = void 0;
13
13
  const index_1 = require("../db/index");
14
- const { getMessaging } = require('firebase-admin/messaging');
15
- const sendNotification = ({ idCliente, title, body }) => __awaiter(void 0, void 0, void 0, function* () {
16
- const messaging = getMessaging();
14
+ const sendNotification = ({ firebaseMessaging, idCliente, title, body }) => __awaiter(void 0, void 0, void 0, function* () {
17
15
  const devices = yield (0, index_1.query)('SELECT [SUBSCRIPTION], [TYPE] FROM [PUSH MANAGER] WHERE [ID CLIENTE] = ?', [idCliente]);
18
16
  for (const device of devices) {
19
- notificationWEB(messaging, {
17
+ notificationWEB(firebaseMessaging, {
20
18
  title,
21
19
  body,
22
20
  }, device.subscription);
@@ -1 +1 @@
1
- {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAmBpD,CAAC;AAiTF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAkBpD,CAAC;AA0SF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -1,7 +1,6 @@
1
1
  import { chatApi } from './api';
2
2
  import { chatExposed } from './exposed';
3
3
  import { getCountNotificaciones } from './utils/getCountNotificaciones';
4
- import { sendChatMessage } from './utils/sendChatMessage';
5
4
  declare const chat: ({ server, app, verify_access_token, tokenExposed, backendExtremeUrl, frontendUrl, isClient }: {
6
5
  server: any;
7
6
  app: any;
@@ -11,5 +10,5 @@ declare const chat: ({ server, app, verify_access_token, tokenExposed, backendEx
11
10
  frontendUrl: any;
12
11
  isClient: any;
13
12
  }) => void;
14
- export { chat, chatApi, chatExposed, getCountNotificaciones, sendChatMessage };
13
+ export { chat, chatApi, chatExposed, getCountNotificaciones };
15
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/chat/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,QAAA,MAAM,IAAI;;;;;;;;UA8BT,CAAC;AAEF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/chat/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE,QAAA,MAAM,IAAI;;;;;;;;UA8BT,CAAC;AAEF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC"}
@@ -1,7 +1,5 @@
1
- import postgresql from 'pg';
2
- declare const pool: postgresql.Pool;
3
1
  declare const query: (queryText: string, values?: (string | number | boolean)[]) => Promise<any>;
4
2
  declare const toPgArray: (arr: string[]) => string;
5
3
  declare const batchQuery: (queries: any, length?: number) => Promise<void>;
6
- export { query, batchQuery, toPgArray, pool };
4
+ export { query, batchQuery, toPgArray };
7
5
  //# 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,iBAMR,CAAC;AAEH,QAAA,MAAM,KAAK,cAAqB,MAAM,WAAU,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,iBAsB5E,CAAC;AAEF,QAAA,MAAM,SAAS,QAAS,MAAM,EAAE,WAM/B,CAAC;AA+BF,QAAA,MAAM,UAAU,YAAmB,GAAG,mCAUrC,CAAC;AAEF,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/db/index.ts"],"names":[],"mappings":"AAYA,QAAA,MAAM,KAAK,cAAqB,MAAM,WAAU,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,iBAsB5E,CAAC;AAEF,QAAA,MAAM,SAAS,QAAS,MAAM,EAAE,WAM/B,CAAC;AA+BF,QAAA,MAAM,UAAU,YAAmB,GAAG,mCAUrC,CAAC;AAEF,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC"}
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
- declare const generateShareMap: (image: any, idWorkout: any, options: any) => Promise<Buffer>;
1
+ declare const generateShareMap: (image: any, idWorkout: any, options: any) => Promise<any>;
3
2
  export { generateShareMap, };
4
3
  //# sourceMappingURL=generateShareMap.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generateShareMap.d.ts","sourceRoot":"","sources":["../../../../src/image/generateShareMap.ts"],"names":[],"mappings":";AAcA,QAAA,MAAM,gBAAgB,+DAkBrB,CAAC;AA0HF,OAAO,EACL,gBAAgB,GACjB,CAAC"}
1
+ {"version":3,"file":"generateShareMap.d.ts","sourceRoot":"","sources":["../../../../src/image/generateShareMap.ts"],"names":[],"mappings":"AAcA,QAAA,MAAM,gBAAgB,4DAkBrB,CAAC;AA0HF,OAAO,EACL,gBAAgB,GACjB,CAAC"}
@@ -1,16 +1,16 @@
1
1
  import { sendNotification } from './sendNotification';
2
2
  import { sleep } from './sleep';
3
- import { query, batchQuery, toPgArray, pool } from './db';
3
+ import { query, batchQuery, toPgArray } from './db';
4
4
  import { sendMail } from './sendMail';
5
5
  import { err } from './err';
6
6
  import { fetchIA } from './fetch/fetchIA';
7
7
  import { notifySlack, CHANNEL_SLACK } from './slack';
8
8
  import { translate, LANGUAGES, useTranslation, getExerciseTranslatedDescription } from './translation';
9
- import { chat, chatApi, chatExposed, getCountNotificaciones, sendChatMessage } from './chat';
9
+ import { chat, chatApi, chatExposed, getCountNotificaciones } from './chat';
10
10
  import { notionGetUsers, notionGetDatabase, notionAddPage, notionEditPage, NOTION_DATABASES_ID } from './notion';
11
11
  import { readSheet, findCellByValue, writeSheet, appendSheet, getNumberByLetter, getLetter } from './googleSheet';
12
12
  import { reduceSizeImage } from './image/reduceSizeImage';
13
13
  import { generateShareMap } from './image/generateShareMap';
14
14
  import { getDefaultWorkoutImage } from './image/getDefaultWorkoutImage';
15
- export { sendNotification, sleep, query, batchQuery, toPgArray, pool, sendMail, err, fetchIA, notifySlack, CHANNEL_SLACK, translate, LANGUAGES, useTranslation, getExerciseTranslatedDescription, chat, chatApi, chatExposed, getCountNotificaciones, sendChatMessage, notionGetUsers, notionGetDatabase, notionAddPage, notionEditPage, NOTION_DATABASES_ID, readSheet, findCellByValue, writeSheet, appendSheet, getNumberByLetter, getLetter, reduceSizeImage, generateShareMap, getDefaultWorkoutImage, };
15
+ export { sendNotification, sleep, query, batchQuery, toPgArray, 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, };
16
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,M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,cAAc,EACd,mBAAmB,EACnB,SAAS,EACT,eAAe,EACf,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,sBAAsB,GACvB,CAAC"}
@@ -4,6 +4,6 @@ interface Notification {
4
4
  title?: string;
5
5
  body: string;
6
6
  }
7
- declare const sendNotification: ({ idCliente, title, body }: Notification) => Promise<void>;
7
+ declare const sendNotification: ({ firebaseMessaging, idCliente, title, body }: Notification) => Promise<void>;
8
8
  export { sendNotification };
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sendNotification/index.ts"],"names":[],"mappings":"AAEA,UAAU,YAAY;IACpB,iBAAiB,EAAE,GAAG,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,QAAA,MAAM,gBAAgB,+BAAsC,YAAY,kBAcvE,CAAC;AAqBF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sendNotification/index.ts"],"names":[],"mappings":"AAEA,UAAU,YAAY;IACpB,iBAAiB,EAAE,GAAG,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,QAAA,MAAM,gBAAgB,kDAAyD,YAAY,kBAa1F,CAAC;AAqBF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,72 +1,72 @@
1
- {
2
- "name": "@runnerpro/backend",
3
- "version": "1.6.6",
4
- "description": "A collection of common backend functions",
5
- "exports": {
6
- ".": "./lib/cjs/index.js"
7
- },
8
- "types": "./lib/cjs/types/index.d.ts",
9
- "main": "./lib/cjs/index.js",
10
- "files": [
11
- "lib/**/*"
12
- ],
13
- "scripts": {
14
- "clean": "del-cli ./lib",
15
- "build": "npm run clean && tsc -p ./configs/tsconfig.cjs.json",
16
- "deploy": "npm run build && npm publish",
17
- "semantic-release": "semantic-release",
18
- "lint": "eslint --ext .ts --ignore-path .gitignore .",
19
- "format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,json,css,scss,md}\"",
20
- "prepare": "husky",
21
- "test": "jest"
22
- },
23
- "release": {
24
- "branches": [
25
- "main"
26
- ]
27
- },
28
- "publishConfig": {
29
- "access": "public"
30
- },
31
- "repository": {
32
- "type": "git",
33
- "url": "https://gitlab.com/runner-pro/runnerpro-backend.git"
34
- },
35
- "author": "Runner Pro",
36
- "license": "MIT",
37
- "devDependencies": {
38
- "@eslint/js": "^9.6.0",
39
- "@types/eslint__js": "^8.42.3",
40
- "@types/nodemailer": "^6.4.15",
41
- "@types/pg": "^8.11.3",
42
- "del-cli": "5.1.0",
43
- "eslint": "^8.57.0",
44
- "eslint-config-prettier": "^9.1.0",
45
- "eslint-plugin-exception-handling": "^1.0.2",
46
- "eslint-plugin-sonarjs": "^1.0.3",
47
- "husky": "^9.0.11",
48
- "jest": "^29.7.0",
49
- "semantic-release": "23.0.2",
50
- "ts-node": "10.9.2",
51
- "typescript": "5.3.3",
52
- "typescript-eslint": "^7.15.0"
53
- },
54
- "peerDependencies": {
55
- "@napi-rs/canvas": "^0.1.53",
56
- "@runnerpro/common": "^1.5.1",
57
- "axios": "^1.6.7",
58
- "image-size": "^1.0.2",
59
- "jimp": "^0.22.10",
60
- "nodemailer": "6.9.9",
61
- "pg": "8.11.3",
62
- "uuidv4": "^6.2.13"
63
- },
64
- "dependencies": {
65
- "@google-cloud/translate": "^8.3.0",
66
- "@notionhq/client": "^2.2.15",
67
- "exifr": "^7.1.3",
68
- "googleapis": "^144.0.0",
69
- "multer": "^1.4.5-lts.1",
70
- "socket.io": "^4.7.2"
71
- }
72
- }
1
+ {
2
+ "name": "@runnerpro/backend",
3
+ "version": "1.6.8",
4
+ "description": "A collection of common backend functions",
5
+ "exports": {
6
+ ".": "./lib/cjs/index.js"
7
+ },
8
+ "types": "./lib/cjs/types/index.d.ts",
9
+ "main": "./lib/cjs/index.js",
10
+ "files": [
11
+ "lib/**/*"
12
+ ],
13
+ "scripts": {
14
+ "clean": "del-cli ./lib",
15
+ "build": "npm run clean && tsc -p ./configs/tsconfig.cjs.json",
16
+ "deploy": "npm run build && npm publish",
17
+ "semantic-release": "semantic-release",
18
+ "lint": "eslint --ext .ts --ignore-path .gitignore .",
19
+ "format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,json,css,scss,md}\"",
20
+ "prepare": "husky",
21
+ "test": "jest"
22
+ },
23
+ "release": {
24
+ "branches": [
25
+ "main"
26
+ ]
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://gitlab.com/runner-pro/runnerpro-backend.git"
34
+ },
35
+ "author": "Runner Pro",
36
+ "license": "MIT",
37
+ "devDependencies": {
38
+ "@eslint/js": "^9.6.0",
39
+ "@types/eslint__js": "^8.42.3",
40
+ "@types/nodemailer": "^6.4.15",
41
+ "@types/pg": "^8.11.3",
42
+ "del-cli": "5.1.0",
43
+ "eslint": "^8.57.0",
44
+ "eslint-config-prettier": "^9.1.0",
45
+ "eslint-plugin-exception-handling": "^1.0.2",
46
+ "eslint-plugin-sonarjs": "^1.0.3",
47
+ "husky": "^9.0.11",
48
+ "jest": "^29.7.0",
49
+ "semantic-release": "23.0.2",
50
+ "ts-node": "10.9.2",
51
+ "typescript": "5.3.3",
52
+ "typescript-eslint": "^7.15.0"
53
+ },
54
+ "peerDependencies": {
55
+ "@napi-rs/canvas": "^0.1.53",
56
+ "@runnerpro/common": "^1.5.1",
57
+ "axios": "^1.6.7",
58
+ "image-size": "^1.0.2",
59
+ "jimp": "^0.22.10",
60
+ "nodemailer": "6.9.9",
61
+ "pg": "8.11.3",
62
+ "uuidv4": "^6.2.13"
63
+ },
64
+ "dependencies": {
65
+ "@google-cloud/translate": "^8.3.0",
66
+ "@notionhq/client": "^2.2.15",
67
+ "exifr": "^7.1.3",
68
+ "googleapis": "^144.0.0",
69
+ "multer": "^1.4.5-lts.1",
70
+ "socket.io": "^4.7.2"
71
+ }
72
+ }
@@ -1,24 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.sendChatMessage = void 0;
13
- const index_1 = require("../../db/index");
14
- const { getMessaging } = require('firebase-admin/messaging');
15
- const sendChatMessage = ({ sendByClient, text, idClient, idSender, type, read, showClient, idWorkout, replyMessageId, textPreferredLanguage, preferredLanguage, fileMimetype, audioDuration, filePath, options, }) => __awaiter(void 0, void 0, void 0, function* () {
16
- const { sendNotification, maskAsRead } = options;
17
- const [cliente] = yield (0, index_1.query)('SELECT [PREFERRED LANGUAGE] FROM [CLIENTE] LIMIT 1');
18
- const messaging = getMessaging();
19
- return {
20
- cliente,
21
- messaging
22
- };
23
- });
24
- exports.sendChatMessage = sendChatMessage;
@@ -1,22 +0,0 @@
1
- declare const sendChatMessage: ({ sendByClient, text, idClient, idSender, type, read, showClient, idWorkout, replyMessageId, textPreferredLanguage, preferredLanguage, fileMimetype, audioDuration, filePath, options, }: {
2
- sendByClient: any;
3
- text: any;
4
- idClient: any;
5
- idSender: any;
6
- type: any;
7
- read: any;
8
- showClient: any;
9
- idWorkout: any;
10
- replyMessageId: any;
11
- textPreferredLanguage: any;
12
- preferredLanguage: any;
13
- fileMimetype: any;
14
- audioDuration: any;
15
- filePath: any;
16
- options: any;
17
- }) => Promise<{
18
- cliente: any;
19
- messaging: any;
20
- }>;
21
- export { sendChatMessage };
22
- //# sourceMappingURL=sendChatMessage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sendChatMessage.d.ts","sourceRoot":"","sources":["../../../../../src/chat/utils/sendChatMessage.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;EA4BpB,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC"}