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