fix: handle recurring charging profiles only in the past
[e-mobility-charging-stations-simulator.git] / src / types / ocpp / Responses.ts
1 import type { OCPP16MeterValuesResponse } from './1.6/MeterValues';
2 import {
3 OCPP16AvailabilityStatus,
4 type OCPP16BootNotificationResponse,
5 OCPP16ChargingProfileStatus,
6 OCPP16ClearChargingProfileStatus,
7 OCPP16ConfigurationStatus,
8 type OCPP16DataTransferResponse,
9 OCPP16DataTransferStatus,
10 type OCPP16DiagnosticsStatusNotificationResponse,
11 type OCPP16FirmwareStatusNotificationResponse,
12 type OCPP16HeartbeatResponse,
13 OCPP16ReservationStatus,
14 type OCPP16StatusNotificationResponse,
15 OCPP16TriggerMessageStatus,
16 OCPP16UnlockStatus,
17 } from './1.6/Responses';
18 import type { OCPP20BootNotificationResponse, OCPP20ClearCacheResponse } from './2.0/Responses';
19 import type { ErrorType } from './ErrorType';
20 import type { MessageType } from './MessageType';
21 import type { ChargingStation } from '../../charging-station';
22 import type { JsonObject, JsonType } from '../JsonType';
23
24 export type Response = [MessageType.CALL_RESULT_MESSAGE, string, JsonType];
25
26 export type ErrorResponse = [MessageType.CALL_ERROR_MESSAGE, string, ErrorType, string, JsonType];
27
28 export type ResponseHandler = (
29 chargingStation: ChargingStation,
30 payload: JsonType,
31 requestPayload?: JsonType,
32 ) => void | Promise<void>;
33
34 export type BootNotificationResponse =
35 | OCPP16BootNotificationResponse
36 | OCPP20BootNotificationResponse;
37
38 export type HeartbeatResponse = OCPP16HeartbeatResponse;
39
40 export type ClearCacheResponse = GenericResponse | OCPP20ClearCacheResponse;
41
42 export type StatusNotificationResponse = OCPP16StatusNotificationResponse;
43
44 export type MeterValuesResponse = OCPP16MeterValuesResponse;
45
46 export type DataTransferResponse = OCPP16DataTransferResponse;
47
48 export type DiagnosticsStatusNotificationResponse = OCPP16DiagnosticsStatusNotificationResponse;
49
50 export type FirmwareStatusNotificationResponse = OCPP16FirmwareStatusNotificationResponse;
51
52 export enum GenericStatus {
53 Accepted = 'Accepted',
54 Rejected = 'Rejected',
55 }
56
57 export interface GenericResponse extends JsonObject {
58 status: GenericStatus;
59 }
60
61 export enum RegistrationStatusEnumType {
62 ACCEPTED = 'Accepted',
63 PENDING = 'Pending',
64 REJECTED = 'Rejected',
65 }
66
67 export const AvailabilityStatus = {
68 ...OCPP16AvailabilityStatus,
69 } as const;
70 export type AvailabilityStatus = OCPP16AvailabilityStatus;
71
72 export const ChargingProfileStatus = {
73 ...OCPP16ChargingProfileStatus,
74 } as const;
75 export type ChargingProfileStatus = OCPP16ChargingProfileStatus;
76
77 export const ClearChargingProfileStatus = {
78 ...OCPP16ClearChargingProfileStatus,
79 } as const;
80 export type ClearChargingProfileStatus = OCPP16ClearChargingProfileStatus;
81
82 export const ConfigurationStatus = {
83 ...OCPP16ConfigurationStatus,
84 } as const;
85 export type ConfigurationStatus = OCPP16ConfigurationStatus;
86
87 export const UnlockStatus = {
88 ...OCPP16UnlockStatus,
89 } as const;
90 export type UnlockStatus = OCPP16UnlockStatus;
91
92 export const TriggerMessageStatus = {
93 ...OCPP16TriggerMessageStatus,
94 } as const;
95 export type TriggerMessageStatus = OCPP16TriggerMessageStatus;
96
97 export const DataTransferStatus = {
98 ...OCPP16DataTransferStatus,
99 } as const;
100 export type DataTransferStatus = OCPP16DataTransferStatus;
101
102 export type ReservationStatus = OCPP16ReservationStatus;
103 export const ReservationStatus = {
104 ...OCPP16ReservationStatus,
105 };
106
107 export type CancelReservationStatus = GenericStatus;
108 export const CancelReservationStatus = {
109 ...GenericStatus,
110 };
111
112 export type CancelReservationResponse = GenericResponse;