@golemio/pid 2.6.9 → 2.6.10-dev.856817708

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 (64) hide show
  1. package/db/example/03_ropidgtfs_dump.sql +1 -1
  2. package/db/migrations/postgresql/20230502115509-positions-output-view.js +53 -0
  3. package/db/migrations/postgresql/sqls/20230502115509-positions-output-view-down.sql +7 -0
  4. package/db/migrations/postgresql/sqls/20230502115509-positions-output-view-up.sql +94 -0
  5. package/dist/integration-engine/vehicle-positions/workers/runs/data-access/CommonRunsRepository.js +2 -5
  6. package/dist/integration-engine/vehicle-positions/workers/runs/data-access/CommonRunsRepository.js.map +1 -1
  7. package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/StopTimeDelayPredictionRepository.d.ts +1 -1
  8. package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/StopTimeDelayPredictionRepository.js +5 -5
  9. package/dist/integration-engine/vehicle-positions/workers/vehicle-positions/data-access/StopTimeDelayPredictionRepository.js.map +1 -1
  10. package/dist/output-gateway/vehicle-positions/VehiclePositionsRouter.d.ts +3 -3
  11. package/dist/output-gateway/vehicle-positions/VehiclePositionsRouter.js +6 -6
  12. package/dist/output-gateway/vehicle-positions/VehiclePositionsRouter.js.map +1 -1
  13. package/dist/output-gateway/vehicle-positions/data-access/ProcessedPositionRepository.d.ts +9 -0
  14. package/dist/output-gateway/vehicle-positions/data-access/ProcessedPositionRepository.js +21 -0
  15. package/dist/output-gateway/vehicle-positions/data-access/ProcessedPositionRepository.js.map +1 -0
  16. package/dist/output-gateway/vehicle-positions/data-access/TripRepository.d.ts +5 -63
  17. package/dist/output-gateway/vehicle-positions/data-access/TripRepository.js +7 -371
  18. package/dist/output-gateway/vehicle-positions/data-access/TripRepository.js.map +1 -1
  19. package/dist/output-gateway/vehicle-positions/data-access/TripWithLastPositionRepository.d.ts +51 -0
  20. package/dist/output-gateway/vehicle-positions/data-access/TripWithLastPositionRepository.js +240 -0
  21. package/dist/output-gateway/vehicle-positions/data-access/TripWithLastPositionRepository.js.map +1 -0
  22. package/dist/output-gateway/vehicle-positions/data-access/helpers/PositionOutputMapper.d.ts +5 -0
  23. package/dist/output-gateway/vehicle-positions/data-access/helpers/PositionOutputMapper.js +104 -0
  24. package/dist/output-gateway/vehicle-positions/data-access/helpers/PositionOutputMapper.js.map +1 -0
  25. package/dist/output-gateway/vehicle-positions/data-access/index.js +5 -1
  26. package/dist/output-gateway/vehicle-positions/data-access/index.js.map +1 -1
  27. package/dist/output-gateway/vehicle-positions/data-access/interfaces/{ITripRepository.d.ts → ITripWithPositionRepository.d.ts} +2 -2
  28. package/dist/output-gateway/vehicle-positions/data-access/interfaces/ITripWithPositionRepository.js +3 -0
  29. package/dist/output-gateway/vehicle-positions/data-access/interfaces/ITripWithPositionRepository.js.map +1 -0
  30. package/dist/output-gateway/vehicle-positions/data-access/interfaces/IVPRepositoryInstances.d.ts +4 -2
  31. package/dist/schema-definitions/vehicle-positions/index.d.ts +0 -8
  32. package/dist/schema-definitions/vehicle-positions/index.js +0 -8
  33. package/dist/schema-definitions/vehicle-positions/index.js.map +1 -1
  34. package/dist/schema-definitions/vehicle-positions/models/index.d.ts +0 -1
  35. package/dist/schema-definitions/vehicle-positions/models/index.js +0 -1
  36. package/dist/schema-definitions/vehicle-positions/models/index.js.map +1 -1
  37. package/dist/schema-definitions/vehicle-positions/models/views/ProcessedPositionModel.d.ts +27 -0
  38. package/dist/schema-definitions/vehicle-positions/models/views/ProcessedPositionModel.js +37 -0
  39. package/dist/schema-definitions/vehicle-positions/models/views/ProcessedPositionModel.js.map +1 -0
  40. package/dist/schema-definitions/vehicle-positions/models/views/StopTimeDelayPredictionModel.js.map +1 -0
  41. package/dist/schema-definitions/vehicle-positions/models/views/TripWithLastPositionModel.d.ts +52 -0
  42. package/dist/schema-definitions/vehicle-positions/models/views/TripWithLastPositionModel.js +56 -0
  43. package/dist/schema-definitions/vehicle-positions/models/views/TripWithLastPositionModel.js.map +1 -0
  44. package/dist/schema-definitions/vehicle-positions/models/views/index.d.ts +3 -0
  45. package/dist/schema-definitions/vehicle-positions/models/views/index.js +20 -0
  46. package/dist/schema-definitions/vehicle-positions/models/views/index.js.map +1 -0
  47. package/dist/schema-definitions/vehicle-positions/models/views/interfaces/IProcessedPositionDto.d.ts +23 -0
  48. package/dist/{output-gateway/vehicle-positions/data-access/interfaces/ITripRepository.js → schema-definitions/vehicle-positions/models/views/interfaces/IProcessedPositionDto.js} +1 -1
  49. package/dist/schema-definitions/vehicle-positions/models/views/interfaces/IProcessedPositionDto.js.map +1 -0
  50. package/dist/schema-definitions/vehicle-positions/models/views/interfaces/IStopTimeDelayPredictionDto.js.map +1 -0
  51. package/dist/schema-definitions/vehicle-positions/models/views/interfaces/ITripWithLastPositionDto.d.ts +42 -0
  52. package/dist/schema-definitions/vehicle-positions/models/views/interfaces/ITripWithLastPositionDto.js +3 -0
  53. package/dist/schema-definitions/vehicle-positions/models/views/interfaces/ITripWithLastPositionDto.js.map +1 -0
  54. package/docs/assets/pid_vp_view_erd.png +0 -0
  55. package/docs/implementation_documentation.md +11 -3
  56. package/docs/openapi-output.yaml +2 -2
  57. package/package.json +1 -1
  58. package/dist/output-gateway/vehicle-positions/data-access/interfaces/ITripRepository.js.map +0 -1
  59. package/dist/schema-definitions/vehicle-positions/models/StopTimeDelayPredictionModel.js.map +0 -1
  60. package/dist/schema-definitions/vehicle-positions/models/interfaces/IStopTimeDelayPredictionDto.js.map +0 -1
  61. /package/dist/schema-definitions/vehicle-positions/models/{StopTimeDelayPredictionModel.d.ts → views/StopTimeDelayPredictionModel.d.ts} +0 -0
  62. /package/dist/schema-definitions/vehicle-positions/models/{StopTimeDelayPredictionModel.js → views/StopTimeDelayPredictionModel.js} +0 -0
  63. /package/dist/schema-definitions/vehicle-positions/models/{interfaces → views/interfaces}/IStopTimeDelayPredictionDto.d.ts +0 -0
  64. /package/dist/schema-definitions/vehicle-positions/models/{interfaces → views/interfaces}/IStopTimeDelayPredictionDto.js +0 -0
@@ -1,387 +1,23 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __rest = (this && this.__rest) || function (s, e) {
35
- var t = {};
36
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
37
- t[p] = s[p];
38
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
39
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
40
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
41
- t[p[i]] = s[p[i]];
42
- }
43
- return t;
44
- };
45
- var __importDefault = (this && this.__importDefault) || function (mod) {
46
- return (mod && mod.__esModule) ? mod : { "default": mod };
47
- };
48
2
  Object.defineProperty(exports, "__esModule", { value: true });
49
3
  exports.TripRepository = void 0;
50
- const data_access_1 = require("../../shared/data-access");
51
4
  const const_1 = require("../../../schema-definitions/const");
52
- const models_1 = require("../../../schema-definitions/vehicle-descriptors/models");
53
- const vehicle_positions_1 = require("../../../schema-definitions/vehicle-positions");
54
- const models_2 = require("../../../schema-definitions/vehicle-positions/models");
55
- const data_access_2 = require("@golemio/core/dist/output-gateway/data-access");
56
- const database_1 = require("@golemio/core/dist/output-gateway/database");
57
- const Geo_1 = require("@golemio/core/dist/output-gateway/Geo");
58
- const models_3 = require("@golemio/core/dist/output-gateway/models");
59
- const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
60
- const moment_timezone_1 = __importDefault(require("@golemio/core/dist/shared/moment-timezone"));
61
- const sequelize_1 = __importStar(require("@golemio/core/dist/shared/sequelize"));
62
- const const_2 = require("../../../const");
63
- const RouteTypeEnums_1 = require("../../../helpers/RouteTypeEnums");
64
- const POSITION_LIMIT = 100;
65
- class TripRepository extends models_3.SequelizeModel {
5
+ const models_1 = require("../../../schema-definitions/vehicle-positions/models");
6
+ const models_2 = require("@golemio/core/dist/output-gateway/models");
7
+ class TripRepository extends models_2.SequelizeModel {
66
8
  constructor() {
67
- super("VPTripsRepository", models_2.VPTripsModel.TABLE_NAME, models_2.VPTripsModel.attributeModel, {
9
+ super("VPTripsRepository", models_1.VPTripsModel.TABLE_NAME, models_1.VPTripsModel.attributeModel, {
68
10
  schema: const_1.PG_SCHEMA,
69
11
  });
70
- this.Associate = (repositories) => {
71
- this.sequelizeModel.hasMany(repositories.positionRepository.sequelizeModel, {
72
- as: "all_positions",
73
- foreignKey: "trips_id",
74
- });
75
- this.sequelizeModel.belongsTo(repositories.positionRepository.sequelizeModel, {
76
- as: "last_position",
77
- foreignKey: "last_position_id",
78
- });
79
- this.sequelizeModel.belongsTo(repositories.vehicleTypeRepository.sequelizeModel, {
80
- as: "vehicle_type",
81
- foreignKey: "vehicle_type_id",
82
- });
83
- this.sequelizeModel.belongsTo(repositories.vehicleDescriptorRepository.sequelizeModel, {
84
- as: "vehicle_descriptor",
85
- foreignKey: "vehicle_registration_number",
86
- targetKey: "registration_number",
87
- scope: {
88
- [sequelize_1.default.Op.and]: [
89
- sequelize_1.default.literal(`${models_2.VPTripsModel.TABLE_NAME}.gtfs_route_type = vehicle_descriptor.gtfs_route_type`),
90
- ],
91
- },
92
- });
93
- };
94
- /** Retrieves all vehicle trips
95
- * @param {object} options Options object with params
96
- * @param {number} [options.limit] Limit
97
- * @param {number} [options.offset] Offset
98
- * @param {string} [options.routeId] Filter trips by specific route id
99
- * @param {string} [options.routeShortName] Filter trips by specific route short name
100
- * @param {string} [options.tripId] Filter trips by specific trip id
101
- * @param {boolean} [options.includeNotTracking] Should include not tracking vehicle positions (those off a trip)
102
- * @param {boolean} [options.includePositions] Should include all vehicle positions
103
- * @returns Array of the retrieved records
104
- */
105
- this.GetAll = (options) => __awaiter(this, void 0, void 0, function* () {
106
- try {
107
- const { limit, offset, updatedSince } = options;
108
- const minUpdatedAt = (0, moment_timezone_1.default)().subtract(10, "minutes");
109
- // updatedSince cannot be more than 10 minutes ago
110
- const maxUpdatedAt = updatedSince && (0, moment_timezone_1.default)(updatedSince).isSameOrAfter(minUpdatedAt) ? updatedSince.toISOString() : null;
111
- const include = this.ComposeIncludes(options);
112
- const isMetroVisible = yield data_access_2.featureFlagService.isFeatureEnabled(data_access_1.FeatureFlagEnum.PIDShowMetroOnMap, true);
113
- const rows = yield this.sequelizeModel.findAll({
114
- attributes: {
115
- include: ["updated_at", this.convertEpochMsColumnToISOString("start_timestamp", options.preferredTimezone)],
116
- },
117
- include,
118
- limit: options.includePositions ? (limit && limit < POSITION_LIMIT ? limit : POSITION_LIMIT) : limit,
119
- offset,
120
- where: {
121
- [sequelize_1.Op.and]: [
122
- {
123
- [sequelize_1.Op.or]: [
124
- { gtfs_trip_id: { [sequelize_1.Op.ne]: null } },
125
- {
126
- vehicle_registration_number: { [sequelize_1.Op.in]: const_2.ArrayNotPublicRegistrationNumbers },
127
- },
128
- ],
129
- },
130
- maxUpdatedAt
131
- ? {
132
- updated_at: {
133
- [sequelize_1.Op.gt]: maxUpdatedAt,
134
- },
135
- }
136
- : {},
137
- options.cisTripNumber ? { cis_trip_number: options.cisTripNumber } : {},
138
- options.routeId ? { gtfs_route_id: options.routeId } : {},
139
- options.routeShortName ? { gtfs_route_short_name: options.routeShortName } : {},
140
- options.tripId ? { gtfs_trip_id: options.tripId } : {},
141
- isMetroVisible ? {} : { vehicle_type_id: { [sequelize_1.Op.ne]: RouteTypeEnums_1.MPVRouteTypesEnum.METRO } },
142
- ],
143
- },
144
- });
145
- if (rows.length === 0) {
146
- return {
147
- data: (0, Geo_1.buildGeojsonFeatureCollection)([]),
148
- metadata: {
149
- maxUpdatedAt: maxUpdatedAt || new Date().toISOString(),
150
- },
151
- };
152
- }
153
- let returnData = [];
154
- let maxUpdatedAtData = null;
155
- for (const row of rows) {
156
- returnData.push(this.ConvertItem(row));
157
- if (row.updated_at > maxUpdatedAtData) {
158
- maxUpdatedAtData = row.updated_at;
159
- }
160
- }
161
- return {
162
- data: (0, Geo_1.buildGeojsonFeatureCollection)(returnData),
163
- metadata: {
164
- maxUpdatedAt: maxUpdatedAtData || new Date().toISOString(),
165
- },
166
- };
167
- }
168
- catch (err) {
169
- throw new golemio_errors_1.CustomError("Database error", true, "VehiclepositionsTripsModel", 500, err);
170
- }
171
- });
172
- /** Retrieves specific vehicle trip
173
- * @param {string} id Id of the trip
174
- * @param {object} [options] Options object with params
175
- * @param {string} [options.includeNotTracking] Returns last known trip even if it is not tracked at time
176
- * @param {boolean} [options.includePositions] Should include all vehicle positions
177
- * @returns Object of the retrieved record or null
178
- */
179
- this.GetOneByGTFSTripId = (id, options) => __awaiter(this, void 0, void 0, function* () {
180
- try {
181
- const include = this.ComposeIncludes(options);
182
- const data = yield this.sequelizeModel.findOne({
183
- attributes: {
184
- include: [this.convertEpochMsColumnToISOString("start_timestamp", options.preferredTimezone)],
185
- },
186
- include,
187
- order: [["start_timestamp", "DESC"]],
188
- where: {
189
- gtfs_trip_id: id,
190
- },
191
- });
192
- if (!data) {
193
- return null;
194
- }
195
- return this.ConvertItem(data);
196
- }
197
- catch (err) {
198
- throw new golemio_errors_1.CustomError("Database error", true, "VehiclePositionsTripsModel", 500, err);
199
- }
200
- });
201
- /**
202
- * Convert db result to proper output format
203
- * @param {object} item Trip object
204
- * @return
205
- */
206
- this.ConvertItem = (item) => {
207
- var _a, _b;
208
- const _c = item.toJSON ? item.toJSON() : item, { last_position, vehicle_type, vehicle_descriptor, ropidgtfs_trip, all_positions = [] } = _c, trip = __rest(_c, ["last_position", "vehicle_type", "vehicle_descriptor", "ropidgtfs_trip", "all_positions"]);
209
- const tripObject = Object.assign({ last_position: {
210
- // TODO: status is at stop, or on route
211
- // status: last_position.this_stop_id ? 'at_stop' : 'on_route/before_route/after_route',
212
- bearing: last_position.bearing,
213
- delay: {
214
- actual: last_position.delay,
215
- last_stop_arrival: last_position.delay_stop_arrival,
216
- last_stop_departure: last_position.delay_stop_departure,
217
- },
218
- is_canceled: last_position.is_canceled,
219
- last_stop: {
220
- arrival_time: last_position.last_stop_arrival_time_isostring,
221
- departure_time: last_position.last_stop_departure_time_isostring,
222
- id: last_position.last_stop_id,
223
- sequence: last_position.last_stop_sequence,
224
- },
225
- next_stop: {
226
- arrival_time: last_position.next_stop_arrival_time_isostring,
227
- departure_time: last_position.next_stop_departure_time_isostring,
228
- id: last_position.next_stop_id,
229
- sequence: last_position.next_stop_sequence,
230
- },
231
- origin_timestamp: last_position.origin_timestamp_isostring,
232
- shape_dist_traveled: last_position.shape_dist_traveled,
233
- speed: last_position.speed,
234
- state_position: last_position.state_position || null,
235
- tracking: last_position.tracking === const_2.PositionTrackingEnum.TRACKING ? true : false,
236
- }, trip: {
237
- agency_name: {
238
- real: trip.agency_name_real,
239
- scheduled: trip.agency_name_scheduled,
240
- },
241
- cis: {
242
- line_id: trip.cis_line_id,
243
- trip_number: trip.cis_trip_number,
244
- },
245
- gtfs: {
246
- route_id: trip.gtfs_route_id,
247
- route_short_name: trip.gtfs_route_short_name,
248
- route_type: trip.gtfs_route_type,
249
- trip_headsign: (_a = last_position.last_stop_headsign) !== null && _a !== void 0 ? _a : trip.gtfs_trip_headsign,
250
- trip_id: trip.gtfs_trip_id,
251
- trip_short_name: trip.gtfs_trip_short_name,
252
- },
253
- origin_route_name: trip.origin_route_name,
254
- sequence_id: trip.run_number,
255
- start_timestamp: trip.start_timestamp_isostring,
256
- vehicle_registration_number: trip.vehicle_registration_number,
257
- vehicle_type,
258
- wheelchair_accessible: trip.wheelchair_accessible,
259
- air_conditioned: (_b = vehicle_descriptor === null || vehicle_descriptor === void 0 ? void 0 : vehicle_descriptor.is_air_conditioned) !== null && _b !== void 0 ? _b : null,
260
- } }, (all_positions.length && {
261
- all_positions: (0, Geo_1.buildGeojsonFeatureCollection)(all_positions.map((position) => {
262
- return {
263
- bearing: position.bearing,
264
- delay: {
265
- actual: position.delay,
266
- last_stop_arrival: position.delay_stop_arrival,
267
- last_stop_departure: position.delay_stop_departure,
268
- },
269
- is_canceled: position.is_canceled,
270
- last_stop: {
271
- arrival_time: position.last_stop_arrival_time_isostring,
272
- departure_time: position.last_stop_departure_time_isostring,
273
- id: position.last_stop_id,
274
- sequence: position.last_stop_sequence,
275
- },
276
- lat: position.lat,
277
- lng: position.lng,
278
- next_stop: {
279
- arrival_time: position.next_stop_arrival_time_isostring,
280
- departure_time: position.next_stop_departure_time_isostring,
281
- id: position.next_stop_id,
282
- sequence: position.next_stop_sequence,
283
- },
284
- origin_timestamp: position.origin_timestamp_isostring,
285
- shape_dist_traveled: position.shape_dist_traveled,
286
- speed: position.speed,
287
- };
288
- }), "lng", "lat", true),
289
- }));
290
- return (0, Geo_1.buildGeojsonFeatureLatLng)(tripObject, last_position.lng, last_position.lat);
291
- };
292
- /** Prepare orm query with selected params
293
- * @param {object} options Options object with params
294
- * @param {boolean} [options.includeNotTracking] Should include all vehicles, even not tracked
295
- * @param {boolean} [options.includePositions] Should include all vehicle positions
296
- * @param {Date | null} [options.updatedSince] Should include all newer positions than updatedSince
297
- * @param {string} [options.preferredTimezone] Preferred timezone code
298
- * @returns Array of inclusions
299
- */
300
- this.ComposeIncludes = (options) => {
301
- const possibleStatePosition = [const_2.StatePositionEnum.AT_STOP, const_2.StatePositionEnum.ON_TRACK];
302
- if (options.includeNotTracking) {
303
- possibleStatePosition.push(const_2.StatePositionEnum.AFTER_TRACK, const_2.StatePositionEnum.BEFORE_TRACK, const_2.StatePositionEnum.BEFORE_TRACK_DELAYED, const_2.StatePositionEnum.CANCELED, const_2.StatePositionEnum.OFF_TRACK);
304
- }
305
- if (options.includeNotPublic) {
306
- possibleStatePosition.push(const_2.StatePositionEnum.NOT_PUBLIC);
307
- }
308
- const include = [
309
- {
310
- attributes: {
311
- include: [
312
- this.convertEpochMsColumnToISOString("last_stop_arrival_time", options.preferredTimezone),
313
- this.convertEpochMsColumnToISOString("last_stop_departure_time", options.preferredTimezone),
314
- this.convertEpochMsColumnToISOString("next_stop_arrival_time", options.preferredTimezone),
315
- this.convertEpochMsColumnToISOString("next_stop_departure_time", options.preferredTimezone),
316
- this.convertEpochMsColumnToISOString("origin_timestamp", options.preferredTimezone),
317
- ],
318
- exclude: ["valid_to"],
319
- },
320
- as: "last_position",
321
- model: database_1.sequelizeConnection.models[vehicle_positions_1.VehiclePositions.positions.pgTableName],
322
- where: {
323
- valid_to: {
324
- [sequelize_1.Op.or]: [null, { [sequelize_1.Op.gte]: new Date().valueOf() }],
325
- },
326
- state_position: {
327
- [sequelize_1.Op.in]: possibleStatePosition,
328
- },
329
- },
330
- },
331
- {
332
- as: "vehicle_type",
333
- model: database_1.sequelizeConnection.models[vehicle_positions_1.VehiclePositions.vehicleTypes.pgTableName],
334
- },
335
- {
336
- as: "vehicle_descriptor",
337
- model: database_1.sequelizeConnection.models[models_1.DescriptorModel.tableName],
338
- attributes: ["is_air_conditioned"],
339
- },
340
- ];
341
- if (options.includePositions) {
342
- include.push({
343
- attributes: {
344
- include: [
345
- this.convertEpochMsColumnToISOString("last_stop_arrival_time", options.preferredTimezone),
346
- this.convertEpochMsColumnToISOString("last_stop_departure_time", options.preferredTimezone),
347
- this.convertEpochMsColumnToISOString("next_stop_arrival_time", options.preferredTimezone),
348
- this.convertEpochMsColumnToISOString("next_stop_departure_time", options.preferredTimezone),
349
- this.convertEpochMsColumnToISOString("origin_timestamp", options.preferredTimezone),
350
- ],
351
- exclude: ["valid_to"],
352
- },
353
- as: "all_positions",
354
- model: database_1.sequelizeConnection.models[vehicle_positions_1.VehiclePositions.positions.pgTableName],
355
- where: {
356
- state_position: {
357
- [sequelize_1.Op.in]: possibleStatePosition,
358
- },
359
- },
360
- });
361
- }
362
- return include;
363
- };
364
12
  // last_position_context and provider_source_type should never be consumed by API users
365
13
  this.sequelizeModel.removeAttribute("last_position_context");
366
14
  this.sequelizeModel.removeAttribute("provider_source_type");
367
15
  }
368
- GetOne() {
16
+ GetAll() {
369
17
  throw new Error("Not implemented");
370
18
  }
371
- /** Creates Projection Alias for epoch in milliseconds column converted to ISO String in defined timezone
372
- * @param {string} name Column name
373
- * @param {string} preferredTimezone Preferred timezone code
374
- * @returns Projection Alias with _isostring suffix
375
- */
376
- convertEpochMsColumnToISOString(name, preferredTimezone) {
377
- return [
378
- sequelize_1.default.literal(` TO_CHAR(DATE_TRUNC('second',TO_TIMESTAMP("${name}"/1000)) AT TIME ZONE '${preferredTimezone}',` +
379
- ` 'YYYY-MM-DD"T"HH24:MI:SS') || replace('+'` +
380
- ` || to_char(DATE_TRUNC('second',TO_TIMESTAMP("${name}"/1000))` +
381
- ` AT TIME ZONE '${preferredTimezone}' - DATE_TRUNC('second',TO_TIMESTAMP("${name}"/1000))` +
382
- ` AT TIME ZONE 'UTC','HH24:MMFM'),'+-', '-')`),
383
- name + `_isostring`,
384
- ];
19
+ GetOne() {
20
+ throw new Error("Not implemented");
385
21
  }
386
22
  }
387
23
  exports.TripRepository = TripRepository;
@@ -1 +1 @@
1
- {"version":3,"file":"TripRepository.js","sourceRoot":"","sources":["../../../../src/output-gateway/vehicle-positions/data-access/TripRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAyD;AACzD,6DAAuC;AACvC,mFAAkE;AAClE,qFAA0D;AAC1D,iFAA6D;AAC7D,+EAAmF;AACnF,yEAAiF;AACjF,+DAAkI;AAClI,qEAA0E;AAE1E,6EAAuE;AACvE,gGAA+D;AAC/D,iFAAgH;AAChH,0CAAuG;AACvG,oEAA+D;AAI/D,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B,MAAa,cAAe,SAAQ,uBAAc;IAC9C;QACI,KAAK,CAAC,mBAAmB,EAAE,qBAAY,CAAC,UAAU,EAAE,qBAAY,CAAC,cAAc,EAAE;YAC7E,MAAM,EAAE,iBAAS;SACpB,CAAC,CAAC;QAOA,cAAS,GAAG,CAAC,YAAoC,EAAE,EAAE;YACxD,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,YAAY,CAAC,kBAAkB,CAAC,cAAc,EAAE;gBACxE,EAAE,EAAE,eAAe;gBACnB,UAAU,EAAE,UAAU;aACzB,CAAC,CAAC;YAEH,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,YAAY,CAAC,kBAAkB,CAAC,cAAc,EAAE;gBAC1E,EAAE,EAAE,eAAe;gBACnB,UAAU,EAAE,kBAAkB;aACjC,CAAC,CAAC;YAEH,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,YAAY,CAAC,qBAAqB,CAAC,cAAc,EAAE;gBAC7E,EAAE,EAAE,cAAc;gBAClB,UAAU,EAAE,iBAAiB;aACh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AAC,CAAC;QAC7D,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,sBAAsB,CAAC,CAAC;IAChE,CAAC;IA+HM,MAAM;QACT,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;IA0OD;;;;OAIG;IACK,+BAA+B,CAAC,IAAY,EAAE,iBAAyB;QAC3E,OAAO;YACH,mBAAS,CAAC,OAAO,CACb,8CAA8C,IAAI,0BAA0B,iBAAiB,IAAI;gBAC7F,4CAA4C;gBAC5C,iDAAiD,IAAI,UAAU;gBAC/D,kBAAkB,iBAAiB,yCAAyC,IAAI,UAAU;gBAC1F,6CAA6C,CACpD;YACD,IAAI,GAAG,YAAY;SACtB,CAAC;IACN,CAAC;CACJ;AArYD,wCAqYC"}
1
+ {"version":3,"file":"TripRepository.js","sourceRoot":"","sources":["../../../../src/output-gateway/vehicle-positions/data-access/TripRepository.ts"],"names":[],"mappings":";;;AAAA,6DAAuC;AACvC,iFAA6D;AAC7D,qEAA0E;AAG1E,MAAa,cAAe,SAAQ,uBAAc;IAG9C;QACI,KAAK,CAAC,mBAAmB,EAAE,qBAAY,CAAC,UAAU,EAAE,qBAAY,CAAC,cAAc,EAAE;YAC7E,MAAM,EAAE,iBAAS;SACpB,CAAC,CAAC;QAEH,uFAAuF;QACvF,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,uBAAuB,CAAC,CAAC;QAC7D,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,sBAAsB,CAAC,CAAC;IAChE,CAAC;IAEM,MAAM;QACT,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;IAEM,MAAM;QACT,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;CACJ;AApBD,wCAoBC"}
@@ -0,0 +1,51 @@
1
+ import { TripWithLastPositionModel } from "../../../schema-definitions/vehicle-positions/models/views";
2
+ import { SequelizeModel } from "@golemio/core/dist/output-gateway";
3
+ import { IGeoJSONFeature } from "@golemio/core/dist/output-gateway/Geo";
4
+ import { ModelStatic } from "@golemio/core/dist/shared/sequelize";
5
+ import { ITripGetAllOutput, ITripWithPositionRepository } from "./interfaces/ITripWithPositionRepository";
6
+ import { IVPRepositoryInstances } from "./interfaces/IVPRepositoryInstances";
7
+ export declare class TripWithLastPositionRepository extends SequelizeModel implements ITripWithPositionRepository {
8
+ sequelizeModel: ModelStatic<TripWithLastPositionModel>;
9
+ constructor();
10
+ Associate: (repositories: IVPRepositoryInstances) => void;
11
+ /** Retrieves all vehicle trips
12
+ * @param {object} options Options object with params
13
+ * @param {number} [options.limit] Limit
14
+ * @param {number} [options.offset] Offset
15
+ * @param {string} [options.routeId] Filter trips by specific route id
16
+ * @param {string} [options.routeShortName] Filter trips by specific route short name
17
+ * @param {string} [options.tripId] Filter trips by specific trip id
18
+ * @param {boolean} [options.includeNotTracking] Should include not tracking vehicle positions (those off a trip)
19
+ * @param {boolean} [options.includePositions] Should include all vehicle positions
20
+ * @returns Array of the retrieved records
21
+ */
22
+ GetAll: (options: {
23
+ cisTripNumber?: number;
24
+ routeId?: string;
25
+ routeShortName?: string;
26
+ tripId?: string;
27
+ includeNotTracking?: boolean;
28
+ includePositions?: boolean;
29
+ includeNotPublic?: boolean;
30
+ limit?: number;
31
+ offset?: number;
32
+ updatedSince?: Date | null;
33
+ preferredTimezone: string;
34
+ }) => Promise<ITripGetAllOutput>;
35
+ GetOne(): never;
36
+ /** Retrieves specific vehicle trip
37
+ * @param {string} id Id of the trip
38
+ * @param {object} [options] Options object with params
39
+ * @param {string} [options.includeNotTracking] Returns last known trip even if it is not tracked at time
40
+ * @param {boolean} [options.includePositions] Should include all vehicle positions
41
+ * @returns Object of the retrieved record or null
42
+ */
43
+ GetOneByGTFSTripId: (id: string, options: {
44
+ includeNotTracking?: boolean;
45
+ includePositions?: boolean;
46
+ includeNotPublic?: boolean;
47
+ preferredTimezone: string;
48
+ }) => Promise<IGeoJSONFeature | null>;
49
+ private composeIncludes;
50
+ private determinePossibleStatePositions;
51
+ }