// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
-import fs from 'fs';
-import path from 'path';
-import { fileURLToPath } from 'url';
-
import type { JSONSchemaType } from 'ajv';
import { OCPP20ServiceUtils } from './OCPP20ServiceUtils';
this.jsonSchemas = new Map<OCPP20IncomingRequestCommand, JSONSchemaType<JsonObject>>([
[
OCPP20IncomingRequestCommand.CLEAR_CACHE,
- this.parseJsonSchemaFile<OCPP20ClearCacheRequest>(
+ OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20ClearCacheRequest>(
'../../../assets/json-schemas/ocpp/2.0/ClearCacheRequest.json'
),
],
);
return false;
}
-
- private parseJsonSchemaFile<T extends JsonType>(relativePath: string): JSONSchemaType<T> {
- return JSON.parse(
- fs.readFileSync(
- path.resolve(path.dirname(fileURLToPath(import.meta.url)), relativePath),
- 'utf8'
- )
- ) as JSONSchemaType<T>;
- }
}