Refine TS and linter configuration
[e-mobility-charging-stations-simulator.git] / src / types / ocpp / Requests.ts
CommitLineData
8114d10e 1import type ChargingStation from '../../charging-station/ChargingStation';
6c1761d4
JB
2import type OCPPError from '../../exception/OCPPError';
3import type { JsonType } from '../JsonType';
8114d10e 4import { OCPP16DiagnosticsStatus } from './1.6/DiagnosticsStatus';
6c1761d4 5import type { OCPP16MeterValuesRequest } from './1.6/MeterValues';
e7aeea18
JB
6import {
7 OCPP16AvailabilityType,
8 OCPP16BootNotificationRequest,
ef6fa3fb 9 OCPP16HeartbeatRequest,
e7aeea18
JB
10 OCPP16IncomingRequestCommand,
11 OCPP16RequestCommand,
ef6fa3fb 12 OCPP16StatusNotificationRequest,
e7aeea18 13} from './1.6/Requests';
6c1761d4 14import type { MessageType } from './MessageType';
6a64534b 15
e3018bc4
JB
16export type RequestCommand = OCPP16RequestCommand;
17
18export const RequestCommand = {
19 ...OCPP16RequestCommand,
20};
21
5cc4b63b 22export type OutgoingRequest = [MessageType.CALL_MESSAGE, string, RequestCommand, JsonType];
b3ec7bc1 23
e3018bc4
JB
24export interface RequestParams {
25 skipBufferingOnError?: boolean;
26 triggerMessage?: boolean;
27}
28
29export type IncomingRequestCommand = OCPP16IncomingRequestCommand;
30
31export const IncomingRequestCommand = {
32 ...OCPP16IncomingRequestCommand,
33};
34
5cc4b63b 35export type IncomingRequest = [MessageType.CALL_MESSAGE, string, IncomingRequestCommand, JsonType];
b3ec7bc1
JB
36
37export type CachedRequest = [
5cc4b63b 38 (payload: JsonType, requestPayload: JsonType) => void,
b3ec7bc1
JB
39 (error: OCPPError, requestStatistic?: boolean) => void,
40 RequestCommand | IncomingRequestCommand,
5cc4b63b 41 JsonType
b3ec7bc1
JB
42];
43
c0560973
JB
44export type BootNotificationRequest = OCPP16BootNotificationRequest;
45
ef6fa3fb
JB
46export type HeartbeatRequest = OCPP16HeartbeatRequest;
47
48export type StatusNotificationRequest = OCPP16StatusNotificationRequest;
49
50export type MeterValuesRequest = OCPP16MeterValuesRequest;
51
e3018bc4
JB
52export type IncomingRequestHandler = (
53 chargingStation: ChargingStation,
54 commandPayload: JsonType
55) => JsonType | Promise<JsonType>;
56
7e3926cc 57export type AvailabilityType = OCPP16AvailabilityType;
c0560973
JB
58
59export const AvailabilityType = {
e7aeea18 60 ...OCPP16AvailabilityType,
c0560973
JB
61};
62
47e22477
JB
63export type DiagnosticsStatus = OCPP16DiagnosticsStatus;
64
65export const DiagnosticsStatus = {
e7aeea18 66 ...OCPP16DiagnosticsStatus,
47e22477 67};
e3018bc4
JB
68
69export type ResponseType = JsonType | OCPPError;