@runnerpro/backend 1.5.6 → 1.5.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.
- package/lib/cjs/db/index.js +11 -1
- package/lib/cjs/index.js +2 -1
- package/lib/cjs/sendNotification/index.js +15 -1
- package/lib/cjs/types/db/index.d.ts +2 -1
- 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/lib/cjs/types/sendNotification/index.d.ts.map +1 -1
- package/package.json +1 -1
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.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({
|
|
@@ -45,6 +45,16 @@ const query = (queryText, values = []) => __awaiter(void 0, void 0, void 0, func
|
|
|
45
45
|
});
|
|
46
46
|
});
|
|
47
47
|
exports.query = query;
|
|
48
|
+
const toPgArray = (arr) => {
|
|
49
|
+
if (!Array.isArray(arr) || arr.length === 0)
|
|
50
|
+
return '{}';
|
|
51
|
+
const filtered = arr.filter((item) => item.trim() !== '');
|
|
52
|
+
if (filtered.length === 0)
|
|
53
|
+
return '{}';
|
|
54
|
+
const escaped = filtered.map((item) => `"${item.replace(/"/g, '\\"')}"`);
|
|
55
|
+
return `{${escaped.join(',')}}`;
|
|
56
|
+
};
|
|
57
|
+
exports.toPgArray = toPgArray;
|
|
48
58
|
function getParseQuery(queryText, values) {
|
|
49
59
|
queryText = queryText.split('[').join('"').split(']').join('"');
|
|
50
60
|
const splitted = queryText.split('?');
|
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.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.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");
|
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "sleep", { enumerable: true, get: function () { r
|
|
|
8
8
|
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
|
+
Object.defineProperty(exports, "toPgArray", { enumerable: true, get: function () { return db_1.toPgArray; } });
|
|
11
12
|
const sendMail_1 = require("./sendMail");
|
|
12
13
|
Object.defineProperty(exports, "sendMail", { enumerable: true, get: function () { return sendMail_1.sendMail; } });
|
|
13
14
|
const err_1 = require("./err");
|
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.sendNotification = void 0;
|
|
16
16
|
const node_apn_1 = __importDefault(require("@parse/node-apn"));
|
|
17
17
|
const index_1 = require("../db/index");
|
|
18
|
+
const sendMail_1 = require("../sendMail");
|
|
18
19
|
const sendNotification = ({ firebaseMessaging, idCliente, title, body, url }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
20
|
const devices = yield (0, index_1.query)('SELECT [SUBSCRIPTION], [TYPE] FROM [PUSH MANAGER] WHERE [ID CLIENTE] = ?', [idCliente]);
|
|
20
21
|
for (const device of devices) {
|
|
@@ -53,7 +54,20 @@ function notificationIOS(msg, token) {
|
|
|
53
54
|
body: msg.body,
|
|
54
55
|
};
|
|
55
56
|
note.topic = 'ios.runnerpro.cliente';
|
|
56
|
-
|
|
57
|
+
note.pushType = 'alert';
|
|
58
|
+
note.priority = 10;
|
|
59
|
+
try {
|
|
60
|
+
yield apnProvider.send(note, token);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
(0, sendMail_1.sendMail)({
|
|
64
|
+
to: ['david.jimenez@runnerpro.app'],
|
|
65
|
+
subject: 'Error enviando notificación APN',
|
|
66
|
+
title: 'Error enviando notificación APN',
|
|
67
|
+
body: JSON.stringify(error),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
apnProvider.shutdown();
|
|
57
71
|
});
|
|
58
72
|
}
|
|
59
73
|
function notificationWEB(firebaseMessaging, msg, token) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
declare const query: (queryText: string, values?: (string | number | boolean)[]) => Promise<any>;
|
|
2
|
+
declare const toPgArray: (arr: string[]) => string;
|
|
2
3
|
declare const batchQuery: (queries: any, length?: number) => Promise<void>;
|
|
3
|
-
export { query, batchQuery };
|
|
4
|
+
export { query, batchQuery, toPgArray };
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;AA+BF,QAAA,MAAM,UAAU,YAAmB,GAAG,mCAUrC,CAAC;AAEF,OAAO,EAAE,KAAK,EAAE,UAAU,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"}
|
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 } 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';
|
|
@@ -12,5 +12,5 @@ import { readSheet, findCellByValue, writeSheet, appendSheet, getNumberByLetter,
|
|
|
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, 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, };
|
|
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,MAAM,MAAM,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,SAAS,EAAE,MAAM,MAAM,CAAC;AACpD,OAAO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/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sendNotification/index.ts"],"names":[],"mappings":"AAIA,UAAU,YAAY;IACpB,iBAAiB,EAAE,GAAG,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAED,QAAA,MAAM,gBAAgB,uDAA8D,YAAY,kBAwB/F,CAAC;AAyDF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|