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