@tmlmobilidade/utils 20260525.1751.19 → 20260525.1830.15
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.
|
@@ -43,3 +43,10 @@ export declare function getPublicRouteId(agencyId: string, routeId: string): str
|
|
|
43
43
|
* @returns The public pattern ID.
|
|
44
44
|
*/
|
|
45
45
|
export declare function getPublicPatternId(agencyId: string, patternId: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Enforces the public fare ID format.
|
|
48
|
+
* @param agencyId The ID of the agency this fare belongs to.
|
|
49
|
+
* @param fareId The ID of the fare.
|
|
50
|
+
* @returns The public fare ID.
|
|
51
|
+
*/
|
|
52
|
+
export declare function getPublicFareId(agencyId: string, fareId: string): string;
|
|
@@ -121,3 +121,21 @@ export function getPublicPatternId(agencyId, patternId) {
|
|
|
121
121
|
// Construct the public pattern ID using a consistent format
|
|
122
122
|
return `[${agencyId}]${patternId}`;
|
|
123
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Enforces the public fare ID format.
|
|
126
|
+
* @param agencyId The ID of the agency this fare belongs to.
|
|
127
|
+
* @param fareId The ID of the fare.
|
|
128
|
+
* @returns The public fare ID.
|
|
129
|
+
*/
|
|
130
|
+
export function getPublicFareId(agencyId, fareId) {
|
|
131
|
+
// Validate that the agency ID is a non-empty string
|
|
132
|
+
if (typeof agencyId !== 'string' || !agencyId.trim()) {
|
|
133
|
+
throw new Error('Invalid agency ID: must be a non-empty string.');
|
|
134
|
+
}
|
|
135
|
+
// Validate that the fare ID is a non-empty string
|
|
136
|
+
if (typeof fareId !== 'string' || !fareId.trim()) {
|
|
137
|
+
throw new Error('Invalid fare ID: must be a non-empty string.');
|
|
138
|
+
}
|
|
139
|
+
// Construct the public fare ID using a consistent format
|
|
140
|
+
return `[${agencyId}]${fareId}`;
|
|
141
|
+
}
|