goldstars-services 1.0.71 → 1.0.73

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.
@@ -43,6 +43,12 @@ var scheduleExceptionSchema = new _mongoose.default.Schema({
43
43
  isActive: {
44
44
  type: Boolean,
45
45
  default: true
46
+ },
47
+ duration: {
48
+ type: Number,
49
+ default: 45,
50
+ min: 15,
51
+ max: 180
46
52
  }
47
53
  }],
48
54
  // Para SLOT_BLOCKED
@@ -16,13 +16,13 @@ var weeklyScheduleTemplateSchema = new _mongoose.default.Schema({
16
16
  dayOfWeek: {
17
17
  type: Number,
18
18
  required: true,
19
- min: 1,
20
- // Monday
21
- max: 5,
22
- // Friday
19
+ min: 0,
20
+ // Sunday
21
+ max: 6,
22
+ // Saturday
23
23
  validate: {
24
24
  validator: Number.isInteger,
25
- message: 'dayOfWeek debe ser un número entero entre 1 (Lunes) y 5 (Viernes)'
25
+ message: 'dayOfWeek debe ser un número entero entre 0 (Domingo) y 6 (Sábado)'
26
26
  }
27
27
  },
28
28
  timeSlots: [{
@@ -41,9 +41,12 @@ var weeklyScheduleTemplateSchema = new _mongoose.default.Schema({
41
41
  type: Boolean,
42
42
  default: true
43
43
  },
44
- maxCapacity: {
44
+ duration: {
45
45
  type: Number,
46
- default: null // null = usar todas las bikes disponibles en esa ubicación
46
+ default: 45,
47
+ // Duración en minutos (45, 60, 75, 90, etc.)
48
+ min: 15,
49
+ max: 180
47
50
  }
48
51
  }],
49
52
  isActive: {
@@ -47,11 +47,6 @@ var isTimeSlotAvailableForReservation = /*#__PURE__*/function () {
47
47
  var _ref = _asyncToGenerator(function* (location, timestamp) {
48
48
  try {
49
49
  var dayOfWeek = timestamp.getDay();
50
-
51
- // Fines de semana no disponibles
52
- if (dayOfWeek === 0 || dayOfWeek === 6) {
53
- return false;
54
- }
55
50
  var timeSlot = extractTimeSlotFromTimestamp(timestamp);
56
51
 
57
52
  // 1. Verificar excepciones (tienen prioridad)
@@ -231,6 +226,16 @@ var getBikeAvailabilityForSlot = /*#__PURE__*/function () {
231
226
  throw new Error('Timestamp inválido proporcionado para obtener disponibilidad.');
232
227
  }
233
228
 
229
+ // ===== NUEVA VALIDACIÓN: Verificar si el horario está disponible en el nuevo sistema =====
230
+ var isSlotAvailable = yield isTimeSlotAvailableForReservation(location, checkTimestamp);
231
+ if (!isSlotAvailable) {
232
+ // Si el horario no está configurado en WeeklyScheduleTemplate o ScheduleException,
233
+ // retornar array vacío (no hay horarios disponibles)
234
+ console.log("Horario no disponible para ".concat(location, " en ").concat(checkTimestamp.toISOString()));
235
+ return [];
236
+ }
237
+ // ===== FIN NUEVA VALIDACIÓN =====
238
+
234
239
  // 1. Find all bikes for the given location
235
240
  var bikesInLocation = yield _bikeModel.default.find({
236
241
  location
@@ -11,7 +11,7 @@ function _asyncToGenerator(n) { return function () { var t = this, e = arguments
11
11
  /**
12
12
  * Crear o actualizar un template de horario semanal
13
13
  * @param {String} location - Ubicación ('C.C Las Virtudes' | 'Sambil Paraguaná')
14
- * @param {Number} dayOfWeek - Día de la semana (1-5, Lunes-Viernes)
14
+ * @param {Number} dayOfWeek - Día de la semana (0-6, Domingo-Sábado)
15
15
  * @param {Array} timeSlots - Array de slots [{time: String, isActive: Boolean, maxCapacity: Number}]
16
16
  * @returns {Object} Template creado o actualizado
17
17
  */
@@ -19,8 +19,8 @@ var upsertWeeklySchedule = exports.upsertWeeklySchedule = /*#__PURE__*/function
19
19
  var _ref = _asyncToGenerator(function* (location, dayOfWeek, timeSlots) {
20
20
  try {
21
21
  // Validar dayOfWeek
22
- if (dayOfWeek < 1 || dayOfWeek > 5) {
23
- throw new Error('dayOfWeek debe estar entre 1 (Lunes) y 5 (Viernes)');
22
+ if (dayOfWeek < 0 || dayOfWeek > 6) {
23
+ throw new Error('dayOfWeek debe estar entre 0 (Domingo) y 6 (Sábado)');
24
24
  }
25
25
 
26
26
  // Validar que location sea válida
@@ -87,7 +87,7 @@ var getWeeklyScheduleByLocation = exports.getWeeklyScheduleByLocation = /*#__PUR
87
87
  /**
88
88
  * Obtener template de horario para un día específico
89
89
  * @param {String} location - Ubicación
90
- * @param {Number} dayOfWeek - Día de la semana (1-5)
90
+ * @param {Number} dayOfWeek - Día de la semana (0-6)
91
91
  * @returns {Object|null} Template de horario o null
92
92
  */
93
93
  var getWeeklyScheduleForDay = exports.getWeeklyScheduleForDay = /*#__PURE__*/function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "goldstars-services",
3
- "version": "1.0.71",
3
+ "version": "1.0.73",
4
4
  "description": "This is the services layer for GoldStars",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {