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