Report typing from Jerome' PR
MODIFY
src/server/ocpi/AbstractOCPIService.ts
src/server/ocpi/AbstractOCPIService.ts
@@ -4,11 +4,11 @@ import AbstractEndpoint from './ocpi-services-impl/AbstractEndpoint';
import AppAuthError from '../../exception/AppAuthError';
import AppError from '../../exception/AppError';
import BackendError from '../../exception/BackendError';
-import { Configuration } from '../../types/configuration/Configuration';
import Constants from '../../utils/Constants';
import { HTTPError } from '../../types/HTTPError';
import Logging from '../../utils/Logging';
import OCPIEndpointStorage from '../../storage/mongodb/OCPIEndpointStorage';
+import OCPIServiceConfiguration from '../../types/configuration/OCPIServiceConfiguration';
import { OCPIStatusCode } from '../../types/ocpi/OCPIStatusCode';
import OCPIUtils from './OCPIUtils';
import { ServerAction } from '../../types/Server';
@@ -31,7 +31,7 @@ export default abstract class AbstractOCPIService {
// Create OCPI Service
protected constructor(
- private readonly ocpiRestConfig: Configuration['OCPIService'],
+ private readonly ocpiRestConfig: OCPIServiceConfiguration,
private readonly role: string,
private readonly version: string) {
}
@@ -207,7 +207,7 @@ export default abstract class AbstractOCPIService {
// Handle request action (endpoint)
const endpoint = registeredEndpoints.get(action);
if (endpoint) {
- Logging.logDebug({
+ await Logging.logDebug({
tenantID: tenant.id,
source: Constants.CENTRAL_SERVER,
module: MODULE_NAME, method: action,
@@ -217,7 +217,7 @@ export default abstract class AbstractOCPIService {
});
const response = await endpoint.process(req, res, next, tenant, ocpiEndpoint);
if (response) {
- Logging.logDebug({
+ await Logging.logDebug({
tenantID: tenant.id,
source: Constants.CENTRAL_SERVER,
module: MODULE_NAME, method: action,
@@ -227,7 +227,7 @@ export default abstract class AbstractOCPIService {
});
res.json(response);
} else {
- Logging.logWarning({
+ await Logging.logWarning({
tenantID: tenant.id,
source: Constants.CENTRAL_SERVER,
module: MODULE_NAME, method: action,
@@ -247,7 +247,7 @@ export default abstract class AbstractOCPIService {
});
}
} catch (error) {
- Logging.logError({
+ await Logging.logError({
tenantID: req.user && req.user.tenantID ? req.user.tenantID : Constants.DEFAULT_TENANT,
source: Constants.CENTRAL_SERVER,
module: MODULE_NAME, method: action,
@@ -255,7 +255,7 @@ export default abstract class AbstractOCPIService {
action: ServerAction.OCPI_ENDPOINT,
detailedMessages: { error: error.message, stack: error.stack }
});
- Logging.logActionExceptionMessage(req.user && req.user.tenantID ? req.user.tenantID : Constants.DEFAULT_TENANT, ServerAction.OCPI_ENDPOINT, error);
+ await Logging.logActionExceptionMessage(req.user && req.user.tenantID ? req.user.tenantID : Constants.DEFAULT_TENANT, ServerAction.OCPI_ENDPOINT, error);
let errorCode: any = {};
if (error instanceof AppError || error instanceof AppAuthError) {
errorCode = error.params.errorCode;

MODIFY
src/server/ocpi/OCPIServices.ts
src/server/ocpi/OCPIServices.ts
@@ -2,9 +2,9 @@ import { NextFunction, Request, Response } from 'express';
import AbstractOCPIService from './AbstractOCPIService';
import CPOService211 from './ocpi-services-impl/ocpi-2.1.1/CPOService';
-import { Configuration } from '../../types/configuration/Configuration';
import EMSPCPOService200 from './ocpi-services-impl/ocpi-2.0/OCPIService';
import EMSPService211 from './ocpi-services-impl/ocpi-2.1.1/EMSPService';
+import OCPIServiceConfiguration from '../../types/configuration/OCPIServiceConfiguration';
import OCPIUtils from '../ocpi/OCPIUtils';
export default class OCPIServices {
@@ -13,7 +13,7 @@ export default class OCPIServices {
private emspServices: AbstractOCPIService[] = [];
// Create OCPI Service
- constructor(ocpiRestConfig: Configuration['OCPIService']) {
+ constructor(ocpiRestConfig: OCPIServiceConfiguration) {
// Add available OCPI services
// version 2.1.1
this.cpoServices.push(new CPOService211(ocpiRestConfig));

MODIFY
src/server/ocpi/ocpi-services-impl/ocpi-2.0/OCPIService.ts
src/server/ocpi/ocpi-services-impl/ocpi-2.0/OCPIService.ts
import { NextFunction, Request, Response } from 'express';
import AbstractOCPIService from '../../AbstractOCPIService';
-import { Configuration } from '../../../../types/configuration/Configuration';
+import OCPIServiceConfiguration from '../../../../types/configuration/OCPIServiceConfiguration';
import { StatusCodes } from 'http-status-codes';
const VERSION = '2.0';
@@ -11,7 +11,7 @@ const VERSION = '2.0';
*/
export default class OCPIService extends AbstractOCPIService {
// Create OCPI Service
- constructor(ocpiRestConfig: Configuration['OCPIService'], path: string) {
+ constructor(ocpiRestConfig: OCPIServiceConfiguration, path: string) {
super(ocpiRestConfig, path, VERSION);
}

MODIFY
src/server/ocpi/ocpi-services-impl/ocpi-2.1.1/CPOService.ts
src/server/ocpi/ocpi-services-impl/ocpi-2.1.1/CPOService.ts
@@ -5,8 +5,8 @@ import CPOLocationsEndpoint from './cpo/CPOLocationsEndpoint';
import CPOSessionsEndpoint from './cpo/CPOSessionsEndpoint';
import CPOTariffsEndpoint from './cpo/CPOTariffsEndpoint';
import CPOTokensEndpoint from './cpo/CPOTokensEndpoint';
-import { Configuration } from '../../../../types/configuration/Configuration';
import CredentialsEndpoint from './credentials/CredentialsEndpoint';
+import OCPIServiceConfiguration from '../../../../types/configuration/OCPIServiceConfiguration';
/**
* OCPI Service 2.1.1 - Implementation
@@ -16,7 +16,7 @@ export default class CPOService extends AbstractOCPIService {
public static readonly PATH = '/ocpi/cpo';
// Create OCPI Service
- constructor(ocpiRestConfig: Configuration['OCPIService']) {
+ constructor(ocpiRestConfig: OCPIServiceConfiguration) {
super(ocpiRestConfig, CPOService.PATH, CPOService.VERSION);
// Register Endpoints

MODIFY
src/server/ocpi/ocpi-services-impl/ocpi-2.1.1/EMSPService.ts
src/server/ocpi/ocpi-services-impl/ocpi-2.1.1/EMSPService.ts
import AbstractOCPIService from '../../AbstractOCPIService';
-import { Configuration } from '../../../../types/configuration/Configuration';
import CredentialsEndpoint from './credentials/CredentialsEndpoint';
import EMSPCdrsEndpoint from './emsp/EMSPCdrsEndpoint';
import EMSPCommandsEndpoint from './emsp/EMSPCommandsEndpoint';
@@ -7,6 +6,7 @@ import EMSPLocationsEndpoint from './emsp/EMSPLocationsEndpoint';
import EMSPSessionsEndpoint from './emsp/EMSPSessionsEndpoint';
import EMSPTariffsEndpoint from './emsp/EMSPTariffsEndpoint';
import EMSPTokensEndpoint from './emsp/EMSPTokensEndpoint';
+import OCPIServiceConfiguration from '../../../../types/configuration/OCPIServiceConfiguration';
/**
* OCPI Service 2.1.1 - Implementation
@@ -15,7 +15,7 @@ export default class EMSPService extends AbstractOCPIService {
public static readonly VERSION = '2.1.1';
public static readonly PATH = '/ocpi/emsp';
// Create OCPI Service
- constructor(ocpiRestConfig: Configuration['OCPIService']) {
+ constructor(ocpiRestConfig: OCPIServiceConfiguration) {
super(ocpiRestConfig, EMSPService.PATH, EMSPService.VERSION);
// Register Endpoints

MODIFY
src/server/oicp/AbstractOICPService.ts
src/server/oicp/AbstractOICPService.ts
@@ -3,10 +3,10 @@ import { NextFunction, Request, Response } from 'express';
import AbstractEndpoint from './oicp-services-impl/AbstractEndpoint';
import AppAuthError from '../../exception/AppAuthError';
import AppError from '../../exception/AppError';
-import { Configuration } from '../../types/configuration/Configuration';
import Constants from '../../utils/Constants';
import { HTTPError } from '../../types/HTTPError';
import Logging from '../../utils/Logging';
+import OICPServiceConfiguration from '../../types/configuration/OICPServiceConfiguration';
import { OICPStatusCode } from '../../types/oicp/OICPStatusCode';
import OICPUtils from './OICPUtils';
import { ServerAction } from '../../types/Server';
@@ -28,7 +28,7 @@ export default abstract class AbstractOICPService {
// Create OICP Service
protected constructor(
- private readonly oicpRestConfig: Configuration['OICPService'],
+ private readonly oicpRestConfig: OICPServiceConfiguration,
private readonly path: string,
private readonly version: string) {
}
@@ -129,7 +129,7 @@ export default abstract class AbstractOICPService {
// Handle request action (endpoint)
const endpoint = registeredEndpoints.get(endpointName);
if (endpoint) {
- Logging.logDebug({
+ await Logging.logDebug({
tenantID: tenant.id,
source: Constants.CENTRAL_SERVER,
module: MODULE_NAME, method: endpointName,
@@ -139,7 +139,7 @@ export default abstract class AbstractOICPService {
});
const response = await endpoint.process(req, res, next, tenant);
if (response) {
- Logging.logDebug({
+ await Logging.logDebug({
tenantID: tenant.id,
source: Constants.CENTRAL_SERVER,
module: MODULE_NAME, method: endpointName,
@@ -149,7 +149,7 @@ export default abstract class AbstractOICPService {
});
res.json(response);
} else {
- Logging.logWarning({
+ await Logging.logWarning({
tenantID: tenant.id,
source: Constants.CENTRAL_SERVER,
module: MODULE_NAME, method: endpointName,
@@ -169,7 +169,7 @@ export default abstract class AbstractOICPService {
});
}
} catch (error) {
- Logging.logError({
+ await Logging.logError({
tenantID: req.user && req.user.tenantID ? req.user.tenantID : Constants.DEFAULT_TENANT,
source: Constants.CENTRAL_SERVER,
module: MODULE_NAME, method: endpointName,
@@ -177,7 +177,7 @@ export default abstract class AbstractOICPService {
action: ServerAction.OICP_ENDPOINT,
detailedMessages: { error: error.message, stack: error.stack }
});
- Logging.logActionExceptionMessage(req.user && req.user.tenantID ? req.user.tenantID : Constants.DEFAULT_TENANT, ServerAction.OICP_ENDPOINT, error);
+ await Logging.logActionExceptionMessage(req.user && req.user.tenantID ? req.user.tenantID : Constants.DEFAULT_TENANT, ServerAction.OICP_ENDPOINT, error);
let errorCode: any = {};
if (error instanceof AppError || error instanceof AppAuthError) {
errorCode = error.params.errorCode;

MODIFY
src/server/oicp/OICPServices.ts
src/server/oicp/OICPServices.ts
import AbstractOICPService from './AbstractOICPService';
import CPOService from './oicp-services-impl/oicp-2.3.0/CPOService';
-import { Configuration } from '../../types/configuration/Configuration';
+import OICPServiceConfiguration from '../../types/configuration/OICPServiceConfiguration';
export default class OICPServices {
@@ -9,7 +9,7 @@ export default class OICPServices {
// private emspServices: AbstractOICPService[] = [];
// Create OICP Service
- constructor(oicpRestConfig: Configuration['OICPService']) {
+ constructor(oicpRestConfig: OICPServiceConfiguration) {
// Add available OICP services
// version 2.3.0
this.cpoServices.push(new CPOService(oicpRestConfig));

MODIFY
src/server/oicp/oicp-services-impl/oicp-2.3.0/CPOService.ts
src/server/oicp/oicp-services-impl/oicp-2.3.0/CPOService.ts
import AbstractOICPService from '../../AbstractOICPService';
import CPORemoteAuthorizationsEndpoint from './CPORemoteAuthorizationsEndpoint';
-import { Configuration } from '../../../../types/configuration/Configuration';
+import OICPServiceConfiguration from '../../../../types/configuration/OICPServiceConfiguration';
import { OICPVersion } from '../../../../types/oicp/OICPGeneral';
/**
@@ -11,7 +11,7 @@ export default class CPOService extends AbstractOICPService {
public static readonly PATH = '/:protocol/:role/:version/:tenantSubdomain/api/oicp/:module/:endpointVersion/providers/:providerID/:endpoint/:endpointAction?';
// Create OICP Service
- constructor(oicpRestConfig: Configuration['OICPService']) {
+ constructor(oicpRestConfig: OICPServiceConfiguration) {
super(oicpRestConfig, CPOService.PATH, CPOService.VERSION);
// Register Endpoints

Report typing from Jerome' PR