1683654c73cc13c9bb22c473c067f2cead27c46c
[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 interface RequestParams {
17 skipBufferingOnError?: boolean;
18 triggerMessage?: boolean;
19 }
20
21 export type IncomingRequestHandler = (commandPayload: JsonType) => JsonType | Promise<JsonType>;
22
23 export type ResponseType = JsonType | OCPPError | string;
24
25 export type BootNotificationRequest = OCPP16BootNotificationRequest;
26
27 export type HeartbeatRequest = OCPP16HeartbeatRequest;
28
29 export type StatusNotificationRequest = OCPP16StatusNotificationRequest;
30
31 export type MeterValuesRequest = OCPP16MeterValuesRequest;
32
33 export type AvailabilityType = OCPP16AvailabilityType;
34
35 export const AvailabilityType = {
36 ...OCPP16AvailabilityType,
37 };
38
39 export type RequestCommand = OCPP16RequestCommand;
40
41 export const RequestCommand = {
42 ...OCPP16RequestCommand,
43 };
44
45 export type IncomingRequestCommand = OCPP16IncomingRequestCommand;
46
47 export const IncomingRequestCommand = {
48 ...OCPP16IncomingRequestCommand,
49 };
50
51 export type DiagnosticsStatus = OCPP16DiagnosticsStatus;
52
53 export const DiagnosticsStatus = {
54 ...OCPP16DiagnosticsStatus,
55 };
56
57 export type Request = [MessageType, string, RequestCommand, JsonType, JsonType];
58
59 export type IncomingRequest = [MessageType, string, IncomingRequestCommand, JsonType, JsonType];
60
61 export type CachedRequest = [
62 (payload: JsonType, requestPayload: JsonType) => void,
63 (error: OCPPError, requestStatistic?: boolean) => void,
64 RequestCommand | IncomingRequestCommand,
65 JsonType | OCPPError
66 ];