@runnerpro/backend 1.8.1 → 1.8.3
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 +2 -2
- package/lib/cjs/chat/sendMessageChatToClient.js +38 -0
- package/lib/cjs/index.js +3 -1
- package/lib/cjs/sendNotification/index.js +6 -2
- package/lib/cjs/types/chat/sendMessageChatToClient.d.ts +3 -0
- package/lib/cjs/types/chat/sendMessageChatToClient.d.ts.map +1 -0
- package/lib/cjs/types/index.d.ts +2 -1
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/cjs/types/sendNotification/index.d.ts +3 -1
- package/lib/cjs/types/sendNotification/index.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -180,7 +180,7 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, query, isC
|
|
|
180
180
|
firebaseMessaging,
|
|
181
181
|
idCliente,
|
|
182
182
|
body: `Rubén: ${textPreferredLanguage || textSpanish}`,
|
|
183
|
-
|
|
183
|
+
screen: common_1.NOTIFICATION_SCREEN_TYPES.CHAT,
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
186
|
res.send({ status: 'ok' });
|
|
@@ -234,7 +234,7 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, query, isClie
|
|
|
234
234
|
firebaseMessaging,
|
|
235
235
|
idCliente,
|
|
236
236
|
body: `Rubén: ${(0, index_2.t)(Number(type) === 4 ? 'Audio' : 'Archivo adjunto', cliente.preferredLanguage)}`,
|
|
237
|
-
|
|
237
|
+
screen: common_1.NOTIFICATION_SCREEN_TYPES.CHAT,
|
|
238
238
|
});
|
|
239
239
|
}
|
|
240
240
|
res.send({ idFile });
|
|
@@ -0,0 +1,38 @@
|
|
|
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.sendMessageChatToClient = void 0;
|
|
13
|
+
const messaging_1 = require("firebase-admin/messaging");
|
|
14
|
+
const index_1 = require("../err/index");
|
|
15
|
+
const index_2 = require("../sendNotification/index");
|
|
16
|
+
const index_3 = require("../db/index");
|
|
17
|
+
const common_1 = require("@runnerpro/common");
|
|
18
|
+
const sendMessageChatToClient = (idCliente, text, textPreferredLanguage, preferredLanguage, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
const { notification } = options;
|
|
20
|
+
const [entrenador] = yield (0, index_3.query)('SELECT [ID ENTRENADOR] FROM [CLIENTE ENTRENADOR] WHERE [ID CLIENTE] = ? LIMIT 1', [idCliente]);
|
|
21
|
+
if (!entrenador)
|
|
22
|
+
return;
|
|
23
|
+
if (notification) {
|
|
24
|
+
try {
|
|
25
|
+
yield (0, index_2.sendNotification)({
|
|
26
|
+
firebaseMessaging: (0, messaging_1.getMessaging)(),
|
|
27
|
+
idCliente,
|
|
28
|
+
body: (0, common_1.removeAccent)((textPreferredLanguage || text).substring(0, 50)) + ((textPreferredLanguage || text).length > 50 ? '...' : ''),
|
|
29
|
+
screen: common_1.NOTIFICATION_SCREEN_TYPES.CHAT,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
(0, index_1.err)(null, null, e, null);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
yield (0, index_3.query)('INSERT INTO [CHAT MESSAGE] ([ID CLIENTE], [ID SENDER], [TEXT], [TEXT PREFERRED LANGUAGE], [PREFERRED LANGUAGE], [TYPE]) VALUES (?, ?, ?, ?, ?, 1)', [idCliente, entrenador.idEntrenador, text, textPreferredLanguage, preferredLanguage]);
|
|
37
|
+
});
|
|
38
|
+
exports.sendMessageChatToClient = sendMessageChatToClient;
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
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.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;
|
|
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");
|
|
@@ -54,3 +54,5 @@ const planificacionPrueba7dias_1 = require("./workout/planificacionPrueba7dias")
|
|
|
54
54
|
Object.defineProperty(exports, "getPlanificacionPrueba7dias", { enumerable: true, get: function () { return planificacionPrueba7dias_1.getPlanificacionPrueba7dias; } });
|
|
55
55
|
const saveWorkoutAplication_1 = require("./workout/saveWorkoutAplication");
|
|
56
56
|
Object.defineProperty(exports, "saveWorkoutAplication", { enumerable: true, get: function () { return saveWorkoutAplication_1.saveWorkoutAplication; } });
|
|
57
|
+
const sendMessageChatToClient_1 = require("./chat/sendMessageChatToClient");
|
|
58
|
+
Object.defineProperty(exports, "sendMessageChatToClient", { enumerable: true, get: function () { return sendMessageChatToClient_1.sendMessageChatToClient; } });
|
|
@@ -11,12 +11,16 @@ 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
|
|
14
|
+
const common_1 = require("@runnerpro/common");
|
|
15
|
+
const sendNotification = ({ firebaseMessaging, idCliente, title, body, screen = common_1.NOTIFICATION_SCREEN_TYPES.HOME, screenParams = {}, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
16
|
const devices = yield (0, index_1.query)('SELECT [SUBSCRIPTION], [TYPE] FROM [PUSH MANAGER] WHERE [ID CLIENTE] = ?', [idCliente]);
|
|
17
|
+
const screenParamsString = JSON.stringify(screenParams);
|
|
16
18
|
for (const device of devices) {
|
|
17
19
|
notificationWEB(firebaseMessaging, {
|
|
18
20
|
title,
|
|
19
21
|
body,
|
|
22
|
+
screen,
|
|
23
|
+
screenParams: screenParamsString,
|
|
20
24
|
}, device.subscription);
|
|
21
25
|
}
|
|
22
26
|
});
|
|
@@ -29,7 +33,7 @@ function notificationWEB(firebaseMessaging, msg, token) {
|
|
|
29
33
|
.send({
|
|
30
34
|
token,
|
|
31
35
|
notification: msg,
|
|
32
|
-
data: msg,
|
|
36
|
+
data: Object.assign(Object.assign({}, msg), { screen: msg.screen, screenParams: msg.screenParams }),
|
|
33
37
|
})
|
|
34
38
|
.catch((error) => {
|
|
35
39
|
if (error.errorInfo.code === 'messaging/registration-token-not-registered') {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendMessageChatToClient.d.ts","sourceRoot":"","sources":["../../../../src/chat/sendMessageChatToClient.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,uBAAuB,gHAsB5B,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
|
package/lib/cjs/types/index.d.ts
CHANGED
|
@@ -15,5 +15,6 @@ import { getDefaultWorkoutImage } from './image/getDefaultWorkoutImage';
|
|
|
15
15
|
import { sendWorkoutToWatch } from './workout/sendToWatch';
|
|
16
16
|
import { getPlanificacionPrueba7dias } from './workout/planificacionPrueba7dias';
|
|
17
17
|
import { saveWorkoutAplication } from './workout/saveWorkoutAplication';
|
|
18
|
-
|
|
18
|
+
import { sendMessageChatToClient } from './chat/sendMessageChatToClient';
|
|
19
|
+
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, };
|
|
19
20
|
//# sourceMappingURL=index.d.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AChB,KAAK,EACL,KAAK,EACL,UAAU,EACV,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,GAAG,EACH,OAAO,EACP,WAAW,EACX,aAAa,EACb,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,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,2BAA2B,EAC3B,qBAAqB,EACrB,uBAAuB,GACxB,CAAC"}
|
|
@@ -3,7 +3,9 @@ interface Notification {
|
|
|
3
3
|
idCliente: number;
|
|
4
4
|
title?: string;
|
|
5
5
|
body: string;
|
|
6
|
+
screen?: string;
|
|
7
|
+
screenParams?: any;
|
|
6
8
|
}
|
|
7
|
-
declare const sendNotification: ({ firebaseMessaging, idCliente, title, body }: Notification) => Promise<void>;
|
|
9
|
+
declare const sendNotification: ({ firebaseMessaging, idCliente, title, body, screen, screenParams, }: Notification) => Promise<void>;
|
|
8
10
|
export { sendNotification };
|
|
9
11
|
//# 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;
|
|
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;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,GAAG,CAAC;CACpB;AAED,QAAA,MAAM,gBAAgB,yEAOnB,YAAY,kBAgBd,CAAC;AAyBF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runnerpro/backend",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.3",
|
|
4
4
|
"description": "A collection of common backend functions",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./lib/cjs/index.js"
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@napi-rs/canvas": "^0.1.53",
|
|
56
|
-
"@runnerpro/common": "^1.5.
|
|
56
|
+
"@runnerpro/common": "^1.5.10",
|
|
57
57
|
"axios": "^1.6.7",
|
|
58
58
|
"image-size": "^1.0.2",
|
|
59
59
|
"jimp": "^0.22.10",
|