@runnerpro/backend 1.1.9 → 1.1.11

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.
@@ -44,11 +44,11 @@ const conversationRoute = (_a) => {
44
44
  },
45
45
  });
46
46
  router.get('/conversation', (req, res, next) => getConversation(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
47
- router.get('/conversation/suggestion', (req, res, next) => getConversationSuggestion(req, res, next).catch((error) => (0, index_1.err)(req, res, error, next)));
47
+ router.get('/conversation/suggestion', (req, res, next) => getConversationSuggestion(req, res).catch((error) => (0, index_1.err)(req, res, error, next)));
48
48
  router.get('/conversation/image/:id', (req, res, next) => getConversationImage(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
49
49
  router.get('/conversation/file/:id', (req, res, next) => getConversationFile(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
50
50
  router.post('/conversation/send', (req, res, next) => sendMessage(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
51
- router.post('/conversation/send-file', uploadFile.single('file'), (req, res, next) => sendFile(req, res, params, next).catch((error) => (0, index_1.err)(req, res, error, next)));
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
53
  router.post('/conversation/read-feelings', (req, res, next) => readFeelings(req, res, params).catch((error) => (0, index_1.err)(req, res, error, next)));
54
54
  };
@@ -56,13 +56,13 @@ exports.conversationRoute = conversationRoute;
56
56
  const getConversation = (req, res, { query, isClient }) => __awaiter(void 0, void 0, void 0, function* () {
57
57
  const idCliente = isClient ? req.session.userid : req.query.id;
58
58
  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
- [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
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
+ [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
66
66
  LIMIT 100`, [idCliente]);
67
67
  messages = messages.reverse();
68
68
  // 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]
@@ -127,7 +127,7 @@ const getChatFile = ({ query, bucket, id, isClient, userid }) => __awaiter(void
127
127
  return null;
128
128
  }
129
129
  });
130
- const getConversationSuggestion = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
130
+ const getConversationSuggestion = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
131
131
  let result;
132
132
  try {
133
133
  result = yield axios_1.default
@@ -141,7 +141,7 @@ const getConversationSuggestion = (req, res, next) => __awaiter(void 0, void 0,
141
141
  .then((response) => response.data);
142
142
  }
143
143
  catch (e) {
144
- (0, index_1.err)(null, null, e, next);
144
+ (0, index_1.err)(null, null, e, null);
145
145
  result = { error: 'Ha habido un error con el servidor' };
146
146
  }
147
147
  finally {
@@ -196,7 +196,7 @@ const getPreferredLanguageForChat = ({ text, idCliente, isClient, query }) => __
196
196
  preferredLanguage: preferredLanguage,
197
197
  };
198
198
  });
199
- const sendFile = (req, res, { sendNotification, firebaseMessaging, query, isClient, bucket }, next) => __awaiter(void 0, void 0, void 0, function* () {
199
+ const sendFile = (req, res, { sendNotification, firebaseMessaging, query, isClient, bucket }) => __awaiter(void 0, void 0, void 0, function* () {
200
200
  const { idCliente, type, duration } = req.body;
201
201
  const { userid } = req.session;
202
202
  const [{ id: idFile }] = yield query('INSERT INTO [CHAT MESSAGE] ([ID CLIENTE], [ID SENDER], [TEXT], [MIMETYPE], [DURATION], [TYPE]) VALUES (?, ?, ?, ?, ?, ?) RETURNING [ID]', [isClient ? userid : idCliente, userid, req.file.originalname, req.file.mimetype, duration || null, type || 2]);
@@ -211,7 +211,7 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, query, isClie
211
211
  files.push({ data: fileDataOriented, id: `${idFile}-original` });
212
212
  }
213
213
  catch (error) {
214
- (0, index_1.err)(null, null, error, next);
214
+ (0, index_1.err)(null, null, error, null);
215
215
  }
216
216
  }
217
217
  else {
@@ -23,7 +23,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.listConversationsRoute = void 0;
24
24
  const listConversationsRoute = (_a) => {
25
25
  var { router, err } = _a, params = __rest(_a, ["router", "err"]);
26
- router.get('/list', (req, res, next) => getList(req, res, params).catch((error) => err(req, res, error, next)));
26
+ router.get('/list', (req, res) => getList(req, res, params).catch((error) => err(req, res, error)));
27
27
  };
28
28
  exports.listConversationsRoute = listConversationsRoute;
29
29
  const getList = (req, res, { query, isClient }) => __awaiter(void 0, void 0, void 0, function* () {
@@ -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
  }
@@ -24,7 +24,7 @@ exports.conversationRoute = void 0;
24
24
  const getRoom_1 = require("../utils/getRoom");
25
25
  const conversationRoute = (_a) => {
26
26
  var { router, err } = _a, params = __rest(_a, ["router", "err"]);
27
- router.post('/conversation/socket', (req, res, next) => socketConversation(req, res, params).catch((error) => err(req, res, error, next)));
27
+ router.post('/conversation/socket', (req, res) => socketConversation(req, res, params).catch((error) => err(req, res, error)));
28
28
  };
29
29
  exports.conversationRoute = conversationRoute;
30
30
  const socketConversation = (req, res, { isClient }) => __awaiter(void 0, void 0, void 0, function* () {
@@ -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
  }
@@ -24,7 +24,7 @@ const fetchIA = {
24
24
  Authorization: `Bearer ${process.env.IA_ACCESS_TOKEN}`,
25
25
  } }, options === null || options === void 0 ? void 0 : options.extra))
26
26
  .then(({ data }) => data)
27
- .catch((error) => catchAxios(error, !!(options === null || options === void 0 ? void 0 : options.bypassStatus), url));
27
+ .catch((error) => catchAxios(error, !!(options === null || options === void 0 ? void 0 : options.bypassStatus)));
28
28
  }),
29
29
  post: (url, body, options) => __awaiter(void 0, void 0, void 0, function* () {
30
30
  return axios_1.default
@@ -36,7 +36,7 @@ const fetchIA = {
36
36
  },
37
37
  })
38
38
  .then(({ data }) => data)
39
- .catch((error) => catchAxios(error, !!(options === null || options === void 0 ? void 0 : options.bypassStatus), url));
39
+ .catch((error) => catchAxios(error, !!(options === null || options === void 0 ? void 0 : options.bypassStatus)));
40
40
  }),
41
41
  put: (url, body, options) => __awaiter(void 0, void 0, void 0, function* () {
42
42
  return axios_1.default
@@ -48,7 +48,7 @@ const fetchIA = {
48
48
  },
49
49
  })
50
50
  .then(({ data }) => data)
51
- .catch((error) => catchAxios(error, !!(options === null || options === void 0 ? void 0 : options.bypassStatus), url));
51
+ .catch((error) => catchAxios(error, !!(options === null || options === void 0 ? void 0 : options.bypassStatus)));
52
52
  }),
53
53
  delete: (url, body, options) => __awaiter(void 0, void 0, void 0, function* () {
54
54
  return axios_1.default
@@ -61,13 +61,13 @@ const fetchIA = {
61
61
  },
62
62
  })
63
63
  .then(({ data }) => data)
64
- .catch((error) => catchAxios(error, !!(options === null || options === void 0 ? void 0 : options.bypassStatus), url));
64
+ .catch((error) => catchAxios(error, !!(options === null || options === void 0 ? void 0 : options.bypassStatus)));
65
65
  }),
66
66
  };
67
67
  exports.fetchIA = fetchIA;
68
- function catchAxios(error, bypassStatus, url) {
69
- var _a, _b;
68
+ function catchAxios(error, bypassStatus) {
69
+ var _a;
70
70
  if (bypassStatus)
71
71
  return error.response;
72
- (0, index_1.err)(url, (_a = error.response) === null || _a === void 0 ? void 0 : _a.status, (_b = error.response) === null || _b === void 0 ? void 0 : _b.data, null);
72
+ (0, index_1.err)(null, null, (_a = error.response) === null || _a === void 0 ? void 0 : _a.status, null);
73
73
  }
@@ -0,0 +1,136 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getLetter = exports.getNumberByLetter = exports.writeSheet = exports.findCellByValue = exports.readSheet = void 0;
16
+ const path_1 = __importDefault(require("path"));
17
+ const googleapis_1 = require("googleapis");
18
+ const fs_1 = __importDefault(require("fs"));
19
+ const err_1 = require("../err");
20
+ // @ts-ignore
21
+ const credentials = JSON.parse(fs_1.default.readFileSync(path_1.default.join(process.cwd(), process.env.FIREBASE_ADMIN_CREDENTIALS)));
22
+ // ID de la hoja viene en la URL -> https://docs.google.com/spreadsheets/d/{__ID__}/edit#gid=0
23
+ const googleSheeIds = {
24
+ INFLUENCER: '1Uv5Prbjo4h0X74WzaGryKsEbnRX_QM8z0DGYZnvSJ-4',
25
+ NORTH_STAR: '1RkLAXb8iH-QKQ1MAeUZLpBN2lWvab4GMZkKbG-DNv64',
26
+ INFLUENCER_BUTTON: '1wSxtowC1yUUgkYDKhY_Wci6nZeYz13PiZuA7H_1tRfs',
27
+ };
28
+ // authenticate the service account
29
+ const googleAuth = new googleapis_1.google.auth.JWT(credentials.client_email, null, credentials.private_key.replace(/\\n/g, '\n'), 'https://www.googleapis.com/auth/spreadsheets');
30
+ const getSheetInstance = () => __awaiter(void 0, void 0, void 0, function* () {
31
+ return googleapis_1.google.sheets({ version: 'v4', auth: googleAuth });
32
+ });
33
+ function readSheet({ sheetInstance, sheetName, sheetPage, cellPositionStart, cellPositionEnd }) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ try {
36
+ if (!sheetInstance)
37
+ sheetInstance = yield getSheetInstance();
38
+ const infoObjectFromSheet = yield sheetInstance.spreadsheets.values.get({
39
+ auth: googleAuth,
40
+ spreadsheetId: googleSheeIds[sheetName],
41
+ range: `${sheetPage}!${cellPositionStart}:${cellPositionEnd}`,
42
+ });
43
+ return infoObjectFromSheet.data.values;
44
+ }
45
+ catch (error) {
46
+ (0, err_1.err)(null, null, error, null);
47
+ }
48
+ });
49
+ }
50
+ exports.readSheet = readSheet;
51
+ const findCellByValue = ({ sheetName, sheetPage, value, positionX, positionXStart, positionY, positionYStart, valueType }) => __awaiter(void 0, void 0, void 0, function* () {
52
+ const sheetInstance = yield getSheetInstance();
53
+ let array = [];
54
+ if (positionX) {
55
+ const readColumn = yield readSheet({
56
+ sheetInstance,
57
+ sheetName,
58
+ sheetPage,
59
+ cellPositionStart: `${positionX}${positionYStart || 1}`,
60
+ cellPositionEnd: `${positionX}${(positionYStart || 1) + 2000}`,
61
+ });
62
+ if (readColumn)
63
+ array = readColumn.map((row) => row[0] || '');
64
+ }
65
+ else {
66
+ const readRow = yield readSheet({
67
+ sheetInstance,
68
+ sheetName,
69
+ sheetPage,
70
+ cellPositionStart: `${positionXStart || 'A'}${positionY}`,
71
+ cellPositionEnd: `ZZ${positionY}`,
72
+ });
73
+ if (readRow && readRow[0])
74
+ array = readRow[0];
75
+ }
76
+ let index;
77
+ // @ts-ignore
78
+ if (valueType === 'CONTAIN')
79
+ index = array.findIndex((cell) => cell.includes(value));
80
+ // @ts-ignore
81
+ else
82
+ index = array.indexOf(value);
83
+ if (index === -1)
84
+ return -1;
85
+ if (positionX)
86
+ return `${positionX}:${(positionYStart || 1) + index}`;
87
+ else
88
+ return `${getLetter((getNumberByLetter(positionXStart) || 1) + index)}:${positionY}`;
89
+ });
90
+ exports.findCellByValue = findCellByValue;
91
+ // funcion que pasandolee un numero te devuelve la letra de la columna excel (teniendo en cuenta que la A es la 1 y que la AA es la 27)
92
+ function getLetter(number) {
93
+ let letter = '';
94
+ if (number > 26) {
95
+ letter += String.fromCharCode(64 + Math.floor(number / 26)); // Agregar el cociente entero
96
+ number = number % 26;
97
+ if (number === 0) {
98
+ // Manejar el caso especial cuando el número es divisible por 26
99
+ letter = String.fromCharCode(letter.charCodeAt(0) - 1); // Restar 1 a la letra
100
+ number = 26; // Establecer el número a 26
101
+ }
102
+ }
103
+ letter += String.fromCharCode(64 + number);
104
+ return letter;
105
+ }
106
+ exports.getLetter = getLetter;
107
+ // funcion que pasandole unas letras de la columna de excel te devuelve el numero de la columna (teniendo en cuenta que la A es la 1 y que la AA es la 27)
108
+ function getNumberByLetter(letter) {
109
+ if (!letter)
110
+ return 1;
111
+ let number = 0;
112
+ for (let i = 0; i < letter.length; i++) {
113
+ number += (letter.charCodeAt(i) - 64) * Math.pow(26, letter.length - i - 1);
114
+ }
115
+ return number;
116
+ }
117
+ exports.getNumberByLetter = getNumberByLetter;
118
+ const writeSheet = ({ sheetInstance, sheetName, sheetPage, cellValue, cellPosition }) => __awaiter(void 0, void 0, void 0, function* () {
119
+ try {
120
+ if (!sheetInstance)
121
+ sheetInstance = yield getSheetInstance();
122
+ yield sheetInstance.spreadsheets.values.update({
123
+ auth: googleAuth,
124
+ spreadsheetId: googleSheeIds[sheetName],
125
+ range: `${sheetPage}!${cellPosition}:${cellPosition}`,
126
+ valueInputOption: 'RAW',
127
+ resource: {
128
+ values: [[cellValue]],
129
+ },
130
+ });
131
+ }
132
+ catch (error) {
133
+ (0, err_1.err)(null, null, error, null);
134
+ }
135
+ });
136
+ exports.writeSheet = writeSheet;
package/lib/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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.fetchIA = exports.err = exports.sendMail = exports.batchQuery = exports.query = exports.sleep = exports.sendNotification = void 0;
3
+ exports.getLetter = exports.getNumberByLetter = 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.fetchIA = exports.err = exports.sendMail = 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");
@@ -30,3 +30,9 @@ Object.defineProperty(exports, "notionGetDatabase", { enumerable: true, get: fun
30
30
  Object.defineProperty(exports, "notionAddPage", { enumerable: true, get: function () { return notion_1.notionAddPage; } });
31
31
  Object.defineProperty(exports, "notionEditPage", { enumerable: true, get: function () { return notion_1.notionEditPage; } });
32
32
  Object.defineProperty(exports, "NOTION_DATABASES_ID", { enumerable: true, get: function () { return notion_1.NOTION_DATABASES_ID; } });
33
+ const googleSheet_1 = require("./googleSheet");
34
+ Object.defineProperty(exports, "readSheet", { enumerable: true, get: function () { return googleSheet_1.readSheet; } });
35
+ Object.defineProperty(exports, "findCellByValue", { enumerable: true, get: function () { return googleSheet_1.findCellByValue; } });
36
+ Object.defineProperty(exports, "writeSheet", { enumerable: true, get: function () { return googleSheet_1.writeSheet; } });
37
+ Object.defineProperty(exports, "getNumberByLetter", { enumerable: true, get: function () { return googleSheet_1.getNumberByLetter; } });
38
+ Object.defineProperty(exports, "getLetter", { enumerable: true, get: function () { return googleSheet_1.getLetter; } });
@@ -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 ? link.url : `${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="${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
  }
@@ -39,7 +39,7 @@ function notificationIOS(msg, token) {
39
39
  const options = {
40
40
  token: {
41
41
  key: 'env/apple_notification.p8',
42
- keyId: 'B7CYLPUCAM',
42
+ keyId: '49XT5X2ZYD',
43
43
  teamId: 'UA78D3SXQG',
44
44
  },
45
45
  production: true,
@@ -1 +1 @@
1
- {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAiBpD,CAAC;AAmQF,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,SAmBpD,CAAC;AAmQF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,28 @@
1
+ declare function readSheet({ sheetInstance, sheetName, sheetPage, cellPositionStart, cellPositionEnd }: {
2
+ sheetInstance: any;
3
+ sheetName: any;
4
+ sheetPage: any;
5
+ cellPositionStart: any;
6
+ cellPositionEnd: any;
7
+ }): Promise<any>;
8
+ declare const findCellByValue: ({ sheetName, sheetPage, value, positionX, positionXStart, positionY, positionYStart, valueType }: {
9
+ sheetName: any;
10
+ sheetPage: any;
11
+ value: any;
12
+ positionX: any;
13
+ positionXStart: any;
14
+ positionY: any;
15
+ positionYStart: any;
16
+ valueType: any;
17
+ }) => Promise<string | -1>;
18
+ declare function getLetter(number: any): string;
19
+ declare function getNumberByLetter(letter: any): number;
20
+ declare const writeSheet: ({ sheetInstance, sheetName, sheetPage, cellValue, cellPosition }: {
21
+ sheetInstance: any;
22
+ sheetName: any;
23
+ sheetPage: any;
24
+ cellValue: any;
25
+ cellPosition: any;
26
+ }) => Promise<void>;
27
+ export { readSheet, findCellByValue, writeSheet, getNumberByLetter, getLetter };
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/googleSheet/index.ts"],"names":[],"mappings":"AA2BA,iBAAe,SAAS,CAAC,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,iBAAiB,EAAE,eAAe,EAAE;;;;;;CAAA,gBAcnG;AAED,QAAA,MAAM,eAAe;;;;;;;;;0BAiCpB,CAAC;AAGF,iBAAS,SAAS,CAAC,MAAM,KAAA,UAaxB;AAED,iBAAS,iBAAiB,CAAC,MAAM,KAAA,UAOhC;AAED,QAAA,MAAM,UAAU;;;;;;mBAgBf,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,iBAAiB,EAAE,SAAS,EAAE,CAAC"}
@@ -7,5 +7,6 @@ import { fetchIA } from './fetch/fetchIA';
7
7
  import { translate, LANGUAGES, useTranslation, getExerciseTranslatedDescription } from './translation';
8
8
  import { chat, chatApi, chatExposed, getCountNotificaciones } from './chat';
9
9
  import { notionGetUsers, notionGetDatabase, notionAddPage, notionEditPage, NOTION_DATABASES_ID } from './notion';
10
- export { sendNotification, sleep, query, batchQuery, sendMail, err, fetchIA, translate, LANGUAGES, useTranslation, getExerciseTranslatedDescription, chat, chatApi, chatExposed, getCountNotificaciones, notionGetUsers, notionGetDatabase, notionAddPage, notionEditPage, NOTION_DATABASES_ID, };
10
+ import { readSheet, findCellByValue, writeSheet, getNumberByLetter, getLetter } from './googleSheet';
11
+ export { sendNotification, sleep, query, batchQuery, sendMail, err, fetchIA, translate, LANGUAGES, useTranslation, getExerciseTranslatedDescription, chat, chatApi, chatExposed, getCountNotificaciones, notionGetUsers, notionGetDatabase, notionAddPage, notionEditPage, NOTION_DATABASES_ID, readSheet, findCellByValue, writeSheet, getNumberByLetter, getLetter, };
11
12
  //# 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,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,gCAAgC,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEjH,OAAO,EACL,gBAAgB,EAChB,KAAK,EACL,KAAK,EACL,UAAU,EACV,QAAQ,EACR,GAAG,EACH,OAAO,EACP,SAAS,EACT,SAAS,EACT,cAAc,EACd,gCAAgC,EAChC,IAAI,EACJ,OAAO,EACP,WAAW,EACX,sBAAsB,EACtB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,mBAAmB,GACpB,CAAC"}
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,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,gCAAgC,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACjH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAErG,OAAO,EACL,gBAAgB,EAChB,KAAK,EACL,KAAK,EACL,UAAU,EACV,QAAQ,EACR,GAAG,EACH,OAAO,EACP,SAAS,EACT,SAAS,EACT,cAAc,EACd,gCAAgC,EAChC,IAAI,EACJ,OAAO,EACP,WAAW,EACX,sBAAsB,EACtB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,SAAS,EACT,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,SAAS,GACV,CAAC"}
package/package.json CHANGED
@@ -1,70 +1,71 @@
1
- {
2
- "name": "@runnerpro/backend",
3
- "version": "1.1.9",
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
- "@parse/node-apn": "6.0.1",
56
- "@runnerpro/common": "^1.4.1",
57
- "axios": "^1.6.7",
58
- "jimp": "^0.22.10",
59
- "nodemailer": "6.9.9",
60
- "pg": "8.11.3"
61
- },
62
- "dependencies": {
63
- "@google-cloud/translate": "^8.3.0",
64
- "@notionhq/client": "^2.2.15",
65
- "exifr": "^7.1.3",
66
- "image-size": "^1.0.2",
67
- "multer": "^1.4.5-lts.1",
68
- "socket.io": "^4.7.2"
69
- }
70
- }
1
+ {
2
+ "name": "@runnerpro/backend",
3
+ "version": "1.1.11",
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
+ "@parse/node-apn": "6.0.1",
56
+ "@runnerpro/common": "^1.4.1",
57
+ "axios": "^1.6.7",
58
+ "jimp": "^0.22.10",
59
+ "nodemailer": "6.9.9",
60
+ "pg": "8.11.3"
61
+ },
62
+ "dependencies": {
63
+ "@google-cloud/translate": "^8.3.0",
64
+ "@notionhq/client": "^2.2.15",
65
+ "exifr": "^7.1.3",
66
+ "googleapis": "^144.0.0",
67
+ "image-size": "^1.0.2",
68
+ "multer": "^1.4.5-lts.1",
69
+ "socket.io": "^4.7.2"
70
+ }
71
+ }