@tmlmobilidade/types 20260605.142.19 → 20260605.1145.54

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,13 @@
1
+ import { z } from 'zod';
2
+ export declare const CALENDAR_DATE_FORMAT = "yyyy-MM-dd";
3
+ export type CalendarDate = string & {
4
+ __brand: 'CalendarDate';
5
+ };
6
+ export declare const CalendarDateSchema: z.ZodEffects<z.ZodString, CalendarDate, string>;
7
+ /**
8
+ * This function validates if a string is a valid calendar date.
9
+ * Throws an error if the date is invalid.
10
+ * @param date - The date to be validated.
11
+ * @returns The given string as a CalendarDate.
12
+ */
13
+ export declare function validateCalendarDate(date: string): CalendarDate;
@@ -0,0 +1,20 @@
1
+ /* * */
2
+ import { DateTime } from 'luxon';
3
+ import { z } from 'zod';
4
+ /* * */
5
+ export const CALENDAR_DATE_FORMAT = 'yyyy-MM-dd';
6
+ export const CalendarDateSchema = z
7
+ .string()
8
+ .transform(validateCalendarDate);
9
+ /**
10
+ * This function validates if a string is a valid calendar date.
11
+ * Throws an error if the date is invalid.
12
+ * @param date - The date to be validated.
13
+ * @returns The given string as a CalendarDate.
14
+ */
15
+ export function validateCalendarDate(date) {
16
+ const parsedDate = DateTime.fromFormat(date, CALENDAR_DATE_FORMAT);
17
+ if (!parsedDate.isValid)
18
+ throw new Error(`Invalid date format '${date}', expected format: ${CALENDAR_DATE_FORMAT}, explanation: ${parsedDate.invalidExplanation}`);
19
+ return date;
20
+ }
@@ -1,3 +1,4 @@
1
+ export * from './calendar-date.js';
1
2
  export * from './comment.js';
2
3
  export * from './document.js';
3
4
  export * from './environment.js';
@@ -1,3 +1,4 @@
1
+ export * from './calendar-date.js';
1
2
  export * from './comment.js';
2
3
  export * from './document.js';
3
4
  export * from './environment.js';
@@ -31,3 +31,7 @@ export type ValidityStatus = z.infer<typeof ValidityStatusSchema>;
31
31
  export declare const SystemStatusValues: readonly ["waiting", "incomplete", "complete", "error"];
32
32
  export declare const SystemStatusSchema: z.ZodEnum<["waiting", "incomplete", "complete", "error"]>;
33
33
  export type SystemStatus = z.infer<typeof SystemStatusSchema>;
34
+ /***/
35
+ export declare const TicketingStatusValues: readonly ["has_ticketing", "no_ticketing"];
36
+ export declare const TicketingStatusSchema: z.ZodEnum<["has_ticketing", "no_ticketing"]>;
37
+ export type TicketingStatus = z.infer<typeof TicketingStatusSchema>;
@@ -44,3 +44,7 @@ export const ValidityStatusSchema = z.enum(ValidityStatusValues);
44
44
  /* SYSTEM STATUS */
45
45
  export const SystemStatusValues = ['waiting', 'incomplete', 'complete', 'error'];
46
46
  export const SystemStatusSchema = z.enum(SystemStatusValues);
47
+ /***/
48
+ /* TICKETING STATUS */
49
+ export const TicketingStatusValues = ['has_ticketing', 'no_ticketing'];
50
+ export const TicketingStatusSchema = z.enum(TicketingStatusValues);
@@ -2,6 +2,7 @@ export * from './alerts/index.js';
2
2
  export * from './lines.js';
3
3
  export * from './patterns.js';
4
4
  export * from './plans/index.js';
5
+ export * from './realtime-eta-gtfs.js';
5
6
  export * from './realtime/index.js';
6
7
  export * from './shapes.js';
7
8
  export * from './stop.js';
@@ -2,6 +2,7 @@ export * from './alerts/index.js';
2
2
  export * from './lines.js';
3
3
  export * from './patterns.js';
4
4
  export * from './plans/index.js';
5
+ export * from './realtime-eta-gtfs.js';
5
6
  export * from './realtime/index.js';
6
7
  export * from './shapes.js';
7
8
  export * from './stop.js';
@@ -38,8 +38,11 @@ export interface HubTrip {
38
38
  export interface HubArrival {
39
39
  arrival_time: string;
40
40
  arrival_time_24h: string;
41
+ line_id: string;
42
+ pattern_id: string;
41
43
  stop_id: string;
42
44
  stop_sequence: number;
45
+ trip_id: string;
43
46
  }
44
47
  export interface HubPatternRealtime {
45
48
  estimated_arrival: null | string;
@@ -2,12 +2,12 @@ import { z } from 'zod';
2
2
  export declare const HubVehiclePositionSchema: z.ZodObject<{
3
3
  _id: z.ZodString;
4
4
  agency_id: z.ZodString;
5
- calendar_date: z.ZodEffects<z.ZodString, import("../../../index.js").OperationalDate, string>;
6
- created_at: z.ZodEffects<z.ZodNumber, import("../../../index.js").UnixTimestamp, number>;
5
+ calendar_date: z.ZodEffects<z.ZodString, import("../../../_common/index.js").CalendarDate, string>;
6
+ created_at: z.ZodEffects<z.ZodNumber, import("../../../_common/unix-timestamp.js").UnixTimestamp, number>;
7
7
  geohash: z.ZodOptional<z.ZodNullable<z.ZodString>>;
8
- latitude: z.ZodEffects<z.ZodNumber, number, number>;
9
- longitude: z.ZodEffects<z.ZodNumber, number, number>;
10
- received_at: z.ZodEffects<z.ZodNumber, import("../../../index.js").UnixTimestamp, number>;
8
+ latitude: z.ZodEffects<z.ZodEffects<z.ZodNumber, string, number>, number, number>;
9
+ longitude: z.ZodEffects<z.ZodEffects<z.ZodNumber, string, number>, number, number>;
10
+ received_at: z.ZodEffects<z.ZodNumber, import("../../../_common/unix-timestamp.js").UnixTimestamp, number>;
11
11
  trip_id: z.ZodString;
12
12
  vehicle_id: z.ZodString;
13
13
  bearing: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
@@ -32,7 +32,7 @@ export declare const HubVehiclePositionSchema: z.ZodObject<{
32
32
  speed: number | null;
33
33
  current_status: "INCOMING_AT" | "STOPPED_AT" | "IN_TRANSIT_TO" | null;
34
34
  calendar_date: string & {
35
- __brand: "OperationalDate";
35
+ __brand: "CalendarDate";
36
36
  };
37
37
  geohash?: string | null | undefined;
38
38
  }, {
@@ -1,6 +1,6 @@
1
1
  /* * */
2
+ import { CalendarDateSchema } from '../../../_common/index.js';
2
3
  import { UnixTimestampSchema } from '../../../_common/unix-timestamp.js';
3
- import { OperationalDateSchema } from '../../../index.js';
4
4
  import { z } from 'zod';
5
5
  /* * */
6
6
  export const HubVehiclePositionSchema = z.object({
@@ -8,17 +8,19 @@ export const HubVehiclePositionSchema = z.object({
8
8
  // Required Fields
9
9
  _id: z.string(),
10
10
  agency_id: z.string(),
11
- calendar_date: OperationalDateSchema,
11
+ calendar_date: CalendarDateSchema,
12
12
  created_at: UnixTimestampSchema,
13
13
  geohash: z.string().nullish(),
14
14
  latitude: z.number()
15
15
  .min(-90)
16
16
  .max(90)
17
- .refine(value => value.toFixed(6) === value.toString()),
17
+ .transform(value => value.toFixed(6))
18
+ .transform(value => parseFloat(value)),
18
19
  longitude: z.number()
19
20
  .min(-180)
20
21
  .max(180)
21
- .refine(value => value.toFixed(6) === value.toString()),
22
+ .transform(value => value.toFixed(6))
23
+ .transform(value => parseFloat(value)),
22
24
  received_at: UnixTimestampSchema,
23
25
  trip_id: z.string(),
24
26
  vehicle_id: z.string(),
@@ -0,0 +1,41 @@
1
+ export interface HubGtfsRtStopTimeEvent {
2
+ delay?: null | number;
3
+ time?: null | number;
4
+ }
5
+ export interface HubGtfsRtStopTimeUpdate {
6
+ arrival?: HubGtfsRtStopTimeEvent | null;
7
+ schedule_relationship?: null | string;
8
+ stop_id?: null | string;
9
+ stop_sequence?: null | number;
10
+ }
11
+ export interface HubGtfsRtTripDescriptor {
12
+ schedule_relationship?: null | string;
13
+ trip_id?: null | string;
14
+ }
15
+ export interface HubGtfsRtTripUpdate {
16
+ stop_time_update?: HubGtfsRtStopTimeUpdate[] | null;
17
+ timestamp?: null | number;
18
+ trip?: HubGtfsRtTripDescriptor | null;
19
+ vehicle?: null | {
20
+ id?: null | string;
21
+ };
22
+ }
23
+ export interface HubGtfsRtFeedEntity {
24
+ id?: null | string;
25
+ stop_time_update?: HubGtfsRtStopTimeUpdate[] | null;
26
+ timestamp?: null | number;
27
+ trip?: HubGtfsRtTripDescriptor | null;
28
+ trip_update?: HubGtfsRtTripUpdate | null;
29
+ vehicle?: null | {
30
+ id?: null | string;
31
+ };
32
+ }
33
+ export interface HubGtfsRtFeedHeader {
34
+ gtfs_realtime_version?: string;
35
+ incrementality?: string;
36
+ timestamp?: number;
37
+ }
38
+ export interface HubGtfsRtFeedMessage {
39
+ entity: HubGtfsRtFeedEntity[];
40
+ header: HubGtfsRtFeedHeader;
41
+ }
@@ -0,0 +1,2 @@
1
+ /* * */
2
+ export {};
@@ -15,6 +15,7 @@ export declare const GetRidesBatchQuerySchema: z.ZodObject<{
15
15
  stop_ids: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], unknown>>;
16
16
  acceptance_status: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodEnum<["justification_required", "under_review", "accepted", "rejected", "none"]>, "many">, ("none" | "rejected" | "justification_required" | "under_review" | "accepted")[], unknown>>;
17
17
  favorites: z.ZodOptional<z.ZodBoolean>;
18
+ ticketing_status: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodEnum<["has_ticketing", "no_ticketing"]>, "many">, ("has_ticketing" | "no_ticketing")[], unknown>>;
18
19
  }, "strip", z.ZodTypeAny, {
19
20
  agency_ids: string[];
20
21
  date_end: number & {
@@ -35,6 +36,7 @@ export declare const GetRidesBatchQuerySchema: z.ZodObject<{
35
36
  analysis_ended_at_last_stop_grade?: ("error" | "none" | "pass" | "fail" | "skip")[] | undefined;
36
37
  analysis_simple_three_vehicle_events_grade?: ("error" | "none" | "pass" | "fail" | "skip")[] | undefined;
37
38
  favorites?: boolean | undefined;
39
+ ticketing_status?: ("has_ticketing" | "no_ticketing")[] | undefined;
38
40
  }, {
39
41
  date_end: number;
40
42
  date_start: number;
@@ -51,5 +53,6 @@ export declare const GetRidesBatchQuerySchema: z.ZodObject<{
51
53
  analysis_ended_at_last_stop_grade?: unknown;
52
54
  analysis_simple_three_vehicle_events_grade?: unknown;
53
55
  favorites?: boolean | undefined;
56
+ ticketing_status?: unknown;
54
57
  }>;
55
58
  export type GetRidesBatchQuery = z.infer<typeof GetRidesBatchQuerySchema>;
@@ -1,5 +1,5 @@
1
1
  /* * */
2
- import { DelayStatusSchema, OperationalStatusSchema, SeenStatusSchema } from '../../_common/status.js';
2
+ import { DelayStatusSchema, OperationalStatusSchema, SeenStatusSchema, TicketingStatusSchema } from '../../_common/status.js';
3
3
  import { UnixTimestampSchema } from '../../_common/unix-timestamp.js';
4
4
  import { RideAcceptanceStatusSchema } from './ride-acceptance.js';
5
5
  import { RideAnalysisGradeSchema } from './ride-analysis.js';
@@ -55,4 +55,7 @@ export const GetRidesBatchQuerySchema = z.object({
55
55
  favorites: z
56
56
  .boolean()
57
57
  .optional(),
58
+ ticketing_status: z
59
+ .preprocess((val) => (val && typeof val === 'string') ? val.split(',').map(status => status.trim()) : [], z.array(TicketingStatusSchema))
60
+ .optional(),
58
61
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/types",
3
- "version": "20260605.142.19",
3
+ "version": "20260605.1145.54",
4
4
  "author": {
5
5
  "email": "iso@tmlmobilidade.pt",
6
6
  "name": "TML-ISO"