@tmlmobilidade/types 20260612.214.31 → 20260612.1446.12
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/distance.d.ts +10 -0
- package/dist/gtfs/distance.js +21 -0
- package/dist/gtfs/index.d.ts +1 -0
- package/dist/gtfs/index.js +1 -0
- package/dist/offer/index.d.ts +1 -0
- package/dist/offer/index.js +1 -0
- package/dist/offer/vkm.d.ts +207 -0
- package/dist/offer/vkm.js +51 -0
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts pattern extension metres to GTFS kilometres (shapes.txt, stop_times.txt).
|
|
3
|
+
* Rounds to 3 decimal places (1 m precision), matching stop_times export.
|
|
4
|
+
*/
|
|
5
|
+
export declare function metersToGtfsKm(meters: number): number;
|
|
6
|
+
/**
|
|
7
|
+
* Cumulative shape distance in metres at a shape point.
|
|
8
|
+
* The last point (index pointCount - 1) equals extensionMeters.
|
|
9
|
+
*/
|
|
10
|
+
export declare function shapeDistTraveledMetersAtPoint(extensionMeters: number, pointIndex: number, pointCount: number): number;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* * */
|
|
2
|
+
/**
|
|
3
|
+
* Converts pattern extension metres to GTFS kilometres (shapes.txt, stop_times.txt).
|
|
4
|
+
* Rounds to 3 decimal places (1 m precision), matching stop_times export.
|
|
5
|
+
*/
|
|
6
|
+
export function metersToGtfsKm(meters) {
|
|
7
|
+
return Math.round((meters / 1000) * 1000) / 1000;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Cumulative shape distance in metres at a shape point.
|
|
11
|
+
* The last point (index pointCount - 1) equals extensionMeters.
|
|
12
|
+
*/
|
|
13
|
+
export function shapeDistTraveledMetersAtPoint(extensionMeters, pointIndex, pointCount) {
|
|
14
|
+
if (pointCount <= 1 || extensionMeters <= 0)
|
|
15
|
+
return 0;
|
|
16
|
+
if (pointIndex <= 0)
|
|
17
|
+
return 0;
|
|
18
|
+
if (pointIndex >= pointCount - 1)
|
|
19
|
+
return extensionMeters;
|
|
20
|
+
return (pointIndex / (pointCount - 1)) * extensionMeters;
|
|
21
|
+
}
|
package/dist/gtfs/index.d.ts
CHANGED
package/dist/gtfs/index.js
CHANGED
package/dist/offer/index.d.ts
CHANGED
package/dist/offer/index.js
CHANGED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const VkmCalculationMethodValues: readonly ["rolling_year", "fixed_range"];
|
|
3
|
+
export declare const VkmCalculationMethodSchema: z.ZodEnum<["rolling_year", "fixed_range"]>;
|
|
4
|
+
export type VkmCalculationMethod = z.infer<typeof VkmCalculationMethodSchema>;
|
|
5
|
+
export declare const VkmExtensionSourceValues: readonly ["go", "stop_times"];
|
|
6
|
+
export declare const VkmExtensionSourceSchema: z.ZodEnum<["go", "stop_times"]>;
|
|
7
|
+
export type VkmExtensionSource = z.infer<typeof VkmExtensionSourceSchema>;
|
|
8
|
+
export declare const LegacyVkmDayTypeSchema: z.ZodEnum<["1", "2", "3"]>;
|
|
9
|
+
export type LegacyVkmDayType = z.infer<typeof LegacyVkmDayTypeSchema>;
|
|
10
|
+
export declare const CalculateVkmSchema: z.ZodObject<{
|
|
11
|
+
agency_id: z.ZodString;
|
|
12
|
+
calculation_method: z.ZodEnum<["rolling_year", "fixed_range"]>;
|
|
13
|
+
end_date: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, import("@tmlmobilidade/go-types-shared").OperationalDate, string>>>;
|
|
14
|
+
extension_source: z.ZodEnum<["go", "stop_times"]>;
|
|
15
|
+
start_date: z.ZodEffects<z.ZodString, import("@tmlmobilidade/go-types-shared").OperationalDate, string>;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
agency_id: string;
|
|
18
|
+
start_date: string & {
|
|
19
|
+
__brand: "OperationalDate";
|
|
20
|
+
};
|
|
21
|
+
calculation_method: "rolling_year" | "fixed_range";
|
|
22
|
+
extension_source: "go" | "stop_times";
|
|
23
|
+
end_date?: import("@tmlmobilidade/go-types-shared").OperationalDate | null | undefined;
|
|
24
|
+
}, {
|
|
25
|
+
agency_id: string;
|
|
26
|
+
start_date: string;
|
|
27
|
+
calculation_method: "rolling_year" | "fixed_range";
|
|
28
|
+
extension_source: "go" | "stop_times";
|
|
29
|
+
end_date?: string | null | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
export declare const VkmCalculationInputsSchema: z.ZodObject<{
|
|
32
|
+
agency_id: z.ZodString;
|
|
33
|
+
agency_name: z.ZodString;
|
|
34
|
+
calculation_method: z.ZodEnum<["rolling_year", "fixed_range"]>;
|
|
35
|
+
end_date: z.ZodEffects<z.ZodString, import("@tmlmobilidade/go-types-shared").OperationalDate, string>;
|
|
36
|
+
price_per_km: z.ZodNumber;
|
|
37
|
+
start_date: z.ZodEffects<z.ZodString, import("@tmlmobilidade/go-types-shared").OperationalDate, string>;
|
|
38
|
+
total_vkm_per_year: z.ZodNumber;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
price_per_km: number;
|
|
41
|
+
agency_id: string;
|
|
42
|
+
start_date: string & {
|
|
43
|
+
__brand: "OperationalDate";
|
|
44
|
+
};
|
|
45
|
+
agency_name: string;
|
|
46
|
+
calculation_method: "rolling_year" | "fixed_range";
|
|
47
|
+
end_date: string & {
|
|
48
|
+
__brand: "OperationalDate";
|
|
49
|
+
};
|
|
50
|
+
total_vkm_per_year: number;
|
|
51
|
+
}, {
|
|
52
|
+
price_per_km: number;
|
|
53
|
+
agency_id: string;
|
|
54
|
+
start_date: string;
|
|
55
|
+
agency_name: string;
|
|
56
|
+
calculation_method: "rolling_year" | "fixed_range";
|
|
57
|
+
end_date: string;
|
|
58
|
+
total_vkm_per_year: number;
|
|
59
|
+
}>;
|
|
60
|
+
export declare const VkmPeriodResultSchema: z.ZodObject<{
|
|
61
|
+
code: z.ZodNullable<z.ZodString>;
|
|
62
|
+
day_type_one: z.ZodNumber;
|
|
63
|
+
day_type_three: z.ZodNumber;
|
|
64
|
+
day_type_two: z.ZodNumber;
|
|
65
|
+
id: z.ZodNullable<z.ZodString>;
|
|
66
|
+
name: z.ZodString;
|
|
67
|
+
total: z.ZodNumber;
|
|
68
|
+
}, "strip", z.ZodTypeAny, {
|
|
69
|
+
code: string | null;
|
|
70
|
+
name: string;
|
|
71
|
+
id: string | null;
|
|
72
|
+
total: number;
|
|
73
|
+
day_type_one: number;
|
|
74
|
+
day_type_three: number;
|
|
75
|
+
day_type_two: number;
|
|
76
|
+
}, {
|
|
77
|
+
code: string | null;
|
|
78
|
+
name: string;
|
|
79
|
+
id: string | null;
|
|
80
|
+
total: number;
|
|
81
|
+
day_type_one: number;
|
|
82
|
+
day_type_three: number;
|
|
83
|
+
day_type_two: number;
|
|
84
|
+
}>;
|
|
85
|
+
export declare const VkmCalculationResultSchema: z.ZodObject<{
|
|
86
|
+
day_type_one: z.ZodNumber;
|
|
87
|
+
day_type_three: z.ZodNumber;
|
|
88
|
+
day_type_two: z.ZodNumber;
|
|
89
|
+
inputs: z.ZodObject<{
|
|
90
|
+
agency_id: z.ZodString;
|
|
91
|
+
agency_name: z.ZodString;
|
|
92
|
+
calculation_method: z.ZodEnum<["rolling_year", "fixed_range"]>;
|
|
93
|
+
end_date: z.ZodEffects<z.ZodString, import("@tmlmobilidade/go-types-shared").OperationalDate, string>;
|
|
94
|
+
price_per_km: z.ZodNumber;
|
|
95
|
+
start_date: z.ZodEffects<z.ZodString, import("@tmlmobilidade/go-types-shared").OperationalDate, string>;
|
|
96
|
+
total_vkm_per_year: z.ZodNumber;
|
|
97
|
+
}, "strip", z.ZodTypeAny, {
|
|
98
|
+
price_per_km: number;
|
|
99
|
+
agency_id: string;
|
|
100
|
+
start_date: string & {
|
|
101
|
+
__brand: "OperationalDate";
|
|
102
|
+
};
|
|
103
|
+
agency_name: string;
|
|
104
|
+
calculation_method: "rolling_year" | "fixed_range";
|
|
105
|
+
end_date: string & {
|
|
106
|
+
__brand: "OperationalDate";
|
|
107
|
+
};
|
|
108
|
+
total_vkm_per_year: number;
|
|
109
|
+
}, {
|
|
110
|
+
price_per_km: number;
|
|
111
|
+
agency_id: string;
|
|
112
|
+
start_date: string;
|
|
113
|
+
agency_name: string;
|
|
114
|
+
calculation_method: "rolling_year" | "fixed_range";
|
|
115
|
+
end_date: string;
|
|
116
|
+
total_vkm_per_year: number;
|
|
117
|
+
}>;
|
|
118
|
+
periods: z.ZodArray<z.ZodObject<{
|
|
119
|
+
code: z.ZodNullable<z.ZodString>;
|
|
120
|
+
day_type_one: z.ZodNumber;
|
|
121
|
+
day_type_three: z.ZodNumber;
|
|
122
|
+
day_type_two: z.ZodNumber;
|
|
123
|
+
id: z.ZodNullable<z.ZodString>;
|
|
124
|
+
name: z.ZodString;
|
|
125
|
+
total: z.ZodNumber;
|
|
126
|
+
}, "strip", z.ZodTypeAny, {
|
|
127
|
+
code: string | null;
|
|
128
|
+
name: string;
|
|
129
|
+
id: string | null;
|
|
130
|
+
total: number;
|
|
131
|
+
day_type_one: number;
|
|
132
|
+
day_type_three: number;
|
|
133
|
+
day_type_two: number;
|
|
134
|
+
}, {
|
|
135
|
+
code: string | null;
|
|
136
|
+
name: string;
|
|
137
|
+
id: string | null;
|
|
138
|
+
total: number;
|
|
139
|
+
day_type_one: number;
|
|
140
|
+
day_type_three: number;
|
|
141
|
+
day_type_two: number;
|
|
142
|
+
}>, "many">;
|
|
143
|
+
total_from_distance: z.ZodNumber;
|
|
144
|
+
total_from_shape: z.ZodNumber;
|
|
145
|
+
total_in_euros: z.ZodNumber;
|
|
146
|
+
total_relative_to_contract: z.ZodNumber;
|
|
147
|
+
}, "strip", z.ZodTypeAny, {
|
|
148
|
+
day_type_one: number;
|
|
149
|
+
day_type_three: number;
|
|
150
|
+
day_type_two: number;
|
|
151
|
+
inputs: {
|
|
152
|
+
price_per_km: number;
|
|
153
|
+
agency_id: string;
|
|
154
|
+
start_date: string & {
|
|
155
|
+
__brand: "OperationalDate";
|
|
156
|
+
};
|
|
157
|
+
agency_name: string;
|
|
158
|
+
calculation_method: "rolling_year" | "fixed_range";
|
|
159
|
+
end_date: string & {
|
|
160
|
+
__brand: "OperationalDate";
|
|
161
|
+
};
|
|
162
|
+
total_vkm_per_year: number;
|
|
163
|
+
};
|
|
164
|
+
periods: {
|
|
165
|
+
code: string | null;
|
|
166
|
+
name: string;
|
|
167
|
+
id: string | null;
|
|
168
|
+
total: number;
|
|
169
|
+
day_type_one: number;
|
|
170
|
+
day_type_three: number;
|
|
171
|
+
day_type_two: number;
|
|
172
|
+
}[];
|
|
173
|
+
total_from_distance: number;
|
|
174
|
+
total_from_shape: number;
|
|
175
|
+
total_in_euros: number;
|
|
176
|
+
total_relative_to_contract: number;
|
|
177
|
+
}, {
|
|
178
|
+
day_type_one: number;
|
|
179
|
+
day_type_three: number;
|
|
180
|
+
day_type_two: number;
|
|
181
|
+
inputs: {
|
|
182
|
+
price_per_km: number;
|
|
183
|
+
agency_id: string;
|
|
184
|
+
start_date: string;
|
|
185
|
+
agency_name: string;
|
|
186
|
+
calculation_method: "rolling_year" | "fixed_range";
|
|
187
|
+
end_date: string;
|
|
188
|
+
total_vkm_per_year: number;
|
|
189
|
+
};
|
|
190
|
+
periods: {
|
|
191
|
+
code: string | null;
|
|
192
|
+
name: string;
|
|
193
|
+
id: string | null;
|
|
194
|
+
total: number;
|
|
195
|
+
day_type_one: number;
|
|
196
|
+
day_type_three: number;
|
|
197
|
+
day_type_two: number;
|
|
198
|
+
}[];
|
|
199
|
+
total_from_distance: number;
|
|
200
|
+
total_from_shape: number;
|
|
201
|
+
total_in_euros: number;
|
|
202
|
+
total_relative_to_contract: number;
|
|
203
|
+
}>;
|
|
204
|
+
export type CalculateVkmDto = z.infer<typeof CalculateVkmSchema>;
|
|
205
|
+
export type VkmCalculationInputs = z.infer<typeof VkmCalculationInputsSchema>;
|
|
206
|
+
export type VkmCalculationResult = z.infer<typeof VkmCalculationResultSchema>;
|
|
207
|
+
export type VkmPeriodResult = z.infer<typeof VkmPeriodResultSchema>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { OperationalDateSchema } from '@tmlmobilidade/go-types-shared';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/* * */
|
|
4
|
+
export const VkmCalculationMethodValues = [
|
|
5
|
+
'rolling_year',
|
|
6
|
+
'fixed_range',
|
|
7
|
+
];
|
|
8
|
+
export const VkmCalculationMethodSchema = z.enum(VkmCalculationMethodValues);
|
|
9
|
+
export const VkmExtensionSourceValues = [
|
|
10
|
+
'go',
|
|
11
|
+
'stop_times',
|
|
12
|
+
];
|
|
13
|
+
export const VkmExtensionSourceSchema = z.enum(VkmExtensionSourceValues);
|
|
14
|
+
export const LegacyVkmDayTypeSchema = z.enum(['1', '2', '3']);
|
|
15
|
+
/* * */
|
|
16
|
+
export const CalculateVkmSchema = z.object({
|
|
17
|
+
agency_id: z.string(),
|
|
18
|
+
calculation_method: VkmCalculationMethodSchema,
|
|
19
|
+
end_date: OperationalDateSchema.nullable().optional(),
|
|
20
|
+
extension_source: VkmExtensionSourceSchema,
|
|
21
|
+
start_date: OperationalDateSchema,
|
|
22
|
+
});
|
|
23
|
+
export const VkmCalculationInputsSchema = z.object({
|
|
24
|
+
agency_id: z.string(),
|
|
25
|
+
agency_name: z.string(),
|
|
26
|
+
calculation_method: VkmCalculationMethodSchema,
|
|
27
|
+
end_date: OperationalDateSchema,
|
|
28
|
+
price_per_km: z.number(),
|
|
29
|
+
start_date: OperationalDateSchema,
|
|
30
|
+
total_vkm_per_year: z.number(),
|
|
31
|
+
});
|
|
32
|
+
export const VkmPeriodResultSchema = z.object({
|
|
33
|
+
code: z.string().nullable(),
|
|
34
|
+
day_type_one: z.number(),
|
|
35
|
+
day_type_three: z.number(),
|
|
36
|
+
day_type_two: z.number(),
|
|
37
|
+
id: z.string().nullable(),
|
|
38
|
+
name: z.string(),
|
|
39
|
+
total: z.number(),
|
|
40
|
+
});
|
|
41
|
+
export const VkmCalculationResultSchema = z.object({
|
|
42
|
+
day_type_one: z.number(),
|
|
43
|
+
day_type_three: z.number(),
|
|
44
|
+
day_type_two: z.number(),
|
|
45
|
+
inputs: VkmCalculationInputsSchema,
|
|
46
|
+
periods: z.array(VkmPeriodResultSchema),
|
|
47
|
+
total_from_distance: z.number(),
|
|
48
|
+
total_from_shape: z.number(),
|
|
49
|
+
total_in_euros: z.number(),
|
|
50
|
+
total_relative_to_contract: z.number(),
|
|
51
|
+
});
|