Added CS inerror validation
MODIFY
src/assets/server/rest/v1/schemas/chargingstation/chargingstations-get.json
src/assets/server/rest/v1/schemas/chargingstation/chargingstations-get.json
"type": "boolean",
"sanitize": "mongo"
},
- "ErrorType": {
- "type": "string",
- "sanitize": "mongo"
- },
"LocLongitude": {
"type": "number",
"sanitize": "mongo"

ADD
src/assets/server/rest/v1/schemas/chargingstation/chargingstations-inerror-get.json
+{
+ "title": "Get Charging Stations in error Request",
+ "type": "object",
+ "properties": {
+ "Search": {
+ "$ref": "common.json#/definitions/search"
+ },
+ "SiteID": {
+ "$ref": "common.json#/definitions/ids"
+ },
+ "SiteAreaID": {
+ "$ref": "common.json#/definitions/ids"
+ },
+ "ErrorType": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "Limit": {
+ "$ref": "common.json#/definitions/limit"
+ },
+ "SortFields": {
+ "$ref": "common.json#/definitions/sortFields"
+ },
+ "Skip": {
+ "$ref": "common.json#/definitions/skip"
+ },
+ "OnlyRecordCount": {
+ "$ref": "common.json#/definitions/onlyRecordCount"
+ },
+ "ProjectFields": {
+ "$ref": "common.json#/definitions/projectFields"
+ }
+ },
+ "required": []
+}

RENAME
src/assets/server/rest/v1/schemas/chargingstation/smartcharing-trigger.json
src/assets/server/rest/v1/schemas/chargingstation/smartcharging-trigger.json
MODIFY
src/assets/server/rest/v1/schemas/transaction/transactions-get.json
src/assets/server/rest/v1/schemas/transaction/transactions-get.json
"sanitize": "mongo"
},
"ConnectorID": {
- "$ref": "chargingstation.json#/definitions/connectorID"
+ "$ref": "chargingstation.json#/definitions/connector/properties/connectorId"
},
"SiteAreaID": {
"$ref": "common.json#/definitions/ids"

MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -6,7 +6,6 @@ import { OCPPConfigurationStatus, OCPPGetCompositeScheduleCommandResult, OCPPRem
import AppAuthError from '../../../../exception/AppAuthError';
import AppError from '../../../../exception/AppError';
-import AuthorizationService from './AuthorizationService';
import Authorizations from '../../../../authorization/Authorizations';
import BackendError from '../../../../exception/BackendError';
import { ChargingProfile } from '../../../../types/ChargingProfile';
@@ -1070,7 +1069,7 @@ export default class ChargingStationService {
});
}
// Filter
- const filteredRequest = ChargingStationSecurity.filterChargingStationsRequest(req.query);
+ const filteredRequest = ChargingStationValidator.getInstance().validateChargingStationInErrorReq(req.query);
// Check component
if (filteredRequest.SiteID) {
UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.ORGANIZATION,
@@ -1107,7 +1106,7 @@ export default class ChargingStationService {
{
limit: filteredRequest.Limit,
skip: filteredRequest.Skip,
- sort: filteredRequest.SortFields,
+ sort: UtilsService.httpSortFieldsToMongoDB(filteredRequest.SortFields),
onlyRecordCount: filteredRequest.OnlyRecordCount
},
projectFields

MODIFY
src/server/rest/v1/validator/ChargingStationValidator.ts
src/server/rest/v1/validator/ChargingStationValidator.ts
-import { HttpChargingStationCommandRequest, HttpChargingStationConnectorRequest, HttpChargingStationGetFirmwareRequest, HttpChargingStationLimitPowerRequest, HttpChargingStationOcppParametersRequest, HttpChargingStationOcppRequest, HttpChargingStationParamsUpdateRequest, HttpChargingStationRequest, HttpChargingStationsRequest, HttpDownloadQrCodeRequest, HttpTriggerSmartChargingRequest } from '../../../../types/requests/HttpChargingStationRequest';
+import { HttpChargingStationCommandRequest, HttpChargingStationConnectorRequest, HttpChargingStationGetFirmwareRequest, HttpChargingStationLimitPowerRequest, HttpChargingStationOcppParametersRequest, HttpChargingStationOcppRequest, HttpChargingStationParamsUpdateRequest, HttpChargingStationRequest, HttpChargingStationsInErrorRequest, HttpChargingStationsRequest, HttpDownloadQrCodeRequest, HttpTriggerSmartChargingRequest } from '../../../../types/requests/HttpChargingStationRequest';
import { ChargingProfile } from '../../../../types/ChargingProfile';
import HttpByIDRequest from '../../../../types/requests/HttpByIDRequest';
@@ -22,6 +22,7 @@ export default class ChargingStationValidator extends SchemaValidator {
private chargingStationLimitPower: Schema;
private chargingStationFirmwareDownload: Schema;
private smartChargingTrigger: Schema;
+ private chargingStationInErrorGet: Schema;
private constructor() {
super('ChargingStationValidator');
@@ -38,6 +39,7 @@ export default class ChargingStationValidator extends SchemaValidator {
this.chargingStationLimitPower = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-limit-power.json`, 'utf8'));
this.chargingStationFirmwareDownload = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-firmware-download.json`, 'utf8'));
this.smartChargingTrigger = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/smartcharging-trigger.json`, 'utf8'));
+ this.chargingStationInErrorGet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstations-inerror-get.json`, 'utf8'));
}
public static getInstance(): ChargingStationValidator {
@@ -125,4 +127,10 @@ export default class ChargingStationValidator extends SchemaValidator {
this.validate(this.smartChargingTrigger, data);
return data;
}
+
+ public validateChargingStationInErrorReq(data: any): HttpChargingStationsInErrorRequest {
+ // Validate schema
+ this.validate(this.chargingStationInErrorGet, data);
+ return data;
+ }
}

MODIFY
src/server/rest/v1/validator/TransactionValidator.ts
src/server/rest/v1/validator/TransactionValidator.ts
-import { HttpChargingStationCommandRequest, HttpChargingStationConnectorRequest, HttpChargingStationOcppParametersRequest, HttpChargingStationOcppRequest, HttpChargingStationsRequest, HttpDownloadQrCodeRequest } from '../../../../types/requests/HttpChargingStationRequest';
-
-import HttpByIDRequest from '../../../../types/requests/HttpByIDRequest';
import { HttpTransactionsRequest } from '../../../../types/requests/HttpTransactionRequest';
-import Schema from './Schema';
+import Schema from '../../../../types/validator/Schema';
import SchemaValidator from './SchemaValidator';
import fs from 'fs';
import global from '../../../../types/GlobalType';

MODIFY
src/types/requests/HttpChargingStationRequest.ts
src/types/requests/HttpChargingStationRequest.ts
@@ -46,6 +46,13 @@ export interface HttpChargingStationsRequest extends HttpDatabaseRequest {
LocMaxDistanceMeters?: number;
}
+export interface HttpChargingStationsInErrorRequest extends HttpDatabaseRequest {
+ Search?: string;
+ SiteID?: string;
+ SiteAreaID?: string;
+ ErrorType?: string;
+}
+
export interface HttpChargingStationParamsUpdateRequest {
id: string;
chargingStationURL: string;

Added CS inerror validation