@tmlmobilidade/utils 20260604.2324.46 → 20260605.101.50
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.
|
@@ -50,3 +50,10 @@ export declare function getPublicPatternId(agencyId: string, patternId: string):
|
|
|
50
50
|
* @returns The public fare ID.
|
|
51
51
|
*/
|
|
52
52
|
export declare function getPublicFareId(agencyId: string, fareId: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* Enforces the public vehicle ID format.
|
|
55
|
+
* @param agencyId The ID of the agency this vehicle belongs to.
|
|
56
|
+
* @param vehicleId The ID of the vehicle.
|
|
57
|
+
* @returns The public vehicle ID.
|
|
58
|
+
*/
|
|
59
|
+
export declare function getPublicVehicleId(agencyId: string, vehicleId: string): string;
|
|
@@ -139,3 +139,21 @@ export function getPublicFareId(agencyId, fareId) {
|
|
|
139
139
|
// Construct the public fare ID using a consistent format
|
|
140
140
|
return `[${agencyId}]${fareId}`;
|
|
141
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Enforces the public vehicle ID format.
|
|
144
|
+
* @param agencyId The ID of the agency this vehicle belongs to.
|
|
145
|
+
* @param vehicleId The ID of the vehicle.
|
|
146
|
+
* @returns The public vehicle ID.
|
|
147
|
+
*/
|
|
148
|
+
export function getPublicVehicleId(agencyId, vehicleId) {
|
|
149
|
+
// Validate that the agency ID is a non-empty string
|
|
150
|
+
if (typeof agencyId !== 'string' || !agencyId.trim()) {
|
|
151
|
+
throw new Error('Invalid agency ID: must be a non-empty string.');
|
|
152
|
+
}
|
|
153
|
+
// Validate that the vehicle ID is a non-empty string
|
|
154
|
+
if (typeof vehicleId !== 'string' || !vehicleId.trim()) {
|
|
155
|
+
throw new Error('Invalid vehicle ID: must be a non-empty string.');
|
|
156
|
+
}
|
|
157
|
+
// Construct the public vehicle ID using a consistent format
|
|
158
|
+
return `[${agencyId}]${vehicleId}`;
|
|
159
|
+
}
|