@tmlmobilidade/types 20260518.901.35 → 20260518.1511.41
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.
- package/dist/gtfs/common.d.ts +17 -0
- package/dist/gtfs/common.js +37 -0
- package/dist/gtfs/stops.d.ts +8 -8
- package/dist/gtfs/stops.js +7 -7
- package/package.json +1 -1
package/dist/gtfs/common.d.ts
CHANGED
|
@@ -45,3 +45,20 @@ export type GTFS_PickupDropoffType = 0 | 1 | 2 | 3;
|
|
|
45
45
|
* @throws Error if the value is not a valid PickupDropoffType representation.
|
|
46
46
|
*/
|
|
47
47
|
export declare function validateGtfsPickupDropoffType(value?: number | string): GTFS_PickupDropoffType;
|
|
48
|
+
/**
|
|
49
|
+
* Describes if the stop has a "has" field.
|
|
50
|
+
* 0 - Not Applicable for this stop
|
|
51
|
+
* 1 - Stop has no "has" field
|
|
52
|
+
* 2 - Has "has" field but is in bad condition
|
|
53
|
+
* 3 - Has "has" field and is in good condition
|
|
54
|
+
*/
|
|
55
|
+
export type GTFS_HasField = 0 | 1 | 2 | 3;
|
|
56
|
+
/**
|
|
57
|
+
* Validates and transforms a value into a GTFS_HasField type.
|
|
58
|
+
* It accepts numeric or string representations of "has" field values.
|
|
59
|
+
* If the value is not provided, it defaults to 0 (Not Applicable for this stop).
|
|
60
|
+
* @param value The value to validate and transform.
|
|
61
|
+
* @returns A GTFS_HasField value (0, 1, 2, or 3).
|
|
62
|
+
* @throws Error if the value is not a valid GTFS_HasField representation.
|
|
63
|
+
*/
|
|
64
|
+
export declare function validateGtfsHasField(value?: number | string): GTFS_HasField;
|
package/dist/gtfs/common.js
CHANGED
|
@@ -88,3 +88,40 @@ export function validateGtfsPickupDropoffType(value) {
|
|
|
88
88
|
// If the value does not match any known PickupDropoffType, throw an error
|
|
89
89
|
throw new Error(`Invalid PickupDropoffType value: "${value}". It must be a number between 0 and 3.`);
|
|
90
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Validates and transforms a value into a GTFS_HasField type.
|
|
93
|
+
* It accepts numeric or string representations of "has" field values.
|
|
94
|
+
* If the value is not provided, it defaults to 0 (Not Applicable for this stop).
|
|
95
|
+
* @param value The value to validate and transform.
|
|
96
|
+
* @returns A GTFS_HasField value (0, 1, 2, or 3).
|
|
97
|
+
* @throws Error if the value is not a valid GTFS_HasField representation.
|
|
98
|
+
*/
|
|
99
|
+
export function validateGtfsHasField(value) {
|
|
100
|
+
// Return NOT_APPLICABLE if the value is not provided or is null/undefined
|
|
101
|
+
if (value === undefined || value === null || value === '')
|
|
102
|
+
return 0;
|
|
103
|
+
// Handle numeric and string representations of GTFS_HasField values
|
|
104
|
+
if (typeof value === 'number') {
|
|
105
|
+
if (value === 0)
|
|
106
|
+
return 0;
|
|
107
|
+
if (value === 1)
|
|
108
|
+
return 1;
|
|
109
|
+
if (value === 2)
|
|
110
|
+
return 2;
|
|
111
|
+
if (value === 3)
|
|
112
|
+
return 3;
|
|
113
|
+
}
|
|
114
|
+
// Handle string representations of GTFS_HasField values
|
|
115
|
+
if (typeof value === 'string') {
|
|
116
|
+
if (value === '0')
|
|
117
|
+
return 0;
|
|
118
|
+
if (value === '1')
|
|
119
|
+
return 1;
|
|
120
|
+
if (value === '2')
|
|
121
|
+
return 2;
|
|
122
|
+
if (value === '3')
|
|
123
|
+
return 3;
|
|
124
|
+
}
|
|
125
|
+
// If the value does not match any known GTFS_HasField representation, throw an error
|
|
126
|
+
throw new Error(`Invalid GTFS_HasField value: "${value}". It must be a number between 0 and 3.`);
|
|
127
|
+
}
|
package/dist/gtfs/stops.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type GTFS_Binary, type GTFS_Ternary } from './common.js';
|
|
1
|
+
import { type GTFS_Binary, GTFS_HasField, type GTFS_Ternary } from './common.js';
|
|
2
2
|
/**
|
|
3
3
|
* Represents a GTFS (General Transit Feed Specification) Location Type.
|
|
4
4
|
* This type is used to categorize the location based on its function in the transit system.
|
|
@@ -71,13 +71,13 @@ export declare function validateGtfsStop(rawData: GTFS_Stop_Raw): GTFS_Stop;
|
|
|
71
71
|
* should be used for working with the GTFS-TML standard.
|
|
72
72
|
*/
|
|
73
73
|
export interface GTFS_Stop_Extended extends GTFS_Stop {
|
|
74
|
-
has_bench?:
|
|
75
|
-
has_network_map?:
|
|
76
|
-
has_pip_real_time?:
|
|
77
|
-
has_schedules?:
|
|
78
|
-
has_shelter?:
|
|
79
|
-
has_stop_sign?:
|
|
80
|
-
has_tariffs_information?:
|
|
74
|
+
has_bench?: GTFS_HasField;
|
|
75
|
+
has_network_map?: GTFS_HasField;
|
|
76
|
+
has_pip_real_time?: GTFS_HasField;
|
|
77
|
+
has_schedules?: GTFS_HasField;
|
|
78
|
+
has_shelter?: GTFS_HasField;
|
|
79
|
+
has_stop_sign?: GTFS_HasField;
|
|
80
|
+
has_tariffs_information?: GTFS_HasField;
|
|
81
81
|
municipality_id?: string;
|
|
82
82
|
parish_id?: string;
|
|
83
83
|
public_visible?: GTFS_Binary;
|
package/dist/gtfs/stops.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* * */
|
|
2
|
-
import { validateGtfsBinary, validateGtfsTernary } from './common.js';
|
|
2
|
+
import { validateGtfsBinary, validateGtfsHasField, validateGtfsTernary } from './common.js';
|
|
3
3
|
/**
|
|
4
4
|
* Validates and transforms a value into a GTFS Location Type.
|
|
5
5
|
* It accepts numeric or string representations of location types.
|
|
@@ -77,13 +77,13 @@ export function validateGtfsStopExtended(rawData) {
|
|
|
77
77
|
// Transform the raw data into the output format
|
|
78
78
|
return {
|
|
79
79
|
...stop,
|
|
80
|
-
has_bench:
|
|
81
|
-
has_network_map:
|
|
82
|
-
has_pip_real_time:
|
|
83
|
-
has_schedules:
|
|
80
|
+
has_bench: validateGtfsHasField(rawData.has_bench),
|
|
81
|
+
has_network_map: validateGtfsHasField(rawData.has_network_map),
|
|
82
|
+
has_pip_real_time: validateGtfsHasField(rawData.has_pip_real_time),
|
|
83
|
+
has_schedules: validateGtfsHasField(rawData.has_schedules),
|
|
84
84
|
has_shelter: validateGtfsBinary(rawData.has_shelter),
|
|
85
|
-
has_stop_sign:
|
|
86
|
-
has_tariffs_information:
|
|
85
|
+
has_stop_sign: validateGtfsHasField(rawData.has_stop_sign),
|
|
86
|
+
has_tariffs_information: validateGtfsHasField(rawData.has_tariffs_information),
|
|
87
87
|
municipality_id: rawData.municipality_id,
|
|
88
88
|
parish_id: rawData.parish_id,
|
|
89
89
|
public_visible: validateGtfsBinary(rawData.public_visible),
|