refactor(simulator): add type shorcuts for OCPP configuration keys
[e-mobility-charging-stations-simulator.git] / src / types / ocpp / Requests.ts
CommitLineData
2896e06d
JB
1import type { ChargingStation } from '../../charging-station';
2import type { OCPPError } from '../../exception';
e7aeea18 3import {
2896e06d
JB
4 type JsonType,
5 type MessageType,
e7aeea18 6 OCPP16AvailabilityType,
953d6b02
JB
7 type OCPP16BootNotificationRequest,
8 type OCPP16DataTransferRequest,
2896e06d 9 OCPP16DiagnosticsStatus,
c9a4f9ea 10 type OCPP16DiagnosticsStatusNotificationRequest,
d4c84337 11 OCPP16FirmwareStatus,
c9a4f9ea 12 type OCPP16FirmwareStatusNotificationRequest,
953d6b02 13 type OCPP16HeartbeatRequest,
e7aeea18 14 OCPP16IncomingRequestCommand,
c60ed4b8 15 OCPP16MessageTrigger,
2896e06d 16 type OCPP16MeterValuesRequest,
e7aeea18 17 OCPP16RequestCommand,
953d6b02 18 type OCPP16StatusNotificationRequest,
d270cc87
JB
19 type OCPP20BootNotificationRequest,
20 OCPP20IncomingRequestCommand,
21 OCPP20RequestCommand,
6e939d9e 22 type OCPP20StatusNotificationRequest,
2896e06d 23} from '../internal';
6a64534b 24
e3018bc4
JB
25export const RequestCommand = {
26 ...OCPP16RequestCommand,
953d6b02 27 ...OCPP20RequestCommand,
edd13439
JB
28} as const;
29export type RequestCommand = OCPP16RequestCommand | OCPP20RequestCommand;
e3018bc4 30
5cc4b63b 31export type OutgoingRequest = [MessageType.CALL_MESSAGE, string, RequestCommand, JsonType];
b3ec7bc1 32
83e00df1 33export type RequestParams = {
e3018bc4
JB
34 skipBufferingOnError?: boolean;
35 triggerMessage?: boolean;
8ec8e3d0 36 throwError?: boolean;
83e00df1 37};
e3018bc4 38
e3018bc4
JB
39export const IncomingRequestCommand = {
40 ...OCPP16IncomingRequestCommand,
953d6b02 41 ...OCPP20IncomingRequestCommand,
edd13439
JB
42} as const;
43export type IncomingRequestCommand = OCPP16IncomingRequestCommand | OCPP20IncomingRequestCommand;
e3018bc4 44
5cc4b63b 45export type IncomingRequest = [MessageType.CALL_MESSAGE, string, IncomingRequestCommand, JsonType];
b3ec7bc1 46
d900c8d7
JB
47export type ResponseCallback = (payload: JsonType, requestPayload: JsonType) => void;
48
49export type ErrorCallback = (error: OCPPError, requestStatistic?: boolean) => void;
50
b3ec7bc1 51export type CachedRequest = [
d900c8d7
JB
52 ResponseCallback,
53 ErrorCallback,
b3ec7bc1 54 RequestCommand | IncomingRequestCommand,
5cc4b63b 55 JsonType
b3ec7bc1
JB
56];
57
c60ed4b8
JB
58export const MessageTrigger = {
59 ...OCPP16MessageTrigger,
edd13439
JB
60} as const;
61export type MessageTrigger = OCPP16MessageTrigger;
c60ed4b8 62
d270cc87 63export type BootNotificationRequest = OCPP16BootNotificationRequest | OCPP20BootNotificationRequest;
c0560973 64
ef6fa3fb
JB
65export type HeartbeatRequest = OCPP16HeartbeatRequest;
66
6e939d9e
JB
67export type StatusNotificationRequest =
68 | OCPP16StatusNotificationRequest
69 | OCPP20StatusNotificationRequest;
ef6fa3fb
JB
70
71export type MeterValuesRequest = OCPP16MeterValuesRequest;
72
91a7d3ea
JB
73export type DataTransferRequest = OCPP16DataTransferRequest;
74
c9a4f9ea
JB
75export type DiagnosticsStatusNotificationRequest = OCPP16DiagnosticsStatusNotificationRequest;
76
77export type FirmwareStatusNotificationRequest = OCPP16FirmwareStatusNotificationRequest;
78
e3018bc4
JB
79export type IncomingRequestHandler = (
80 chargingStation: ChargingStation,
81 commandPayload: JsonType
82) => JsonType | Promise<JsonType>;
83
c0560973 84export const AvailabilityType = {
e7aeea18 85 ...OCPP16AvailabilityType,
edd13439
JB
86} as const;
87export type AvailabilityType = OCPP16AvailabilityType;
47e22477
JB
88
89export const DiagnosticsStatus = {
e7aeea18 90 ...OCPP16DiagnosticsStatus,
edd13439
JB
91} as const;
92export type DiagnosticsStatus = OCPP16DiagnosticsStatus;
e3018bc4 93
d4c84337
JB
94export const FirmwareStatus = {
95 ...OCPP16FirmwareStatus,
96} as const;
97export type FirmwareStatus = OCPP16FirmwareStatus;
98
e3018bc4 99export type ResponseType = JsonType | OCPPError;