@tmlmobilidade/generate-offer-files 20250627.1200.48 → 20250627.1219.55

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.
Files changed (2) hide show
  1. package/dist/main.js +9 -18
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import LOGGER from '@helperkits/logger';
3
3
  import TIMETRACKER from '@helperkits/timer';
4
4
  import { JsonWriter } from '@helperkits/writer';
5
- import { validateGtfsCalendar, validateGtfsCalendarDate, validateGtfsRouteExtended, validateGtfsStopExtended, validateGtfsTripExtended } from '@tmlmobilidade/types';
5
+ import { validateGtfsCalendar, validateGtfsCalendarDate, validateGtfsRouteExtended, validateGtfsStopExtended, validateGtfsStopTime, validateGtfsTripExtended } from '@tmlmobilidade/types';
6
6
  import { convertMetersOrKilometersToMeters, Dates, getOperationalDatesFromRange } from '@tmlmobilidade/utils';
7
7
  import { parse as csvParser } from 'csv-parse';
8
8
  import extract from 'extract-zip';
@@ -293,35 +293,26 @@ export async function generateOfferOutput(filePath, startDate, endDate, outputDi
293
293
  const parseEachRow = async (data) => {
294
294
  //
295
295
  //
296
+ // Validate the current row against the proper type
297
+ const validatedData = validateGtfsStopTime(data);
298
+ //
296
299
  // For each stopTime of each trip, check if the associated trip_id was saved
297
300
  // in the previous step or not. Skip if this row's trip_id was not saved before.
298
301
  // Also, check if the stop_id is valid and was saved before.
299
- const tripData = savedTrips.get(data.trip_id);
302
+ const tripData = savedTrips.get(validatedData.trip_id);
300
303
  if (!tripData)
301
304
  return;
302
- const stopData = savedStops.get(data.stop_id);
305
+ const stopData = savedStops.get(validatedData.stop_id);
303
306
  if (!stopData)
304
307
  return;
305
308
  //
306
309
  // Format the exported row. Only include the minimum required data
307
310
  // to prevent memory bloat later on, and include the stop data right away.
308
- const parsedRowData = {
309
- arrival_time: data.arrival_time,
310
- continuous_drop_off: data.continuous_drop_off,
311
- continuous_pickup: data.continuous_pickup,
312
- departure_time: data.departure_time,
313
- shape_dist_traveled: data.shape_dist_traveled,
314
- stop_headsign: data.stop_headsign,
315
- stop_id: data.stop_id,
316
- stop_sequence: data.stop_sequence,
317
- timepoint: data.timepoint,
318
- trip_id: data.trip_id,
319
- };
320
- const savedStopTime = savedStopTimes.get(data.trip_id);
311
+ const savedStopTime = savedStopTimes.get(validatedData.trip_id);
321
312
  if (savedStopTime)
322
- savedStopTimes.set(data.trip_id, [...savedStopTime, parsedRowData]);
313
+ savedStopTimes.set(validatedData.trip_id, [...savedStopTime, validatedData]);
323
314
  else
324
- savedStopTimes.set(data.trip_id, [parsedRowData]);
315
+ savedStopTimes.set(validatedData.trip_id, [validatedData]);
325
316
  //
326
317
  };
327
318
  //
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/generate-offer-files",
3
- "version": "20250627.1200.48",
3
+ "version": "20250627.1219.55",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"