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