@tmlmobilidade/types 20260518.827.12 → 20260518.1500.45

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.
@@ -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;
@@ -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
+ }
@@ -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?: GTFS_Binary;
75
- has_network_map?: GTFS_Binary;
76
- has_pip_real_time?: GTFS_Binary;
77
- has_schedules?: GTFS_Binary;
78
- has_shelter?: GTFS_Binary;
79
- has_stop_sign?: GTFS_Binary;
80
- has_tariffs_information?: GTFS_Binary;
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/types",
3
- "version": "20260518.827.12",
3
+ "version": "20260518.1500.45",
4
4
  "author": {
5
5
  "email": "iso@tmlmobilidade.pt",
6
6
  "name": "TML-ISO"