@runnerpro/backend 1.6.0 → 1.6.2

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.
@@ -1,7 +1,24 @@
1
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
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.sendChatMessage = void 0;
4
- const sendChatMessage = () => {
5
- return 'hola';
6
- };
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
+ });
7
24
  exports.sendChatMessage = sendChatMessage;
@@ -13,31 +13,27 @@ exports.sendNotification = void 0;
13
13
  const index_1 = require("../db/index");
14
14
  const sendNotification = ({ firebaseMessaging, idCliente, title, body }) => __awaiter(void 0, void 0, void 0, function* () {
15
15
  const devices = yield (0, index_1.query)('SELECT [SUBSCRIPTION], [TYPE] FROM [PUSH MANAGER] WHERE [ID CLIENTE] = ?', [idCliente]);
16
+ const promises = [];
16
17
  for (const device of devices) {
18
+ promises.push(
19
+ // @ts-ignore
17
20
  notificationWEB(firebaseMessaging, {
18
21
  title,
19
22
  body,
20
- }, device.subscription);
23
+ }, device.subscription));
21
24
  }
25
+ return promises;
22
26
  });
23
27
  exports.sendNotification = sendNotification;
24
28
  function notificationWEB(firebaseMessaging, msg, token) {
25
29
  return __awaiter(this, void 0, void 0, function* () {
26
30
  if (!msg.title)
27
31
  msg.title = '';
28
- firebaseMessaging
32
+ return firebaseMessaging
29
33
  .send({
30
34
  token,
31
35
  notification: msg,
32
36
  data: msg,
33
- })
34
- .catch((error) => {
35
- if (error.errorInfo.code === 'messaging/registration-token-not-registered') {
36
- // query(
37
- // 'DELETE FROM [PUSH MANAGER] WHERE [ID CLIENTE] = ? AND [SUBSCRIPTION] = ?',
38
- // [idCliente, subscription]
39
- // );
40
- }
41
37
  });
42
38
  });
43
39
  }
@@ -1,3 +1,22 @@
1
- declare const sendChatMessage: () => string;
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
+ }>;
2
21
  export { sendChatMessage };
3
22
  //# sourceMappingURL=sendChatMessage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sendChatMessage.d.ts","sourceRoot":"","sources":["../../../../../src/chat/utils/sendChatMessage.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,eAAe,cAEpB,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC"}
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"}
@@ -4,6 +4,6 @@ interface Notification {
4
4
  title?: string;
5
5
  body: string;
6
6
  }
7
- declare const sendNotification: ({ firebaseMessaging, idCliente, title, body }: Notification) => Promise<void>;
7
+ declare const sendNotification: ({ firebaseMessaging, idCliente, title, body }: Notification) => Promise<any[]>;
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,kDAAyD,YAAY,kBAa1F,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,mBAmB1F,CAAC;AAaF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"