@runnerpro/backend 1.6.10 → 1.6.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.
|
@@ -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;;;EAexB,CAAC;AAEF,QAAA,MAAM,mBAAmB,6CASxB,CAAC;AAEF,QAAA,MAAM,mBAAmB,6CAMxB,CAAC;AAEF,QAAA,MAAM,qBAAqB,6CAW1B,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;;;;;;EAuBvB,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -211,14 +211,18 @@ 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');
|
|
214
215
|
const workoutGarmin = translateWorkoutGarmin(workout);
|
|
216
|
+
console.log({ workoutGarmin });
|
|
215
217
|
const data = yield garminOauthActivity({
|
|
216
218
|
url: 'https://apis.garmin.com/training-api/workout',
|
|
217
219
|
userid,
|
|
218
220
|
params: workoutGarmin,
|
|
219
221
|
httpMethod: 'POST',
|
|
220
222
|
});
|
|
223
|
+
console.log({ data });
|
|
221
224
|
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');
|
|
222
226
|
return { workoutGarminId: data.workoutId, workoutGarminOwnerId: data.ownerId };
|
|
223
227
|
});
|
|
224
228
|
exports.createWorkoutGarmin = createWorkoutGarmin;
|
|
@@ -241,6 +245,7 @@ const deleteWorkoutGarmin = (userid, workout) => {
|
|
|
241
245
|
};
|
|
242
246
|
exports.deleteWorkoutGarmin = deleteWorkoutGarmin;
|
|
243
247
|
const scheduleWorkoutGarmin = (userid, workout) => {
|
|
248
|
+
console.log('scheduleWorkoutGarmin');
|
|
244
249
|
return garminOauthActivity({
|
|
245
250
|
url: 'https://apis.garmin.com/training-api/schedule',
|
|
246
251
|
userid,
|
|
@@ -19,17 +19,21 @@ 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 });
|
|
22
23
|
if (!aplicacion)
|
|
23
24
|
return { error: 'No tiene Garmin vinculado' };
|
|
24
25
|
// Obtener el workout
|
|
25
26
|
const [workout] = yield (0, db_1.query)('SELECT * FROM [WORKOUT] WHERE [ID] = ? AND [ID CLIENTE] = ?', [workoutId, clientId]);
|
|
27
|
+
console.log({ workout });
|
|
26
28
|
if (!workout)
|
|
27
29
|
throw new Error('Workout no encontrado');
|
|
28
30
|
const estructura = yield (0, db_1.query)('SELECT * FROM [WORKOUT STRUCTURE] WHERE [ID WORKOUT] = ? ORDER BY [INDEX]', [workoutId]);
|
|
31
|
+
console.log({ estructura });
|
|
29
32
|
if (estructura.length > 0)
|
|
30
33
|
workout.estructura = estructura;
|
|
31
34
|
// Llamar a la función que envía el workout al Garmin
|
|
32
35
|
const { workoutGarminId } = yield (0, garmin_1.createWorkoutGarmin)(clientId, workout);
|
|
36
|
+
console.log({ workoutGarminId });
|
|
33
37
|
yield (0, garmin_1.scheduleWorkoutGarmin)(clientId, { date: (0, moment_1.default)(workout.date).format('YYYY-MM-DD'), workoutId: workoutGarminId });
|
|
34
38
|
return { success: true };
|
|
35
39
|
});
|