@carrismetropolitana/api-types 1.0.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.
@@ -0,0 +1,18 @@
1
+ interface ByHour {
2
+ hour: number
3
+ qty: number
4
+ }
5
+
6
+ interface ByDay {
7
+ by_hour: ByHour[]
8
+ day: string
9
+ qty: number
10
+ }
11
+
12
+ export interface DemandMetrics {
13
+ by_day: ByDay[]
14
+ end_date: string
15
+ item_id: string
16
+ start_date: string
17
+ total_qty: number
18
+ };
@@ -0,0 +1,173 @@
1
+ /* * */
2
+
3
+ import type { Feature, LineString } from 'geojson';
4
+
5
+ /* * */
6
+
7
+ export interface Line {
8
+ color: string
9
+ district_ids: string[]
10
+ facilities: string[]
11
+ id: string
12
+ locality_ids: string[]
13
+ long_name: string
14
+ municipality_ids: string[]
15
+ pattern_ids: string[]
16
+ region_ids: string[]
17
+ route_ids: string[]
18
+ short_name: string
19
+ stop_ids: string[]
20
+ text_color: string
21
+ tts_name: string
22
+ }
23
+
24
+ /* * */
25
+
26
+ export interface Route {
27
+ color: string
28
+ district_ids: string[]
29
+ facilities: string[]
30
+ id: string
31
+ line_id: string
32
+ locality_ids: string[]
33
+ long_name: string
34
+ municipality_ids: string[]
35
+ pattern_ids: string[]
36
+ region_ids: string[]
37
+ short_name: string
38
+ stop_ids: string[]
39
+ text_color: string
40
+ tts_name: string
41
+ }
42
+
43
+ /* * */
44
+
45
+ export interface Pattern {
46
+ color: string
47
+ district_ids: string[]
48
+ facilities: string[]
49
+ headsign: string
50
+ id: string
51
+ line_id: string
52
+ locality_ids: string[]
53
+ long_name: string
54
+ municipality_ids: string[]
55
+ path: Waypoint[]
56
+ region_ids: string[]
57
+ route_id: string[]
58
+ shape_id: string
59
+ short_name: string
60
+ text_color: string
61
+ trips: Trip[]
62
+ tts_headsign: string
63
+ valid_on: string[]
64
+ version_id: string
65
+ }
66
+
67
+ export interface Waypoint {
68
+ allow_drop_off: boolean
69
+ allow_pickup: boolean
70
+ distance: number
71
+ distance_delta: number
72
+ stop_id: string
73
+ stop_sequence: number
74
+ }
75
+
76
+ export interface Trip {
77
+ schedule: Arrival[]
78
+ service_ids: string[]
79
+ trip_group_id: string
80
+ trip_ids: string[]
81
+ valid_on: string[]
82
+ version_id: string
83
+ }
84
+
85
+ export interface Arrival {
86
+ arrival_time: string
87
+ arrival_time_24h: string
88
+ stop_id: string
89
+ stop_sequence: number
90
+ }
91
+
92
+ /* * */
93
+
94
+ export interface Shape {
95
+ extension: number
96
+ geojson: Feature<LineString>
97
+ points: ShapePoint[]
98
+ shape_id: string
99
+ }
100
+
101
+ export interface ShapePoint {
102
+ shape_dist_traveled: number
103
+ shape_pt_lat: number
104
+ shape_pt_lon: number
105
+ shape_pt_sequence: number
106
+ }
107
+
108
+ /* * */
109
+
110
+ export interface Stop {
111
+ district_id: string
112
+ facilities: string[]
113
+ id: string
114
+ lat: number
115
+ line_ids: string[]
116
+ locality_id: string
117
+ lon: number
118
+ long_name: string
119
+ municipality_id: string
120
+ operational_status: StopOperationalStatus
121
+ pattern_ids: string[]
122
+ region_id: string
123
+ route_ids: string[]
124
+ short_name: string
125
+ tts_name: string
126
+ wheelchair_boarding: boolean
127
+ }
128
+
129
+ export enum StopOperationalStatus {
130
+ active = 'active',
131
+ seasonal = 'seasonal',
132
+ voided = 'voided',
133
+ }
134
+
135
+ /* * */
136
+
137
+ export interface Date {
138
+ day_type: DateDayType
139
+ description: string
140
+ holiday: boolean
141
+ id: string
142
+ period_id: string
143
+ }
144
+
145
+ export enum DateDayType {
146
+ saturday = 'saturday',
147
+ sundayHoliday = 'sunday_holiday',
148
+ weekday = 'weekday',
149
+ }
150
+
151
+ /* * */
152
+
153
+ export interface Period {
154
+ dates: string[]
155
+ id: string
156
+ name: string
157
+ valid_on: string[]
158
+ valid_ranges: DateRange[]
159
+ }
160
+
161
+ /* * */
162
+
163
+ export interface Archive {
164
+ agency_id: string
165
+ id: string
166
+ valid_range: DateRange
167
+ }
168
+
169
+ /* * */
170
+ export interface DateRange {
171
+ end?: string
172
+ start: string
173
+ }
@@ -0,0 +1,128 @@
1
+ /* * */
2
+
3
+ export interface Vehicle {
4
+ agency_id: string
5
+ bearing?: number
6
+ bikes_allowed: boolean
7
+ block_id?: string
8
+ capacity_seated?: number
9
+ capacity_standing?: number
10
+ capacity_total?: number
11
+ current_status?: VehicleCurrentStatus
12
+ direction_id?: number
13
+ emission_class?: VehicleEmissionClass
14
+ event_id?: string
15
+ id: string
16
+ lat?: number
17
+ license_plate?: string
18
+ line_id: string
19
+ lon?: number
20
+ make?: string
21
+ model?: string
22
+ occupancy_estimated?: number
23
+ occupancy_status?: VehicleOccupancyStatus
24
+ owner?: string
25
+ pattern_id: string
26
+ propulsion?: VehiclePropulsion
27
+ registration_date?: string
28
+ route_id?: string
29
+ schedule_relationship?: VehicleScheduleRelationship
30
+ shift_id?: string
31
+ speed?: number
32
+ stop_id?: string
33
+ timestamp?: number
34
+ trip_id?: string
35
+ wheelchair_accessible: boolean
36
+ }
37
+
38
+ /* * */
39
+
40
+ export enum VehicleEmissionClass {
41
+ euro1 = 'euro_1',
42
+ euro2 = 'euro_2',
43
+ euro3 = 'euro_3',
44
+ euro4 = 'euro_4',
45
+ euro5 = 'euro_5',
46
+ euro6 = 'euro_6',
47
+ };
48
+
49
+ export function convertVehicleEmissionClassCode(emissionClassCode: string): undefined | VehicleEmissionClass {
50
+ switch (emissionClassCode) {
51
+ case '1':
52
+ return VehicleEmissionClass.euro1;
53
+ case '2':
54
+ return VehicleEmissionClass.euro2;
55
+ case '3':
56
+ return VehicleEmissionClass.euro3;
57
+ case '4':
58
+ return VehicleEmissionClass.euro4;
59
+ case '5':
60
+ return VehicleEmissionClass.euro5;
61
+ case '6':
62
+ return VehicleEmissionClass.euro6;
63
+ default:
64
+ return undefined;
65
+ }
66
+ }
67
+
68
+ /* * */
69
+
70
+ export enum VehiclePropulsion {
71
+ biodiesel = 'biodiesel',
72
+ diesel = 'diesel',
73
+ electricity = 'electricity',
74
+ gasoline = 'gasoline',
75
+ hybrid = 'hybrid',
76
+ lpgAuto = 'lpg_auto',
77
+ mixture = 'mixture',
78
+ natural_gas = 'natural_gas',
79
+ }
80
+
81
+ export function convertVehiclePropulsionCode(propulsionCode: string): undefined | VehiclePropulsion {
82
+ switch (propulsionCode) {
83
+ case '1':
84
+ return VehiclePropulsion.gasoline;
85
+ case '2':
86
+ return VehiclePropulsion.diesel;
87
+ case '3':
88
+ return VehiclePropulsion.lpgAuto;
89
+ case '4':
90
+ return VehiclePropulsion.mixture;
91
+ case '5':
92
+ return VehiclePropulsion.biodiesel;
93
+ case '6':
94
+ return VehiclePropulsion.electricity;
95
+ case '7':
96
+ return VehiclePropulsion.hybrid;
97
+ case '8':
98
+ return VehiclePropulsion.natural_gas;
99
+ default:
100
+ return undefined;
101
+ }
102
+ }
103
+
104
+ /* * */
105
+
106
+ export enum VehicleCurrentStatus {
107
+ in_transit_to = 'in_transit_to',
108
+ incoming_at = 'incoming_at',
109
+ stopped_at = 'stopped_at',
110
+ }
111
+
112
+ /* * */
113
+
114
+ export enum VehicleScheduleRelationship {
115
+ added = 'added',
116
+ canceled = 'canceled',
117
+ scheduled = 'scheduled',
118
+ unscheduled = 'unscheduled',
119
+ }
120
+
121
+ /* * */
122
+
123
+ export enum VehicleOccupancyStatus {
124
+ empty = 'empty',
125
+ full = 'full',
126
+ seats_available = 'seats_available',
127
+ standing_only = 'standing_only',
128
+ }
@@ -0,0 +1 @@
1
+ export * from 'gtfs-types';
@@ -0,0 +1,284 @@
1
+ /* * */
2
+
3
+ import { GTFSBool } from 'gtfs-types';
4
+ import * as GtfsCore from 'gtfs-types';
5
+
6
+ /* * */
7
+
8
+ /**
9
+ * Type for GTFS routes.txt file.
10
+ */
11
+ export interface Route extends GtfsCore.Route {
12
+ line_id: string
13
+ line_long_name: string
14
+ line_short_name: string
15
+ }
16
+
17
+ /**
18
+ * Type for GTFS calendar_dates.txt file.
19
+ */
20
+ export interface CalendarDate extends GtfsCore.CalendarDates {
21
+ day_type: string
22
+ holiday: string
23
+ period: string
24
+ }
25
+
26
+ /**
27
+ * Type for GTFS dates.txt file.
28
+ */
29
+ export interface Date {
30
+ date: string
31
+ day_type: string
32
+ description: string
33
+ holiday: string
34
+ period: string
35
+ }
36
+
37
+ /**
38
+ * Type for GTFS periods.txt file.
39
+ */
40
+ export interface Period {
41
+ period_id: string
42
+ period_name: string
43
+ }
44
+
45
+ /**
46
+ * Type for GTFS trips.txt file.
47
+ */
48
+ export interface Trip extends GtfsCore.Trip {
49
+ calendar_desc: string
50
+ pattern_id: string
51
+ }
52
+
53
+ /**
54
+ * Type for GTFS stop_times.txt file.
55
+ */
56
+ export type StopTime = GtfsCore.StopTime;
57
+
58
+ /**
59
+ * Type for GTFS shapes.txt file.
60
+ */
61
+ export type Shape = GtfsCore.Shapes;
62
+
63
+ /**
64
+ * Type for GTFS stops.txt file.
65
+ */
66
+ export interface Stop extends GtfsCore.Stop {
67
+ airport: boolean
68
+ bike_parking: boolean
69
+ bike_sharing: boolean
70
+ boat: boolean
71
+ car_parking: boolean
72
+ district_id: string
73
+ district_name: string
74
+ light_rail: boolean
75
+ locality: string
76
+ municipality_id: string
77
+ municipality_name: string
78
+ near_fire_station: boolean
79
+ near_health_clinic: boolean
80
+ near_historic_building: boolean
81
+ near_hospital: boolean
82
+ near_police_station: boolean
83
+ near_school: boolean
84
+ near_shopping: boolean
85
+ near_transit_office: boolean
86
+ near_university: boolean
87
+ operational_status: string
88
+ parish_id: null
89
+ parish_name: null
90
+ region_id: string
91
+ region_name: string
92
+ stop_id: string
93
+ stop_lat: number
94
+ stop_lon: number
95
+ stop_name: string
96
+ stop_short_name: string
97
+ subway: boolean
98
+ train: boolean
99
+ tts_stop_name: string
100
+ wheelchair_boarding: GtfsCore.WheelchairBoardingType
101
+ }
102
+
103
+ /**
104
+ * Type for GTFS vehicles.txt file.
105
+ */
106
+ export interface Vehicle {
107
+ agency_id: string
108
+ bikes_allowed: GTFSBool
109
+ capacity_seated: number
110
+ capacity_standing: number
111
+ emission_class: string
112
+ license_plate: string
113
+ make: string
114
+ model: string
115
+ owner: string
116
+ passenger_counting: GTFSBool
117
+ propulsion: string
118
+ registration_date: string
119
+ vehicle_id: string
120
+ wheelchair_accessible: GTFSBool
121
+ }
122
+
123
+ /* * */
124
+
125
+ export interface VehicleEvent {
126
+ content: VehicleEventContent
127
+ millis: number
128
+ }
129
+
130
+ export interface VehicleEventContent {
131
+ entity: VehicleEventEntity[]
132
+ header: GtfsCore.FeedHeader
133
+ }
134
+
135
+ export interface VehicleEventEntity {
136
+ _id: string
137
+ vehicle: VehiclePosition
138
+ }
139
+
140
+ export interface VehiclePosition {
141
+ agencyId: string
142
+ currentStatus: GtfsCore.VehicleStopStatus
143
+ operationPlanId: string
144
+ passengerCounting: VehiclePositionPassengerCounting
145
+ position: GtfsCore.Position
146
+ stopId: string
147
+ timestamp: number
148
+ trigger: VehiclePositionTrigger
149
+ trip: VehiclePositionTrip
150
+ vehicle: VehiclePositionVehicle
151
+ }
152
+
153
+ export interface VehiclePositionTrigger {
154
+ activity: string
155
+ door: string
156
+ }
157
+
158
+ export interface VehiclePositionTrip {
159
+ lineId: string
160
+ patternId: string
161
+ routeId: string
162
+ scheduleRelationship: GtfsCore.TripScheduleRelationship
163
+ tripId: string
164
+ }
165
+
166
+ export interface VehiclePositionVehicle {
167
+ _id: string
168
+ blockId: string
169
+ driverId: string
170
+ shiftId: string
171
+ }
172
+
173
+ export interface VehiclePositionPassengerCounting {
174
+ counting: VehiclePositionPassengerCountingCount[]
175
+ }
176
+
177
+ export interface VehiclePositionPassengerCountingCount {
178
+ classId: 'adult' | 'children'
179
+ incoming: number
180
+ outgoing: number
181
+ }
182
+
183
+ /* * */
184
+
185
+ /**
186
+ * GTFS Realtime Feed Message Types
187
+ */
188
+ export interface FeedHeader {
189
+ gtfsRealtimeVersion: '2.0'
190
+ incrementality: 'FULL_DATASET'
191
+ timestamp: number
192
+ }
193
+
194
+ export interface TranslatedString {
195
+ translation: Translation[]
196
+ }
197
+
198
+ /**
199
+ * A translation of a string. Exactly one of text or file must be present.
200
+ * The language field must be a valid BCP 47 language tag.
201
+ *
202
+ * More info: https://gtfs.org/realtime/reference/#message-translation
203
+ *
204
+ * @param language - The language of the text. Must be a valid BCP 47 language tag.
205
+ * @param text - The translated text.
206
+ *
207
+ */
208
+ interface Translation {
209
+ language: string
210
+ text: string
211
+ }
212
+
213
+ export interface TranslatedImage {
214
+ localizedImage: LocalizedImage[]
215
+ }
216
+
217
+ /**
218
+ * A localized image. At least one translation must be provided.
219
+ * The image type must be a valid MIME type. The URL must be a valid URL.
220
+ * The language field must be a valid BCP 47 language tag.
221
+ *
222
+ * More info: https://gtfs.org/realtime/reference/#message-localizedimage
223
+ *
224
+ * @param language - The language of the image. Must be a valid BCP 47 language tag.
225
+ * @param mediaType - The MIME type of the image.
226
+ * @param url - The URL of the image.
227
+ *
228
+ */
229
+ interface LocalizedImage {
230
+ language: string
231
+ mediaType: string
232
+ url: string
233
+ }
234
+
235
+ /**
236
+ * POSIX time (i.e., number of seconds since January 1st 1970 00:00:00 UTC). If start or end is missing,
237
+ * the interval starts at minus or plus infinity. If a TimeRange is provided, either start or end must
238
+ * be provided - both fields cannot be empty.
239
+ *
240
+ * Here, it is expected that a TimeRange object will always be provided with a start value.
241
+ *
242
+ * More info: https://gtfs.org/realtime/reference/#message-timerange
243
+ *
244
+ * @param start - Start time in POSIX time.
245
+ * @param end - End time in POSIX time. If not provided, the interval ends at plus infinity.
246
+ *
247
+ */
248
+ export interface TimeRange {
249
+ end?: number
250
+ start: number
251
+ }
252
+
253
+ /**
254
+ * A selector for an entity in a GTFS feed. The values of the fields should correspond to the appropriate fields in the GTFS feed.
255
+ * At least one specifier must be given. If several are given, they should be interpreted as being joined by the logical AND operator.
256
+ * Additionally, the combination of specifiers must match the corresponding information in the GTFS feed.
257
+ * In other words, in order for an alert to apply to an entity in GTFS it must match all of the provided EntitySelector fields.
258
+ * For example, an EntitySelector that includes the fields route_id: "5" and route_type: "3" applies only
259
+ * to the route_id: "5" bus - it does not apply to any other routes of route_type: "3". If a producer wants an alert
260
+ * to apply to route_id: "5" as well as route_type: "3", it should provide two separate EntitySelectors,
261
+ * one referencing route_id: "5" and another referencing route_type: "3".
262
+ *
263
+ * More info: https://gtfs.org/realtime/reference/#message-entityselector
264
+ *
265
+ * @param agencyId - The agency_id of the agency that operates the entity. Required if the entity is not identified by a specific route_id.
266
+ * @param lineId - The line_id of the line that the entity belongs to. Non-standard.
267
+ * @param routeId - The route_id of the route that the entity belongs to.
268
+ * @param stopId - The stop_id of the stop that the entity is associated with. Optional.
269
+ * @param tripId - The trip_id of the trip that the entity belongs to. Required if the entity is not identified by route_id.
270
+ *
271
+ */
272
+ export interface EntitySelector {
273
+ agencyId?: string
274
+ lineId?: string // Non-standard
275
+ routeId?: string
276
+ stopId?: string
277
+ tripId?: string
278
+ }
279
+
280
+ /* * */
281
+
282
+ export function convertGTFSBoolToBoolean(value: GTFSBool): boolean {
283
+ return Number(value) === GTFSBool.YES ? true : false;
284
+ }
@@ -0,0 +1,101 @@
1
+ export interface TrinoValidations {
2
+ id: string;
3
+ createdat?: string;
4
+ rawloaddate?: string;
5
+ rawloaddateiso?: string;
6
+ issignaturecorrect?: boolean;
7
+ isfraud?: boolean;
8
+ batchid?: string;
9
+ operator?: string;
10
+ csvtransaction?: string;
11
+ apextransactiontype?: number;
12
+ apextransactionversion?: string;
13
+ transactionid?: string;
14
+ transactiongroupid?: string;
15
+ transactiondate?: string;
16
+ apexversion?: string;
17
+ vivaversion?: string;
18
+ technicalparametersversion?: string;
19
+ commercialofferversion?: string;
20
+ networkversion?: string;
21
+ actionlistsversion?: string;
22
+ operatorlongid?: string;
23
+ networkid?: string;
24
+ channelid?: string;
25
+ deviceid?: string;
26
+ cardtypeid?: string;
27
+ cardphysicaltype?: number;
28
+ cardnetworkid?: string;
29
+ cardissuer?: number;
30
+ cardnumber?: bigint;
31
+ cardserialnumber?: string;
32
+ operationplanid?: string;
33
+ vehicleplanid?: string;
34
+ vehicleid?: number;
35
+ driverplanid?: string;
36
+ timetableid?: string;
37
+ unfoldingid?: string;
38
+ validatorid?: number;
39
+ zonelongid?: string;
40
+ routelongid?: string;
41
+ runlongid?: string;
42
+ stoplongid?: string;
43
+ validationtype?: number;
44
+ productlongid?: string;
45
+ tickloaddate?: string;
46
+ tickloadmachcode?: number;
47
+ tickloadnumbdaily?: number;
48
+ unitsquantity?: number;
49
+ unitsremaining?: number;
50
+ contractnumber?: number;
51
+ eventtype?: number;
52
+ validationstatus?: number;
53
+ whitelistitemid?: string;
54
+ calendarid?: string;
55
+ validityperiodid?: string;
56
+ spatialvaliditylongid?: string;
57
+ productmatrixelementid?: string;
58
+ validationdatalongid?: string;
59
+ profilesusedcount?: number;
60
+ profilelongid?: string;
61
+ amounttodebit?: number;
62
+ greylistitemscount?: number;
63
+ greylistitemid?: string;
64
+ signeddata?: string;
65
+ mac?: string;
66
+ blockid?: string;
67
+ dutyid?: string;
68
+ journeyid?: string;
69
+ extrajourneyid?: string;
70
+ linelongid?: string;
71
+ patternlongid?: string;
72
+ isok?: boolean;
73
+ isunique?: boolean;
74
+ errorlist?: string;
75
+ signeddatafields_raw?: string;
76
+ signeddatafields_eventbinaryread?: string;
77
+ signeddatafields_eventbinarywritten?: string;
78
+ signeddatafields_contractbinaryread?: string;
79
+ signeddatafields_contractbinarywritten?: string;
80
+ signeddatafields_environmentbinaryread?: string;
81
+ signeddatafields_environmentbinarywritten?: string;
82
+ macdatafields_raw?: string;
83
+ macdatafields_interruptedstatus?: number;
84
+ macdatafields_macversion?: number;
85
+ macdatafields_binarydatamask?: number;
86
+ macdatafields_sammodel?: number;
87
+ macdatafields_samworkingmode?: number;
88
+ macdatafields_samtypeversion?: number;
89
+ macdatafields_fullmacflag?: number;
90
+ macdatafields_samserialnumber?: bigint;
91
+ macdatafields_bruteforcecounter?: string;
92
+ macdatafields_asecountervalue?: number;
93
+ macdatafields_ticcountervalue?: number;
94
+ macdatafields_ticcounterceiling?: number;
95
+ macdatafields_rldupdcountervalue?: number;
96
+ macdatafields_rldupdcounterceiling?: number;
97
+ macdatafields_transactioncounter?: number;
98
+ outofboundstype?: number;
99
+ outofboundsstoplongid?: string;
100
+ isreprocessed?: boolean;
101
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "@carrismetropolitana/api-tsconfig/base.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "outDir": "dist",
6
+ "paths": {
7
+ "@/*": ["./src/*"]
8
+ },
9
+ "rootDir": "src"
10
+ },
11
+ "include": ["src"],
12
+ "exclude": ["node_modules", "dist"]
13
+ }