@tmlmobilidade/utils 20260525.1615.59 → 20260525.1751.19
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/get-public-trip-id.d.ts +40 -2
- package/dist/get-public-trip-id.js +108 -3
- package/package.json +1 -1
|
@@ -1,7 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Enforces the public trip ID format.
|
|
3
3
|
* @param planId The ID of the plan this trip belongs to.
|
|
4
|
+
* @param agencyId The ID of the agency this trip belongs to.
|
|
4
5
|
* @param tripId The ID of the trip.
|
|
5
6
|
* @returns The public trip ID.
|
|
6
7
|
*/
|
|
7
|
-
export declare function getPublicTripId(planId: string, tripId: string): string;
|
|
8
|
+
export declare function getPublicTripId(planId: string, agencyId: string, tripId: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Enforces the public shape ID format.
|
|
11
|
+
* @param planId The ID of the plan this shape belongs to.
|
|
12
|
+
* @param agencyId The ID of the agency this shape belongs to.
|
|
13
|
+
* @param shapeId The ID of the shape.
|
|
14
|
+
* @returns The public shape ID.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getPublicShapeId(planId: string, agencyId: string, shapeId: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Enforces the public service ID format.
|
|
19
|
+
* @param planId The ID of the plan this service belongs to.
|
|
20
|
+
* @param agencyId The ID of the agency this service belongs to.
|
|
21
|
+
* @param serviceId The ID of the service.
|
|
22
|
+
* @returns The public service ID.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getPublicServiceId(planId: string, agencyId: string, serviceId: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Enforces the public line ID format.
|
|
27
|
+
* @param agencyId The ID of the agency this line belongs to.
|
|
28
|
+
* @param lineId The ID of the line.
|
|
29
|
+
* @returns The public line ID.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getPublicLineId(agencyId: string, lineId: number | string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Enforces the public route ID format.
|
|
34
|
+
* @param agencyId The ID of the agency this route belongs to.
|
|
35
|
+
* @param routeId The ID of the route.
|
|
36
|
+
* @returns The public route ID.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getPublicRouteId(agencyId: string, routeId: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Enforces the public pattern ID format.
|
|
41
|
+
* @param agencyId The ID of the agency this pattern belongs to.
|
|
42
|
+
* @param patternId The ID of the pattern.
|
|
43
|
+
* @returns The public pattern ID.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getPublicPatternId(agencyId: string, patternId: string): string;
|
|
@@ -1,18 +1,123 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Enforces the public trip ID format.
|
|
3
3
|
* @param planId The ID of the plan this trip belongs to.
|
|
4
|
+
* @param agencyId The ID of the agency this trip belongs to.
|
|
4
5
|
* @param tripId The ID of the trip.
|
|
5
6
|
* @returns The public trip ID.
|
|
6
7
|
*/
|
|
7
|
-
export function getPublicTripId(planId, tripId) {
|
|
8
|
+
export function getPublicTripId(planId, agencyId, tripId) {
|
|
8
9
|
// Validate that the plan ID is a non-empty string
|
|
9
10
|
if (typeof planId !== 'string' || !planId.trim()) {
|
|
10
11
|
throw new Error('Invalid plan ID: must be a non-empty string.');
|
|
11
12
|
}
|
|
13
|
+
// Validate that the agency ID is a non-empty string
|
|
14
|
+
if (typeof agencyId !== 'string' || !agencyId.trim()) {
|
|
15
|
+
throw new Error('Invalid agency ID: must be a non-empty string.');
|
|
16
|
+
}
|
|
12
17
|
// Validate that the trip ID is a non-empty string
|
|
13
18
|
if (typeof tripId !== 'string' || !tripId.trim()) {
|
|
14
19
|
throw new Error('Invalid trip ID: must be a non-empty string.');
|
|
15
20
|
}
|
|
16
21
|
// Construct the public trip ID using a consistent format
|
|
17
|
-
return `[${planId}]${tripId}`;
|
|
22
|
+
return `[${planId}][${agencyId}]${tripId}`;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Enforces the public shape ID format.
|
|
26
|
+
* @param planId The ID of the plan this shape belongs to.
|
|
27
|
+
* @param agencyId The ID of the agency this shape belongs to.
|
|
28
|
+
* @param shapeId The ID of the shape.
|
|
29
|
+
* @returns The public shape ID.
|
|
30
|
+
*/
|
|
31
|
+
export function getPublicShapeId(planId, agencyId, shapeId) {
|
|
32
|
+
// Validate that the plan ID is a non-empty string
|
|
33
|
+
if (typeof planId !== 'string' || !planId.trim()) {
|
|
34
|
+
throw new Error('Invalid plan ID: must be a non-empty string.');
|
|
35
|
+
}
|
|
36
|
+
// Validate that the agency ID is a non-empty string
|
|
37
|
+
if (typeof agencyId !== 'string' || !agencyId.trim()) {
|
|
38
|
+
throw new Error('Invalid agency ID: must be a non-empty string.');
|
|
39
|
+
}
|
|
40
|
+
// Validate that the shape ID is a non-empty string
|
|
41
|
+
if (typeof shapeId !== 'string' || !shapeId.trim()) {
|
|
42
|
+
throw new Error('Invalid shape ID: must be a non-empty string.');
|
|
43
|
+
}
|
|
44
|
+
// Construct the public shape ID using a consistent format
|
|
45
|
+
return `[${planId}][${agencyId}]${shapeId}`;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Enforces the public service ID format.
|
|
49
|
+
* @param planId The ID of the plan this service belongs to.
|
|
50
|
+
* @param agencyId The ID of the agency this service belongs to.
|
|
51
|
+
* @param serviceId The ID of the service.
|
|
52
|
+
* @returns The public service ID.
|
|
53
|
+
*/
|
|
54
|
+
export function getPublicServiceId(planId, agencyId, serviceId) {
|
|
55
|
+
// Validate that the plan ID is a non-empty string
|
|
56
|
+
if (typeof planId !== 'string' || !planId.trim()) {
|
|
57
|
+
throw new Error('Invalid plan ID: must be a non-empty string.');
|
|
58
|
+
}
|
|
59
|
+
// Validate that the agency ID is a non-empty string
|
|
60
|
+
if (typeof agencyId !== 'string' || !agencyId.trim()) {
|
|
61
|
+
throw new Error('Invalid agency ID: must be a non-empty string.');
|
|
62
|
+
}
|
|
63
|
+
// Validate that the service ID is a non-empty string
|
|
64
|
+
if (typeof serviceId !== 'string' || !serviceId.trim()) {
|
|
65
|
+
throw new Error('Invalid service ID: must be a non-empty string.');
|
|
66
|
+
}
|
|
67
|
+
// Construct the public service ID using a consistent format
|
|
68
|
+
return `[${planId}][${agencyId}]${serviceId}`;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Enforces the public line ID format.
|
|
72
|
+
* @param agencyId The ID of the agency this line belongs to.
|
|
73
|
+
* @param lineId The ID of the line.
|
|
74
|
+
* @returns The public line ID.
|
|
75
|
+
*/
|
|
76
|
+
export function getPublicLineId(agencyId, lineId) {
|
|
77
|
+
// Validate that the agency ID is a non-empty string
|
|
78
|
+
if (typeof agencyId !== 'string' || !agencyId.trim()) {
|
|
79
|
+
throw new Error('Invalid agency ID: must be a non-empty string.');
|
|
80
|
+
}
|
|
81
|
+
// Validate that the line ID is a non-empty string
|
|
82
|
+
if (typeof lineId !== 'string' || !lineId.trim()) {
|
|
83
|
+
throw new Error('Invalid line ID: must be a non-empty string.');
|
|
84
|
+
}
|
|
85
|
+
// Construct the public line ID using a consistent format
|
|
86
|
+
return `[${agencyId}]${lineId}`;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Enforces the public route ID format.
|
|
90
|
+
* @param agencyId The ID of the agency this route belongs to.
|
|
91
|
+
* @param routeId The ID of the route.
|
|
92
|
+
* @returns The public route ID.
|
|
93
|
+
*/
|
|
94
|
+
export function getPublicRouteId(agencyId, routeId) {
|
|
95
|
+
// Validate that the agency ID is a non-empty string
|
|
96
|
+
if (typeof agencyId !== 'string' || !agencyId.trim()) {
|
|
97
|
+
throw new Error('Invalid agency ID: must be a non-empty string.');
|
|
98
|
+
}
|
|
99
|
+
// Validate that the route ID is a non-empty string
|
|
100
|
+
if (typeof routeId !== 'string' || !routeId.trim()) {
|
|
101
|
+
throw new Error('Invalid route ID: must be a non-empty string.');
|
|
102
|
+
}
|
|
103
|
+
// Construct the public route ID using a consistent format
|
|
104
|
+
return `[${agencyId}]${routeId}`;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Enforces the public pattern ID format.
|
|
108
|
+
* @param agencyId The ID of the agency this pattern belongs to.
|
|
109
|
+
* @param patternId The ID of the pattern.
|
|
110
|
+
* @returns The public pattern ID.
|
|
111
|
+
*/
|
|
112
|
+
export function getPublicPatternId(agencyId, patternId) {
|
|
113
|
+
// Validate that the agency ID is a non-empty string
|
|
114
|
+
if (typeof agencyId !== 'string' || !agencyId.trim()) {
|
|
115
|
+
throw new Error('Invalid agency ID: must be a non-empty string.');
|
|
116
|
+
}
|
|
117
|
+
// Validate that the pattern ID is a non-empty string
|
|
118
|
+
if (typeof patternId !== 'string' || !patternId.trim()) {
|
|
119
|
+
throw new Error('Invalid pattern ID: must be a non-empty string.');
|
|
120
|
+
}
|
|
121
|
+
// Construct the public pattern ID using a consistent format
|
|
122
|
+
return `[${agencyId}]${patternId}`;
|
|
18
123
|
}
|