Added asset / carConnector settings validator
ADD
src/assets/server/rest/v1/schemas/setting/setting-asset-set.json
+{
+ "$id": "setting-asset-set",
+ "title": "Set Assets Settings",
+ "type": "object",
+ "properties": {
+ "content": {
+ "type": "object",
+ "properties": {
+ "asset": {
+ "type": "object",
+ "properties": {
+ "connections": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "name": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "description": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "url": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "type": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "refreshIntervalMins": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "schneiderConnection": {
+ "type": "object",
+ "properties": {
+ "user": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "password": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ }
+ },
+ "greenComConnection": {
+ "type": "object",
+ "properties": {
+ "clientId": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "clientSecret": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ }
+ },
+ "iothinkConnection": {
+ "type": "object",
+ "properties": {
+ "user": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "password": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ }
+ },
+ "witConnection": {
+ "type": "object",
+ "properties": {
+ "authenticationUrl": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "clientId": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "clientSecret": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "user": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "password": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ }
+ },
+ "lacroix": {
+ "type": "object",
+ "properties": {
+ "user": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "password": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "type": {
+ "type": "string",
+ "sanitize": "mongo",
+ "enum": ["asset"]
+ }
+ },
+ "required": [
+ "type"
+ ]
+ },
+ "id": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "identifier": {
+ "type": "string",
+ "sanitize": "mongo",
+ "enum": ["asset"]
+ },
+ "sensitiveData": {
+ "type": "array",
+ "nullable": true,
+ "items": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ }
+ },
+ "required": [
+ "id",
+ "identifier",
+ "content"
+ ]
+}

ADD
src/assets/server/rest/v1/schemas/setting/setting-car-connector-set.json
+{
+ "$id": "setting-car-connector-set",
+ "title": "Set Car Connector Settings",
+ "type": "object",
+ "properties": {
+ "content": {
+ "type": "object",
+ "properties": {
+ "carConnector": {
+ "type": "object",
+ "properties": {
+ "connections": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "name": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "description": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "type": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "mercedesConnection": {
+ "type": "object",
+ "properties": {
+ "authenticationUrl": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "apiUrl": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "clientId": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "clientSecret": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ }
+ },
+ "tronityConnection": {
+ "type": "object",
+ "properties": {
+ "apiUrl": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "clientId": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "clientSecret": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "type": {
+ "type": "string",
+ "sanitize": "mongo",
+ "enum": ["carConnector"]
+ }
+ },
+ "required": [
+ "type"
+ ]
+ },
+ "id": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "identifier": {
+ "type": "string",
+ "sanitize": "mongo",
+ "enum": ["carConnector"]
+ },
+ "sensitiveData": {
+ "type": "array",
+ "nullable": true,
+ "items": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ }
+ },
+ "required": [
+ "id",
+ "identifier",
+ "content"
+ ]
+}

MODIFY
src/server/rest/v1/service/SettingService.ts
src/server/rest/v1/service/SettingService.ts
@@ -205,6 +205,9 @@ export default class SettingService {
case IntegrationSettings.SAC:
filteredRequest = SettingValidator.getInstance().validateSettingSacSetReq(req.body);
break;
+ case IntegrationSettings.ASSET:
+ filteredRequest = SettingValidator.getInstance().validateSettingAssetSetReq(req.body);
+ break;
default:
filteredRequest = SettingSecurity.filterSettingUpdateRequest(req.body);
await Logging.logDebug({

MODIFY
src/server/rest/v1/validator/SettingValidator.ts
src/server/rest/v1/validator/SettingValidator.ts
-import { HttpSettingBillingSetRequest, HttpSettingCryptoSetRequest, HttpSettingOCPISetRequest, HttpSettingOICPSetRequest, HttpSettingPricingSetRequest, HttpSettingRefundSetRequest, HttpSettingSacSetRequest, HttpSettingSmartChargingSetRequest, HttpSettingUserSetRequest } from '../../../../types/requests/HttpSettingRequest';
+import { HttpSettingAssetSetRequest, HttpSettingBillingSetRequest, HttpSettingCarConnectorSetRequest, HttpSettingCryptoSetRequest, HttpSettingOCPISetRequest, HttpSettingOICPSetRequest, HttpSettingPricingSetRequest, HttpSettingRefundSetRequest, HttpSettingSacSetRequest, HttpSettingSmartChargingSetRequest, HttpSettingUserSetRequest } from '../../../../types/requests/HttpSettingRequest';
import Schema from '../../../../types/validator/Schema';
import SchemaValidator from '../../../../validator/SchemaValidator';
@@ -16,6 +16,8 @@ export default class SettingValidator extends SchemaValidator {
private settingSacSet: Schema;
private settingOICPSet: Schema;
private settingBillingSet: Schema;
+ private settingAssetSet: Schema;
+ private settingCarConnectorSet: Schema;
private constructor() {
super('SettingValidator');
@@ -28,6 +30,8 @@ export default class SettingValidator extends SchemaValidator {
this.settingSacSet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/setting/setting-sac-set.json`, 'utf8'));
this.settingOICPSet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/setting/setting-oicp-set.json`, 'utf8'));
this.settingBillingSet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/setting/setting-billing-set.json`, 'utf8'));
+ this.settingAssetSet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/setting/setting-asset-set.json`, 'utf8'));
+ this.settingCarConnectorSet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/setting/setting-car-connector-set.json`, 'utf8'));
}
public static getInstance(): SettingValidator {
@@ -72,4 +76,12 @@ export default class SettingValidator extends SchemaValidator {
public validateSettingBillingSetReq(data: Record<string, unknown>): HttpSettingBillingSetRequest {
return this.validate(this.settingBillingSet, data);
}
+
+ public validateSettingAssetSetReq(data: Record<string, unknown>): HttpSettingAssetSetRequest {
+ return this.validate(this.settingAssetSet, data);
+ }
+
+ public validateSettingCarConnectorSetReq(data: Record<string, unknown>): HttpSettingCarConnectorSetRequest {
+ return this.validate(this.settingCarConnectorSet, data);
+ }
}

MODIFY
src/types/Setting.ts
src/types/Setting.ts
@@ -13,6 +13,7 @@ export enum IntegrationSettings {
SMART_CHARGING = 'smartCharging',
REFUND = 'refund',
PRICING = 'pricing',
+ ASSET = 'asset'
}
export interface Setting extends CreatedUpdatedProps {

MODIFY
src/types/requests/HttpSettingRequest.ts
src/types/requests/HttpSettingRequest.ts
+import { AssetConnectionSetting, CarConnectorConnectionSetting } from '../Setting';
+
import HttpByIDRequest from './HttpByIDRequest';
import HttpDatabaseRequest from './HttpDatabaseRequest';
@@ -11,7 +13,7 @@ export interface HttpSettingsRequest extends HttpDatabaseRequest {
}
export interface HttpSettingSetRequest {
- id: string,
+ id?: string,
identifier: string,
sensitiveData: []
}
@@ -169,3 +171,21 @@ export interface HttpSettingBillingSetRequest extends HttpSettingSetRequest {
}
}
}
+
+export interface HttpSettingAssetSetRequest extends HttpSettingSetRequest {
+ content: {
+ type: string,
+ asset: {
+ connections: AssetConnectionSetting[]
+ }
+ }
+}
+
+export interface HttpSettingCarConnectorSetRequest extends HttpSettingSetRequest {
+ content: {
+ type: string,
+ carConnector: {
+ connections: CarConnectorConnectionSetting[]
+ }
+ }
+}

Added asset / carConnector settings validator