refactor: rename a template key to a more sensible name
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 26 Mar 2023 14:41:19 +0000 (16:41 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 26 Mar 2023 14:41:19 +0000 (16:41 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
26 files changed:
.cfignore
.gitignore
README.md
docker/Dockerfile
docker/autoconfig.sh
docker/idtags.json [moved from docker/authorization-tags.json with 100% similarity]
src/assets/idtags-template.json [moved from src/assets/authorization-tags-template.json with 100% similarity]
src/assets/station-templates/abb-atg.station-template.json
src/assets/station-templates/abb.station-template.json
src/assets/station-templates/chargex.station-template.json
src/assets/station-templates/evlink.station-template.json
src/assets/station-templates/keba.station-template.json
src/assets/station-templates/schneider-imredd.station-template.json
src/assets/station-templates/schneider.station-template.json
src/assets/station-templates/siemens.station-template.json
src/assets/station-templates/virtual-simple-atg.station-template.json
src/assets/station-templates/virtual-simple.station-template.json
src/assets/station-templates/virtual.station-template.json
src/charging-station/ChargingStation.ts
src/charging-station/ChargingStationUtils.ts
src/charging-station/IdTagsCache.ts
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
src/charging-station/ocpp/OCPPIncomingRequestService.ts
src/types/ChargingStationTemplate.ts
src/utils/Configuration.ts
ui/web/src/types/ChargingStationType.ts

index 4b19c682603b51d61d79efa02f25971fef91de38..30ad46d7aad45f179813da8bc38bac0aa1ae6091 100644 (file)
--- a/.cfignore
+++ b/.cfignore
@@ -47,7 +47,7 @@
 *_REMOTE_*.txt
 *.md
 *.db
-*tags-template.*
+*idtags-template.*
 *config-template.*
 *cf-template.*
 manifest-*.yml
index 47cb73efa67f394e44e61b1d8ddd8d75445a8ed7..5bf56abf9cd3fff2ba601c1f2bec88dc500351e4 100644 (file)
@@ -2,8 +2,8 @@
 src/assets/config*.json
 !src/assets/config-template.json
 src/scripts/scriptConfig.json
-src/assets/*tags*.json
-!src/assets/authorization-tags-template.json
+src/assets/*idtags*.json
+!src/assets/idtags-template.json
 mikro-orm.config*.ts
 !mikro-orm.config-template.ts
 manifest*.yml
index 8ce209e59e8b06e25788b498af09e95162c9dbb5..969b8ef4c2af049d0dbfdbf5057e960b312a9977 100644 (file)
--- a/README.md
+++ b/README.md
@@ -49,7 +49,7 @@ pnpm install
 ## Initial configuration
 
 Copy the configuration template file [src/assets/config-template.json](src/assets/config-template.json) to [src/assets/config.json](src/assets/config.json).  
-Copy the authorization RFID tags template file [src/assets/authorization-tags-template.json](src/assets/authorization-tags-template.json) to [src/assets/authorization-tags.json](src/assets/authorization-tags.json).
+Copy the RFID tags template file [src/assets/idtags-template.json](src/assets/idtags-template.json) to [src/assets/idtags.json](src/assets/idtags.json).
 
 Tweak them to your needs by following the section [configuration files syntax](README.md#configuration-files-syntax).
 
@@ -76,7 +76,7 @@ The charging stations simulator's configuration parameters must be within the `s
 
 All charging station configuration templates are in the directory [src/assets/station-templates](src/assets/station-templates).
 
-A list of RFID tags must be defined for the automatic transaction generator with a default location and name: `src/assets/authorization-tags.json`. A template file is available at [src/assets/authorization-tags-template.json](src/assets/authorization-tags-template.json).
+A list of RFID tags must be defined for the automatic transaction generator in a file with a default location and name: `src/assets/idtags.json`. A template file is available at [src/assets/idtags-template.json](src/assets/idtags-template.json).
 
 **Configuration files hierarchy and priority**:
 
@@ -142,7 +142,7 @@ But the modifications to test have to be done to the files in the build target d
 | ocppPersistentConfiguration        | true/false    | true                                                                                                                                | boolean                                                                                                                                                                  | enable persistent OCPP parameters storage by charging stations 'hashId'. The persistency is ensured by the charging stations configuration files in [dist/assets/configurations](dist/assets/configurations)                        |
 | stationInfoPersistentConfiguration | true/false    | true                                                                                                                                | boolean                                                                                                                                                                  | enable persistent station information and specifications storage by charging stations 'hashId'. The persistency is ensured by the charging stations configuration files in [dist/assets/configurations](dist/assets/configurations) |
 | wsOptions                          |               | {}                                                                                                                                  | ClientOptions & ClientRequestArgs                                                                                                                                        | [ws](https://github.com/websockets/ws) and node.js [http](https://nodejs.org/api/http.html) clients options intersection                                                                                                            |
-| authorizationFile                  |               | undefined                                                                                                                           | string                                                                                                                                                                   | RFID tags list file relative to src/assets path                                                                                                                                                                                     |
+| idTagsFile                         |               | undefined                                                                                                                           | string                                                                                                                                                                   | RFID tags list file relative to src/assets path                                                                                                                                                                                     |
 | baseName                           |               | undefined                                                                                                                           | string                                                                                                                                                                   | base name to build charging stations id                                                                                                                                                                                             |
 | nameSuffix                         |               | undefined                                                                                                                           | string                                                                                                                                                                   | name suffix to build charging stations id                                                                                                                                                                                           |
 | fixedName                          | true/false    | false                                                                                                                               | boolean                                                                                                                                                                  | use the baseName as the charging stations unique name                                                                                                                                                                               |
index 5177c03a972e48c6d0d2f23117ff5d3138cf1a6a..588856889f3d992f7986d71219fdaaee8bdefe19 100644 (file)
@@ -5,7 +5,7 @@ WORKDIR /usr/builder
 COPY .npmrc package.json pnpm-lock.yaml tsconfig.json rollup.config.mjs build-requirements.mjs skip-preinstall.cjs prepare.cjs ./
 COPY src ./src
 COPY docker/config.json ./src/assets/config.json
-COPY docker/authorization-tags.json ./src/assets/authorization-tags.json
+COPY docker/idtags.json ./src/assets/idtags.json
 RUN set -ex \
   && apk add --no-cache --virtual .gyp build-base python3 \
   && corepack enable \
index 7b35536cc11fb6a1f3d6bd0112ebf978b84e25ea..118159054402d2ed59987b162694723873ec0fae 100755 (executable)
@@ -8,7 +8,7 @@ then
   [ -z $emobility_service_type ] && { echo "emobility env service type variable not found, exiting"; exit 1; }
 
   cp $emobility_install_dir/dist/assets/configs-aws/$emobility_server_type-$emobility_service_type-$emobility_landscape.json $emobility_install_dir/dist/assets/config.json
-  cp $emobility_install_dir/dist/assets/configs-aws/$emobility_server_type-$emobility_service_type-$emobility_landscape-tags.json $emobility_install_dir/dist/assets/authorization-tags.json
+  cp $emobility_install_dir/dist/assets/configs-aws/$emobility_server_type-$emobility_service_type-$emobility_landscape-idtags.json $emobility_install_dir/dist/assets/idtags.json
 else
   echo "no emobility env defined, start with default configuration"
 fi
index cda5806eae69a23e9f7042ebf2ac791a389cdab9..9414a19e7bbdfd958049fe517bcef77b92b2e852 100644 (file)
@@ -1,5 +1,5 @@
 {
-  "authorizationFile": "authorization-tags.json",
+  "idTagsFile": "idtags.json",
   "baseName": "CS-ABB",
   "chargePointModel": "MD_TERRA_53",
   "chargePointVendor": "ABB",
index 2aef581adf4a69b486af99c06dfbbfd247206cb4..0c6b233adf47329098666c927ef500ccbdbcfa38 100644 (file)
@@ -1,5 +1,5 @@
 {
-  "authorizationFile": "authorization-tags.json",
+  "idTagsFile": "idtags.json",
   "baseName": "CS-ABB",
   "chargePointModel": "MD_TERRA_53",
   "chargePointVendor": "ABB",
index 3f4a6be13e18147202b2a63968817b3c1025f349..6ff7562d823567d5b93db2449df6e7c36082a969 100644 (file)
@@ -1,5 +1,5 @@
 {
-  "authorizationFile": "authorization-tags.json",
+  "idTagsFile": "idtags.json",
   "baseName": "CS-CHARGEX",
   "chargePointModel": "Aqueduct 1.0",
   "chargePointVendor": "ChargeX GmbH",
index 307db670fc7df8744b27011cedcfdbd1fea705fc..fda88bfb9bfa54b72cafc6d7a088f0d7d3e48cd5 100644 (file)
@@ -1,7 +1,7 @@
 {
   "supervisionUrlOcppConfiguration": true,
   "supervisionUrlOcppKey": "ocppcentraladdress",
-  "authorizationFile": "authorization-tags.json",
+  "idTagsFile": "idtags.json",
   "baseName": "CS-EVLINK",
   "chargePointModel": "MONOBLOCK",
   "chargePointVendor": "Schneider Electric",
index a76741d99f195f12c3f5002f63aa5cf5e741d4a5..f91c22e98de0a4fea1ebec4f96566c96b659282f 100644 (file)
@@ -1,5 +1,5 @@
 {
-  "authorizationFile": "authorization-tags.json",
+  "idTagsFile": "idtags.json",
   "baseName": "CS-KEBA",
   "chargePointModel": "KC-P30-ESS400C2-E0R",
   "chargePointVendor": "Keba AG",
index 18c6ea478f62b47808ec3c2685dc21aa56347730..0369d0ac428cb342e9606cb9695f8a50af519367 100644 (file)
@@ -1,7 +1,7 @@
 {
   "supervisionUrlOcppConfiguration": true,
   "supervisionUrlOcppKey": "ocppcentraladdress",
-  "authorizationFile": "authorization-tags.json",
+  "idTagsFile": "idtags.json",
   "baseName": "CS-SCHNEIDER",
   "chargePointModel": "MONOBLOCK",
   "chargePointVendor": "Schneider Electric",
index 65f7f304476a06269d664765dcb4cc8febb399ae..4dd714731bbd4a0fa6bb5e1168f4860c71146750 100644 (file)
@@ -1,7 +1,7 @@
 {
   "supervisionUrlOcppConfiguration": true,
   "supervisionUrlOcppKey": "ocppcentraladdress",
-  "authorizationFile": "authorization-tags.json",
+  "idTagsFile": "idtags.json",
   "baseName": "CS-SCHNEIDER",
   "chargePointModel": "MONOBLOCK",
   "chargePointVendor": "Schneider Electric",
index 74341ca52b97349275f3c6b7bffc4cd007984c2d..aca529ace209bf94da67a4a114bd64242f6cd322 100644 (file)
@@ -1,5 +1,5 @@
 {
-  "authorizationFile": "authorization-tags.json",
+  "idTagsFile": "idtags.json",
   "baseName": "CS-SIEMENS",
   "fixedName": true,
   "chargePointModel": "SIEMENSXX213",
index 666be37bb6d0dbba88aa67640098f1450149b9b1..0dbd6782798ae7c67c0a0ec1a765c07928344e83 100644 (file)
@@ -1,5 +1,5 @@
 {
-  "authorizationFile": "authorization-tags.json",
+  "idTagsFile": "idtags.json",
   "baseName": "CS-BASIC",
   "chargePointModel": "Simulator simple",
   "chargePointVendor": "Ovomaltin",
index ccec3ee55d1ebf74e2892c3e448e42ac01ba6d0f..d94b5d39991b04e2cb08dd89c1837bd682443d0c 100644 (file)
@@ -1,5 +1,5 @@
 {
-  "authorizationFile": "authorization-tags.json",
+  "idTagsFile": "idtags.json",
   "baseName": "CS-BASIC",
   "chargePointModel": "Simulator simple",
   "chargePointVendor": "Ovomaltin",
index 1ecf8875b8ed7868213a2f7cfbf1b358aefeaf0c..3980cba66a60734834cbb0781962eb5c46f524c0 100644 (file)
@@ -1,5 +1,5 @@
 {
-  "authorizationFile": "authorization-tags.json",
+  "idTagsFile": "idtags.json",
   "baseName": "CS-SIMU",
   "chargePointModel": "Simulator connectors",
   "chargePointVendor": "Ovomaltin",
index cc7177119093e12df8e64d613b0c01e09294950a..831c662ef761b2c288ce7cddc24553e6500cab92 100644 (file)
@@ -164,16 +164,16 @@ export class ChargingStation {
   public logPrefix = (): string => {
     return Utils.logPrefix(
       ` ${
-        (Utils.isNotEmptyString(this?.stationInfo?.chargingStationId) &&
-          this?.stationInfo?.chargingStationId) ??
-        ChargingStationUtils.getChargingStationId(this.index, this.getTemplateFromFile()) ??
-        ''
+        (Utils.isNotEmptyString(this?.stationInfo?.chargingStationId)
+          ? this?.stationInfo?.chargingStationId
+          : ChargingStationUtils.getChargingStationId(this.index, this.getTemplateFromFile())) ??
+        'Error at building log prefix'
       } |`
     );
   };
 
   public hasIdTags(): boolean {
-    const idTagsFile = ChargingStationUtils.getAuthorizationFile(this.stationInfo);
+    const idTagsFile = ChargingStationUtils.getIdTagsFile(this.stationInfo);
     return Utils.isNotEmptyArray(this.idTagsCache.getIdTags(idTagsFile));
   }
 
@@ -879,6 +879,18 @@ export class ChargingStation {
       'supervisionUrl',
       'supervisionUrls'
     );
+    ChargingStationUtils.warnDeprecatedTemplateKey(
+      stationTemplate,
+      'authorizationFile',
+      this.templateFile,
+      this.logPrefix(),
+      "Use 'idTagsFile' instead"
+    );
+    ChargingStationUtils.convertDeprecatedTemplateKey(
+      stationTemplate,
+      'authorizationFile',
+      'idTagsFile'
+    );
     const stationInfo: ChargingStationInfo =
       ChargingStationUtils.stationTemplateToStationInfo(stationTemplate);
     stationInfo.hashId = ChargingStationUtils.getHashId(this.index, stationTemplate);
index ca9a93bce9a7c06f851cbea3e1af30c238931eb9..bca8c0881e195ea598ed1f1c10286edd269a398a 100644 (file)
@@ -2,6 +2,7 @@ import crypto from 'node:crypto';
 import path from 'node:path';
 import { fileURLToPath } from 'node:url';
 
+import chalk from 'chalk';
 import moment from 'moment';
 
 import type { ChargingStation } from './internal';
@@ -219,11 +220,11 @@ export class ChargingStationUtils {
     logMsgToAppend = ''
   ): void {
     if (!Utils.isUndefined(template[key])) {
-      logger.warn(
-        `${logPrefix} Deprecated template key '${key}' usage in file '${templateFile}'${
-          Utils.isNotEmptyString(logMsgToAppend) && `. ${logMsgToAppend}`
-        }`
-      );
+      const logMsg = `Deprecated template key '${key}' usage in file '${templateFile}'${
+        Utils.isNotEmptyString(logMsgToAppend) ? `. ${logMsgToAppend}` : ''
+      }`;
+      logger.warn(`${logPrefix} ${logMsg}`);
+      console.warn(chalk.yellow(`${logMsg}`));
     }
   }
 
@@ -413,13 +414,13 @@ export class ChargingStationUtils {
     return defaultVoltageOut;
   }
 
-  public static getAuthorizationFile(stationInfo: ChargingStationInfo): string | undefined {
+  public static getIdTagsFile(stationInfo: ChargingStationInfo): string | undefined {
     return (
-      stationInfo.authorizationFile &&
+      stationInfo.idTagsFile &&
       path.join(
         path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../'),
         'assets',
-        path.basename(stationInfo.authorizationFile)
+        path.basename(stationInfo.idTagsFile)
       )
     );
   }
index 7b49b590d17332a47bc17cbe077ebe664b16b7f0..48ecb552a90b7c23f0f474952cdb33b87cd49dbb 100644 (file)
@@ -32,7 +32,7 @@ export class IdTagsCache {
     connectorId: number
   ): string {
     const hashId = chargingStation.stationInfo.hashId;
-    const idTagsFile = ChargingStationUtils.getAuthorizationFile(chargingStation.stationInfo);
+    const idTagsFile = ChargingStationUtils.getIdTagsFile(chargingStation.stationInfo);
     switch (distribution) {
       case IdTagDistribution.RANDOM:
         return this.getRandomIdTag(hashId, idTagsFile);
@@ -79,7 +79,7 @@ export class IdTagsCache {
   }
 
   private getConnectorAffinityIdTag(chargingStation: ChargingStation, connectorId: number): string {
-    const file = ChargingStationUtils.getAuthorizationFile(chargingStation.stationInfo);
+    const file = ChargingStationUtils.getIdTagsFile(chargingStation.stationInfo);
     const idTags = this.getIdTags(file);
     const hashId = chargingStation.stationInfo.hashId;
     const addressableKey = file + hashId;
index 12a64b6ccd418498e3dae139cee4f8f1c1a133a6..cad78436513906e8ee0e42ab0be7b309a7933f24 100644 (file)
@@ -742,7 +742,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
             chargingStation.hasIdTags() === true &&
             Utils.isNotEmptyString(
               chargingStation.idTagsCache
-                .getIdTags(ChargingStationUtils.getAuthorizationFile(chargingStation.stationInfo))
+                .getIdTags(ChargingStationUtils.getIdTagsFile(chargingStation.stationInfo))
                 ?.find((idTag) => idTag === commandPayload.idTag)
             )
           ) {
index 32402da5f139a4e9945e6f8d6bc45ac0e075b998..2d15ce5d7908435f1d84e9d114df67d02d9bedca 100644 (file)
@@ -91,7 +91,7 @@ export abstract class OCPPIncomingRequestService extends AsyncResource {
 
   protected handleRequestClearCache(chargingStation: ChargingStation): ClearCacheResponse {
     chargingStation.idTagsCache.deleteIdTags(
-      ChargingStationUtils.getAuthorizationFile(chargingStation.stationInfo)
+      ChargingStationUtils.getIdTagsFile(chargingStation.stationInfo)
     );
     return OCPPConstants.OCPP_RESPONSE_ACCEPTED;
   }
index 0cd0e45f1e49707de532e5adab330ba3878c01f2..8060a937449cd5cd1a11c983d287f1d83bc5583b 100644 (file)
@@ -67,8 +67,7 @@ export type ChargingStationTemplate = {
   ocppPersistentConfiguration?: boolean;
   stationInfoPersistentConfiguration?: boolean;
   wsOptions?: WsOptions;
-  // FIXME: rename to idTagFile
-  authorizationFile?: string;
+  idTagsFile?: string;
   baseName: string;
   nameSuffix?: string;
   fixedName?: boolean;
index 7d5b217d5faafa331c8b16ae4768e65003e9c691..8c3d15ccbdde967cb0051f9dab2cd36f5c5d9c7f 100644 (file)
@@ -322,13 +322,13 @@ export class Configuration {
     ) {
       console.error(
         chalk`{green ${Configuration.logPrefix()}} {red Deprecated configuration key '${key}' usage in section '${sectionName}'${
-          logMsgToAppend.trim().length > 0 && `. ${logMsgToAppend}`
+          logMsgToAppend.trim().length > 0 ? `. ${logMsgToAppend}` : ''
         }}`
       );
     } else if (!Utils.isUndefined(Configuration.getConfig()[key])) {
       console.error(
         chalk`{green ${Configuration.logPrefix()}} {red Deprecated configuration key '${key}' usage${
-          logMsgToAppend.trim().length > 0 && `. ${logMsgToAppend}`
+          logMsgToAppend.trim().length > 0 ? `. ${logMsgToAppend}` : ''
         }}`
       );
     }
index 2446839275a6f9f115d95be1e41e7a1ac6e54060..9d2b530a495610f63101d5847d3a809d252924bc 100644 (file)
@@ -39,7 +39,7 @@ export type ChargingStationInfo = {
   ocppStrictCompliance?: boolean;
   ocppPersistentConfiguration?: boolean;
   stationInfoPersistentConfiguration?: boolean;
-  authorizationFile?: string;
+  idTagsFile?: string;
   nameSuffix?: string;
   fixedName?: boolean;
   iccid?: string;