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