goldstars-services 1.0.41 → 1.0.43

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.
@@ -8,11 +8,6 @@ var _reservationModel = _interopRequireDefault(require("../models/reservation.mo
8
8
  var _bikeModel = _interopRequireDefault(require("../models/bike.model.js"));
9
9
  var _mongoose = _interopRequireDefault(require("mongoose"));
10
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
14
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
15
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
16
11
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
17
12
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; } // MicroService/src/services/reservation.service.js
18
13
  // Needed to check bike status/location
@@ -96,73 +91,72 @@ var createReservation = exports.createReservation = /*#__PURE__*/function () {
96
91
  }();
97
92
 
98
93
  /**
99
- * Gets the availability status of all bikes for a specific location, date, and time slot.
94
+ * Gets the availability status of all bikes for a specific location and date.
100
95
  * @param {string} location - The location ('Sambil' or 'Las Virtudes').
101
96
  * @param {Date} date - The date to check.
102
- * @param {string} timeSlot - The time slot to check.
103
97
  * @returns {Promise<Array<object>>} - An array of bike objects, each with an added 'reservationStatus' field.
104
98
  */
105
- var getBikeAvailabilityForSlot = exports.getBikeAvailabilityForSlot = /*#__PURE__*/function () {
106
- var _ref3 = _asyncToGenerator(function* (location, date, timeSlot) {
107
- // 1. Find all bikes for the given location
108
- var bikesInLocation = yield _bikeModel.default.find({
109
- location
110
- }).lean(); // .lean() for plain JS objects
111
-
112
- // 2. Find all reservations for the specific date and time slot
113
- var reservations = yield _reservationModel.default.find({
114
- date,
115
- timeSlot,
116
- location // Filter by location as well for efficiency
117
- // Optional: Add status filter if needed
118
- // status: 'confirmed',
119
- }).populate('userId', 'name email') // Populate user name/email for admin view
120
- .lean();
99
+ // Comentado el código existente para simplificar la función y probar la exportación
100
+ /*
101
+ export const getBikeAvailabilityForSlot = async (location, date) => {
102
+ // 1. Find all bikes for the given location
103
+ const bikesInLocation = await Bike.find({ location }).lean(); // .lean() for plain JS objects
104
+
105
+ // 2. Find all reservations for the specific date
106
+ const reservations = await Reservation.find({
107
+ date,
108
+ location, // Filter by location as well for efficiency
109
+ // Optional: Add status filter if needed
110
+ // status: 'confirmed',
111
+ })
112
+ .populate('userId', 'name email') // Populate user name/email for admin view
113
+ .lean();
114
+
115
+ // 3. Create a map of reserved bike IDs for quick lookup
116
+ const reservedBikeMap = new Map();
117
+ reservations.forEach(res => {
118
+ // Store the user info (or just true if user info isn't needed/allowed)
119
+ reservedBikeMap.set(res.bikeId.toString(), res.userId); // Store populated user object
120
+ });
121
+
122
+ // 4. Combine bike data with reservation status
123
+ const bikesWithStatus = bikesInLocation.map(bike => {
124
+ const bikeIdStr = bike._id.toString();
125
+ const reservedByUser = reservedBikeMap.get(bikeIdStr);
126
+ let reservationStatus;
127
+
128
+ if (bike.isInstructorBike) {
129
+ reservationStatus = { status: 'instructor', reservedBy: null };
130
+ } else if (reservedByUser) {
131
+ // For admin: include user details. For regular user, this might be simplified later.
132
+ reservationStatus = { status: 'agendada', reservedBy: reservedByUser };
133
+ } else if (bike.status === 'Disponible') { // Check the bike's general status
134
+ reservationStatus = { status: 'disponible', reservedBy: null };
135
+ } else {
136
+ // If bike's general status is 'No Disponible' or something else
137
+ reservationStatus = { status: 'no_disponible_general', reservedBy: null };
138
+ }
139
+
140
+ return {
141
+ ...bike, // Spread original bike data
142
+ reservationStatus, // Add the specific status for this slot
143
+ };
144
+ });
145
+
146
+ return bikesWithStatus;
147
+ };
148
+ */
121
149
 
122
- // 3. Create a map of reserved bike IDs for quick lookup
123
- var reservedBikeMap = new Map();
124
- reservations.forEach(res => {
125
- // Store the user info (or just true if user info isn't needed/allowed)
126
- reservedBikeMap.set(res.bikeId.toString(), res.userId); // Store populated user object
127
- });
128
-
129
- // 4. Combine bike data with reservation status
130
- var bikesWithStatus = bikesInLocation.map(bike => {
131
- var bikeIdStr = bike._id.toString();
132
- var reservedByUser = reservedBikeMap.get(bikeIdStr);
133
- var reservationStatus;
134
- if (bike.isInstructorBike) {
135
- reservationStatus = {
136
- status: 'instructor',
137
- reservedBy: null
138
- };
139
- } else if (reservedByUser) {
140
- // For admin: include user details. For regular user, this might be simplified later.
141
- reservationStatus = {
142
- status: 'agendada',
143
- reservedBy: reservedByUser
144
- };
145
- } else if (bike.status === 'Disponible') {
146
- // Check the bike's general status
147
- reservationStatus = {
148
- status: 'disponible',
149
- reservedBy: null
150
- };
151
- } else {
152
- // If bike's general status is 'No Disponible' or something else
153
- reservationStatus = {
154
- status: 'no_disponible_general',
155
- reservedBy: null
156
- };
157
- }
158
- return _objectSpread(_objectSpread({}, bike), {}, {
159
- // Spread original bike data
160
- reservationStatus // Add the specific status for this slot
161
- });
162
- });
163
- return bikesWithStatus;
150
+ // Nueva implementación simplificada para probar la exportación
151
+ var getBikeAvailabilityForSlot = exports.getBikeAvailabilityForSlot = /*#__PURE__*/function () {
152
+ var _ref3 = _asyncToGenerator(function* (location, date) {
153
+ return {
154
+ message: "Function is being called successfully",
155
+ location,
156
+ date
157
+ };
164
158
  });
165
- return function getBikeAvailabilityForSlot(_x5, _x6, _x7) {
159
+ return function getBikeAvailabilityForSlot(_x5, _x6) {
166
160
  return _ref3.apply(this, arguments);
167
161
  };
168
162
  }();
@@ -197,7 +191,7 @@ var cancelReservation = exports.cancelReservation = /*#__PURE__*/function () {
197
191
  message: 'Reserva cancelada exitosamente.'
198
192
  };
199
193
  });
200
- return function cancelReservation(_x8, _x9, _x10) {
194
+ return function cancelReservation(_x7, _x8, _x9) {
201
195
  return _ref4.apply(this, arguments);
202
196
  };
203
197
  }();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "goldstars-services",
3
- "version": "1.0.41",
3
+ "version": "1.0.43",
4
4
  "description": "This is the services layer for GoldStars",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {