@runnerpro/backend 1.18.5 → 1.19.0

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.
@@ -19,7 +19,7 @@ Obtener ID de una BBDD de Notion
19
19
  4º Arriba a la derecha en los 3 puntos horizontales -> Conexiones -> Conectar con API (logo de RunnerPro)
20
20
  */
21
21
  const NOTION_DATABASES_ID = {
22
- REGISTRADOS_PRUEBA_7_DIAS: '25732354-92bd-4bb5-8937-0ad583b795ab',
22
+ REGISTRADOS_PRUEBA_15_DIAS: '25732354-92bd-4bb5-8937-0ad583b795ab',
23
23
  OBSERVAR_CLIENTE: '47fc4035-7028-41c2-8b81-8e91d44a989b',
24
24
  BUSQUEDA_INFLUENCERS: 'a06bd20c-70b3-4962-a8b2-fb0e977e4530',
25
25
  };
@@ -43,22 +43,22 @@ const vertexai_1 = require("@google-cloud/vertexai");
43
43
  * );
44
44
  * ```
45
45
  */
46
- function sendPrompt(prompt, model = 'FLASH', systemPrompt = undefined, media = undefined) {
46
+ function sendPrompt(prompt, model = 'FLASH', systemPrompt = undefined, media = undefined, region = 'europe-west8') {
47
47
  var _a, _b, _c, _d;
48
48
  return __awaiter(this, void 0, void 0, function* () {
49
49
  // Inicializa el cliente de Vertex AI
50
50
  const vertex_ai = new vertexai_1.VertexAI({
51
51
  project: process.env.PROJECT_ID,
52
- location: 'europe-west8',
52
+ location: region,
53
53
  });
54
54
  // Selecciona el modelo de Gemini
55
55
  let modelGemini;
56
56
  if (model === 'LITE')
57
- modelGemini = 'gemini-2.5-flash-lite';
57
+ modelGemini = 'gemini-3.1-flash-lite-preview';
58
58
  else if (model === 'PRO')
59
- modelGemini = 'gemini-2.5-pro'; // Modelo más potente y estable
59
+ modelGemini = 'gemini-3.1-pro-preview'; // Modelo más potente y estable
60
60
  else
61
- modelGemini = 'gemini-2.5-flash';
61
+ modelGemini = 'gemini-3-flash-preview';
62
62
  // Configura el modelo generativo
63
63
  const generativeModel = vertex_ai.preview.getGenerativeModel({
64
64
  model: modelGemini,
@@ -1,5 +1,5 @@
1
1
  declare const NOTION_DATABASES_ID: {
2
- REGISTRADOS_PRUEBA_7_DIAS: string;
2
+ REGISTRADOS_PRUEBA_15_DIAS: string;
3
3
  OBSERVAR_CLIENTE: string;
4
4
  BUSQUEDA_INFLUENCERS: string;
5
5
  };
@@ -40,6 +40,6 @@ interface MediaContent {
40
40
  * );
41
41
  * ```
42
42
  */
43
- declare function sendPrompt(prompt: string, model?: string, systemPrompt?: string | undefined, media?: MediaContent | undefined): Promise<string>;
43
+ declare function sendPrompt(prompt: string, model?: string, systemPrompt?: string | undefined, media?: MediaContent | undefined, region?: string): Promise<string>;
44
44
  export { sendPrompt };
45
45
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/prompt/index.ts"],"names":[],"mappings":";AAEA;;GAEG;AACH,UAAU,YAAY;IACpB,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,iBAAe,UAAU,CACvB,MAAM,EAAE,MAAM,EACd,KAAK,GAAE,MAAgB,EACvB,YAAY,GAAE,MAAM,GAAG,SAAqB,EAC5C,KAAK,GAAE,YAAY,GAAG,SAAqB,mBAsE5C;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/prompt/index.ts"],"names":[],"mappings":";AAEA;;GAEG;AACH,UAAU,YAAY;IACpB,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,iBAAe,UAAU,CACvB,MAAM,EAAE,MAAM,EACd,KAAK,GAAE,MAAgB,EACvB,YAAY,GAAE,MAAM,GAAG,SAAqB,EAC5C,KAAK,GAAE,YAAY,GAAG,SAAqB,EAC3C,MAAM,GAAE,MAAuB,mBAsEhC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -1,3 +1,22 @@
1
+ /**
2
+ * Genera una planificación de prueba de 7 días para un cliente
3
+ *
4
+ * @param c - Objeto con los datos del cliente (días disponibles, objetivo, nivel, etc.)
5
+ * @param options - Opciones adicionales
6
+ * @param options.startDate - Fecha de inicio de la planificación (opcional, por defecto hoy)
7
+ * @returns Array de entrenamientos con fechas asignadas
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const planificacion = getPlanificacionPrueba7dias({
12
+ * monday: true,
13
+ * wednesday: true,
14
+ * saturday: true,
15
+ * goalDistance: 10000,
16
+ * nivelActual: 2,
17
+ * });
18
+ * ```
19
+ */
1
20
  declare const getPlanificacionPrueba7dias: (c: any, options?: any) => any[];
2
21
  export { getPlanificacionPrueba7dias };
3
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/workout/planificacionPrueba7dias/index.ts"],"names":[],"mappings":"AAYA,QAAA,MAAM,2BAA2B,qBAAgB,GAAG,UAoDnD,CAAC;AAmIF,OAAO,EAAE,2BAA2B,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/workout/planificacionPrueba7dias/index.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;;;;GAkBG;AACH,QAAA,MAAM,2BAA2B,qBAAgB,GAAG,UAkEnD,CAAC;AAmIF,OAAO,EAAE,2BAA2B,EAAE,CAAC"}
@@ -12,16 +12,35 @@ const getPlanificacionPrueba7dias42k_1 = require("./42k/getPlanificacionPrueba7d
12
12
  const sendMail_1 = require("../../sendMail");
13
13
  const moment_1 = __importDefault(require("moment"));
14
14
  const common_1 = require("@runnerpro/common");
15
+ /**
16
+ * Genera una planificación de prueba de 7 días para un cliente
17
+ *
18
+ * @param c - Objeto con los datos del cliente (días disponibles, objetivo, nivel, etc.)
19
+ * @param options - Opciones adicionales
20
+ * @param options.startDate - Fecha de inicio de la planificación (opcional, por defecto hoy)
21
+ * @returns Array de entrenamientos con fechas asignadas
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * const planificacion = getPlanificacionPrueba7dias({
26
+ * monday: true,
27
+ * wednesday: true,
28
+ * saturday: true,
29
+ * goalDistance: 10000,
30
+ * nivelActual: 2,
31
+ * });
32
+ * ```
33
+ */
15
34
  const getPlanificacionPrueba7dias = (c, options = {}) => {
16
35
  const { startDate } = options;
17
- const diasDisponibles = [!!c.sunday, !!c.monday, !!c.tuesday, !!c.wednesday, !!c.thursday, !!c.friday, !!c.saturday];
18
- const nDiasDisponibles = diasDisponibles.filter((d) => d).length;
19
- let workouts = [];
36
+ const diasDisponiblesSemana = [!!c.sunday, !!c.monday, !!c.tuesday, !!c.wednesday, !!c.thursday, !!c.friday, !!c.saturday];
37
+ const nDiasDisponibles = diasDisponiblesSemana.filter((d) => d).length;
38
+ let workoutsBase = [];
20
39
  changeGoalDistanceByNivelActual(c);
21
40
  // @ts-ignore
22
- workouts = getWorkoutsByGoalDistance(c);
23
- if (!workouts || workouts.length === 0) {
24
- workouts = [];
41
+ workoutsBase = getWorkoutsByGoalDistance(c);
42
+ if (!workoutsBase || workoutsBase.length === 0) {
43
+ workoutsBase = [];
25
44
  (0, sendMail_1.sendMail)({
26
45
  to: ['david.jimenez@runnerpro.app'],
27
46
  subject: 'Planificación de prueba 7 días - No hay entrenamientos',
@@ -31,10 +50,12 @@ const getPlanificacionPrueba7dias = (c, options = {}) => {
31
50
  }
32
51
  if ((Number(c.nivelEntrenamientoFuerza) === 1 || Number(c.incluirEntrenamientoFuerza) === 1) && nDiasDisponibles >= 4) {
33
52
  // @ts-ignore
34
- workouts.splice(1, 0, addWorkoutFuerza());
53
+ workoutsBase.splice(1, 0, addWorkoutFuerza());
35
54
  }
36
- if (nDiasDisponibles > workouts.length) {
37
- const nDiasExtra = nDiasDisponibles - workouts.length;
55
+ // Ajustar días disponibles si hay más días que entrenamientos en una semana
56
+ const diasDisponibles = [...diasDisponiblesSemana];
57
+ if (nDiasDisponibles > workoutsBase.length) {
58
+ const nDiasExtra = nDiasDisponibles - workoutsBase.length;
38
59
  for (let i = 0; i < nDiasExtra; i++) {
39
60
  if (diasDisponibles[0] && diasDisponibles[1])
40
61
  diasDisponibles[1] = false;
@@ -53,18 +74,25 @@ const getPlanificacionPrueba7dias = (c, options = {}) => {
53
74
  }
54
75
  }
55
76
  const planificacion = [];
56
- // Add workouts to planificacion array based on diasDisponibles and taking into account today day of week and adding to workout the date
57
77
  const today = startDate ? (0, moment_1.default)(startDate) : (0, moment_1.default)();
58
78
  const todayDayOfWeek = today.day();
59
- let todayIndex = todayDayOfWeek;
60
- for (let i = 0; i < diasDisponibles.length; i++) {
61
- if (diasDisponibles[todayIndex]) {
62
- const workout = workouts.shift();
79
+ const diasAGenerar = 7;
80
+ // Índice para iterar sobre los workouts de forma cíclica
81
+ let workoutIndex = 0;
82
+ // Iterar sobre los días a generar
83
+ for (let i = 0; i < diasAGenerar; i++) {
84
+ const dayIndex = (todayDayOfWeek + i) % 7;
85
+ if (diasDisponibles[dayIndex]) {
86
+ // Si se acabaron los workouts, reiniciar desde el principio (repetición cíclica)
87
+ if (workoutIndex >= workoutsBase.length) {
88
+ workoutIndex = 0;
89
+ }
90
+ const workout = workoutsBase[workoutIndex];
63
91
  const date = (0, moment_1.default)(today).add(i, 'days').format('YYYY-MM-DD');
64
92
  // @ts-ignore
65
93
  planificacion.push(Object.assign(Object.assign({}, workout), { date }));
94
+ workoutIndex++;
66
95
  }
67
- todayIndex = (todayIndex + 1) % 7;
68
96
  }
69
97
  return planificacion;
70
98
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.18.5",
3
+ "version": "1.19.0",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"