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