@tmlmobilidade/types
Version:
48 lines (47 loc) • 1.98 kB
TypeScript
import { type OperationalDate } from '@tmlmobilidade/go-types-shared';
/**
* Represents the type of exception for a service
* in the GTFS (General Transit Feed Specification) format.
* The exception type indicates whether a service
* has been added or removed for a specific date.
*/
export type GTFS_ExceptionType = 1 | 2;
/**
* Validates and transforms a value into a GTFS Exception Type.
* It accepts numeric or string representations of exception types.
* @param value The value to validate and transform.
* @returns A GTFS Exception Type value (1 or 2).
* @throws Error if the value is not a valid GTFS Exception Type representation.
*/
export declare function validateGtfsExceptionType(value: number | string): GTFS_ExceptionType;
/**
* Represents a calendar date exception in the GTFS format.
* A calendar date exception indicates a specific date
* when a service is either added or removed from the schedule.
*/
export interface GTFS_CalendarDate {
date: OperationalDate;
exception_type: GTFS_ExceptionType;
service_id: string;
}
/**
* Represents a raw calendar date exception in the GTFS format.
* This interface is used to parse raw data from GTFS files,
* where fields may be optional or represented as strings.
* It is typically used for data ingestion before validation
* and transformation into the `GTFS_CalendarDate` format.
*/
export interface GTFS_CalendarDate_Raw {
date?: string;
exception_type?: string;
service_id?: string;
}
/**
* Validates and transforms a raw GTFS Calendar Date exception
* into the GTFS_CalendarDate format.
* This function checks the types of fields, converts string representations
* to appropriate types, and ensures that required fields are present.
* @param rawData The raw calendar date exception data to validate and transform.
* @returns A validated GTFS_CalendarDate object.
*/
export declare function validateGtfsCalendarDate(rawData: GTFS_CalendarDate_Raw): GTFS_CalendarDate;