@runnerpro/backend 1.6.13 → 1.6.14
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 +5 -1
- package/lib/cjs/types/chat/api/conversation.d.ts.map +1 -1
- package/lib/cjs/types/workout/garmin.d.ts.map +1 -1
- package/lib/cjs/types/workout/sendToWatch.d.ts.map +1 -1
- package/lib/cjs/workout/garmin.js +0 -15
- package/lib/cjs/workout/sendToWatch.js +0 -4
- package/package.json +2 -2
|
@@ -217,6 +217,8 @@ const getPreferredLanguageForChat = ({ text, idCliente, isClient, query }) => __
|
|
|
217
217
|
});
|
|
218
218
|
const sendFile = (req, res, { sendNotification, firebaseMessaging, query, isClient, bucket }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
219
219
|
const { idCliente, type, duration } = req.body;
|
|
220
|
+
console.log('body', req.body);
|
|
221
|
+
console.log('file', req.file);
|
|
220
222
|
const { userid } = req.session;
|
|
221
223
|
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]);
|
|
222
224
|
const filePath = path_1.default.join('./uploads', req.file.filename);
|
|
@@ -236,10 +238,11 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, query, isClie
|
|
|
236
238
|
else {
|
|
237
239
|
files.push({ data: fileData, id: idFile });
|
|
238
240
|
}
|
|
241
|
+
console.log('files', files);
|
|
239
242
|
for (const file of files) {
|
|
240
243
|
yield bucket.file(`Chat/${file.id}`).save(file.data);
|
|
241
244
|
}
|
|
242
|
-
|
|
245
|
+
// fs.unlinkSync(filePath);
|
|
243
246
|
if (!isClient) {
|
|
244
247
|
const [cliente] = yield query('SELECT [PREFERRED LANGUAGE] FROM [CLIENTE] WHERE [ID] = ?', [idCliente]);
|
|
245
248
|
sendNotification({
|
|
@@ -249,6 +252,7 @@ const sendFile = (req, res, { sendNotification, firebaseMessaging, query, isClie
|
|
|
249
252
|
url: '/chat',
|
|
250
253
|
});
|
|
251
254
|
}
|
|
255
|
+
console.log('idFile', idFile);
|
|
252
256
|
res.send({ idFile });
|
|
253
257
|
});
|
|
254
258
|
const readMessage = (req, res, { query, isClient }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAkBpD,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;AA+SF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"garmin.d.ts","sourceRoot":"","sources":["../../../../src/workout/garmin.ts"],"names":[],"mappings":"AAkOA,QAAA,MAAM,mBAAmB;;;
|
|
1
|
+
{"version":3,"file":"garmin.d.ts","sourceRoot":"","sources":["../../../../src/workout/garmin.ts"],"names":[],"mappings":"AAkOA,QAAA,MAAM,mBAAmB;;;EAWxB,CAAC;AAEF,QAAA,MAAM,mBAAmB,6CASxB,CAAC;AAEF,QAAA,MAAM,mBAAmB,6CAMxB,CAAC;AAEF,QAAA,MAAM,qBAAqB,6CAU1B,CAAC;AAEF,QAAA,MAAM,2BAA2B,4DAWhC,CAAC;AAIF,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendToWatch.d.ts","sourceRoot":"","sources":["../../../../src/workout/sendToWatch.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,kBAAkB;;;;;;
|
|
1
|
+
{"version":3,"file":"sendToWatch.d.ts","sourceRoot":"","sources":["../../../../src/workout/sendToWatch.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,kBAAkB;;;;;;EAmBvB,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -211,18 +211,14 @@ const getWorkoutGarminTargetValue = (workout, row) => {
|
|
|
211
211
|
}
|
|
212
212
|
};
|
|
213
213
|
const createWorkoutGarmin = (userid, workout) => __awaiter(void 0, void 0, void 0, function* () {
|
|
214
|
-
console.log('createWorkoutGarmin');
|
|
215
214
|
const workoutGarmin = translateWorkoutGarmin(workout);
|
|
216
|
-
console.log({ workoutGarmin });
|
|
217
215
|
const data = yield garminOauthActivity({
|
|
218
216
|
url: 'https://apis.garmin.com/training-api/workout',
|
|
219
217
|
userid,
|
|
220
218
|
params: workoutGarmin,
|
|
221
219
|
httpMethod: 'POST',
|
|
222
220
|
});
|
|
223
|
-
console.log({ data });
|
|
224
221
|
yield (0, db_1.query)('UPDATE [WORKOUT] SET [WORKOUT ID GARMIN] = ?, [WORKOUT OWNER GARMIN] = ? WHERE [ID] = ?', [data.workoutId, data.ownerId, workout.id]);
|
|
225
|
-
console.log('updateWorkoutGarmin');
|
|
226
222
|
return { workoutGarminId: data.workoutId, workoutGarminOwnerId: data.ownerId };
|
|
227
223
|
});
|
|
228
224
|
exports.createWorkoutGarmin = createWorkoutGarmin;
|
|
@@ -245,17 +241,6 @@ const deleteWorkoutGarmin = (userid, workout) => {
|
|
|
245
241
|
};
|
|
246
242
|
exports.deleteWorkoutGarmin = deleteWorkoutGarmin;
|
|
247
243
|
const scheduleWorkoutGarmin = (userid, workout) => {
|
|
248
|
-
console.log('scheduleWorkoutGarmin');
|
|
249
|
-
console.log(userid, workout);
|
|
250
|
-
console.log({
|
|
251
|
-
url: 'https://apis.garmin.com/training-api/schedule',
|
|
252
|
-
userid,
|
|
253
|
-
httpMethod: 'POST',
|
|
254
|
-
params: {
|
|
255
|
-
workoutId: workout.workoutGarminId,
|
|
256
|
-
date: workout.date,
|
|
257
|
-
},
|
|
258
|
-
});
|
|
259
244
|
return garminOauthActivity({
|
|
260
245
|
url: 'https://apis.garmin.com/training-api/schedule',
|
|
261
246
|
userid,
|
|
@@ -19,21 +19,17 @@ const common_1 = require("@runnerpro/common");
|
|
|
19
19
|
const moment_1 = __importDefault(require("moment"));
|
|
20
20
|
const sendWorkoutToWatch = (clientId, workoutId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
21
|
const [aplicacion] = yield (0, db_1.query)('SELECT [TIPO APLICATION] FROM [CLIENTE APLICACIONES] WHERE [ID CLIENTE] = ? AND [TIPO APLICATION] = ?', [clientId, common_1.TIPO_APLICACION.GARMIN]);
|
|
22
|
-
console.log({ aplicacion });
|
|
23
22
|
if (!aplicacion)
|
|
24
23
|
return { error: 'No tiene Garmin vinculado' };
|
|
25
24
|
// Obtener el workout
|
|
26
25
|
const [workout] = yield (0, db_1.query)('SELECT * FROM [WORKOUT] WHERE [ID] = ? AND [ID CLIENTE] = ?', [workoutId, clientId]);
|
|
27
|
-
console.log({ workout });
|
|
28
26
|
if (!workout)
|
|
29
27
|
throw new Error('Workout no encontrado');
|
|
30
28
|
const estructura = yield (0, db_1.query)('SELECT * FROM [WORKOUT STRUCTURE] WHERE [ID WORKOUT] = ? ORDER BY [INDEX]', [workoutId]);
|
|
31
|
-
console.log({ estructura });
|
|
32
29
|
if (estructura.length > 0)
|
|
33
30
|
workout.estructura = estructura;
|
|
34
31
|
// Llamar a la función que envía el workout al Garmin
|
|
35
32
|
const { workoutGarminId } = yield (0, garmin_1.createWorkoutGarmin)(clientId, workout);
|
|
36
|
-
console.log({ workoutGarminId });
|
|
37
33
|
yield (0, garmin_1.scheduleWorkoutGarmin)(clientId, { date: (0, moment_1.default)(workout.date).format('YYYY-MM-DD'), workoutGarminId });
|
|
38
34
|
return { success: true };
|
|
39
35
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runnerpro/backend",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.14",
|
|
4
4
|
"description": "A collection of common backend functions",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./lib/cjs/index.js"
|
|
@@ -70,4 +70,4 @@
|
|
|
70
70
|
"socket.io": "^4.7.2",
|
|
71
71
|
"oauth-signature": "1.5.0"
|
|
72
72
|
}
|
|
73
|
-
}
|
|
73
|
+
}
|