-
Notifications
You must be signed in to change notification settings - Fork 2
/
ocpi.tariff.v22.ts
90 lines (81 loc) · 2.44 KB
/
ocpi.tariff.v22.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import { z } from "zod";
import { DisplayText } from "./ocpi.common";
import { Price } from "./ocpi.common.v22";
import { EnergyMix } from "./ocpi.location.v22";
const TariffDimensionType = z.enum(["ENERGY", "FLAT", "PARKING_TIME", "TIME"]);
const PriceComponent = z.object({
type: TariffDimensionType,
price: z.number().nonnegative(),
vat: z.number().nonnegative().nullish(),
step_size: z.number().int().nonnegative(),
});
const DayOfWeek = z.enum([
"MONDAY",
"TUESDAY",
"WEDNESDAY",
"THURSDAY",
"FRIDAY",
"SATURDAY",
"SUNDAY",
]);
const ReservationRestrictionType = z.enum(["RESERVATION", "RESERVATION_EXPIRES"])
const TariffRestrictions = z.object({
start_time: z
.string()
.length(5)
.regex(/([0-1][0-9]|2[0-3]):[0-5][0-9]/)
.nullish(),
end_time: z
.string()
.length(5)
.regex(/([0-1][0-9]|2[0-3]):[0-5][0-9]/)
.nullish(),
start_date: z
.string()
.length(10)
.regex(/([12][0-9]{3})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])/)
.nullish(),
end_date: z
.string()
.length(10)
.regex(/([12][0-9]{3})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])/)
.nullish(),
min_kwh: z.number().nonnegative().nullish(),
max_kwh: z.number().nonnegative().nullish(),
min_current: z.number().nonnegative().nullish(),
max_current: z.number().nonnegative().nullish(),
min_power: z.number().nonnegative().nullish(),
max_power: z.number().nonnegative().nullish(),
min_duration: z.number().int().nonnegative().nullish(),
max_duration: z.number().int().nonnegative().nullish(),
day_of_week: z.array(DayOfWeek).nullish(),
reservation: ReservationRestrictionType.nullish()
});
const TariffElement = z.object({
price_components: z.array(PriceComponent).nonempty(),
restrictions: TariffRestrictions.nullish(),
});
const TariffType = z.enum([
"AD_HOC_PAYMENT",
"PROFILE_CHEAP",
"PROFILE_FAST",
"PROFILE_GREEN",
"REGULAR"
])
export const Tariff = z.object({
country_code: z.string().length(2),
party_id: z.string().max(3),
id: z.string().max(36),
currency: z.string().length(3),
type: TariffType.nullish(),
tariff_alt_text: z.array(DisplayText).nullish(),
tariff_alt_url: z.string().url().nullish(),
min_price: Price.nullish(),
max_price: Price.nullish(),
elements: z.array(TariffElement).nonempty(),
start_date_time: z.date().nullish(),
end_date_time: z.date().nullish(),
energy_mix: EnergyMix.nullish(),
last_updated: z.date(),
});
export const Tariffs = z.array(Tariff);