repositories
/
e-mobility-charging-stations-simulator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
refactor: cleanup loops over object keys
[e-mobility-charging-stations-simulator.git]
/
src
/
charging-station
/
ocpp
/
OCPPRequestService.ts
diff --git
a/src/charging-station/ocpp/OCPPRequestService.ts
b/src/charging-station/ocpp/OCPPRequestService.ts
index a3b78ca63ec8e40d44a07c7a12f9689ed38eee63..4ea134b6ef062d5860e2b36e29d8d7d29b794781 100644
(file)
--- a/
src/charging-station/ocpp/OCPPRequestService.ts
+++ b/
src/charging-station/ocpp/OCPPRequestService.ts
@@
-23,7
+23,13
@@
import {
type ResponseCallback,
type ResponseType,
} from '../../types';
type ResponseCallback,
type ResponseType,
} from '../../types';
-import { Constants, Utils, handleSendMessageError, logger } from '../../utils';
+import {
+ Constants,
+ cloneObject,
+ handleSendMessageError,
+ logger,
+ promiseWithTimeout,
+} from '../../utils';
const moduleName = 'OCPPRequestService';
const moduleName = 'OCPPRequestService';
@@
-191,7
+197,7
@@
export abstract class OCPPRequestService {
commandName: RequestCommand | IncomingRequestCommand,
payload: T
): boolean {
commandName: RequestCommand | IncomingRequestCommand,
payload: T
): boolean {
- if (chargingStation.get
PayloadSchemaValidation
() === false) {
+ if (chargingStation.get
OcppStrictCompliance
() === false) {
return true;
}
if (this.jsonSchemas.has(commandName as RequestCommand) === false) {
return true;
}
if (this.jsonSchemas.has(commandName as RequestCommand) === false) {
@@
-201,7
+207,7
@@
export abstract class OCPPRequestService {
return true;
}
const validate = this.ajv.compile(this.jsonSchemas.get(commandName as RequestCommand));
return true;
}
const validate = this.ajv.compile(this.jsonSchemas.get(commandName as RequestCommand));
- payload =
Utils.
cloneObject<T>(payload);
+ payload = cloneObject<T>(payload);
OCPPServiceUtils.convertDateToISOString<T>(payload);
if (validate(payload)) {
return true;
OCPPServiceUtils.convertDateToISOString<T>(payload);
if (validate(payload)) {
return true;
@@
-224,7
+230,7
@@
export abstract class OCPPRequestService {
commandName: RequestCommand | IncomingRequestCommand,
payload: T
): boolean {
commandName: RequestCommand | IncomingRequestCommand,
payload: T
): boolean {
- if (chargingStation.get
PayloadSchemaValidation
() === false) {
+ if (chargingStation.get
OcppStrictCompliance
() === false) {
return true;
}
if (
return true;
}
if (
@@
-242,7
+248,7
@@
export abstract class OCPPRequestService {
commandName as IncomingRequestCommand
)
);
commandName as IncomingRequestCommand
)
);
- payload =
Utils.
cloneObject<T>(payload);
+ payload = cloneObject<T>(payload);
OCPPServiceUtils.convertDateToISOString<T>(payload);
if (validate(payload)) {
return true;
OCPPServiceUtils.convertDateToISOString<T>(payload);
if (validate(payload)) {
return true;
@@
-284,7
+290,7
@@
export abstract class OCPPRequestService {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this;
// Send a message through wsConnection
// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this;
// Send a message through wsConnection
- return
Utils.
promiseWithTimeout(
+ return promiseWithTimeout(
new Promise((resolve, reject) => {
/**
* Function that will receive the request's response
new Promise((resolve, reject) => {
/**
* Function that will receive the request's response