2c7d3df3191f2246eb3086e4bb02d003ef241663
1 // Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
3 import fs from
'node:fs';
4 import path from
'node:path';
5 import { fileURLToPath
} from
'node:url';
7 import type { JSONSchemaType
} from
'ajv';
9 import { FileType
} from
'../../../types/FileType';
10 import type { JsonType
} from
'../../../types/JsonType';
11 import { OCPPVersion
} from
'../../../types/ocpp/OCPPVersion';
12 import FileUtils from
'../../../utils/FileUtils';
13 import { OCPPServiceUtils
} from
'../OCPPServiceUtils';
15 export class OCPP20ServiceUtils
extends OCPPServiceUtils
{
16 public static parseJsonSchemaFile
<T
extends JsonType
>(relativePath
: string): JSONSchemaType
<T
> {
17 const filePath
= path
.resolve(path
.dirname(fileURLToPath(import.meta
.url
)), relativePath
);
19 return JSON
.parse(fs
.readFileSync(filePath
, 'utf8')) as JSONSchemaType
<T
>;
21 FileUtils
.handleFileException(
22 OCPPServiceUtils
.logPrefix(OCPPVersion
.VERSION_20
),
25 error
as NodeJS
.ErrnoException
,