.github
.prettierrc.json
.prettierignore
-.jshintrc
-.eslintrc.json
-.eslintrc.js
-.eslintrc.cjs
-.eslintrc.mjs
-.eslintignore
+eslint.config.js
.eslintcache
.lintstagedrc.json
.lintstagedrc.js
+++ /dev/null
-dist/
-ui/web/
+++ /dev/null
-// eslint-disable-next-line n/no-unpublished-require
-const { defineConfig } = require('eslint-define-config')
-
-module.exports = defineConfig({
- root: true,
- env: {
- es2022: true,
- node: true
- },
- parserOptions: {
- sourceType: 'module',
- ecmaVersion: 2022
- },
- plugins: ['simple-import-sort'],
- extends: ['eslint:recommended', 'plugin:import/recommended'],
- settings: {
- 'import/resolver': {
- typescript: {
- project: './tsconfig.json'
- }
- }
- },
- rules: {
- 'simple-import-sort/imports': 'error',
- 'simple-import-sort/exports': 'error'
- },
- overrides: [
- {
- files: ['**/*.ts'],
- parser: '@typescript-eslint/parser',
- parserOptions: {
- project: './tsconfig.json'
- },
- plugins: ['@typescript-eslint', 'eslint-plugin-tsdoc'],
- extends: [
- 'plugin:@typescript-eslint/strict-type-checked',
- 'plugin:@typescript-eslint/stylistic-type-checked',
- 'plugin:import/typescript',
- 'love'
- ],
- rules: {
- 'operator-linebreak': 'off',
- 'tsdoc/syntax': 'warn'
- }
- },
- {
- files: ['**/*.js', '**/*.cjs', '**/*.mjs'],
- plugins: ['jsdoc'],
- extends: ['plugin:n/recommended', 'plugin:jsdoc/recommended', 'standard'],
- rules: {
- 'n/shebang': 'off'
- }
- }
- ]
-})
export default {
- '{src,tests}/**/*.{ts,tsx,cts,mts}': ['prettier --cache --write', 'eslint --cache --fix'],
+ '{src,tests}/**/*.{ts,tsx,cts,mts}': [
+ /* 'prettier --cache --write', 'eslint --cache --fix' */
+ ],
'**/*.{json,md,yml,yaml}': ['prettier --cache --write'],
- '**/*.{js,jsx,cjs,mjs}': ['prettier --cache --write', 'eslint --cache --fix']
+ '**/*.{js,jsx,cjs,mjs}': ['prettier --cache --write', 'eslint --cache --fix'],
}
"arrowParens": "avoid",
"singleQuote": true,
"semi": false,
- "trailingComma": "none"
+ "trailingComma": "es5"
}
"mikro",
"MILLI",
"mnemonist",
+ "neostandard",
"ocpp",
"olivierbagot",
"onconnection",
[![GitHub commit activity (main)](https://img.shields.io/github/commit-activity/m/SAP/e-mobility-charging-stations-simulator/main?color=brightgreen&logo=github)](https://github.com/SAP/e-mobility-charging-stations-simulator/graphs/commit-activity)
[![CI workflow](https://github.com/SAP/e-mobility-charging-stations-simulator/actions/workflows/ci.yml/badge.svg)](https://github.com/SAP/e-mobility-charging-stations-simulator/actions/workflows/ci.yml)
[![REUSE status](https://api.reuse.software/badge/github.com/SAP/e-mobility-charging-stations-simulator)](https://api.reuse.software/info/github.com/SAP/e-mobility-charging-stations-simulator)
-[![Javascript Standard Style Guide](<https://badgen.net/static/code style/standard/green>)](https://standardjs.com)
+[![neostandard Javascript Code Style](<https://badgen.net/static/code style/neostandard/green>)](https://github.com/neostandard/neostandard)
</div>
`Required node version ${enginesNodeVersion} not satisfied with current version ${version}`
)
)
- // eslint-disable-next-line n/no-process-exit
exit(1)
}
}
'winston',
'winston/*',
'winston-daily-rotate-file',
- 'ws'
+ 'ws',
],
treeShaking: true,
minify: true,
'./dist/assets/json-schemas',
'./dist/assets/station-templates',
'./dist/assets/ui-protocol',
- './dist/assets/configs-docker'
- ]
+ './dist/assets/configs-docker',
+ ],
}),
copy({
assets: [
{
from: ['./src/assets/config.json'],
- to: ['./assets']
+ to: ['./assets'],
},
{
from: ['./src/assets/idtags!(-template)*.json'],
- to: ['./assets']
+ to: ['./assets'],
},
{
from: ['./src/assets/json-schemas/**/*.json'],
- to: ['./assets/json-schemas']
+ to: ['./assets/json-schemas'],
},
{
from: ['./src/assets/station-templates/**/*.json'],
- to: ['./assets/station-templates']
+ to: ['./assets/station-templates'],
},
{
from: ['./src/assets/configs-docker/*.json'],
- to: ['./assets/configs-docker']
- }
- ]
- })
- ]
+ to: ['./assets/configs-docker'],
+ },
+ ],
+ }),
+ ],
})
console.timeEnd('Build time')
{
"folders": [
{
- "path": "."
+ "path": ".",
},
{
- "path": "ui/web"
+ "path": "ui/web",
},
{
- "path": "tests/ocpp-server"
- }
+ "path": "tests/ocpp-server",
+ },
],
"settings": {
"nodejs-testing.extensions": [
{
"extensions": ["mjs", "cjs", "js"],
- "parameters": []
+ "parameters": [],
},
{
"extensions": ["mts", "cts", "ts"],
- "parameters": ["--import", "tsx"]
- }
- ]
- }
+ "parameters": ["--import", "tsx"],
+ },
+ ],
+ },
}
--- /dev/null
+/* eslint-disable n/no-unpublished-import */
+import js from '@eslint/js'
+import { defineFlatConfig } from 'eslint-define-config'
+import jsdoc from 'eslint-plugin-jsdoc'
+import simpleImportSort from 'eslint-plugin-simple-import-sort'
+import neostandard, { plugins } from 'neostandard'
+
+export default defineFlatConfig([
+ {
+ ignores: ['dist/**', 'ui/web/**'],
+ },
+ js.configs.recommended,
+ plugins.promise.configs['flat/recommended'],
+ ...plugins.n.configs['flat/mixed-esm-and-cjs'],
+ jsdoc.configs['flat/recommended-typescript'],
+ {
+ rules: {
+ 'jsdoc/check-tag-names': [
+ 'warn',
+ {
+ typed: true,
+ definedTags: ['defaultValue', 'experimental', 'typeParam'],
+ },
+ ],
+ },
+ },
+ ...neostandard({
+ ts: true,
+ }),
+ ...plugins['typescript-eslint'].config(
+ ...plugins['typescript-eslint'].configs.strictTypeChecked,
+ ...plugins['typescript-eslint'].configs.stylisticTypeChecked
+ ),
+ {
+ languageOptions: {
+ parserOptions: {
+ project: true,
+ tsconfigRootDir: import.meta.dirname,
+ },
+ },
+ },
+ {
+ plugins: {
+ 'simple-import-sort': simpleImportSort,
+ },
+ rules: {
+ 'simple-import-sort/imports': 'error',
+ 'simple-import-sort/exports': 'error',
+ },
+ },
+ {
+ files: [
+ 'src/charging-station/ChargingStation.ts',
+ 'src/charging-station/ocpp/OCPPServiceUtils.ts',
+ 'src/performance/PerformanceStatistics.ts',
+ ],
+ rules: {
+ '@stylistic/operator-linebreak': 'off',
+ },
+ },
+ {
+ files: ['src/scripts/*.cjs'],
+ rules: {
+ '@typescript-eslint/no-require-imports': 'off',
+ },
+ },
+ {
+ files: ['**/*.js', '**/*.mjs', '**/*.cjs'],
+ ...plugins['typescript-eslint'].configs.disableTypeChecked,
+ },
+])
dbName: `${Constants.DEFAULT_PERFORMANCE_DIRECTORY}/${Constants.DEFAULT_PERFORMANCE_RECORDS_DB_NAME}.db`,
entities: ['./dist/types/orm/entities/*.js'],
entitiesTs: ['./src/types/orm/entities/*.ts'],
- debug: true
+ debug: true,
})
"build:entities": "tsc -p tsconfig-mikro-orm.json",
"clean:dist": "pnpm exec rimraf dist",
"clean:node_modules": "pnpm exec rimraf node_modules",
- "lint": "cross-env TIMING=1 eslint --cache src tests ./*.cjs ./*.js ./*.ts",
- "lint:fix": "cross-env TIMING=1 eslint --cache --fix src tests ./*.cjs ./*.js ./*.ts",
- "format": "prettier --cache --write .; eslint --cache --fix src tests ./*.cjs ./*.js ./*.ts",
+ "lint": "cross-env TIMING=1 eslint --cache src tests ./*.js ./*.ts",
+ "lint:fix": "cross-env TIMING=1 eslint --cache --fix src tests ./*.js ./*.ts",
+ "format": "prettier --cache --write .; eslint --cache --fix src tests ./*.js ./*.ts",
+ "prettier": "prettier --cache --write .",
"test": "glob -c \"c8 node --import tsx --test\" \"tests/**/*.test.ts\"",
"test:debug": "glob -c \"node --import tsx --test --inspect\" \"tests/**/*.test.ts\"",
"coverage": "c8 report --reporter=lcov",
"devDependencies": {
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
+ "@eslint/js": "^9.7.0",
"@mikro-orm/cli": "^6.2.9",
"@types/node": "^20.14.10",
"@types/semver": "^7.5.8",
"@types/ws": "^8.5.11",
- "@typescript-eslint/eslint-plugin": "^7.16.0",
- "@typescript-eslint/parser": "^7.16.0",
"c8": "^10.1.2",
"clinic": "^13.0.0",
"cross-env": "^7.0.3",
"esbuild": "^0.23.0",
"esbuild-plugin-clean": "^1.0.1",
"esbuild-plugin-copy": "^2.1.1",
- "eslint": "^8.57.0",
- "eslint-config-love": "^47.0.0",
- "eslint-config-standard": "^17.1.0",
+ "eslint": "^9.7.0",
"eslint-define-config": "^2.1.0",
- "eslint-import-resolver-typescript": "^3.6.1",
- "eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsdoc": "^48.7.0",
- "eslint-plugin-n": "^17.9.0",
"eslint-plugin-simple-import-sort": "^12.1.1",
- "eslint-plugin-tsdoc": "^0.3.0",
"expect": "^29.7.0",
"glob": "^11.0.0",
"husky": "^9.0.11",
"lint-staged": "^15.2.7",
+ "neostandard": "^0.11.0",
"prettier": "^3.3.3",
"rimraf": "^6.0.1",
"semver": "^7.6.2",
'@commitlint/config-conventional':
specifier: ^19.2.2
version: 19.2.2
+ '@eslint/js':
+ specifier: ^9.7.0
+ version: 9.7.0
'@mikro-orm/cli':
specifier: ^6.2.9
version: 6.2.9(mariadb@3.3.0)
'@types/ws':
specifier: ^8.5.11
version: 8.5.11
- '@typescript-eslint/eslint-plugin':
- specifier: ^7.16.0
- version: 7.16.0(@typescript-eslint/parser@7.16.0(eslint@8.57.0)(typescript@5.5.3))(eslint@8.57.0)(typescript@5.5.3)
- '@typescript-eslint/parser':
- specifier: ^7.16.0
- version: 7.16.0(eslint@8.57.0)(typescript@5.5.3)
c8:
specifier: ^10.1.2
version: 10.1.2
specifier: ^2.1.1
version: 2.1.1(esbuild@0.23.0)
eslint:
- specifier: ^8.57.0
- version: 8.57.0
- eslint-config-love:
- specifier: ^47.0.0
- version: 47.0.0(@typescript-eslint/eslint-plugin@7.16.0(@typescript-eslint/parser@7.16.0(eslint@8.57.0)(typescript@5.5.3))(eslint@8.57.0)(typescript@5.5.3))(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.16.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0))(eslint-plugin-n@17.9.0(eslint@8.57.0))(eslint-plugin-promise@6.2.0(eslint@8.57.0))(eslint@8.57.0)(typescript@5.5.3)
- eslint-config-standard:
- specifier: ^17.1.0
- version: 17.1.0(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.16.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0))(eslint-plugin-n@17.9.0(eslint@8.57.0))(eslint-plugin-promise@6.2.0(eslint@8.57.0))(eslint@8.57.0)
+ specifier: ^9.7.0
+ version: 9.7.0
eslint-define-config:
specifier: ^2.1.0
version: 2.1.0
- eslint-import-resolver-typescript:
- specifier: ^3.6.1
- version: 3.6.1(@typescript-eslint/parser@7.16.0(eslint@8.57.0)(typescript@5.5.3))(eslint-plugin-import@2.29.1)(eslint@8.57.0)
- eslint-plugin-import:
- specifier: ^2.29.1
- version: 2.29.1(@typescript-eslint/parser@7.16.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0)
eslint-plugin-jsdoc:
specifier: ^48.7.0
- version: 48.7.0(eslint@8.57.0)
- eslint-plugin-n:
- specifier: ^17.9.0
- version: 17.9.0(eslint@8.57.0)
+ version: 48.7.0(eslint@9.7.0)
eslint-plugin-simple-import-sort:
specifier: ^12.1.1
- version: 12.1.1(eslint@8.57.0)
- eslint-plugin-tsdoc:
- specifier: ^0.3.0
- version: 0.3.0
+ version: 12.1.1(eslint@9.7.0)
expect:
specifier: ^29.7.0
version: 29.7.0
lint-staged:
specifier: ^15.2.7
version: 15.2.7
+ neostandard:
+ specifier: ^0.11.0
+ version: 0.11.0(eslint@9.7.0)(typescript@5.5.3)
prettier:
specifier: ^3.3.3
version: 3.3.3
resolution: {integrity: sha512-G/M/tIiMrTAxEWRfLfQJMmGNX28IxBg4PBz8XqQhqUHLFI6TL2htpIB1iQCj144V5ee/JaKyT9/WZ0MGZWfA7A==}
engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0}
+ '@eslint/config-array@0.17.0':
+ resolution: {integrity: sha512-A68TBu6/1mHHuc5YJL0U0VVeGNiklLAL6rRmhTCP2B5XjWLMnrX+HkO+IAXyHvks5cyyY1jjK5ITPQ1HGS2EVA==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+
'@eslint/eslintrc@2.1.4':
resolution: {integrity: sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
+ '@eslint/eslintrc@3.1.0':
+ resolution: {integrity: sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+
'@eslint/js@8.57.0':
resolution: {integrity: sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
+ '@eslint/js@9.7.0':
+ resolution: {integrity: sha512-ChuWDQenef8OSFnvuxv0TCVxEwmu3+hPNKvM9B34qpM0rDRbjL8t5QkQeHHeAfsKQjuH9wS82WeCi1J/owatng==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+
+ '@eslint/object-schema@2.1.4':
+ resolution: {integrity: sha512-BsWiH1yFGjXXS2yvrf5LyuoSIIbPrGUWob917o+BTKuZ7qJdxX8aJLRxs1fS9n6r7vESrq1OUqb68dANcFXuQQ==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+
'@gar/promisify@1.1.3':
resolution: {integrity: sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw==}
engines: {node: '>=10.10.0'}
deprecated: Use @eslint/config-array instead
+ '@humanwhocodes/gitignore-to-minimatch@1.0.2':
+ resolution: {integrity: sha512-rSqmMJDdLFUsyxR6FMtD00nfQKKLFb1kv+qBbOVKqErvloEIJLo5bDTJTQNTYgeyp78JsA7u/NPi5jT1GR/MuA==}
+
'@humanwhocodes/module-importer@1.0.1':
resolution: {integrity: sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==}
engines: {node: '>=12.22'}
resolution: {integrity: sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==}
deprecated: Use @eslint/object-schema instead
+ '@humanwhocodes/retry@0.3.0':
+ resolution: {integrity: sha512-d2CGZR2o7fS6sWB7DG/3a95bGKQyHMACZ5aW8qGkkqQpUoZV6C0X7Pc7l4ZNMZkfNBf4VWNe9E1jRsf0G146Ew==}
+ engines: {node: '>=18.18'}
+
'@isaacs/cliui@8.0.2':
resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==}
engines: {node: '>=12'}
'@jridgewell/trace-mapping@0.3.9':
resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==}
- '@microsoft/tsdoc-config@0.17.0':
- resolution: {integrity: sha512-v/EYRXnCAIHxOHW+Plb6OWuUoMotxTN0GLatnpOb1xq0KuTNw/WI3pamJx/UbsoJP5k9MCw1QxvvhPcF9pH3Zg==}
-
- '@microsoft/tsdoc@0.15.0':
- resolution: {integrity: sha512-HZpPoABogPvjeJOdzCOSJsXeL/SMCBgBZMVC3X3d7YYp2gf31MfxhUoYUNwf1ERPJOnQc0wkFn9trqI6ZEdZuA==}
-
'@mikro-orm/cli@6.2.9':
resolution: {integrity: sha512-9eW9ZSzdO03KBkUn5Q0OxWBv/2RrKDwOabW2FKzuWslOY3ZBX+k+e8eP6a/+T8GeGGD/uqj8xVZSgM2DuGGqrw==}
engines: {node: '>= 18.12.0'}
resolution: {integrity: sha512-TV7t8GKYaJWsn00tFDqBw8+Uqmr8A0fRU1tvTQhyZzGv0sJCGRQL3JGMI3ucuKo3XIZdUP+Lx7/gh2t3lewy7g==}
engines: {node: '>=14.16'}
+ '@stylistic/eslint-plugin-js@2.6.0-beta.0':
+ resolution: {integrity: sha512-KQiNvzNzvl9AmMs1MiIBszLIy/Xy1bTExnyaVy5dSzOF9c+yT64JQfH0p0jP6XpGwoCnZsrPUNflwP30G42QBQ==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+ peerDependencies:
+ eslint: '>=8.40.0'
+
+ '@stylistic/eslint-plugin-jsx@2.6.0-beta.0':
+ resolution: {integrity: sha512-TOimEpr3vndXHRhuQ5gMqmJv1SBlFI3poIJzyeNMmXi3NWVHoPxfd4QAJHGNJe5G3EO2NAXGf2H7nl8gY5QaZA==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+ peerDependencies:
+ eslint: '>=8.40.0'
+
+ '@stylistic/eslint-plugin-plus@2.6.0-beta.0':
+ resolution: {integrity: sha512-Wp+e4sTbFq0Uk5ncU3PETYfg1IcCZ1KycdlqFYXIA7/bgcieeShXouXUcA+S/S5+gWLXGuVJ12IxNzY8yfe4IA==}
+ peerDependencies:
+ eslint: '*'
+
+ '@stylistic/eslint-plugin-ts@2.6.0-beta.0':
+ resolution: {integrity: sha512-WMz1zgmMC3bvg1L/tiYt5ygvDbTDKlbezoHoX2lV9MnUCAEQZUP4xJ9Wj3jmIKxb4mUuK5+vFZJVcOygvbbqow==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+ peerDependencies:
+ eslint: '>=8.40.0'
+
+ '@stylistic/eslint-plugin@2.6.0-beta.0':
+ resolution: {integrity: sha512-1NJy1iIDSFC4gelDJ82VMTq9J32tNvQ9k1lnxOsipZ0YQB826U5zGLiH37QAM8dRfNY6yeYhjlrUVtZUxFR19w==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+ peerDependencies:
+ eslint: '>=8.40.0'
+
'@szmarczak/http-timer@5.0.1':
resolution: {integrity: sha512-+PmQX0PiAYPMeVYe237LJAYvOMYW1j2rH5YROyS3b4CTVJum34HfRvKvAzozHAQG0TnHNdUfY9nCeUyRAs//cw==}
engines: {node: '>=14.16'}
typescript:
optional: true
+ '@typescript-eslint/eslint-plugin@8.0.0-alpha.42':
+ resolution: {integrity: sha512-la2sVBOUd6oKsSXSrLgDTu0+m6+TeA3YodHtPqUY231ETdd835hWbJkyVU893MWRRDuOyC09I528RRiGjBAODA==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+ peerDependencies:
+ '@typescript-eslint/parser': ^8.0.0 || ^8.0.0-alpha.0
+ eslint: ^8.57.0 || ^9.0.0
+ typescript: '*'
+ peerDependenciesMeta:
+ typescript:
+ optional: true
+
'@typescript-eslint/parser@7.16.0':
resolution: {integrity: sha512-ar9E+k7CU8rWi2e5ErzQiC93KKEFAXA2Kky0scAlPcxYblLt8+XZuHUZwlyfXILyQa95P6lQg+eZgh/dDs3+Vw==}
engines: {node: ^18.18.0 || >=20.0.0}
typescript:
optional: true
+ '@typescript-eslint/parser@8.0.0-alpha.42':
+ resolution: {integrity: sha512-lOUDE+wJwQMq+/KJFCNo9SkJvQ1WGyoubucCWtgDHzr2itfmg0c51Z1wZLyeLSVBsHAWSiR+TIsGoCpHy+5D5Q==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+ peerDependencies:
+ eslint: ^8.57.0 || ^9.0.0
+ typescript: '*'
+ peerDependenciesMeta:
+ typescript:
+ optional: true
+
'@typescript-eslint/scope-manager@7.16.0':
resolution: {integrity: sha512-8gVv3kW6n01Q6TrI1cmTZ9YMFi3ucDT7i7aI5lEikk2ebk1AEjrwX8MDTdaX5D7fPXMBLvnsaa0IFTAu+jcfOw==}
engines: {node: ^18.18.0 || >=20.0.0}
+ '@typescript-eslint/scope-manager@8.0.0-alpha.42':
+ resolution: {integrity: sha512-3nS6VEzxUPEMvqadRaGkjZuL+fsjNf5lCYbvS0IQYzqJl7338yhxvPCraHmXe/xlB08p+5BAd6JYAbkTeSXxJw==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+
'@typescript-eslint/type-utils@7.16.0':
resolution: {integrity: sha512-j0fuUswUjDHfqV/UdW6mLtOQQseORqfdmoBNDFOqs9rvNVR2e+cmu6zJu/Ku4SDuqiJko6YnhwcL8x45r8Oqxg==}
engines: {node: ^18.18.0 || >=20.0.0}
typescript:
optional: true
+ '@typescript-eslint/type-utils@8.0.0-alpha.42':
+ resolution: {integrity: sha512-vmmJgOHycCTUe/d7DdbBkhz1NAJ08wVptyFP17pcmagIq2oTTan9ffIMbIxCKepGi0l5UzdSGf3l9IYZ+xjD8w==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+ peerDependencies:
+ typescript: '*'
+ peerDependenciesMeta:
+ typescript:
+ optional: true
+
'@typescript-eslint/types@7.16.0':
resolution: {integrity: sha512-fecuH15Y+TzlUutvUl9Cc2XJxqdLr7+93SQIbcZfd4XRGGKoxyljK27b+kxKamjRkU7FYC6RrbSCg0ALcZn/xw==}
engines: {node: ^18.18.0 || >=20.0.0}
+ '@typescript-eslint/types@8.0.0-alpha.42':
+ resolution: {integrity: sha512-cvfuxLiSVi6EfsgE/1A07JD67pnv+Grf9YMhGAKUsokIvsMcusLSI1h2On6qoyZghJuFXkH3hiMsg7DtxZBtsw==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+
'@typescript-eslint/typescript-estree@7.16.0':
resolution: {integrity: sha512-a5NTvk51ZndFuOLCh5OaJBELYc2O3Zqxfl3Js78VFE1zE46J2AaVuW+rEbVkQznjkmlzWsUI15BG5tQMixzZLw==}
engines: {node: ^18.18.0 || >=20.0.0}
typescript:
optional: true
+ '@typescript-eslint/typescript-estree@8.0.0-alpha.42':
+ resolution: {integrity: sha512-rIHLylSgsfY5hTE68hd8UXcacZxOq4DWAitRKF8xs33hEBDyxInj4FtUglYU420HvFqyVFtVdB7WEFY4cFQ+iA==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+ peerDependencies:
+ typescript: '*'
+ peerDependenciesMeta:
+ typescript:
+ optional: true
+
'@typescript-eslint/utils@7.16.0':
resolution: {integrity: sha512-PqP4kP3hb4r7Jav+NiRCntlVzhxBNWq6ZQ+zQwII1y/G/1gdIPeYDCKr2+dH6049yJQsWZiHU6RlwvIFBXXGNA==}
engines: {node: ^18.18.0 || >=20.0.0}
peerDependencies:
eslint: ^8.56.0
+ '@typescript-eslint/utils@8.0.0-alpha.42':
+ resolution: {integrity: sha512-ousp9L07jDosMqnayZNF8QOJB2FDZP7lSN2lUI7BknV5B1beUoPizWZl0yDHxrk64ldZu5JoqkhAbOcbPNJu5Q==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+ peerDependencies:
+ eslint: ^8.57.0 || ^9.0.0
+
'@typescript-eslint/visitor-keys@7.16.0':
resolution: {integrity: sha512-rMo01uPy9C7XxG7AFsxa8zLnWXTF8N3PYclekWSrurvhwiw1eW88mrKiAYe6s53AUY57nTRz8dJsuuXdkAhzCg==}
engines: {node: ^18.18.0 || >=20.0.0}
+ '@typescript-eslint/visitor-keys@8.0.0-alpha.42':
+ resolution: {integrity: sha512-Bf/BObckzDnCS9AslkTsuH1vU+h4rppUrmPbTbhGlPurmss6Lt/Ft9H8vQ8wXeN8rk0drRhML2Feo6aODLeKdA==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+
'@ungap/structured-clone@1.2.0':
resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==}
ajv@6.12.6:
resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==}
- ajv@8.12.0:
- resolution: {integrity: sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==}
-
ajv@8.17.1:
resolution: {integrity: sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==}
peerDependencies:
eslint: '>=6.0.0'
- eslint-config-love@47.0.0:
- resolution: {integrity: sha512-wIeJhb4/NF7nE5Ltppg1e9dp1Auxx0+ZPRysrXQ3uBKlW4Nj/UiTZu4r3sKWCxo6HGcRcI4MC1Q5421y3fny2w==}
- peerDependencies:
- '@typescript-eslint/eslint-plugin': ^7.0.1
- eslint: ^8.0.1
- eslint-plugin-import: ^2.25.2
- eslint-plugin-n: '^15.0.0 || ^16.0.0 '
- eslint-plugin-promise: ^6.0.0
- typescript: '*'
-
eslint-config-prettier@9.1.0:
resolution: {integrity: sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==}
hasBin: true
peerDependencies:
eslint: '>=7.0.0'
- eslint-config-standard@17.1.0:
- resolution: {integrity: sha512-IwHwmaBNtDK4zDHQukFDW5u/aTb8+meQWZvNFWkiGmbWjD6bqyuSSBxxXKkCftCUzc1zwCH2m/baCNDLGmuO5Q==}
- engines: {node: '>=12.0.0'}
- peerDependencies:
- eslint: ^8.0.1
- eslint-plugin-import: ^2.25.2
- eslint-plugin-n: '^15.0.0 || ^16.0.0 '
- eslint-plugin-promise: ^6.0.0
-
eslint-define-config@2.1.0:
resolution: {integrity: sha512-QUp6pM9pjKEVannNAbSJNeRuYwW3LshejfyBBpjeMGaJjaDUpVps4C6KVR8R7dWZnD3i0synmrE36znjTkJvdQ==}
engines: {node: '>=18.0.0', npm: '>=9.0.0', pnpm: '>=8.6.0'}
eslint-config-prettier:
optional: true
- eslint-plugin-promise@6.2.0:
- resolution: {integrity: sha512-QmAqwizauvnKOlifxyDj2ObfULpHQawlg/zQdgEixur9vl0CvZGv/LCJV2rtj3210QCoeGBzVMfMXqGAOr/4fA==}
+ eslint-plugin-promise@6.4.0:
+ resolution: {integrity: sha512-/KWWRaD3fGkVCZsdR0RU53PSthFmoHVhZl+y9+6DqeDLSikLdlUVpVEAmI6iCRR5QyOjBYBqHZV/bdv4DJ4Gtw==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
eslint: ^7.0.0 || ^8.0.0 || ^9.0.0
peerDependencies:
eslint: '>=5.0.0'
- eslint-plugin-tsdoc@0.3.0:
- resolution: {integrity: sha512-0MuFdBrrJVBjT/gyhkP2BqpD0np1NxNLfQ38xXDlSs/KVVpKI2A6vN7jx2Rve/CyUsvOsMGwp9KKrinv7q9g3A==}
-
eslint-plugin-vue@9.27.0:
resolution: {integrity: sha512-5Dw3yxEyuBSXTzT5/Ge1X5kIkRTQ3nvBn/VwPwInNiZBSJOO/timWMUaflONnFBzU6NhB68lxnCda7ULV5N7LA==}
engines: {node: ^14.17.0 || >=16.0.0}
resolution: {integrity: sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
+ eslint-scope@8.0.2:
+ resolution: {integrity: sha512-6E4xmrTw5wtxnLA5wYL3WDfhZ/1bUBGOXV0zQvVRDOtrR8D0p6W7fs3JweNYhwRYeGvd/1CKX2se0/2s7Q/nJA==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+
eslint-visitor-keys@3.4.3:
resolution: {integrity: sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
+ eslint-visitor-keys@4.0.0:
+ resolution: {integrity: sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+
eslint@8.57.0:
resolution: {integrity: sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
hasBin: true
+ eslint@9.7.0:
+ resolution: {integrity: sha512-FzJ9D/0nGiCGBf8UXO/IGLTgLVzIxze1zpfA8Ton2mjLovXdAPlYDv+MQDcqj3TmrhAGYfOpz9RfR+ent0AgAw==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+ hasBin: true
+
esm@3.2.25:
resolution: {integrity: sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==}
engines: {node: '>=6'}
resolution: {integrity: sha512-kTUIGKQ/mDPFoJ0oVfcmyJn4iBDRptjNVIzwIFR7tqWXdVI9xfA2RMwY/gbSpJG3lkdWNEjLap/NqVHZiJsdfg==}
engines: {node: '>=0.10'}
+ espree@10.1.0:
+ resolution: {integrity: sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+
espree@9.6.1:
resolution: {integrity: sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==}
engines: {node: ^10.12.0 || >=12.0.0}
+ file-entry-cache@8.0.0:
+ resolution: {integrity: sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==}
+ engines: {node: '>=16.0.0'}
+
file-stream-rotator@0.6.1:
resolution: {integrity: sha512-u+dBid4PvZw17PmDeRcNOtCP9CCK/9lRN2w+r1xIS7yOL9JFrIBKTvrYsxT4P0pGtThYTn++QS5ChHaUov3+zQ==}
resolution: {integrity: sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==}
engines: {node: ^10.12.0 || >=12.0.0}
+ flat-cache@4.0.1:
+ resolution: {integrity: sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==}
+ engines: {node: '>=16'}
+
flatstr@1.0.12:
resolution: {integrity: sha512-4zPxDyhCyiN2wIAtSLI6gc82/EjqZc1onI4Mz/l0pWrAlsSfYH/2ZIcU+e3oA2wDwbzIWNKwa23F8rh6+DRWkw==}
resolution: {integrity: sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==}
engines: {node: '>=8'}
+ globals@14.0.0:
+ resolution: {integrity: sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==}
+ engines: {node: '>=18'}
+
globals@15.8.0:
resolution: {integrity: sha512-VZAJ4cewHTExBWDHR6yptdIBlx9YSSZuwojj9Nt5mBRXQzrKakDsVKQ1J63sklLvzAJm0X5+RpO4i3Y2hcOnFw==}
engines: {node: '>=18'}
resolution: {integrity: sha512-2yTgeWTWzMWkHu6Jp9NKgePDaYHbntiwvYuuJLbbN9vl7DC9DvXKOB2BC3ZZ92D3cvV/aflH0osDfwpHepQ53w==}
hasBin: true
- jju@1.4.0:
- resolution: {integrity: sha512-8wb9Yw966OSxApiCt0K3yNJL8pnNeIv+OEq2YMidz4FKP6nonSRoOXc80iXY4JaN2FC11B9qsNmDsm+ZOfMROA==}
-
js-beautify@1.15.1:
resolution: {integrity: sha512-ESjNzSlt/sWE8sciZH8kBF8BPlwXPwhR6pWKAw8bw4Bwj+iZcnKW6ONWUutJ7eObuBZQpiIb8S7OYspWrKt7rA==}
engines: {node: '>=14'}
resolution: {integrity: sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==}
engines: {node: '>= 0.6'}
+ neostandard@0.11.0:
+ resolution: {integrity: sha512-20B3IxFDnQf9d9sWdCtiuiArOjtozxt4GF1suatqKk/J1qHdaJSkfnQdfdACi8O21W7yTKmc7jc2wvm0vH7Y2w==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+ hasBin: true
+ peerDependencies:
+ eslint: ^9.0.0
+
next-tick@1.1.0:
resolution: {integrity: sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==}
resolution: {integrity: sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA==}
engines: {node: '>=0.12'}
+ peowly@1.3.2:
+ resolution: {integrity: sha512-BYIrwr8JCXY49jUZscgw311w9oGEKo7ux/s+BxrhKTQbiQ0iYNdZNJ5LgagaeercQdFHwnR7Z5IxxFWVQ+BasQ==}
+ engines: {node: '>=18.6.0'}
+
performance-now@2.1.0:
resolution: {integrity: sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==}
resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==}
engines: {node: '>=8.6'}
+ picomatch@4.0.2:
+ resolution: {integrity: sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==}
+ engines: {node: '>=12'}
+
pidtree@0.6.0:
resolution: {integrity: sha512-eG2dWTVw5bzqGRztnHExczNxt5VGsE6OwTeCG3fdUf9KBsZzO3R5OIIIzWR+iZA0NtZ+RDVdaoE2dK1cn6jH4g==}
engines: {node: '>=0.10'}
typedarray@0.0.6:
resolution: {integrity: sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==}
+ typescript-eslint@8.0.0-alpha.42:
+ resolution: {integrity: sha512-lD1yEYS0hGOtRheGp7Lyze2r6AQgJeKHjpNyVlXkYEQgDCs9dPlO2VF9/WMvdA1d3TPa24hVGlUcKJ34G5jNKQ==}
+ engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+ peerDependencies:
+ typescript: '*'
+ peerDependenciesMeta:
+ typescript:
+ optional: true
+
typescript@5.5.3:
resolution: {integrity: sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==}
engines: {node: '>=14.17'}
eslint: 8.57.0
eslint-visitor-keys: 3.4.3
+ '@eslint-community/eslint-utils@4.4.0(eslint@9.7.0)':
+ dependencies:
+ eslint: 9.7.0
+ eslint-visitor-keys: 3.4.3
+
'@eslint-community/regexpp@4.11.0': {}
+ '@eslint/config-array@0.17.0':
+ dependencies:
+ '@eslint/object-schema': 2.1.4
+ debug: 4.3.5
+ minimatch: 3.1.2
+ transitivePeerDependencies:
+ - supports-color
+
'@eslint/eslintrc@2.1.4':
dependencies:
ajv: 6.12.6
transitivePeerDependencies:
- supports-color
+ '@eslint/eslintrc@3.1.0':
+ dependencies:
+ ajv: 6.12.6
+ debug: 4.3.5
+ espree: 10.1.0
+ globals: 14.0.0
+ ignore: 5.3.1
+ import-fresh: 3.3.0
+ js-yaml: 4.1.0
+ minimatch: 3.1.2
+ strip-json-comments: 3.1.1
+ transitivePeerDependencies:
+ - supports-color
+
'@eslint/js@8.57.0': {}
+ '@eslint/js@9.7.0': {}
+
+ '@eslint/object-schema@2.1.4': {}
+
'@gar/promisify@1.1.3':
optional: true
transitivePeerDependencies:
- supports-color
+ '@humanwhocodes/gitignore-to-minimatch@1.0.2': {}
+
'@humanwhocodes/module-importer@1.0.1': {}
'@humanwhocodes/object-schema@2.0.3': {}
+ '@humanwhocodes/retry@0.3.0': {}
+
'@isaacs/cliui@8.0.2':
dependencies:
string-width: 5.1.2
'@jridgewell/resolve-uri': 3.1.2
'@jridgewell/sourcemap-codec': 1.5.0
- '@microsoft/tsdoc-config@0.17.0':
- dependencies:
- '@microsoft/tsdoc': 0.15.0
- ajv: 8.12.0
- jju: 1.4.0
- resolve: 1.22.8
-
- '@microsoft/tsdoc@0.15.0': {}
-
'@mikro-orm/cli@6.2.9(mariadb@3.3.0)':
dependencies:
'@jercle/yargonaut': 1.1.5
'@sindresorhus/is@5.6.0': {}
+ '@stylistic/eslint-plugin-js@2.6.0-beta.0(eslint@9.7.0)':
+ dependencies:
+ '@types/eslint': 8.56.10
+ acorn: 8.12.1
+ eslint: 9.7.0
+ eslint-visitor-keys: 4.0.0
+ espree: 10.1.0
+
+ '@stylistic/eslint-plugin-jsx@2.6.0-beta.0(eslint@9.7.0)':
+ dependencies:
+ '@stylistic/eslint-plugin-js': 2.6.0-beta.0(eslint@9.7.0)
+ '@types/eslint': 8.56.10
+ eslint: 9.7.0
+ estraverse: 5.3.0
+ picomatch: 4.0.2
+
+ '@stylistic/eslint-plugin-plus@2.6.0-beta.0(eslint@9.7.0)(typescript@5.5.3)':
+ dependencies:
+ '@types/eslint': 8.56.10
+ '@typescript-eslint/utils': 8.0.0-alpha.42(eslint@9.7.0)(typescript@5.5.3)
+ eslint: 9.7.0
+ transitivePeerDependencies:
+ - supports-color
+ - typescript
+
+ '@stylistic/eslint-plugin-ts@2.6.0-beta.0(eslint@9.7.0)(typescript@5.5.3)':
+ dependencies:
+ '@stylistic/eslint-plugin-js': 2.6.0-beta.0(eslint@9.7.0)
+ '@types/eslint': 8.56.10
+ '@typescript-eslint/utils': 8.0.0-alpha.42(eslint@9.7.0)(typescript@5.5.3)
+ eslint: 9.7.0
+ transitivePeerDependencies:
+ - supports-color
+ - typescript
+
+ '@stylistic/eslint-plugin@2.6.0-beta.0(eslint@9.7.0)(typescript@5.5.3)':
+ dependencies:
+ '@stylistic/eslint-plugin-js': 2.6.0-beta.0(eslint@9.7.0)
+ '@stylistic/eslint-plugin-jsx': 2.6.0-beta.0(eslint@9.7.0)
+ '@stylistic/eslint-plugin-plus': 2.6.0-beta.0(eslint@9.7.0)(typescript@5.5.3)
+ '@stylistic/eslint-plugin-ts': 2.6.0-beta.0(eslint@9.7.0)(typescript@5.5.3)
+ '@types/eslint': 8.56.10
+ eslint: 9.7.0
+ transitivePeerDependencies:
+ - supports-color
+ - typescript
+
'@szmarczak/http-timer@5.0.1':
dependencies:
defer-to-connect: 2.0.1
dependencies:
'@types/estree': 1.0.5
'@types/json-schema': 7.0.15
- optional: true
'@types/estree@1.0.5': {}
'@types/tough-cookie': 4.0.5
parse5: 7.1.2
- '@types/json-schema@7.0.15':
- optional: true
+ '@types/json-schema@7.0.15': {}
'@types/json5@0.0.29': {}
transitivePeerDependencies:
- supports-color
+ '@typescript-eslint/eslint-plugin@8.0.0-alpha.42(@typescript-eslint/parser@8.0.0-alpha.42(eslint@9.7.0)(typescript@5.5.3))(eslint@9.7.0)(typescript@5.5.3)':
+ dependencies:
+ '@eslint-community/regexpp': 4.11.0
+ '@typescript-eslint/parser': 8.0.0-alpha.42(eslint@9.7.0)(typescript@5.5.3)
+ '@typescript-eslint/scope-manager': 8.0.0-alpha.42
+ '@typescript-eslint/type-utils': 8.0.0-alpha.42(eslint@9.7.0)(typescript@5.5.3)
+ '@typescript-eslint/utils': 8.0.0-alpha.42(eslint@9.7.0)(typescript@5.5.3)
+ '@typescript-eslint/visitor-keys': 8.0.0-alpha.42
+ eslint: 9.7.0
+ graphemer: 1.4.0
+ ignore: 5.3.1
+ natural-compare: 1.4.0
+ ts-api-utils: 1.3.0(typescript@5.5.3)
+ optionalDependencies:
+ typescript: 5.5.3
+ transitivePeerDependencies:
+ - supports-color
+
'@typescript-eslint/parser@7.16.0(eslint@8.57.0)(typescript@5.5.3)':
dependencies:
'@typescript-eslint/scope-manager': 7.16.0
transitivePeerDependencies:
- supports-color
+ '@typescript-eslint/parser@8.0.0-alpha.42(eslint@9.7.0)(typescript@5.5.3)':
+ dependencies:
+ '@typescript-eslint/scope-manager': 8.0.0-alpha.42
+ '@typescript-eslint/types': 8.0.0-alpha.42
+ '@typescript-eslint/typescript-estree': 8.0.0-alpha.42(typescript@5.5.3)
+ '@typescript-eslint/visitor-keys': 8.0.0-alpha.42
+ debug: 4.3.5
+ eslint: 9.7.0
+ optionalDependencies:
+ typescript: 5.5.3
+ transitivePeerDependencies:
+ - supports-color
+
'@typescript-eslint/scope-manager@7.16.0':
dependencies:
'@typescript-eslint/types': 7.16.0
'@typescript-eslint/visitor-keys': 7.16.0
+ '@typescript-eslint/scope-manager@8.0.0-alpha.42':
+ dependencies:
+ '@typescript-eslint/types': 8.0.0-alpha.42
+ '@typescript-eslint/visitor-keys': 8.0.0-alpha.42
+
'@typescript-eslint/type-utils@7.16.0(eslint@8.57.0)(typescript@5.5.3)':
dependencies:
'@typescript-eslint/typescript-estree': 7.16.0(typescript@5.5.3)
transitivePeerDependencies:
- supports-color
+ '@typescript-eslint/type-utils@8.0.0-alpha.42(eslint@9.7.0)(typescript@5.5.3)':
+ dependencies:
+ '@typescript-eslint/typescript-estree': 8.0.0-alpha.42(typescript@5.5.3)
+ '@typescript-eslint/utils': 8.0.0-alpha.42(eslint@9.7.0)(typescript@5.5.3)
+ debug: 4.3.5
+ ts-api-utils: 1.3.0(typescript@5.5.3)
+ optionalDependencies:
+ typescript: 5.5.3
+ transitivePeerDependencies:
+ - eslint
+ - supports-color
+
'@typescript-eslint/types@7.16.0': {}
+ '@typescript-eslint/types@8.0.0-alpha.42': {}
+
'@typescript-eslint/typescript-estree@7.16.0(typescript@5.5.3)':
dependencies:
'@typescript-eslint/types': 7.16.0
transitivePeerDependencies:
- supports-color
+ '@typescript-eslint/typescript-estree@8.0.0-alpha.42(typescript@5.5.3)':
+ dependencies:
+ '@typescript-eslint/types': 8.0.0-alpha.42
+ '@typescript-eslint/visitor-keys': 8.0.0-alpha.42
+ debug: 4.3.5
+ globby: 11.1.0
+ is-glob: 4.0.3
+ minimatch: 9.0.5
+ semver: 7.6.2
+ ts-api-utils: 1.3.0(typescript@5.5.3)
+ optionalDependencies:
+ typescript: 5.5.3
+ transitivePeerDependencies:
+ - supports-color
+
'@typescript-eslint/utils@7.16.0(eslint@8.57.0)(typescript@5.5.3)':
dependencies:
'@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0)
- supports-color
- typescript
+ '@typescript-eslint/utils@8.0.0-alpha.42(eslint@9.7.0)(typescript@5.5.3)':
+ dependencies:
+ '@eslint-community/eslint-utils': 4.4.0(eslint@9.7.0)
+ '@typescript-eslint/scope-manager': 8.0.0-alpha.42
+ '@typescript-eslint/types': 8.0.0-alpha.42
+ '@typescript-eslint/typescript-estree': 8.0.0-alpha.42(typescript@5.5.3)
+ eslint: 9.7.0
+ transitivePeerDependencies:
+ - supports-color
+ - typescript
+
'@typescript-eslint/visitor-keys@7.16.0':
dependencies:
'@typescript-eslint/types': 7.16.0
eslint-visitor-keys: 3.4.3
+ '@typescript-eslint/visitor-keys@8.0.0-alpha.42':
+ dependencies:
+ '@typescript-eslint/types': 8.0.0-alpha.42
+ eslint-visitor-keys: 3.4.3
+
'@ungap/structured-clone@1.2.0': {}
'@vitejs/plugin-vue-jsx@4.0.0(vite@5.3.3(@types/node@20.14.10))(vue@3.4.31(typescript@5.5.3))':
json-schema-traverse: 0.4.1
uri-js: 4.4.1
- ajv@8.12.0:
- dependencies:
- fast-deep-equal: 3.1.3
- json-schema-traverse: 1.0.0
- require-from-string: 2.0.2
- uri-js: 4.4.1
-
ajv@8.17.1:
dependencies:
fast-deep-equal: 3.1.3
optionalDependencies:
source-map: 0.6.1
- eslint-compat-utils@0.5.1(eslint@8.57.0):
+ eslint-compat-utils@0.5.1(eslint@9.7.0):
dependencies:
- eslint: 8.57.0
+ eslint: 9.7.0
semver: 7.6.2
- eslint-config-love@47.0.0(@typescript-eslint/eslint-plugin@7.16.0(@typescript-eslint/parser@7.16.0(eslint@8.57.0)(typescript@5.5.3))(eslint@8.57.0)(typescript@5.5.3))(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.16.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0))(eslint-plugin-n@17.9.0(eslint@8.57.0))(eslint-plugin-promise@6.2.0(eslint@8.57.0))(eslint@8.57.0)(typescript@5.5.3):
- dependencies:
- '@typescript-eslint/eslint-plugin': 7.16.0(@typescript-eslint/parser@7.16.0(eslint@8.57.0)(typescript@5.5.3))(eslint@8.57.0)(typescript@5.5.3)
- '@typescript-eslint/parser': 7.16.0(eslint@8.57.0)(typescript@5.5.3)
- eslint: 8.57.0
- eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.16.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0)
- eslint-plugin-n: 17.9.0(eslint@8.57.0)
- eslint-plugin-promise: 6.2.0(eslint@8.57.0)
- typescript: 5.5.3
- transitivePeerDependencies:
- - supports-color
-
eslint-config-prettier@9.1.0(eslint@8.57.0):
dependencies:
eslint: 8.57.0
- eslint-config-standard@17.1.0(eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.16.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0))(eslint-plugin-n@17.9.0(eslint@8.57.0))(eslint-plugin-promise@6.2.0(eslint@8.57.0))(eslint@8.57.0):
- dependencies:
- eslint: 8.57.0
- eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.16.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0)
- eslint-plugin-n: 17.9.0(eslint@8.57.0)
- eslint-plugin-promise: 6.2.0(eslint@8.57.0)
-
eslint-define-config@2.1.0: {}
eslint-import-resolver-node@0.3.9:
transitivePeerDependencies:
- supports-color
- eslint-plugin-es-x@7.8.0(eslint@8.57.0):
+ eslint-plugin-es-x@7.8.0(eslint@9.7.0):
dependencies:
- '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0)
+ '@eslint-community/eslint-utils': 4.4.0(eslint@9.7.0)
'@eslint-community/regexpp': 4.11.0
- eslint: 8.57.0
- eslint-compat-utils: 0.5.1(eslint@8.57.0)
+ eslint: 9.7.0
+ eslint-compat-utils: 0.5.1(eslint@9.7.0)
eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.16.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0):
dependencies:
- eslint-import-resolver-webpack
- supports-color
- eslint-plugin-jsdoc@48.7.0(eslint@8.57.0):
+ eslint-plugin-jsdoc@48.7.0(eslint@9.7.0):
dependencies:
'@es-joy/jsdoccomment': 0.46.0
are-docs-informative: 0.0.2
comment-parser: 1.4.1
debug: 4.3.5
escape-string-regexp: 4.0.0
- eslint: 8.57.0
+ eslint: 9.7.0
esquery: 1.6.0
parse-imports: 2.1.1
semver: 7.6.2
transitivePeerDependencies:
- supports-color
- eslint-plugin-n@17.9.0(eslint@8.57.0):
+ eslint-plugin-n@17.9.0(eslint@9.7.0):
dependencies:
- '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0)
+ '@eslint-community/eslint-utils': 4.4.0(eslint@9.7.0)
enhanced-resolve: 5.17.0
- eslint: 8.57.0
- eslint-plugin-es-x: 7.8.0(eslint@8.57.0)
+ eslint: 9.7.0
+ eslint-plugin-es-x: 7.8.0(eslint@9.7.0)
get-tsconfig: 4.7.5
globals: 15.8.0
ignore: 5.3.1
'@types/eslint': 8.56.10
eslint-config-prettier: 9.1.0(eslint@8.57.0)
- eslint-plugin-promise@6.2.0(eslint@8.57.0):
+ eslint-plugin-promise@6.4.0(eslint@9.7.0):
dependencies:
- eslint: 8.57.0
+ eslint: 9.7.0
eslint-plugin-simple-import-sort@12.1.1(eslint@8.57.0):
dependencies:
eslint: 8.57.0
- eslint-plugin-tsdoc@0.3.0:
+ eslint-plugin-simple-import-sort@12.1.1(eslint@9.7.0):
dependencies:
- '@microsoft/tsdoc': 0.15.0
- '@microsoft/tsdoc-config': 0.17.0
+ eslint: 9.7.0
eslint-plugin-vue@9.27.0(eslint@8.57.0):
dependencies:
esrecurse: 4.3.0
estraverse: 5.3.0
+ eslint-scope@8.0.2:
+ dependencies:
+ esrecurse: 4.3.0
+ estraverse: 5.3.0
+
eslint-visitor-keys@3.4.3: {}
+ eslint-visitor-keys@4.0.0: {}
+
eslint@8.57.0:
dependencies:
'@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0)
transitivePeerDependencies:
- supports-color
+ eslint@9.7.0:
+ dependencies:
+ '@eslint-community/eslint-utils': 4.4.0(eslint@9.7.0)
+ '@eslint-community/regexpp': 4.11.0
+ '@eslint/config-array': 0.17.0
+ '@eslint/eslintrc': 3.1.0
+ '@eslint/js': 9.7.0
+ '@humanwhocodes/module-importer': 1.0.1
+ '@humanwhocodes/retry': 0.3.0
+ '@nodelib/fs.walk': 1.2.8
+ ajv: 6.12.6
+ chalk: 4.1.2
+ cross-spawn: 7.0.3
+ debug: 4.3.5
+ escape-string-regexp: 4.0.0
+ eslint-scope: 8.0.2
+ eslint-visitor-keys: 4.0.0
+ espree: 10.1.0
+ esquery: 1.6.0
+ esutils: 2.0.3
+ fast-deep-equal: 3.1.3
+ file-entry-cache: 8.0.0
+ find-up: 5.0.0
+ glob-parent: 6.0.2
+ ignore: 5.3.1
+ imurmurhash: 0.1.4
+ is-glob: 4.0.3
+ is-path-inside: 3.0.3
+ json-stable-stringify-without-jsonify: 1.0.1
+ levn: 0.4.1
+ lodash.merge: 4.6.2
+ minimatch: 3.1.2
+ natural-compare: 1.4.0
+ optionator: 0.9.4
+ strip-ansi: 6.0.1
+ text-table: 0.2.0
+ transitivePeerDependencies:
+ - supports-color
+
esm@3.2.25: {}
esniff@2.0.1:
event-emitter: 0.3.5
type: 2.7.3
+ espree@10.1.0:
+ dependencies:
+ acorn: 8.12.1
+ acorn-jsx: 5.3.2(acorn@8.12.1)
+ eslint-visitor-keys: 4.0.0
+
espree@9.6.1:
dependencies:
acorn: 8.12.1
dependencies:
flat-cache: 3.2.0
+ file-entry-cache@8.0.0:
+ dependencies:
+ flat-cache: 4.0.1
+
file-stream-rotator@0.6.1:
dependencies:
moment: 2.30.1
keyv: 4.5.4
rimraf: 3.0.2
+ flat-cache@4.0.1:
+ dependencies:
+ flatted: 3.3.1
+ keyv: 4.5.4
+
flatstr@1.0.12: {}
flatted@3.3.1: {}
dependencies:
type-fest: 0.20.2
+ globals@14.0.0: {}
+
globals@15.8.0: {}
globalthis@1.0.4:
jiti@1.21.6: {}
- jju@1.4.0: {}
-
js-beautify@1.15.1:
dependencies:
config-chain: 1.1.13
negotiator@0.6.3:
optional: true
+ neostandard@0.11.0(eslint@9.7.0)(typescript@5.5.3):
+ dependencies:
+ '@humanwhocodes/gitignore-to-minimatch': 1.0.2
+ '@stylistic/eslint-plugin': 2.6.0-beta.0(eslint@9.7.0)(typescript@5.5.3)
+ '@typescript-eslint/utils': 8.0.0-alpha.42(eslint@9.7.0)(typescript@5.5.3)
+ eslint: 9.7.0
+ eslint-plugin-n: 17.9.0(eslint@9.7.0)
+ eslint-plugin-promise: 6.4.0(eslint@9.7.0)
+ find-up: 5.0.0
+ globals: 15.8.0
+ peowly: 1.3.2
+ typescript-eslint: 8.0.0-alpha.42(eslint@9.7.0)(typescript@5.5.3)
+ transitivePeerDependencies:
+ - supports-color
+ - typescript
+
next-tick@1.1.0: {}
no-case@2.3.2:
safe-buffer: 5.2.1
sha.js: 2.4.11
+ peowly@1.3.2: {}
+
performance-now@2.1.0: {}
pg-connection-string@2.6.2: {}
picomatch@2.3.1: {}
+ picomatch@4.0.2: {}
+
pidtree@0.6.0: {}
pify@2.3.0: {}
typedarray@0.0.6: {}
+ typescript-eslint@8.0.0-alpha.42(eslint@9.7.0)(typescript@5.5.3):
+ dependencies:
+ '@typescript-eslint/eslint-plugin': 8.0.0-alpha.42(@typescript-eslint/parser@8.0.0-alpha.42(eslint@9.7.0)(typescript@5.5.3))(eslint@9.7.0)(typescript@5.5.3)
+ '@typescript-eslint/parser': 8.0.0-alpha.42(eslint@9.7.0)(typescript@5.5.3)
+ '@typescript-eslint/utils': 8.0.0-alpha.42(eslint@9.7.0)(typescript@5.5.3)
+ optionalDependencies:
+ typescript: 5.5.3
+ transitivePeerDependencies:
+ - eslint
+ - supports-color
+
typescript@5.5.3: {}
umd@3.0.3: {}
const isCFEnvironment = env.VCAP_APPLICATION != null
if (isCFEnvironment === false && isCIEnvironment === false) {
// eslint-disable-next-line n/no-unpublished-import
- import('husky').then(husky => console.warn(husky.default()))
+ import('husky')
+ .then(husky => {
+ return console.warn(husky.default())
+ })
+ .catch(console.error)
}
const skipPreinstall = Number.parseInt(env.SKIP_PREINSTALL) || env.VCAP_APPLICATION != null
if (skipPreinstall) {
- // eslint-disable-next-line n/no-process-exit
exit()
} else {
- // eslint-disable-next-line n/no-process-exit
exit(1)
}
type StartTransactionResponse,
type Status,
StopTransactionReason,
- type StopTransactionResponse
+ type StopTransactionResponse,
} from '../types/index.js'
import {
clone,
logger,
logPrefix,
secureRandom,
- sleep
+ sleep,
} from '../utils/index.js'
import type { ChargingStation } from './ChargingStation.js'
import { checkChargingStation } from './Helpers.js'
export class AutomaticTransactionGenerator {
private static readonly instances: Map<string, AutomaticTransactionGenerator> = new Map<
- string,
- AutomaticTransactionGenerator
+ string,
+ AutomaticTransactionGenerator
>()
public readonly connectorsStatus: Map<number, Status>
}
if (!this.connectorsStatus.has(connectorId)) {
logger.error(`${this.logPrefix(connectorId)} starting on non existing connector`)
- throw new BaseError(`Connector ${connectorId} does not exist`)
+ throw new BaseError(`Connector ${connectorId.toString()} does not exist`)
}
if (this.connectorsStatus.get(connectorId)?.start === false) {
this.internalStartConnector(connectorId, stopAbsoluteDuration).catch(Constants.EMPTY_FUNCTION)
public stopConnector (connectorId: number): void {
if (!this.connectorsStatus.has(connectorId)) {
logger.error(`${this.logPrefix(connectorId)} stopping on non existing connector`)
- throw new BaseError(`Connector ${connectorId} does not exist`)
+ throw new BaseError(`Connector ${connectorId.toString()} does not exist`)
}
if (this.connectorsStatus.get(connectorId)?.start === true) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
)
logger.info(
`${this.logPrefix(connectorId)} transaction started with id ${
- this.chargingStation.getConnectorStatus(connectorId)?.transactionId
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ this.chargingStation.getConnectorStatus(connectorId)?.transactionId?.toString()
} and will stop in ${formatDurationMilliSeconds(waitTrxEnd)}`
)
await sleep(waitTrxEnd)
++this.connectorsStatus.get(connectorId)!.skippedTransactions
logger.info(
`${this.logPrefix(connectorId)} skipped consecutively ${
- this.connectorsStatus.get(connectorId)?.skippedConsecutiveTransactions
- }/${this.connectorsStatus.get(connectorId)?.skippedTransactions} transaction(s)`
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ this.connectorsStatus.get(connectorId)?.skippedConsecutiveTransactions.toString()
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ }/${this.connectorsStatus.get(connectorId)?.skippedTransactions.toString()} transaction(s)`
)
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
logger.info(
`${this.logPrefix(
connectorId
- )} entered in transaction loop while the connector ${connectorId} is unavailable`
+ )} entered in transaction loop while the connector ${connectorId.toString()} is unavailable`
)
return false
}
if (connectorStatus?.transactionStarted === true) {
logger.info(
`${this.logPrefix(connectorId)} entered in transaction loop while a transaction ${
- connectorStatus.transactionId
- } is already started on connector ${connectorId}`
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ connectorStatus.transactionId?.toString()
+ } is already started on connector ${connectorId.toString()}`
)
return false
}
logger.info(
`${this.logPrefix(
connectorId
- )} transaction loop waiting for connector ${connectorId} to be available`
+ )} transaction loop waiting for connector ${connectorId.toString()} to be available`
)
logged = true
}
if (!logged) {
logger.info(
`${this.logPrefix(connectorId)} transaction loop waiting for started transaction ${
- connectorStatus.transactionId
- } on connector ${connectorId} to be stopped`
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ connectorStatus.transactionId?.toString()
+ } on connector ${connectorId.toString()} to be stopped`
)
logged = true
}
const statusIndex = connectorId - 1
if (statusIndex < 0) {
logger.error(`${this.logPrefix(connectorId)} invalid connector id`)
- throw new BaseError(`Invalid connector id ${connectorId}`)
+ throw new BaseError(`Invalid connector id ${connectorId.toString()}`)
}
let connectorStatus: Status | undefined
if (this.chargingStation.getAutomaticTransactionGeneratorStatuses()?.[statusIndex] != null) {
logger.warn(
`${this.logPrefix(
connectorId
- )} no status found for connector #${connectorId} in charging station configuration file. New status will be created`
+ )} no status found for connector #${connectorId.toString()} in charging station configuration file. New status will be created`
)
}
if (connectorStatus != null) {
acceptedStopTransactionRequests: 0,
rejectedStopTransactionRequests: 0,
skippedConsecutiveTransactions: 0,
- skippedTransactions: 0
+ skippedTransactions: 0,
}
)
}
logger.info(startTransactionLogMsg)
// Start transaction
startResponse = await this.chargingStation.ocppRequestService.requestHandler<
- Partial<StartTransactionRequest>,
- StartTransactionResponse
+ Partial<StartTransactionRequest>,
+ StartTransactionResponse
>(this.chargingStation, RequestCommand.START_TRANSACTION, {
connectorId,
- idTag
+ idTag,
})
this.handleStartTransactionResponse(connectorId, startResponse)
PerformanceStatistics.endMeasure(measureId, beginId)
logger.info(startTransactionLogMsg)
// Start transaction
startResponse = await this.chargingStation.ocppRequestService.requestHandler<
- Partial<StartTransactionRequest>,
- StartTransactionResponse
+ Partial<StartTransactionRequest>,
+ StartTransactionResponse
>(this.chargingStation, RequestCommand.START_TRANSACTION, {
connectorId,
- idTag
+ idTag,
})
this.handleStartTransactionResponse(connectorId, startResponse)
PerformanceStatistics.endMeasure(measureId, beginId)
}
logger.info(`${this.logPrefix(connectorId)} start transaction without an idTag`)
startResponse = await this.chargingStation.ocppRequestService.requestHandler<
- Partial<StartTransactionRequest>,
- StartTransactionResponse
+ Partial<StartTransactionRequest>,
+ StartTransactionResponse
>(this.chargingStation, RequestCommand.START_TRANSACTION, {
- connectorId
+ connectorId,
})
this.handleStartTransactionResponse(connectorId, startResponse)
PerformanceStatistics.endMeasure(measureId, beginId)
if (this.chargingStation.getConnectorStatus(connectorId)?.transactionStarted === true) {
logger.info(
`${this.logPrefix(connectorId)} stop transaction with id ${
- this.chargingStation.getConnectorStatus(connectorId)?.transactionId
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ this.chargingStation.getConnectorStatus(connectorId)?.transactionId?.toString()
}`
)
stopResponse = await this.chargingStation.stopTransactionOnConnector(connectorId, reason)
const transactionId = this.chargingStation.getConnectorStatus(connectorId)?.transactionId
logger.debug(
`${this.logPrefix(connectorId)} stopping a not started transaction${
- transactionId != null ? ` with id ${transactionId}` : ''
+ transactionId != null ? ` with id ${transactionId.toString()}` : ''
}`
)
}
private readonly logPrefix = (connectorId?: number): string => {
return logPrefix(
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
` ${this.chargingStation.stationInfo?.chargingStationId} | ATG${
- connectorId != null ? ` on connector #${connectorId}` : ''
+ connectorId != null ? ` on connector #${connectorId.toString()}` : ''
}:`
)
}
type StorageConfiguration,
type TemplateStatistics,
type UIServerConfiguration,
- type WorkerConfiguration
+ type WorkerConfiguration,
} from '../types/index.js'
import {
Configuration,
isAsyncFunction,
isNotEmptyArray,
logger,
- logPrefix
+ logPrefix,
} from '../utils/index.js'
import { DEFAULT_ELEMENTS_PER_WORKER, type WorkerAbstract, WorkerFactory } from '../worker/index.js'
import { buildTemplateName, waitChargingStationEvents } from './Helpers.js'
version: this.version,
configuration: Configuration.getConfigurationData(),
started: this.started,
- templateStatistics: this.templateStatistics
+ templateStatistics: this.templateStatistics,
}
}
if (isAsyncFunction(this.workerImplementation?.start)) {
await this.workerImplementation.start()
} else {
- (this.workerImplementation?.start as () => void)()
+ ;(this.workerImplementation?.start as () => void)()
}
const performanceStorageConfiguration =
Configuration.getConfigurationSection<StorageConfiguration>(
console.info(
chalk.green(
`Charging stations simulator ${this.version} started with ${
- this.numberOfConfiguredChargingStations
+ this.numberOfConfiguredChargingStations.toString()
} configured and ${
- this.numberOfProvisionedChargingStations
+ this.numberOfProvisionedChargingStations.toString()
} provisioned charging station(s) from ${
- this.numberOfChargingStationTemplates
+ this.numberOfChargingStationTemplates.toString()
} charging station template(s) and ${
- Configuration.workerDynamicPoolInUse() ? `${workerConfiguration.poolMinSize}/` : ''
- }${this.workerImplementation?.size}${
- Configuration.workerPoolInUse() ? `/${workerConfiguration.poolMaxSize}` : ''
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ Configuration.workerDynamicPoolInUse() ? `${workerConfiguration.poolMinSize?.toString()}/` : ''
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ }${this.workerImplementation?.size.toString()}${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ Configuration.workerPoolInUse() ? `/${workerConfiguration.poolMaxSize?.toString()}` : ''
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
} worker(s) concurrently running in '${workerConfiguration.processType}' mode${
this.workerImplementation?.maxElementsPerWorker != null
- ? ` (${this.workerImplementation.maxElementsPerWorker} charging station(s) per worker)`
+ ? ` (${this.workerImplementation.maxElementsPerWorker.toString()} charging station(s) per worker)`
: ''
}`
)
ChargingStationWorkerMessageEvents.stopped,
this.numberOfStartedChargingStations
)
- .then(() => {
+ .then((events) => {
resolve('Charging stations stopped')
+ return events
})
- .catch(reject)
.finally(() => {
clearTimeout(waitTimeout)
})
+ .catch(reject)
})
}
elementsPerWorker = workerConfiguration.elementsPerWorker ?? DEFAULT_ELEMENTS_PER_WORKER
}
this.workerImplementation = WorkerFactory.getWorkerImplementation<
- ChargingStationWorkerData,
- ChargingStationInfo
+ ChargingStationWorkerData,
+ ChargingStationInfo
>(
join(
dirname(fileURLToPath(import.meta.url)),
messageHandler: this.messageHandler.bind(this) as MessageHandler<Worker>,
...(workerConfiguration.resourceLimits != null && {
workerOptions: {
- resourceLimits: workerConfiguration.resourceLimits
- }
- })
- }
+ resourceLimits: workerConfiguration.resourceLimits,
+ },
+ }),
+ },
}
)
}
this.uiServer.chargingStations.set(data.stationInfo.hashId, data)
logger.info(
`${this.logPrefix()} ${moduleName}.workerEventAdded: Charging station ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
data.stationInfo.chargingStationId
} (hashId: ${data.stationInfo.hashId}) added (${
- this.numberOfAddedChargingStations
- } added from ${this.numberOfConfiguredChargingStations} configured and ${
- this.numberOfProvisionedChargingStations
+ this.numberOfAddedChargingStations.toString()
+ } added from ${this.numberOfConfiguredChargingStations.toString()} configured and ${
+ this.numberOfProvisionedChargingStations.toString()
} provisioned charging station(s))`
)
}
templateStatistics.indexes.delete(data.stationInfo.templateIndex)
logger.info(
`${this.logPrefix()} ${moduleName}.workerEventDeleted: Charging station ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
data.stationInfo.chargingStationId
} (hashId: ${data.stationInfo.hashId}) deleted (${
- this.numberOfAddedChargingStations
- } added from ${this.numberOfConfiguredChargingStations} configured and ${
- this.numberOfProvisionedChargingStations
+ this.numberOfAddedChargingStations.toString()
+ } added from ${this.numberOfConfiguredChargingStations.toString()} configured and ${
+ this.numberOfProvisionedChargingStations.toString()
} provisioned charging station(s))`
)
}
++this.templateStatistics.get(data.stationInfo.templateName)!.started
logger.info(
`${this.logPrefix()} ${moduleName}.workerEventStarted: Charging station ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
data.stationInfo.chargingStationId
} (hashId: ${data.stationInfo.hashId}) started (${
- this.numberOfStartedChargingStations
- } started from ${this.numberOfAddedChargingStations} added charging station(s))`
+ this.numberOfStartedChargingStations.toString()
+ } started from ${this.numberOfAddedChargingStations.toString()} added charging station(s))`
)
}
--this.templateStatistics.get(data.stationInfo.templateName)!.started
logger.info(
`${this.logPrefix()} ${moduleName}.workerEventStopped: Charging station ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
data.stationInfo.chargingStationId
} (hashId: ${data.stationInfo.hashId}) stopped (${
- this.numberOfStartedChargingStations
- } started from ${this.numberOfAddedChargingStations} added charging station(s))`
+ this.numberOfStartedChargingStations.toString()
+ } started from ${this.numberOfAddedChargingStations.toString()} added charging station(s))`
)
}
private readonly workerEventPerformanceStatistics = (data: Statistics): void => {
// eslint-disable-next-line @typescript-eslint/unbound-method
if (isAsyncFunction(this.storage?.storePerformanceStatistics)) {
- (
+ ;(
this.storage.storePerformanceStatistics as (
performanceStatistics: Statistics
) => Promise<void>
)(data).catch(Constants.EMPTY_FUNCTION)
} else {
- (this.storage?.storePerformanceStatistics as (performanceStatistics: Statistics) => void)(
+ ;(this.storage?.storePerformanceStatistics as (performanceStatistics: Statistics) => void)(
data
)
}
provisioned: stationTemplateUrl.provisionedNumberOfStations ?? 0,
added: 0,
started: 0,
- indexes: new Set<number>()
+ indexes: new Set<number>(),
})
this.uiServer.chargingStationTemplates.add(templateName)
}
'station-templates',
templateFile
),
- options
+ options,
})
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const templateStatistics = this.templateStatistics.get(buildTemplateName(templateFile))!
this.uiServer.stop()
this.uiServerStarted = false
this.waitChargingStationsStopped()
+ // eslint-disable-next-line promise/no-nesting
.then(() => {
- exit(exitCodes.succeeded)
+ return exit(exitCodes.succeeded)
})
+ // eslint-disable-next-line promise/no-nesting
.catch(() => {
exit(exitCodes.gracefulShutdownError)
})
+ return undefined
})
.catch((error: unknown) => {
console.error(chalk.red('Error while shutdowning charging stations simulator: '), error)
type Voltage,
WebSocketCloseEventStatusCode,
type WSError,
- type WsOptions
+ type WsOptions,
} from '../types/index.js'
import {
ACElectricUtils,
roundTo,
secureRandom,
sleep,
- watchJsonFile
+ watchJsonFile,
} from '../utils/index.js'
import { AutomaticTransactionGenerator } from './AutomaticTransactionGenerator.js'
import { ChargingStationWorkerBroadcastChannel } from './broadcast-channel/ChargingStationWorkerBroadcastChannel.js'
addConfigurationKey,
deleteConfigurationKey,
getConfigurationKey,
- setConfigurationKeyValue
+ setConfigurationKeyValue,
} from './ConfigurationKeyUtils.js'
import {
buildConnectorsMap,
propagateSerialNumber,
setChargingStationOptions,
stationTemplateToStationInfo,
- warnTemplateKeysDeprecation
+ warnTemplateKeysDeprecation,
} from './Helpers.js'
import { IdTagsCache } from './IdTagsCache.js'
import {
OCPP20ResponseService,
type OCPPIncomingRequestService,
type OCPPRequestService,
- sendAndSetConnectorStatus
+ sendAndSetConnectorStatus,
} from './ocpp/index.js'
import { SharedLRUCache } from './SharedLRUCache.js'
public get wsConnectionUrl (): URL {
const wsConnectionBaseUrlStr = `${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
this.stationInfo?.supervisionUrlOcppConfiguration === true &&
isNotEmptyString(this.stationInfo.supervisionUrlOcppKey) &&
isNotEmptyString(getConfigurationKey(this, this.stationInfo.supervisionUrlOcppKey)?.value)
return new URL(
`${wsConnectionBaseUrlStr}${
!wsConnectionBaseUrlStr.endsWith('/') ? '/' : ''
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
}${this.stationInfo?.chargingStationId}`
)
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
isNaN(connectorAmperageLimitationLimit!)
? Number.POSITIVE_INFINITY
- : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- connectorAmperageLimitationLimit!,
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ : connectorAmperageLimitationLimit!,
isNaN(chargingStationChargingProfilesLimit)
? Number.POSITIVE_INFINITY
: chargingStationChargingProfilesLimit,
this.stationInfo?.autoRegister === false &&
logger.warn(
`${this.logPrefix()} Heartbeat interval configuration key not set, using default value: ${
- Constants.DEFAULT_HEARTBEAT_INTERVAL
+ Constants.DEFAULT_HEARTBEAT_INTERVAL.toString()
}`
)
return Constants.DEFAULT_HEARTBEAT_INTERVAL
)
} else {
logger.error(
- `${this.logPrefix()} Heartbeat interval set to ${heartbeatInterval}, not starting the heartbeat`
+ `${this.logPrefix()} Heartbeat interval set to ${heartbeatInterval.toString()}, not starting the heartbeat`
)
}
}
public startMeterValues (connectorId: number, interval: number): void {
if (connectorId === 0) {
- logger.error(`${this.logPrefix()} Trying to start MeterValues on connector id ${connectorId}`)
+ logger.error(`${this.logPrefix()} Trying to start MeterValues on connector id ${connectorId.toString()}`)
return
}
const connectorStatus = this.getConnectorStatus(connectorId)
if (connectorStatus == null) {
logger.error(
`${this.logPrefix()} Trying to start MeterValues on non existing connector id
- ${connectorId}`
+ ${connectorId.toString()}`
)
return
}
if (connectorStatus.transactionStarted === false) {
logger.error(
- `${this.logPrefix()} Trying to start MeterValues on connector id ${connectorId} with no transaction started`
+ `${this.logPrefix()} Trying to start MeterValues on connector id ${connectorId.toString()} with no transaction started`
)
return
} else if (
connectorStatus.transactionId == null
) {
logger.error(
- `${this.logPrefix()} Trying to start MeterValues on connector id ${connectorId} with no transaction id`
+ `${this.logPrefix()} Trying to start MeterValues on connector id ${connectorId.toString()} with no transaction id`
)
return
}
)
this.ocppRequestService
.requestHandler<MeterValuesRequest, MeterValuesResponse>(
- this,
- RequestCommand.METER_VALUES,
- {
- connectorId,
- transactionId: connectorStatus.transactionId,
- meterValue: [meterValue]
- }
- )
+ this,
+ RequestCommand.METER_VALUES,
+ {
+ connectorId,
+ transactionId: connectorStatus.transactionId,
+ meterValue: [meterValue],
+ }
+ )
.catch((error: unknown) => {
logger.error(
`${this.logPrefix()} Error while sending '${RequestCommand.METER_VALUES}':`,
logger.error(
`${this.logPrefix()} Charging station ${
StandardParametersKey.MeterValueSampleInterval
- } configuration set to ${interval}, not sending MeterValues`
+ } configuration set to ${interval.toString()}, not sending MeterValues`
)
}
}
public openWSConnection (
options?: WsOptions,
- params?: { closeOpened?: boolean, terminateOpened?: boolean }
+ params?: { closeOpened?: boolean; terminateOpened?: boolean }
): void {
options = {
handshakeTimeout: secondsToMilliseconds(this.getConnectionTimeout()),
...this.stationInfo?.wsOptions,
- ...options
+ ...options,
}
params = { ...{ closeOpened: false, terminateOpened: false }, ...params }
if (!checkChargingStation(this, this.logPrefix())) {
if (this.stationInfo?.supervisionUser != null && this.stationInfo.supervisionPassword != null) {
options.auth = `${this.stationInfo.supervisionUser}:${this.stationInfo.supervisionPassword}`
}
- if (params.closeOpened === true) {
+ if (params.closeOpened) {
this.closeWSConnection()
}
- if (params.terminateOpened === true) {
+ if (params.terminateOpened) {
this.terminateWSConnection()
}
this.wsConnection = new WebSocket(
this.wsConnectionUrl,
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`ocpp${this.stationInfo?.ocppVersion}`,
options
)
}
public getAutomaticTransactionGeneratorConfiguration ():
- | AutomaticTransactionGeneratorConfiguration
- | undefined {
+ | AutomaticTransactionGeneratorConfiguration
+ | undefined {
if (this.automaticTransactionGeneratorConfiguration == null) {
let automaticTransactionGeneratorConfiguration:
- | AutomaticTransactionGeneratorConfiguration
- | undefined
+ | AutomaticTransactionGeneratorConfiguration
+ | undefined
const stationTemplate = this.getTemplateFromFile()
const stationConfiguration = this.getConfigurationFromFile()
if (
}
this.automaticTransactionGeneratorConfiguration = {
...Constants.DEFAULT_ATG_CONFIGURATION,
- ...automaticTransactionGeneratorConfiguration
+ ...automaticTransactionGeneratorConfiguration,
}
}
return this.automaticTransactionGeneratorConfiguration
{
connectorId,
transactionId,
- meterValue: [transactionEndMeterValue]
+ meterValue: [transactionEndMeterValue],
}
)
}
return await this.ocppRequestService.requestHandler<
- Partial<StopTransactionRequest>,
- StopTransactionResponse
+ Partial<StopTransactionRequest>,
+ StopTransactionResponse
>(this, RequestCommand.STOP_TRANSACTION, {
transactionId,
meterStop: this.getEnergyActiveImportRegisterByTransactionId(transactionId, true),
- ...(reason != null && { reason })
+ ...(reason != null && { reason }),
})
}
const [messageType] = JSON.parse(message) as OutgoingRequest | Response | ErrorResponse
const isRequest = messageType === MessageType.CALL_MESSAGE
if (isRequest) {
- [, , commandName] = JSON.parse(message) as OutgoingRequest
+ ;[, , commandName] = JSON.parse(message) as OutgoingRequest
beginId = PerformanceStatistics.beginMeasure(commandName)
}
this.wsConnection?.send(message, (error?: Error) => {
.stationInfoPersistentConfiguration
): ChargingStationInfo | undefined {
let stationInfo: ChargingStationInfo | undefined
- if (stationInfoPersistentConfiguration === true) {
+ if (stationInfoPersistentConfiguration) {
stationInfo = this.getConfigurationFromFile()?.stationInfo
if (stationInfo != null) {
delete stationInfo.infoHash
}
private handleUnsupportedVersion (version: OCPPVersion | undefined): void {
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
const errorMsg = `Unsupported protocol version '${version}' configured in template file ${this.templateFile}`
logger.error(`${this.logPrefix()} ${errorMsg}`)
throw new BaseError(errorMsg)
this.bootNotificationResponse = {
currentTime: new Date(),
interval: millisecondsToSeconds(this.getHeartbeatInterval()),
- status: RegistrationStatusEnumType.ACCEPTED
+ status: RegistrationStatusEnumType.ACCEPTED,
}
}
}
}
if (getConfigurationKey(this, StandardParametersKey.HeartBeatInterval) == null) {
addConfigurationKey(this, StandardParametersKey.HeartBeatInterval, '0', {
- visible: false
+ visible: false,
})
}
if (
getConfigurationKey(this, this.stationInfo.supervisionUrlOcppKey) != null
) {
deleteConfigurationKey(this, this.stationInfo.supervisionUrlOcppKey, {
- save: false
+ save: false,
})
}
if (
}
} else {
for (const connectorId of this.connectors.keys()) {
- connectorsPhaseRotation.push(
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- getPhaseRotationValue(connectorId, this.getNumberOfPhases())!
- )
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ connectorsPhaseRotation.push(getPhaseRotationValue(connectorId, this.getNumberOfPhases())!)
}
}
addConfigurationKey(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
evseStatusConfiguration.connectorsStatus!.map((connectorStatus, connectorId) => [
connectorId,
- prepareConnectorStatus(connectorStatus)
+ prepareConnectorStatus(connectorStatus),
])
- )
+ ),
})
}
} else if (configuration.evsesStatus != null && configuration.connectorsStatus != null) {
this.logPrefix(),
this.templateFile
),
- availability: AvailabilityType.Operative
+ availability: AvailabilityType.Operative,
})
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
initializeConnectorsMapStatus(this.evses.get(evseId)!.connectors, this.logPrefix())
configurationKey: configurationData.configurationKey,
automaticTransactionGenerator: configurationData.automaticTransactionGenerator,
...(this.connectors.size > 0 && {
- connectorsStatus: configurationData.connectorsStatus
+ connectorsStatus: configurationData.connectorsStatus,
}),
...(this.evses.size > 0 && {
- evsesStatus: configurationData.evsesStatus
- })
+ evsesStatus: configurationData.evsesStatus,
+ }),
} satisfies ChargingStationConfiguration)
)
.digest('hex')
ocppPersistentConfiguration?: boolean
): ChargingStationOcppConfiguration | undefined {
const configurationKey = this.getConfigurationFromFile()?.configurationKey
- if (ocppPersistentConfiguration === true && Array.isArray(configurationKey)) {
+ if (ocppPersistentConfiguration && Array.isArray(configurationKey)) {
return { configurationKey }
}
return undefined
// Send BootNotification
do {
await this.ocppRequestService.requestHandler<
- BootNotificationRequest,
- BootNotificationResponse
+ BootNotificationRequest,
+ BootNotificationResponse
>(this, RequestCommand.BOOT_NOTIFICATION, this.bootNotificationRequest, {
- skipBufferingOnError: true
+ skipBufferingOnError: true,
})
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.bootNotificationResponse!.currentTime = convertToDate(
if (!this.isRegistered()) {
this.stationInfo?.registrationMaxRetries !== -1 && ++registrationRetryCount
await sleep(
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
this.bootNotificationResponse?.interval != null
? secondsToMilliseconds(this.bootNotificationResponse.interval)
: Constants.DEFAULT_BOOT_NOTIFICATION_INTERVAL
}
if (!this.isRegistered()) {
logger.error(
- `${this.logPrefix()} Registration failure: maximum retries reached (${registrationRetryCount}) or retry disabled (${
- this.stationInfo?.registrationMaxRetries
+ `${this.logPrefix()} Registration failure: maximum retries reached (${registrationRetryCount.toString()}) or retry disabled (${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ this.stationInfo?.registrationMaxRetries?.toString()
})`
)
}
this.reconnect()
.then(() => {
this.emit(ChargingStationEvents.updated)
+ return undefined
})
.catch((error: unknown) =>
logger.error(`${this.logPrefix()} Error while reconnecting:`, error)
// eslint-disable-next-line @typescript-eslint/no-base-to-string
request = JSON.parse(data.toString()) as IncomingRequest | Response | ErrorResponse
if (Array.isArray(request)) {
- [messageType] = request
+ ;[messageType] = request
// Check the type of message
switch (messageType) {
// Incoming Message
'Incoming message is not an array',
undefined,
{
- request
+ request,
}
)
}
} catch (error) {
if (!Array.isArray(request)) {
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
logger.error(`${this.logPrefix()} Incoming message '${request}' parsing error:`, error)
return
}
const [, messageId] = request
switch (messageType) {
case MessageType.CALL_MESSAGE:
- [, , commandName] = request as IncomingRequest
+ ;[, , commandName] = request as IncomingRequest
// Send error
await this.ocppRequestService.sendError(this, messageId, error as OCPPError, commandName)
break
case MessageType.CALL_ERROR_MESSAGE:
if (this.requests.has(messageId)) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- [, errorCallback, requestCommandName] = this.getCachedRequest(messageType, messageId)!
+ ;[, errorCallback, requestCommandName] = this.getCachedRequest(messageType, messageId)!
// Reject the deferred promise in case of error at response handling (rejecting an already fulfilled promise is a no-op)
errorCallback(error as OCPPError, false)
} else {
logger.warn(
`${this.logPrefix()} Error thrown at incoming OCPP command ${
commandName ?? requestCommandName ?? Constants.UNKNOWN_OCPP_COMMAND
- // eslint-disable-next-line @typescript-eslint/no-base-to-string
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
} message '${data.toString()}' handling is not an OCPPError:`,
error
)
logger.error(
`${this.logPrefix()} Incoming OCPP command '${
commandName ?? requestCommandName ?? Constants.UNKNOWN_OCPP_COMMAND
- // eslint-disable-next-line @typescript-eslint/no-base-to-string
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
}' message '${data.toString()}'${
this.requests.has(messageId)
? ` matching cached request '${JSON.stringify(
private async startMessageSequence (ATGStopAbsoluteDuration?: boolean): Promise<void> {
if (this.stationInfo?.autoRegister === true) {
await this.ocppRequestService.requestHandler<
- BootNotificationRequest,
- BootNotificationResponse
+ BootNotificationRequest,
+ BootNotificationResponse
>(this, RequestCommand.BOOT_NOTIFICATION, this.bootNotificationRequest, {
- skipBufferingOnError: true
+ skipBufferingOnError: true,
})
}
// Start WebSocket ping
}
if (this.stationInfo?.firmwareStatus === FirmwareStatus.Installing) {
await this.ocppRequestService.requestHandler<
- FirmwareStatusNotificationRequest,
- FirmwareStatusNotificationResponse
+ FirmwareStatusNotificationRequest,
+ FirmwareStatusNotificationResponse
>(this, RequestCommand.FIRMWARE_STATUS_NOTIFICATION, {
- status: FirmwareStatus.Installed
+ status: FirmwareStatus.Installed,
})
this.stationInfo.firmwareStatus = FirmwareStatus.Installed
}
): Promise<void> {
this.internalStopMessageSequence()
// Stop ongoing transactions
- stopTransactions === true && (await this.stopRunningTransactions(reason))
+ stopTransactions && (await this.stopRunningTransactions(reason))
if (this.hasEvses) {
for (const [evseId, evseStatus] of this.evses) {
if (evseId > 0) {
)
} else {
logger.error(
- `${this.logPrefix()} WebSocket ping interval set to ${webSocketPingInterval}, not starting the WebSocket ping`
+ `${this.logPrefix()} WebSocket ping interval set to ${webSocketPingInterval.toString()}, not starting the WebSocket ping`
)
}
}
Configuration.getSupervisionUrlDistribution()!
) &&
logger.warn(
- // eslint-disable-next-line @typescript-eslint/no-base-to-string
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-base-to-string
`${this.logPrefix()} Unknown supervision url distribution '${Configuration.getSupervisionUrlDistribution()}' in configuration from values '${SupervisionUrlDistribution.toString()}', defaulting to '${
SupervisionUrlDistribution.CHARGING_STATION_AFFINITY
}'`
`${this.logPrefix()} WebSocket connection retry in ${roundTo(
reconnectDelay,
2
- )}ms, timeout ${reconnectTimeout}ms`
+ ).toString()}ms, timeout ${reconnectTimeout.toString()}ms`
)
await sleep(reconnectDelay)
logger.error(
)
this.openWSConnection(
{
- handshakeTimeout: reconnectTimeout
+ handshakeTimeout: reconnectTimeout,
},
{ closeOpened: true }
)
} else if (this.stationInfo?.autoReconnectMaxRetries !== -1) {
logger.error(
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`${this.logPrefix()} WebSocket connection retries failure: maximum retries reached (${this.wsConnectionRetryCount.toString()}) or retries disabled (${this.stationInfo?.autoReconnectMaxRetries?.toString()})`
)
}
export let chargingStationWorker: object
if (Configuration.workerPoolInUse()) {
chargingStationWorker = new ThreadWorker<
- ChargingStationWorkerData,
- ChargingStationInfo | undefined
+ ChargingStationWorkerData,
+ ChargingStationInfo | undefined
>((data?: ChargingStationWorkerData): ChargingStationInfo | undefined => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const { index, templateFile, options } = data!
uuid,
event: WorkerMessageEvents.addedWorkerElement,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- data: chargingStation.stationInfo!
+ data: chargingStation.stationInfo!,
} satisfies WorkerMessage<ChargingStationInfo>)
} catch (error) {
parentPort?.postMessage({
event,
name: (error as Error).name,
message: (error as Error).message,
- stack: (error as Error).stack
- }
+ stack: (error as Error).stack,
+ },
} satisfies WorkerMessage<WorkerDataError>)
}
break
...{
readonly: false,
visible: true,
- reboot: false
+ reboot: false,
},
- ...options
+ ...options,
}
params = { ...{ overwrite: false, save: false }, ...params }
let keyFound = getConfigurationKey(chargingStation, key)
- if (keyFound != null && params.overwrite === true) {
+ if (keyFound != null && params.overwrite) {
deleteConfigurationKey(chargingStation, keyFound.key, {
- save: false
+ save: false,
})
keyFound = undefined
}
readonly: options.readonly!,
value,
visible: options.visible,
- reboot: options.reboot
+ reboot: options.reboot,
})
- params.save === true && chargingStation.saveOcppConfiguration()
+ params.save && chargingStation.saveOcppConfiguration()
} else {
logger.error(
`${chargingStation.logPrefix()} Trying to add an already existing configuration key: %j`,
chargingStation.ocppConfiguration.configurationKey.indexOf(keyFound),
1
)
- params.save === true && chargingStation.saveOcppConfiguration()
+ params.save && chargingStation.saveOcppConfiguration()
return deletedConfigurationKey
}
}
isDate,
isPast,
isWithinInterval,
- toDate
+ toDate,
} from 'date-fns'
import { maxTime } from 'date-fns/constants'
import { isEmpty } from 'rambda'
ReservationTerminationReason,
StandardParametersKey,
type SupportedFeatureProfiles,
- Voltage
+ Voltage,
} from '../types/index.js'
import {
ACElectricUtils,
isNotEmptyString,
isValidDate,
logger,
- secureRandom
+ secureRandom,
} from '../utils/index.js'
import type { ChargingStation } from './ChargingStation.js'
import { getConfigurationKey } from './ConfigurationKeyUtils.js'
chargePointModel: stationTemplate.chargePointModel,
chargePointVendor: stationTemplate.chargePointVendor,
...(stationTemplate.chargeBoxSerialNumberPrefix != null && {
- chargeBoxSerialNumber: stationTemplate.chargeBoxSerialNumberPrefix
+ chargeBoxSerialNumber: stationTemplate.chargeBoxSerialNumberPrefix,
}),
...(stationTemplate.chargePointSerialNumberPrefix != null && {
- chargePointSerialNumber: stationTemplate.chargePointSerialNumberPrefix
+ chargePointSerialNumber: stationTemplate.chargePointSerialNumberPrefix,
}),
...(stationTemplate.meterSerialNumberPrefix != null && {
- meterSerialNumber: stationTemplate.meterSerialNumberPrefix
+ meterSerialNumber: stationTemplate.meterSerialNumberPrefix,
}),
...(stationTemplate.meterType != null && {
- meterType: stationTemplate.meterType
- })
+ meterType: stationTemplate.meterType,
+ }),
}
return createHash(Constants.DEFAULT_HASH_ALGORITHM)
.update(`${JSON.stringify(chargingStationInfo)}${getChargingStationId(index, stationTemplate)}`)
): string | undefined => {
// AC/DC
if (connectorId === 0 && numberOfPhases === 0) {
- return `${connectorId}.${ConnectorPhaseRotation.RST}`
+ return `${connectorId.toString()}.${ConnectorPhaseRotation.RST}`
} else if (connectorId > 0 && numberOfPhases === 0) {
- return `${connectorId}.${ConnectorPhaseRotation.NotApplicable}`
+ return `${connectorId.toString()}.${ConnectorPhaseRotation.NotApplicable}`
// AC
} else if (connectorId >= 0 && numberOfPhases === 1) {
- return `${connectorId}.${ConnectorPhaseRotation.NotApplicable}`
+ return `${connectorId.toString()}.${ConnectorPhaseRotation.NotApplicable}`
} else if (connectorId >= 0 && numberOfPhases === 3) {
- return `${connectorId}.${ConnectorPhaseRotation.RST}`
+ return `${connectorId.toString()}.${ConnectorPhaseRotation.RST}`
}
}
return {
configuredMaxConnectors,
templateMaxConnectors,
- templateMaxAvailableConnectors
+ templateMaxAvailableConnectors,
}
}
): void => {
if (connectorStatus.status != null) {
logger.warn(
- `${logPrefix} Charging station information from template ${templateFile} with connector id ${connectorId} status configuration defined, undefine it`
+ `${logPrefix} Charging station information from template ${templateFile} with connector id ${connectorId.toString()} status configuration defined, undefine it`
)
delete connectorStatus.status
}
for (const connectorId of connectors.keys()) {
if (connectorId > 0 && connectors.get(connectorId)?.transactionStarted === true) {
logger.warn(
- `${logPrefix} Connector id ${connectorId} at initialization has a transaction started with id ${
- connectors.get(connectorId)?.transactionId
+ `${logPrefix} Connector id ${connectorId.toString()} at initialization has a transaction started with id ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ connectors.get(connectorId)?.transactionId?.toString()
}`
)
}
chargePointModel: stationInfo.chargePointModel,
chargePointVendor: stationInfo.chargePointVendor,
...(stationInfo.chargeBoxSerialNumber != null && {
- chargeBoxSerialNumber: stationInfo.chargeBoxSerialNumber
+ chargeBoxSerialNumber: stationInfo.chargeBoxSerialNumber,
}),
...(stationInfo.chargePointSerialNumber != null && {
- chargePointSerialNumber: stationInfo.chargePointSerialNumber
+ chargePointSerialNumber: stationInfo.chargePointSerialNumber,
}),
...(stationInfo.firmwareVersion != null && {
- firmwareVersion: stationInfo.firmwareVersion
+ firmwareVersion: stationInfo.firmwareVersion,
}),
...(stationInfo.iccid != null && { iccid: stationInfo.iccid }),
...(stationInfo.imsi != null && { imsi: stationInfo.imsi }),
...(stationInfo.meterSerialNumber != null && {
- meterSerialNumber: stationInfo.meterSerialNumber
+ meterSerialNumber: stationInfo.meterSerialNumber,
}),
...(stationInfo.meterType != null && {
- meterType: stationInfo.meterType
- })
+ meterType: stationInfo.meterType,
+ }),
} satisfies OCPP16BootNotificationRequest
case OCPPVersion.VERSION_20:
case OCPPVersion.VERSION_201:
model: stationInfo.chargePointModel,
vendorName: stationInfo.chargePointVendor,
...(stationInfo.firmwareVersion != null && {
- firmwareVersion: stationInfo.firmwareVersion
+ firmwareVersion: stationInfo.firmwareVersion,
}),
...(stationInfo.chargeBoxSerialNumber != null && {
- serialNumber: stationInfo.chargeBoxSerialNumber
+ serialNumber: stationInfo.chargeBoxSerialNumber,
}),
...((stationInfo.iccid != null || stationInfo.imsi != null) && {
modem: {
...(stationInfo.iccid != null && { iccid: stationInfo.iccid }),
- ...(stationInfo.imsi != null && { imsi: stationInfo.imsi })
- }
- })
- }
+ ...(stationInfo.imsi != null && { imsi: stationInfo.imsi }),
+ },
+ }),
+ },
} satisfies OCPP20BootNotificationRequest
}
}
logPrefix: string,
templateFile: string
): void => {
- const templateKeys: Array<{ deprecatedKey: string, key?: string }> = [
+ const templateKeys: { deprecatedKey: string; key?: string }[] = [
{ deprecatedKey: 'supervisionUrl', key: 'supervisionUrls' },
{ deprecatedKey: 'authorizationFile', key: 'idTagsFile' },
{ deprecatedKey: 'payloadSchemaValidation', key: 'ocppStrictCompliance' },
- { deprecatedKey: 'mustAuthorizeAtRemoteStart', key: 'remoteAuthorization' }
+ { deprecatedKey: 'mustAuthorizeAtRemoteStart', key: 'remoteAuthorization' },
]
for (const templateKey of templateKeys) {
warnDeprecatedTemplateKey(
): void => {
params = {
...{ randomSerialNumberUpperCase: true, randomSerialNumber: true },
- ...params
+ ...params,
}
- const serialNumberSuffix =
- params.randomSerialNumber === true
- ? getRandomSerialNumberSuffix({
- upperCase: params.randomSerialNumberUpperCase
- })
- : ''
+ const serialNumberSuffix = params.randomSerialNumber
+ ? getRandomSerialNumberSuffix({
+ upperCase: params.randomSerialNumberUpperCase,
+ })
+ : ''
isNotEmptyString(stationTemplate.chargePointSerialNumberPrefix) &&
(stationInfo.chargePointSerialNumber = `${stationTemplate.chargePointSerialNumberPrefix}${serialNumberSuffix}`)
isNotEmptyString(stationTemplate.chargeBoxSerialNumberPrefix) &&
if (limit > chargingStationMaximumPower) {
logger.error(
`${chargingStation.logPrefix()} ${moduleName}.getChargingStationChargingProfilesLimit: Charging profile id ${
- chargingProfilesLimit.chargingProfile.chargingProfileId
- } limit ${limit} is greater than charging station maximum ${chargingStationMaximumPower}: %j`,
+ chargingProfilesLimit.chargingProfile.chargingProfileId.toString()
+ } limit ${limit.toString()} is greater than charging station maximum ${chargingStationMaximumPower.toString()}: %j`,
chargingProfilesLimit
)
return chargingStationMaximumPower
/**
* Gets the connector charging profiles relevant for power limitation shallow cloned
* and sorted by priorities
- *
* @param chargingStation - Charging station
* @param connectorId - Connector id
* @returns connector charging profiles array
if (limit > connectorMaximumPower) {
logger.error(
`${chargingStation.logPrefix()} ${moduleName}.getConnectorChargingProfilesLimit: Charging profile id ${
- chargingProfilesLimit.chargingProfile.chargingProfileId
- } limit ${limit} is greater than connector ${connectorId} maximum ${connectorMaximumPower}: %j`,
+ chargingProfilesLimit.chargingProfile.chargingProfileId.toString()
+ } limit ${limit.toString()} is greater than connector ${connectorId.toString()} maximum ${connectorMaximumPower.toString()}: %j`,
chargingProfilesLimit
)
return connectorMaximumPower
chargingStation: ChargingStation,
chargingProfilesLimit: ChargingProfilesLimit
): number => {
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
const errorMsg = `Unknown ${chargingStation.stationInfo?.currentOutType} currentOutType in charging station information, cannot build charging profiles limit`
const { limit, chargingProfile } = chargingProfilesLimit
switch (chargingStation.stationInfo?.currentOutType) {
case CurrentType.DC:
return chargingProfile.chargingSchedule.chargingRateUnit === ChargingRateUnitType.WATT
? limit
- : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- DCElectricUtils.power(chargingStation.stationInfo.voltageOut!, limit)
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ : DCElectricUtils.power(chargingStation.stationInfo.voltageOut!, limit)
default:
logger.error(
`${chargingStation.logPrefix()} ${moduleName}.buildChargingProfilesLimit: ${errorMsg}`
): void => {
if (configuredMaxConnectors <= 0) {
logger.warn(
- `${logPrefix} Charging station information from template ${templateFile} with ${configuredMaxConnectors} connectors`
+ `${logPrefix} Charging station information from template ${templateFile} with ${configuredMaxConnectors.toString()} connectors`
)
}
}
): void => {
if (template[deprecatedKey as keyof ChargingStationTemplate] != null) {
if (key != null) {
- (template as unknown as Record<string, unknown>)[key] =
+ ;(template as unknown as Record<string, unknown>)[key] =
template[deprecatedKey as keyof ChargingStationTemplate]
}
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
/**
* Get the charging profiles limit for a connector
* Charging profiles shall already be sorted by priorities
- *
* @param chargingStation -
* @param connectorId -
* @param chargingProfiles -
const chargingSchedule = chargingProfile.chargingSchedule
if (chargingSchedule.startSchedule == null) {
logger.debug(
- `${chargingStation.logPrefix()} ${moduleName}.getChargingProfilesLimit: Charging profile id ${chargingProfile.chargingProfileId} has no startSchedule defined. Trying to set it to the connector current transaction start date`
+ `${chargingStation.logPrefix()} ${moduleName}.getChargingProfilesLimit: Charging profile id ${chargingProfile.chargingProfileId.toString()} has no startSchedule defined. Trying to set it to the connector current transaction start date`
)
// OCPP specifies that if startSchedule is not defined, it should be relative to start of the connector transaction
chargingSchedule.startSchedule = connectorStatus?.transactionStart
}
if (!isDate(chargingSchedule.startSchedule)) {
logger.warn(
- `${chargingStation.logPrefix()} ${moduleName}.getChargingProfilesLimit: Charging profile id ${chargingProfile.chargingProfileId} startSchedule property is not a Date instance. Trying to convert it to a Date instance`
+ `${chargingStation.logPrefix()} ${moduleName}.getChargingProfilesLimit: Charging profile id ${chargingProfile.chargingProfileId.toString()} startSchedule property is not a Date instance. Trying to convert it to a Date instance`
)
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
chargingSchedule.startSchedule = convertToDate(chargingSchedule.startSchedule)!
}
if (chargingSchedule.duration == null) {
logger.debug(
- `${chargingStation.logPrefix()} ${moduleName}.getChargingProfilesLimit: Charging profile id ${chargingProfile.chargingProfileId} has no duration defined and will be set to the maximum time allowed`
+ `${chargingStation.logPrefix()} ${moduleName}.getChargingProfilesLimit: Charging profile id ${chargingProfile.chargingProfileId.toString()} has no duration defined and will be set to the maximum time allowed`
)
// OCPP specifies that if duration is not defined, it should be infinite
chargingSchedule.duration = differenceInSeconds(maxTime, chargingSchedule.startSchedule)
if (
isWithinInterval(currentDate, {
start: chargingSchedule.startSchedule,
- end: addSeconds(chargingSchedule.startSchedule, chargingSchedule.duration)
+ end: addSeconds(chargingSchedule.startSchedule, chargingSchedule.duration),
})
) {
if (isNotEmptyArray(chargingSchedule.chargingSchedulePeriod)) {
)
) {
logger.warn(
- `${chargingStation.logPrefix()} ${moduleName}.getChargingProfilesLimit: Charging profile id ${chargingProfile.chargingProfileId} schedule periods are not sorted by start period`
+ `${chargingStation.logPrefix()} ${moduleName}.getChargingProfilesLimit: Charging profile id ${chargingProfile.chargingProfileId.toString()} schedule periods are not sorted by start period`
)
chargingSchedule.chargingSchedulePeriod.sort(chargingSchedulePeriodCompareFn)
}
// Check if the first schedule period startPeriod property is equal to 0
if (chargingSchedule.chargingSchedulePeriod[0].startPeriod !== 0) {
logger.error(
- `${chargingStation.logPrefix()} ${moduleName}.getChargingProfilesLimit: Charging profile id ${chargingProfile.chargingProfileId} first schedule period start period ${chargingSchedule.chargingSchedulePeriod[0].startPeriod} is not equal to 0`
+ `${chargingStation.logPrefix()} ${moduleName}.getChargingProfilesLimit: Charging profile id ${chargingProfile.chargingProfileId.toString()} first schedule period start period ${chargingSchedule.chargingSchedulePeriod[0].startPeriod.toString()} is not equal to 0`
)
continue
}
if (chargingSchedule.chargingSchedulePeriod.length === 1) {
const chargingProfilesLimit: ChargingProfilesLimit = {
limit: chargingSchedule.chargingSchedulePeriod[0].limit,
- chargingProfile
+ chargingProfile,
}
logger.debug(debugLogMsg, chargingProfilesLimit)
return chargingProfilesLimit
// Search for the right schedule period
for (const [
index,
- chargingSchedulePeriod
+ chargingSchedulePeriod,
] of chargingSchedule.chargingSchedulePeriod.entries()) {
// Find the right schedule period
if (
// Found the schedule period: previous is the correct one
const chargingProfilesLimit: ChargingProfilesLimit = {
limit: previousChargingSchedulePeriod?.limit ?? chargingSchedulePeriod.limit,
- chargingProfile: previousActiveChargingProfile ?? chargingProfile
+ chargingProfile: previousActiveChargingProfile ?? chargingProfile,
}
logger.debug(debugLogMsg, chargingProfilesLimit)
return chargingProfilesLimit
) {
const chargingProfilesLimit: ChargingProfilesLimit = {
limit: chargingSchedulePeriod.limit,
- chargingProfile
+ chargingProfile,
}
logger.debug(debugLogMsg, chargingProfilesLimit)
return chargingProfilesLimit
case ChargingProfileKindType.RELATIVE:
if (chargingProfile.chargingSchedule.startSchedule != null) {
logger.warn(
- `${logPrefix} ${moduleName}.prepareChargingProfileKind: Relative charging profile id ${chargingProfile.chargingProfileId} has a startSchedule property defined. It will be ignored or used if the connector has a transaction started`
+ `${logPrefix} ${moduleName}.prepareChargingProfileKind: Relative charging profile id ${chargingProfile.chargingProfileId.toString()} has a startSchedule property defined. It will be ignored or used if the connector has a transaction started`
)
delete chargingProfile.chargingSchedule.startSchedule
}
) {
logger.debug(
`${logPrefix} ${moduleName}.canProceedChargingProfile: Charging profile id ${
- chargingProfile.chargingProfileId
+ chargingProfile.chargingProfileId.toString()
} is not valid for the current date ${
- isDate(currentDate) ? currentDate.toISOString() : currentDate
+ isDate(currentDate) ? currentDate.toISOString() : currentDate.toString()
}`
)
return false
chargingProfile.chargingSchedule.duration == null
) {
logger.error(
- `${logPrefix} ${moduleName}.canProceedChargingProfile: Charging profile id ${chargingProfile.chargingProfileId} has no startSchedule or duration defined`
+ `${logPrefix} ${moduleName}.canProceedChargingProfile: Charging profile id ${chargingProfile.chargingProfileId.toString()} has no startSchedule or duration defined`
)
return false
}
if (!isValidDate(chargingProfile.chargingSchedule.startSchedule)) {
logger.error(
- `${logPrefix} ${moduleName}.canProceedChargingProfile: Charging profile id ${chargingProfile.chargingProfileId} has an invalid startSchedule date defined`
+ `${logPrefix} ${moduleName}.canProceedChargingProfile: Charging profile id ${chargingProfile.chargingProfileId.toString()} has an invalid startSchedule date defined`
)
return false
}
if (!Number.isSafeInteger(chargingProfile.chargingSchedule.duration)) {
logger.error(
- `${logPrefix} ${moduleName}.canProceedChargingProfile: Charging profile id ${chargingProfile.chargingProfileId} has non integer duration defined`
+ `${logPrefix} ${moduleName}.canProceedChargingProfile: Charging profile id ${chargingProfile.chargingProfileId.toString()} has non integer duration defined`
)
return false
}
chargingProfile.recurrencyKind == null
) {
logger.error(
- `${logPrefix} ${moduleName}.canProceedRecurringChargingProfile: Recurring charging profile id ${chargingProfile.chargingProfileId} has no recurrencyKind defined`
+ `${logPrefix} ${moduleName}.canProceedRecurringChargingProfile: Recurring charging profile id ${chargingProfile.chargingProfileId.toString()} has no recurrencyKind defined`
)
return false
}
chargingProfile.chargingSchedule.startSchedule == null
) {
logger.error(
- `${logPrefix} ${moduleName}.canProceedRecurringChargingProfile: Recurring charging profile id ${chargingProfile.chargingProfileId} has no startSchedule defined`
+ `${logPrefix} ${moduleName}.canProceedRecurringChargingProfile: Recurring charging profile id ${chargingProfile.chargingProfileId.toString()} has no startSchedule defined`
)
return false
}
/**
* Adjust recurring charging profile startSchedule to the current recurrency time interval if needed
- *
* @param chargingProfile -
* @param currentDate -
* @param logPrefix -
+ * @returns boolean
*/
const prepareRecurringChargingProfile = (
chargingProfile: ChargingProfile,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
start: chargingSchedule.startSchedule!,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- end: addDays(chargingSchedule.startSchedule!, 1)
+ end: addDays(chargingSchedule.startSchedule!, 1),
}
checkRecurringChargingProfileDuration(chargingProfile, recurringInterval, logPrefix)
if (
)
recurringInterval = {
start: chargingSchedule.startSchedule,
- end: addDays(chargingSchedule.startSchedule, 1)
+ end: addDays(chargingSchedule.startSchedule, 1),
}
recurringIntervalTranslated = true
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
start: chargingSchedule.startSchedule!,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- end: addWeeks(chargingSchedule.startSchedule!, 1)
+ end: addWeeks(chargingSchedule.startSchedule!, 1),
}
checkRecurringChargingProfileDuration(chargingProfile, recurringInterval, logPrefix)
if (
)
recurringInterval = {
start: chargingSchedule.startSchedule,
- end: addWeeks(chargingSchedule.startSchedule, 1)
+ end: addWeeks(chargingSchedule.startSchedule, 1),
}
recurringIntervalTranslated = true
}
break
default:
logger.error(
- `${logPrefix} ${moduleName}.prepareRecurringChargingProfile: Recurring ${chargingProfile.recurrencyKind} charging profile id ${chargingProfile.chargingProfileId} is not supported`
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ `${logPrefix} ${moduleName}.prepareRecurringChargingProfile: Recurring ${chargingProfile.recurrencyKind} charging profile id ${chargingProfile.chargingProfileId.toString()} is not supported`
)
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
if (recurringIntervalTranslated && !isWithinInterval(currentDate, recurringInterval!)) {
logger.error(
`${logPrefix} ${moduleName}.prepareRecurringChargingProfile: Recurring ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
chargingProfile.recurrencyKind
- } charging profile id ${chargingProfile.chargingProfileId} recurrency time interval [${toDate(
+ } charging profile id ${chargingProfile.chargingProfileId.toString()} recurrency time interval [${toDate(
recurringInterval?.start as Date
).toISOString()}, ${toDate(
recurringInterval?.end as Date
).toISOString()}] has not been properly translated to current date ${
- isDate(currentDate) ? currentDate.toISOString() : currentDate
+ isDate(currentDate) ? currentDate.toISOString() : currentDate.toString()
} `
)
}
`${logPrefix} ${moduleName}.checkRecurringChargingProfileDuration: Recurring ${
chargingProfile.chargingProfileKind
} charging profile id ${
- chargingProfile.chargingProfileId
+ chargingProfile.chargingProfileId.toString()
} duration is not defined, set it to the recurrency time interval duration ${differenceInSeconds(
interval.end,
interval.start
- )}`
+ ).toString()}`
)
chargingProfile.chargingSchedule.duration = differenceInSeconds(interval.end, interval.start)
} else if (
logger.warn(
`${logPrefix} ${moduleName}.checkRecurringChargingProfileDuration: Recurring ${
chargingProfile.chargingProfileKind
- } charging profile id ${chargingProfile.chargingProfileId} duration ${
- chargingProfile.chargingSchedule.duration
+ } charging profile id ${chargingProfile.chargingProfileId.toString()} duration ${
+ chargingProfile.chargingSchedule.duration.toString()
} is greater than the recurrency time interval duration ${differenceInSeconds(
interval.end,
interval.start
- )}`
+ ).toString()}`
)
chargingProfile.chargingSchedule.duration = differenceInSeconds(interval.end, interval.start)
}
randomBytesLength?: number
upperCase?: boolean
}): string => {
- const randomSerialNumberSuffix = randomBytes(params?.randomBytesLength ?? 16).toString('hex')
- if (params?.upperCase === true) {
+ const randomSerialNumberSuffix = randomBytes(params.randomBytesLength ?? 16).toString('hex')
+ if (params.upperCase) {
return randomSerialNumberSuffix.toUpperCase()
}
return randomSerialNumberSuffix
logger,
logPrefix,
secureRandom,
- watchJsonFile
+ watchJsonFile,
} from '../utils/index.js'
import type { ChargingStation } from './ChargingStation.js'
import { getIdTagsFile } from './Helpers.js'
/**
* Gets one idtag from the cache given the distribution
* Must be called after checking the cache is not an empty array
- *
* @param distribution -
* @param chargingStation -
* @param connectorId -
- * @returns
+ * @returns string
*/
public getIdTag (
distribution: IdTagDistribution,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const hashId = chargingStation.stationInfo!.hashId
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- const idTagsFile = getIdTagsFile(chargingStation.stationInfo!)!
+ const idTagsFile = getIdTagsFile(chargingStation.stationInfo)!
switch (distribution) {
case IdTagDistribution.RANDOM:
return this.getRandomIdTag(hashId, idTagsFile)
/**
* Gets all idtags from the cache
* Must be called after checking the cache is not an empty array
- *
* @param file -
- * @returns
+ * @returns string[] | undefined
*/
public getIdTags (file: string): string[] | undefined {
if (!this.hasIdTagsCache(file)) {
error as NodeJS.ErrnoException,
this.logPrefix(file),
{
- throwError: false
+ throwError: false,
}
)
}
}
}
- )
+ ),
})
}
type StatusNotificationRequest,
type StatusNotificationResponse,
type StopTransactionRequest,
- type StopTransactionResponse
+ type StopTransactionResponse,
} from '../../types/index.js'
import { Constants, convertToInt, isAsyncFunction, logger } from '../../utils/index.js'
import type { ChargingStation } from '../ChargingStation.js'
constructor (chargingStation: ChargingStation) {
super()
const requestParams: RequestParams = {
- throwError: true
+ throwError: true,
}
this.commandHandlers = new Map<BroadcastChannelProcedureName, CommandHandler>([
[
BroadcastChannelProcedureName.START_CHARGING_STATION,
() => {
this.chargingStation.start()
- }
+ },
],
[
BroadcastChannelProcedureName.STOP_CHARGING_STATION,
async () => {
await this.chargingStation.stop()
- }
+ },
],
[
BroadcastChannelProcedureName.DELETE_CHARGING_STATIONS,
async (requestPayload?: BroadcastChannelRequestPayload) => {
await this.chargingStation.delete(requestPayload?.deleteConfiguration as boolean)
- }
+ },
],
[
BroadcastChannelProcedureName.OPEN_CONNECTION,
() => {
this.chargingStation.openWSConnection()
- }
+ },
],
[
BroadcastChannelProcedureName.CLOSE_CONNECTION,
() => {
this.chargingStation.closeWSConnection()
- }
+ },
],
[
BroadcastChannelProcedureName.START_AUTOMATIC_TRANSACTION_GENERATOR,
(requestPayload?: BroadcastChannelRequestPayload) => {
this.chargingStation.startAutomaticTransactionGenerator(requestPayload?.connectorIds)
- }
+ },
],
[
BroadcastChannelProcedureName.STOP_AUTOMATIC_TRANSACTION_GENERATOR,
(requestPayload?: BroadcastChannelRequestPayload) => {
this.chargingStation.stopAutomaticTransactionGenerator(requestPayload?.connectorIds)
- }
+ },
],
[
BroadcastChannelProcedureName.SET_SUPERVISION_URL,
(requestPayload?: BroadcastChannelRequestPayload) => {
this.chargingStation.setSupervisionUrl(requestPayload?.url as string)
- }
+ },
],
[
BroadcastChannelProcedureName.START_TRANSACTION,
async (requestPayload?: BroadcastChannelRequestPayload) =>
await this.chargingStation.ocppRequestService.requestHandler<
- StartTransactionRequest,
- StartTransactionResponse
- >(this.chargingStation, RequestCommand.START_TRANSACTION, requestPayload, requestParams)
+ StartTransactionRequest,
+ StartTransactionResponse
+ >(this.chargingStation, RequestCommand.START_TRANSACTION, requestPayload as StartTransactionRequest, requestParams),
],
[
BroadcastChannelProcedureName.STOP_TRANSACTION,
async (requestPayload?: BroadcastChannelRequestPayload) =>
await this.chargingStation.ocppRequestService.requestHandler<
- StopTransactionRequest,
- StartTransactionResponse
+ StopTransactionRequest,
+ StartTransactionResponse
>(
this.chargingStation,
RequestCommand.STOP_TRANSACTION,
requestPayload?.transactionId,
true
),
- ...requestPayload
- },
+ ...requestPayload,
+ } as StopTransactionRequest,
requestParams
- )
+ ),
],
[
BroadcastChannelProcedureName.AUTHORIZE,
async (requestPayload?: BroadcastChannelRequestPayload) =>
await this.chargingStation.ocppRequestService.requestHandler<
- AuthorizeRequest,
- AuthorizeResponse
- >(this.chargingStation, RequestCommand.AUTHORIZE, requestPayload, requestParams)
+ AuthorizeRequest,
+ AuthorizeResponse
+ >(this.chargingStation, RequestCommand.AUTHORIZE, requestPayload as AuthorizeRequest, requestParams),
],
[
BroadcastChannelProcedureName.BOOT_NOTIFICATION,
async (requestPayload?: BroadcastChannelRequestPayload) => {
return await this.chargingStation.ocppRequestService.requestHandler<
- BootNotificationRequest,
- BootNotificationResponse
+ BootNotificationRequest,
+ BootNotificationResponse
>(
this.chargingStation,
RequestCommand.BOOT_NOTIFICATION,
{
...this.chargingStation.bootNotificationRequest,
- ...requestPayload
- },
+ ...requestPayload,
+ } as BootNotificationRequest,
{
skipBufferingOnError: true,
- throwError: true
+ throwError: true,
}
)
- }
+ },
],
[
BroadcastChannelProcedureName.STATUS_NOTIFICATION,
async (requestPayload?: BroadcastChannelRequestPayload) =>
await this.chargingStation.ocppRequestService.requestHandler<
- StatusNotificationRequest,
- StatusNotificationResponse
- >(this.chargingStation, RequestCommand.STATUS_NOTIFICATION, requestPayload, requestParams)
+ StatusNotificationRequest,
+ StatusNotificationResponse
+ >(
+ this.chargingStation,
+ RequestCommand.STATUS_NOTIFICATION,
+ requestPayload as StatusNotificationRequest,
+ requestParams
+ ),
],
[
BroadcastChannelProcedureName.HEARTBEAT,
async (requestPayload?: BroadcastChannelRequestPayload) =>
await this.chargingStation.ocppRequestService.requestHandler<
- HeartbeatRequest,
- HeartbeatResponse
- >(this.chargingStation, RequestCommand.HEARTBEAT, requestPayload, requestParams)
+ HeartbeatRequest,
+ HeartbeatResponse
+ >(this.chargingStation, RequestCommand.HEARTBEAT, requestPayload as HeartbeatRequest, requestParams),
],
[
BroadcastChannelProcedureName.METER_VALUES,
StandardParametersKey.MeterValueSampleInterval
)
return await this.chargingStation.ocppRequestService.requestHandler<
- MeterValuesRequest,
- MeterValuesResponse
+ MeterValuesRequest,
+ MeterValuesResponse
>(
this.chargingStation,
RequestCommand.METER_VALUES,
configuredMeterValueSampleInterval != null
? secondsToMilliseconds(convertToInt(configuredMeterValueSampleInterval.value))
: Constants.DEFAULT_METER_VALUES_INTERVAL
- )
+ ),
],
- ...requestPayload
- },
+ ...requestPayload,
+ } as MeterValuesRequest,
requestParams
)
- }
+ },
],
[
BroadcastChannelProcedureName.DATA_TRANSFER,
async (requestPayload?: BroadcastChannelRequestPayload) =>
await this.chargingStation.ocppRequestService.requestHandler<
- DataTransferRequest,
- DataTransferResponse
- >(this.chargingStation, RequestCommand.DATA_TRANSFER, requestPayload, requestParams)
+ DataTransferRequest,
+ DataTransferResponse
+ >(this.chargingStation, RequestCommand.DATA_TRANSFER, requestPayload as DataTransferRequest, requestParams),
],
[
BroadcastChannelProcedureName.DIAGNOSTICS_STATUS_NOTIFICATION,
async (requestPayload?: BroadcastChannelRequestPayload) =>
await this.chargingStation.ocppRequestService.requestHandler<
- DiagnosticsStatusNotificationRequest,
- DiagnosticsStatusNotificationResponse
+ DiagnosticsStatusNotificationRequest,
+ DiagnosticsStatusNotificationResponse
>(
this.chargingStation,
RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION,
- requestPayload,
+ requestPayload as DiagnosticsStatusNotificationRequest,
requestParams
- )
+ ),
],
[
BroadcastChannelProcedureName.FIRMWARE_STATUS_NOTIFICATION,
async (requestPayload?: BroadcastChannelRequestPayload) =>
await this.chargingStation.ocppRequestService.requestHandler<
- FirmwareStatusNotificationRequest,
- FirmwareStatusNotificationResponse
+ FirmwareStatusNotificationRequest,
+ FirmwareStatusNotificationResponse
>(
this.chargingStation,
RequestCommand.FIRMWARE_STATUS_NOTIFICATION,
- requestPayload,
+ requestPayload as FirmwareStatusNotificationRequest,
requestParams
- )
- ]
+ ),
+ ],
])
this.chargingStation = chargingStation
this.onmessage = this.requestHandler.bind(this) as (message: unknown) => void
if (commandResponse == null || isEmpty(commandResponse)) {
responsePayload = {
hashId: this.chargingStation.stationInfo?.hashId,
- status: ResponseStatus.SUCCESS
+ status: ResponseStatus.SUCCESS,
}
} else {
responsePayload = this.commandResponseToResponsePayload(
commandResponse
)
}
+ return undefined
+ })
+ .finally(() => {
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ this.sendResponse([uuid, responsePayload!])
})
.catch((error: unknown) => {
logger.error(
requestPayload,
errorMessage: (error as OCPPError).message,
errorStack: (error as OCPPError).stack,
- errorDetails: (error as OCPPError).details
+ errorDetails: (error as OCPPError).details,
} satisfies BroadcastChannelResponsePayload
})
- .finally(() => {
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- this.sendResponse([uuid, responsePayload!])
- })
}
private messageErrorHandler (messageEvent: MessageEvent): void {
delete requestPayload.hashIds
![
BroadcastChannelProcedureName.START_AUTOMATIC_TRANSACTION_GENERATOR,
- BroadcastChannelProcedureName.STOP_AUTOMATIC_TRANSACTION_GENERATOR
+ BroadcastChannelProcedureName.STOP_AUTOMATIC_TRANSACTION_GENERATOR,
].includes(command) && delete requestPayload.connectorIds
}
if (responseStatus === ResponseStatus.SUCCESS) {
return {
hashId: this.chargingStation.stationInfo?.hashId,
- status: responseStatus
+ status: responseStatus,
}
}
return {
status: responseStatus,
command,
requestPayload,
- commandResponse
+ commandResponse,
}
}
case BroadcastChannelProcedureName.START_TRANSACTION:
case BroadcastChannelProcedureName.STOP_TRANSACTION:
case BroadcastChannelProcedureName.AUTHORIZE:
- if (
- (
- commandResponse as
- | StartTransactionResponse
- | StopTransactionResponse
- | AuthorizeResponse
- ).idTagInfo?.status === AuthorizationStatus.ACCEPTED
- ) {
+ if ((commandResponse as
+ | StartTransactionResponse
+ | StopTransactionResponse
+ | AuthorizeResponse).idTagInfo?.status === AuthorizationStatus.ACCEPTED) {
return ResponseStatus.SUCCESS
}
return ResponseStatus.FAILURE
type BroadcastChannelResponsePayload,
type MessageEvent,
type ResponsePayload,
- ResponseStatus
+ ResponseStatus,
} from '../../types/index.js'
import { logger } from '../../utils/index.js'
import type { AbstractUIService } from '../ui-server/ui-services/AbstractUIService.js'
this.responses.set(uuid, {
responsesExpected: this.uiService.getBroadcastChannelExpectedResponses(uuid),
responsesReceived: 1,
- responses: [responsePayload]
+ responses: [responsePayload],
})
} else if (
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
}
return undefined
})
- .filter(hashId => hashId != null)!
+ .filter(hashId => hashId != null)!,
}),
...(responsesStatus === ResponseStatus.FAILURE && {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
}
return undefined
})
- .filter(response => response != null)!
- })
+ .filter(response => response != null)!,
+ }),
}
}
BroadcastChannelRequest,
BroadcastChannelResponse,
JsonType,
- MessageEvent
+ MessageEvent,
} from '../../types/index.js'
import { logger, logPrefix, validateUUID } from '../../utils/index.js'
export {
addConfigurationKey,
getConfigurationKey,
- setConfigurationKeyValue
+ setConfigurationKeyValue,
} from './ConfigurationKeyUtils.js'
export {
canProceedChargingProfile,
prepareChargingProfileKind,
removeExpiredReservations,
resetAuthorizeConnectorStatus,
- resetConnectorStatus
+ resetConnectorStatus,
} from './Helpers.js'
// { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Available },
{
from: OCPP16ChargePointStatus.Available,
- to: OCPP16ChargePointStatus.Unavailable
+ to: OCPP16ChargePointStatus.Unavailable,
},
{
from: OCPP16ChargePointStatus.Available,
- to: OCPP16ChargePointStatus.Faulted
+ to: OCPP16ChargePointStatus.Faulted,
},
{ to: OCPP16ChargePointStatus.Unavailable },
{
from: OCPP16ChargePointStatus.Unavailable,
- to: OCPP16ChargePointStatus.Available
+ to: OCPP16ChargePointStatus.Available,
},
// { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Unavailable },
{
from: OCPP16ChargePointStatus.Unavailable,
- to: OCPP16ChargePointStatus.Faulted
+ to: OCPP16ChargePointStatus.Faulted,
},
{ to: OCPP16ChargePointStatus.Faulted },
{
from: OCPP16ChargePointStatus.Faulted,
- to: OCPP16ChargePointStatus.Available
+ to: OCPP16ChargePointStatus.Available,
},
{
from: OCPP16ChargePointStatus.Faulted,
- to: OCPP16ChargePointStatus.Unavailable
- }
+ to: OCPP16ChargePointStatus.Unavailable,
+ },
// { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Faulted }
])
// { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Available },
{
from: OCPP16ChargePointStatus.Available,
- to: OCPP16ChargePointStatus.Preparing
+ to: OCPP16ChargePointStatus.Preparing,
},
{
from: OCPP16ChargePointStatus.Available,
- to: OCPP16ChargePointStatus.Charging
+ to: OCPP16ChargePointStatus.Charging,
},
{
from: OCPP16ChargePointStatus.Available,
- to: OCPP16ChargePointStatus.SuspendedEV
+ to: OCPP16ChargePointStatus.SuspendedEV,
},
{
from: OCPP16ChargePointStatus.Available,
- to: OCPP16ChargePointStatus.SuspendedEVSE
+ to: OCPP16ChargePointStatus.SuspendedEVSE,
},
// { from: OCPP16ChargePointStatus.Available, to: OCPP16ChargePointStatus.Finishing },
{
from: OCPP16ChargePointStatus.Available,
- to: OCPP16ChargePointStatus.Reserved
+ to: OCPP16ChargePointStatus.Reserved,
},
{
from: OCPP16ChargePointStatus.Available,
- to: OCPP16ChargePointStatus.Unavailable
+ to: OCPP16ChargePointStatus.Unavailable,
},
{
from: OCPP16ChargePointStatus.Available,
- to: OCPP16ChargePointStatus.Faulted
+ to: OCPP16ChargePointStatus.Faulted,
},
// { to: OCPP16ChargePointStatus.Preparing },
{
from: OCPP16ChargePointStatus.Preparing,
- to: OCPP16ChargePointStatus.Available
+ to: OCPP16ChargePointStatus.Available,
},
// { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.Preparing },
{
from: OCPP16ChargePointStatus.Preparing,
- to: OCPP16ChargePointStatus.Charging
+ to: OCPP16ChargePointStatus.Charging,
},
{
from: OCPP16ChargePointStatus.Preparing,
- to: OCPP16ChargePointStatus.SuspendedEV
+ to: OCPP16ChargePointStatus.SuspendedEV,
},
{
from: OCPP16ChargePointStatus.Preparing,
- to: OCPP16ChargePointStatus.SuspendedEVSE
+ to: OCPP16ChargePointStatus.SuspendedEVSE,
},
{
from: OCPP16ChargePointStatus.Preparing,
- to: OCPP16ChargePointStatus.Finishing
+ to: OCPP16ChargePointStatus.Finishing,
},
// { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.Reserved },
// { from: OCPP16ChargePointStatus.Preparing, to: OCPP16ChargePointStatus.Unavailable },
{
from: OCPP16ChargePointStatus.Preparing,
- to: OCPP16ChargePointStatus.Faulted
+ to: OCPP16ChargePointStatus.Faulted,
},
// { to: OCPP16ChargePointStatus.Charging },
{
from: OCPP16ChargePointStatus.Charging,
- to: OCPP16ChargePointStatus.Available
+ to: OCPP16ChargePointStatus.Available,
},
// { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.Preparing },
// { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.Charging },
{
from: OCPP16ChargePointStatus.Charging,
- to: OCPP16ChargePointStatus.SuspendedEV
+ to: OCPP16ChargePointStatus.SuspendedEV,
},
{
from: OCPP16ChargePointStatus.Charging,
- to: OCPP16ChargePointStatus.SuspendedEVSE
+ to: OCPP16ChargePointStatus.SuspendedEVSE,
},
{
from: OCPP16ChargePointStatus.Charging,
- to: OCPP16ChargePointStatus.Finishing
+ to: OCPP16ChargePointStatus.Finishing,
},
// { from: OCPP16ChargePointStatus.Charging, to: OCPP16ChargePointStatus.Reserved },
{
from: OCPP16ChargePointStatus.Charging,
- to: OCPP16ChargePointStatus.Unavailable
+ to: OCPP16ChargePointStatus.Unavailable,
},
{
from: OCPP16ChargePointStatus.Charging,
- to: OCPP16ChargePointStatus.Faulted
+ to: OCPP16ChargePointStatus.Faulted,
},
// { to: OCPP16ChargePointStatus.SuspendedEV },
{
from: OCPP16ChargePointStatus.SuspendedEV,
- to: OCPP16ChargePointStatus.Available
+ to: OCPP16ChargePointStatus.Available,
},
// { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.Preparing },
{
from: OCPP16ChargePointStatus.SuspendedEV,
- to: OCPP16ChargePointStatus.Charging
+ to: OCPP16ChargePointStatus.Charging,
},
// { from: OCPP16ChargePointStatus.SuspendedEV, OCPP16ChargePointStatus.SuspendedEV },
{
from: OCPP16ChargePointStatus.SuspendedEV,
- to: OCPP16ChargePointStatus.SuspendedEVSE
+ to: OCPP16ChargePointStatus.SuspendedEVSE,
},
{
from: OCPP16ChargePointStatus.SuspendedEV,
- to: OCPP16ChargePointStatus.Finishing
+ to: OCPP16ChargePointStatus.Finishing,
},
// { from: OCPP16ChargePointStatus.SuspendedEV, to: OCPP16ChargePointStatus.Reserved },
{
from: OCPP16ChargePointStatus.SuspendedEV,
- to: OCPP16ChargePointStatus.Unavailable
+ to: OCPP16ChargePointStatus.Unavailable,
},
{
from: OCPP16ChargePointStatus.SuspendedEV,
- to: OCPP16ChargePointStatus.Faulted
+ to: OCPP16ChargePointStatus.Faulted,
},
// { to: OCPP16ChargePointStatus.SuspendedEVSE },
{
from: OCPP16ChargePointStatus.SuspendedEVSE,
- to: OCPP16ChargePointStatus.Available
+ to: OCPP16ChargePointStatus.Available,
},
// { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.Preparing },
{
from: OCPP16ChargePointStatus.SuspendedEVSE,
- to: OCPP16ChargePointStatus.Charging
+ to: OCPP16ChargePointStatus.Charging,
},
{
from: OCPP16ChargePointStatus.SuspendedEVSE,
- to: OCPP16ChargePointStatus.SuspendedEV
+ to: OCPP16ChargePointStatus.SuspendedEV,
},
// { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.SuspendedEVSE },
{
from: OCPP16ChargePointStatus.SuspendedEVSE,
- to: OCPP16ChargePointStatus.Finishing
+ to: OCPP16ChargePointStatus.Finishing,
},
// { from: OCPP16ChargePointStatus.SuspendedEVSE, to: OCPP16ChargePointStatus.Reserved },
{
from: OCPP16ChargePointStatus.SuspendedEVSE,
- to: OCPP16ChargePointStatus.Unavailable
+ to: OCPP16ChargePointStatus.Unavailable,
},
{
from: OCPP16ChargePointStatus.SuspendedEVSE,
- to: OCPP16ChargePointStatus.Faulted
+ to: OCPP16ChargePointStatus.Faulted,
},
// { to: OCPP16ChargePointStatus.Finishing},
{
from: OCPP16ChargePointStatus.Finishing,
- to: OCPP16ChargePointStatus.Available
+ to: OCPP16ChargePointStatus.Available,
},
{
from: OCPP16ChargePointStatus.Finishing,
- to: OCPP16ChargePointStatus.Preparing
+ to: OCPP16ChargePointStatus.Preparing,
},
// { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.Charging },
// { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.SuspendedEV },
// { from: OCPP16ChargePointStatus.Finishing, to: OCPP16ChargePointStatus.Reserved },
{
from: OCPP16ChargePointStatus.Finishing,
- to: OCPP16ChargePointStatus.Unavailable
+ to: OCPP16ChargePointStatus.Unavailable,
},
{
from: OCPP16ChargePointStatus.Finishing,
- to: OCPP16ChargePointStatus.Faulted
+ to: OCPP16ChargePointStatus.Faulted,
},
// { to: OCPP16ChargePointStatus.Reserved },
{
from: OCPP16ChargePointStatus.Reserved,
- to: OCPP16ChargePointStatus.Available
+ to: OCPP16ChargePointStatus.Available,
},
{
from: OCPP16ChargePointStatus.Reserved,
- to: OCPP16ChargePointStatus.Preparing
+ to: OCPP16ChargePointStatus.Preparing,
},
// { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.Charging },
// { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.SuspendedEV },
// { from: OCPP16ChargePointStatus.Reserved, to: OCPP16ChargePointStatus.Reserved },
{
from: OCPP16ChargePointStatus.Reserved,
- to: OCPP16ChargePointStatus.Unavailable
+ to: OCPP16ChargePointStatus.Unavailable,
},
{
from: OCPP16ChargePointStatus.Reserved,
- to: OCPP16ChargePointStatus.Faulted
+ to: OCPP16ChargePointStatus.Faulted,
},
{ to: OCPP16ChargePointStatus.Unavailable },
{
from: OCPP16ChargePointStatus.Unavailable,
- to: OCPP16ChargePointStatus.Available
+ to: OCPP16ChargePointStatus.Available,
},
{
from: OCPP16ChargePointStatus.Unavailable,
- to: OCPP16ChargePointStatus.Preparing
+ to: OCPP16ChargePointStatus.Preparing,
},
{
from: OCPP16ChargePointStatus.Unavailable,
- to: OCPP16ChargePointStatus.Charging
+ to: OCPP16ChargePointStatus.Charging,
},
{
from: OCPP16ChargePointStatus.Unavailable,
- to: OCPP16ChargePointStatus.SuspendedEV
+ to: OCPP16ChargePointStatus.SuspendedEV,
},
{
from: OCPP16ChargePointStatus.Unavailable,
- to: OCPP16ChargePointStatus.SuspendedEVSE
+ to: OCPP16ChargePointStatus.SuspendedEVSE,
},
// { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Finishing },
// { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Reserved },
// { from: OCPP16ChargePointStatus.Unavailable, to: OCPP16ChargePointStatus.Unavailable },
{
from: OCPP16ChargePointStatus.Unavailable,
- to: OCPP16ChargePointStatus.Faulted
+ to: OCPP16ChargePointStatus.Faulted,
},
{ to: OCPP16ChargePointStatus.Faulted },
{
from: OCPP16ChargePointStatus.Faulted,
- to: OCPP16ChargePointStatus.Available
+ to: OCPP16ChargePointStatus.Available,
},
{
from: OCPP16ChargePointStatus.Faulted,
- to: OCPP16ChargePointStatus.Preparing
+ to: OCPP16ChargePointStatus.Preparing,
},
{
from: OCPP16ChargePointStatus.Faulted,
- to: OCPP16ChargePointStatus.Charging
+ to: OCPP16ChargePointStatus.Charging,
},
{
from: OCPP16ChargePointStatus.Faulted,
- to: OCPP16ChargePointStatus.SuspendedEV
+ to: OCPP16ChargePointStatus.SuspendedEV,
},
{
from: OCPP16ChargePointStatus.Faulted,
- to: OCPP16ChargePointStatus.SuspendedEVSE
+ to: OCPP16ChargePointStatus.SuspendedEVSE,
},
{
from: OCPP16ChargePointStatus.Faulted,
- to: OCPP16ChargePointStatus.Finishing
+ to: OCPP16ChargePointStatus.Finishing,
},
{
from: OCPP16ChargePointStatus.Faulted,
- to: OCPP16ChargePointStatus.Reserved
+ to: OCPP16ChargePointStatus.Reserved,
},
{
from: OCPP16ChargePointStatus.Faulted,
- to: OCPP16ChargePointStatus.Unavailable
- }
+ to: OCPP16ChargePointStatus.Unavailable,
+ },
// { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Faulted }
])
}
differenceInSeconds,
type Interval,
isDate,
- secondsToMilliseconds
+ secondsToMilliseconds,
} from 'date-fns'
import { maxTime } from 'date-fns/constants'
import { isEmpty } from 'rambda'
prepareChargingProfileKind,
removeExpiredReservations,
resetAuthorizeConnectorStatus,
- setConfigurationKeyValue
+ setConfigurationKeyValue,
} from '../../../charging-station/index.js'
import { OCPPError } from '../../../exception/index.js'
import {
type SetChargingProfileRequest,
type SetChargingProfileResponse,
type UnlockConnectorRequest,
- type UnlockConnectorResponse
+ type UnlockConnectorResponse,
} from '../../../types/index.js'
import {
Configuration,
isNotEmptyArray,
isNotEmptyString,
logger,
- sleep
+ sleep,
} from '../../../utils/index.js'
import { OCPPIncomingRequestService } from '../OCPPIncomingRequestService.js'
import { OCPP16Constants } from './OCPP16Constants.js'
protected payloadValidateFunctions: Map<OCPP16IncomingRequestCommand, ValidateFunction<JsonType>>
private readonly incomingRequestHandlers: Map<
- OCPP16IncomingRequestCommand,
- IncomingRequestHandler
+ OCPP16IncomingRequestCommand,
+ IncomingRequestHandler
>
public constructor () {
this.incomingRequestHandlers = new Map<OCPP16IncomingRequestCommand, IncomingRequestHandler>([
[
OCPP16IncomingRequestCommand.RESET,
- this.handleRequestReset.bind(this) as unknown as IncomingRequestHandler
+ this.handleRequestReset.bind(this) as unknown as IncomingRequestHandler,
],
[
OCPP16IncomingRequestCommand.CLEAR_CACHE,
- this.handleRequestClearCache.bind(this) as IncomingRequestHandler
+ this.handleRequestClearCache.bind(this) as IncomingRequestHandler,
],
[
OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR,
- this.handleRequestUnlockConnector.bind(this) as unknown as IncomingRequestHandler
+ this.handleRequestUnlockConnector.bind(this) as unknown as IncomingRequestHandler,
],
[
OCPP16IncomingRequestCommand.GET_CONFIGURATION,
- this.handleRequestGetConfiguration.bind(this) as IncomingRequestHandler
+ this.handleRequestGetConfiguration.bind(this) as IncomingRequestHandler,
],
[
OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION,
- this.handleRequestChangeConfiguration.bind(this) as unknown as IncomingRequestHandler
+ this.handleRequestChangeConfiguration.bind(this) as unknown as IncomingRequestHandler,
],
[
OCPP16IncomingRequestCommand.GET_COMPOSITE_SCHEDULE,
- this.handleRequestGetCompositeSchedule.bind(this) as unknown as IncomingRequestHandler
+ this.handleRequestGetCompositeSchedule.bind(this) as unknown as IncomingRequestHandler,
],
[
OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE,
- this.handleRequestSetChargingProfile.bind(this) as unknown as IncomingRequestHandler
+ this.handleRequestSetChargingProfile.bind(this) as unknown as IncomingRequestHandler,
],
[
OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE,
- this.handleRequestClearChargingProfile.bind(this) as IncomingRequestHandler
+ this.handleRequestClearChargingProfile.bind(this) as IncomingRequestHandler,
],
[
OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY,
- this.handleRequestChangeAvailability.bind(this) as unknown as IncomingRequestHandler
+ this.handleRequestChangeAvailability.bind(this) as unknown as IncomingRequestHandler,
],
[
OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION,
- this.handleRequestRemoteStartTransaction.bind(this) as unknown as IncomingRequestHandler
+ this.handleRequestRemoteStartTransaction.bind(this) as unknown as IncomingRequestHandler,
],
[
OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION,
- this.handleRequestRemoteStopTransaction.bind(this) as unknown as IncomingRequestHandler
+ this.handleRequestRemoteStopTransaction.bind(this) as unknown as IncomingRequestHandler,
],
[
OCPP16IncomingRequestCommand.GET_DIAGNOSTICS,
- this.handleRequestGetDiagnostics.bind(this) as IncomingRequestHandler
+ this.handleRequestGetDiagnostics.bind(this) as IncomingRequestHandler,
],
[
OCPP16IncomingRequestCommand.TRIGGER_MESSAGE,
- this.handleRequestTriggerMessage.bind(this) as unknown as IncomingRequestHandler
+ this.handleRequestTriggerMessage.bind(this) as unknown as IncomingRequestHandler,
],
[
OCPP16IncomingRequestCommand.DATA_TRANSFER,
- this.handleRequestDataTransfer.bind(this) as unknown as IncomingRequestHandler
+ this.handleRequestDataTransfer.bind(this) as unknown as IncomingRequestHandler,
],
[
OCPP16IncomingRequestCommand.UPDATE_FIRMWARE,
- this.handleRequestUpdateFirmware.bind(this) as unknown as IncomingRequestHandler
+ this.handleRequestUpdateFirmware.bind(this) as unknown as IncomingRequestHandler,
],
[
OCPP16IncomingRequestCommand.RESERVE_NOW,
- this.handleRequestReserveNow.bind(this) as unknown as IncomingRequestHandler
+ this.handleRequestReserveNow.bind(this) as unknown as IncomingRequestHandler,
],
[
OCPP16IncomingRequestCommand.CANCEL_RESERVATION,
- this.handleRequestCancelReservation.bind(this) as unknown as IncomingRequestHandler
- ]
+ this.handleRequestCancelReservation.bind(this) as unknown as IncomingRequestHandler,
+ ],
])
this.payloadValidateFunctions = new Map<
- OCPP16IncomingRequestCommand,
- ValidateFunction<JsonType>
+ OCPP16IncomingRequestCommand,
+ ValidateFunction<JsonType>
>([
[
OCPP16IncomingRequestCommand.RESET,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.CLEAR_CACHE,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.GET_CONFIGURATION,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.GET_DIAGNOSTICS,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.GET_COMPOSITE_SCHEDULE,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.TRIGGER_MESSAGE,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.DATA_TRANSFER,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.UPDATE_FIRMWARE,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.RESERVE_NOW,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.CANCEL_RESERVATION,
'constructor'
)
)
- .bind(this)
- ]
+ .bind(this),
+ ],
])
// Handle incoming request events
this.on(
chargingStation.getConnectorStatus(connectorId!)!.transactionRemoteStarted = true
chargingStation.ocppRequestService
.requestHandler<Partial<OCPP16StartTransactionRequest>, OCPP16StartTransactionResponse>(
- chargingStation,
- OCPP16RequestCommand.START_TRANSACTION,
- {
- connectorId,
- idTag
- }
- )
+ chargingStation,
+ OCPP16RequestCommand.START_TRANSACTION,
+ {
+ connectorId,
+ idTag,
+ }
+ )
.then(response => {
if (response.idTagInfo.status === OCPP16AuthorizationStatus.ACCEPTED) {
logger.debug(
`${chargingStation.logPrefix()} Remote start transaction ACCEPTED on ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
chargingStation.stationInfo?.chargingStationId
- }#${connectorId} for idTag '${idTag}'`
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ }#${connectorId?.toString()} for idTag '${idTag}'`
)
} else {
logger.debug(
`${chargingStation.logPrefix()} Remote start transaction REJECTED on ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
chargingStation.stationInfo?.chargingStationId
- }#${connectorId} for idTag '${idTag}'`
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ }#${connectorId?.toString()} for idTag '${idTag}'`
)
}
+ return undefined
})
.catch((error: unknown) => {
logger.error(
if (response.status === GenericStatus.Accepted) {
logger.debug(
`${chargingStation.logPrefix()} Remote stop transaction ACCEPTED on ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
chargingStation.stationInfo?.chargingStationId
- }#${connectorId} for transaction '${transactionId}'`
+ }#${connectorId.toString()} for transaction '${transactionId.toString()}'`
)
} else {
logger.debug(
`${chargingStation.logPrefix()} Remote stop transaction REJECTED on ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
chargingStation.stationInfo?.chargingStationId
- }#${connectorId} for transaction '${transactionId}'`
+ }#${connectorId.toString()} for transaction '${transactionId.toString()}'`
)
}
+ return undefined
})
.catch((error: unknown) => {
logger.error(
case OCPP16MessageTrigger.BootNotification:
chargingStation.ocppRequestService
.requestHandler<
- OCPP16BootNotificationRequest,
- OCPP16BootNotificationResponse
- >(chargingStation, OCPP16RequestCommand.BOOT_NOTIFICATION, chargingStation.bootNotificationRequest as OCPP16BootNotificationRequest, { skipBufferingOnError: true, triggerMessage: true })
+ OCPP16BootNotificationRequest,
+ OCPP16BootNotificationResponse
+ >(chargingStation, OCPP16RequestCommand.BOOT_NOTIFICATION, chargingStation.bootNotificationRequest as OCPP16BootNotificationRequest, { skipBufferingOnError: true, triggerMessage: true })
.catch(errorHandler)
break
case OCPP16MessageTrigger.Heartbeat:
chargingStation.ocppRequestService
.requestHandler<OCPP16HeartbeatRequest, OCPP16HeartbeatResponse>(
- chargingStation,
- OCPP16RequestCommand.HEARTBEAT,
- undefined,
- {
- triggerMessage: true
- }
- )
+ chargingStation,
+ OCPP16RequestCommand.HEARTBEAT,
+ undefined,
+ {
+ triggerMessage: true,
+ }
+ )
.catch(errorHandler)
break
case OCPP16MessageTrigger.StatusNotification:
if (connectorId != null) {
chargingStation.ocppRequestService
.requestHandler<OCPP16StatusNotificationRequest, OCPP16StatusNotificationResponse>(
- chargingStation,
- OCPP16RequestCommand.STATUS_NOTIFICATION,
- {
- connectorId,
- errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
- status: chargingStation.getConnectorStatus(connectorId)
- ?.status as OCPP16ChargePointStatus
- },
- {
- triggerMessage: true
- }
- )
+ chargingStation,
+ OCPP16RequestCommand.STATUS_NOTIFICATION,
+ {
+ connectorId,
+ errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
+ status: chargingStation.getConnectorStatus(connectorId)
+ ?.status as OCPP16ChargePointStatus,
+ },
+ {
+ triggerMessage: true,
+ }
+ )
.catch(errorHandler)
} else if (chargingStation.hasEvses) {
for (const evseStatus of chargingStation.evses.values()) {
for (const [id, connectorStatus] of evseStatus.connectors) {
chargingStation.ocppRequestService
.requestHandler<
- OCPP16StatusNotificationRequest,
- OCPP16StatusNotificationResponse
+ OCPP16StatusNotificationRequest,
+ OCPP16StatusNotificationResponse
+ >(
+ chargingStation,
+ OCPP16RequestCommand.STATUS_NOTIFICATION,
+ {
+ connectorId: id,
+ errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
+ status: connectorStatus.status as OCPP16ChargePointStatus,
+ },
+ {
+ triggerMessage: true,
+ }
+ )
+ .catch(errorHandler)
+ }
+ }
+ } else {
+ for (const [id, connectorStatus] of chargingStation.connectors) {
+ chargingStation.ocppRequestService
+ .requestHandler<
+ OCPP16StatusNotificationRequest,
+ OCPP16StatusNotificationResponse
>(
chargingStation,
OCPP16RequestCommand.STATUS_NOTIFICATION,
{
connectorId: id,
errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
- status: connectorStatus.status as OCPP16ChargePointStatus
+ status: connectorStatus.status as OCPP16ChargePointStatus,
},
{
- triggerMessage: true
+ triggerMessage: true,
}
)
- .catch(errorHandler)
- }
- }
- } else {
- for (const [id, connectorStatus] of chargingStation.connectors) {
- chargingStation.ocppRequestService
- .requestHandler<
- OCPP16StatusNotificationRequest,
- OCPP16StatusNotificationResponse
- >(
- chargingStation,
- OCPP16RequestCommand.STATUS_NOTIFICATION,
- {
- connectorId: id,
- errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
- status: connectorStatus.status as OCPP16ChargePointStatus
- },
- {
- triggerMessage: true
- }
- )
.catch(errorHandler)
}
}
const { connectorId } = commandPayload
if (!chargingStation.hasConnector(connectorId)) {
logger.error(
- `${chargingStation.logPrefix()} Trying to unlock a non existing connector id ${connectorId}`
+ `${chargingStation.logPrefix()} Trying to unlock a non existing connector id ${connectorId.toString()}`
)
return OCPP16Constants.OCPP_RESPONSE_UNLOCK_NOT_SUPPORTED
}
if (connectorId === 0) {
- logger.error(`${chargingStation.logPrefix()} Trying to unlock connector id ${connectorId}`)
+ logger.error(`${chargingStation.logPrefix()} Trying to unlock connector id ${connectorId.toString()}`)
return OCPP16Constants.OCPP_RESPONSE_UNLOCK_NOT_SUPPORTED
}
if (chargingStation.getConnectorStatus(connectorId)?.transactionStarted === true) {
configurationKey.push({
key: configKey.key,
readonly: configKey.readonly,
- value: configKey.value
+ value: configKey.value,
})
}
} else if (isNotEmptyArray(key)) {
configurationKey.push({
key: keyFound.key,
readonly: keyFound.readonly,
- value: keyFound.value
+ value: keyFound.value,
})
} else {
unknownKey.push(k)
}
return {
configurationKey,
- unknownKey
+ unknownKey,
}
}
const { connectorId, csChargingProfiles } = commandPayload
if (!chargingStation.hasConnector(connectorId)) {
logger.error(
- `${chargingStation.logPrefix()} Trying to set charging profile(s) to a non existing connector id ${connectorId}`
+ `${chargingStation.logPrefix()} Trying to set charging profile(s) to a non existing connector id ${connectorId.toString()}`
)
return OCPP16Constants.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED
}
connectorId === 0
) {
logger.error(
- `${chargingStation.logPrefix()} Trying to set transaction charging profile(s) on connector ${connectorId}`
+ `${chargingStation.logPrefix()} Trying to set transaction charging profile(s) on connector ${connectorId.toString()}`
)
return OCPP16Constants.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED
}
connectorStatus?.transactionStarted === false
) {
logger.error(
- `${chargingStation.logPrefix()} Trying to set transaction charging profile(s) on connector ${connectorId} without a started transaction`
+ `${chargingStation.logPrefix()} Trying to set transaction charging profile(s) on connector ${connectorId.toString()} without a started transaction`
)
return OCPP16Constants.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED
}
csChargingProfiles.transactionId !== connectorStatus.transactionId
) {
logger.error(
- `${chargingStation.logPrefix()} Trying to set transaction charging profile(s) on connector ${connectorId} with a different transaction id ${
- csChargingProfiles.transactionId
- } than the started transaction id ${connectorStatus.transactionId}`
+ `${chargingStation.logPrefix()} Trying to set transaction charging profile(s) on connector ${connectorId.toString()} with a different transaction id ${
+ csChargingProfiles.transactionId.toString()
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ } than the started transaction id ${connectorStatus.transactionId?.toString()}`
)
return OCPP16Constants.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED
}
OCPP16ServiceUtils.setChargingProfile(chargingStation, connectorId, csChargingProfiles)
logger.debug(
- `${chargingStation.logPrefix()} Charging profile(s) set on connector id ${connectorId}: %j`,
+ `${chargingStation.logPrefix()} Charging profile(s) set on connector id ${connectorId.toString()}: %j`,
csChargingProfiles
)
return OCPP16Constants.OCPP_SET_CHARGING_PROFILE_RESPONSE_ACCEPTED
const { connectorId, duration, chargingRateUnit } = commandPayload
if (!chargingStation.hasConnector(connectorId)) {
logger.error(
- `${chargingStation.logPrefix()} Trying to get composite schedule to a non existing connector id ${connectorId}`
+ `${chargingStation.logPrefix()} Trying to get composite schedule to a non existing connector id ${connectorId.toString()}`
)
return OCPP16Constants.OCPP_RESPONSE_REJECTED
}
if (connectorId === 0) {
logger.error(
- `${chargingStation.logPrefix()} Get composite schedule on connector id ${connectorId} is not yet supported`
+ `${chargingStation.logPrefix()} Get composite schedule on connector id ${connectorId.toString()} is not yet supported`
)
return OCPP16Constants.OCPP_RESPONSE_REJECTED
}
const currentDate = new Date()
const compositeScheduleInterval: Interval = {
start: currentDate,
- end: addSeconds(currentDate, duration)
+ end: addSeconds(currentDate, duration),
}
// FIXME: add and handle charging station charging profiles
const chargingProfiles: OCPP16ChargingProfile[] = getConnectorChargingProfiles(
if (chargingProfile.chargingSchedule.startSchedule == null) {
logger.debug(
`${chargingStation.logPrefix()} ${moduleName}.handleRequestGetCompositeSchedule: Charging profile id ${
- chargingProfile.chargingProfileId
+ chargingProfile.chargingProfileId.toString()
} has no startSchedule defined. Trying to set it to the connector current transaction start date`
)
// OCPP specifies that if startSchedule is not defined, it should be relative to start of the connector transaction
if (!isDate(chargingProfile.chargingSchedule.startSchedule)) {
logger.warn(
`${chargingStation.logPrefix()} ${moduleName}.handleRequestGetCompositeSchedule: Charging profile id ${
- chargingProfile.chargingProfileId
+ chargingProfile.chargingProfileId.toString()
} startSchedule property is not a Date instance. Trying to convert it to a Date instance`
)
chargingProfile.chargingSchedule.startSchedule = convertToDate(
if (chargingProfile.chargingSchedule.duration == null) {
logger.debug(
`${chargingStation.logPrefix()} ${moduleName}.handleRequestGetCompositeSchedule: Charging profile id ${
- chargingProfile.chargingProfileId
+ chargingProfile.chargingProfileId.toString()
} has no duration defined and will be set to the maximum time allowed`
)
// OCPP specifies that if duration is not defined, it should be infinite
status: GenericStatus.Accepted,
scheduleStart: compositeSchedule.startSchedule,
connectorId,
- chargingSchedule: compositeSchedule
+ chargingSchedule: compositeSchedule,
}
}
return OCPP16Constants.OCPP_RESPONSE_REJECTED
if (connectorId != null) {
if (!chargingStation.hasConnector(connectorId)) {
logger.error(
- `${chargingStation.logPrefix()} Trying to clear a charging profile(s) to a non existing connector id ${connectorId}`
+ `${chargingStation.logPrefix()} Trying to clear a charging profile(s) to a non existing connector id ${connectorId.toString()}`
)
return OCPP16Constants.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN
}
if (isNotEmptyArray(connectorStatus?.chargingProfiles)) {
connectorStatus.chargingProfiles = []
logger.debug(
- `${chargingStation.logPrefix()} Charging profile(s) cleared on connector id ${connectorId}`
+ `${chargingStation.logPrefix()} Charging profile(s) cleared on connector id ${connectorId.toString()}`
)
return OCPP16Constants.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_ACCEPTED
}
const { connectorId, type } = commandPayload
if (!chargingStation.hasConnector(connectorId)) {
logger.error(
- `${chargingStation.logPrefix()} Trying to change the availability of a non existing connector id ${connectorId}`
+ `${chargingStation.logPrefix()} Trying to change the availability of a non existing connector id ${connectorId.toString()}`
)
return OCPP16Constants.OCPP_AVAILABILITY_RESPONSE_REJECTED
}
if (commandPayload.connectorId == null) {
logger.debug(
`${chargingStation.logPrefix()} Remote start transaction REJECTED on ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
chargingStation.stationInfo?.chargingStationId
}, idTag '${commandPayload.idTag}': no available connector found`
)
}
logger.debug(
`${chargingStation.logPrefix()} Remote start transaction ACCEPTED on ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
chargingStation.stationInfo?.chargingStationId
- }#${transactionConnectorId}}, idTag '${idTag}'`
+ }#${transactionConnectorId.toString()}}, idTag '${idTag}'`
)
return OCPP16Constants.OCPP_RESPONSE_ACCEPTED
}
const connectorStatus = chargingStation.getConnectorStatus(connectorId)
logger.debug(
`${chargingStation.logPrefix()} Remote start transaction REJECTED on ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
chargingStation.stationInfo?.chargingStationId
- }#${connectorId}, idTag '${idTag}', availability '${
+ }#${connectorId.toString()}, idTag '${idTag}', availability '${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
connectorStatus?.availability
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
}', status '${connectorStatus?.status}'`
)
return OCPP16Constants.OCPP_RESPONSE_REJECTED
OCPP16ServiceUtils.setChargingProfile(chargingStation, connectorId, chargingProfile)
logger.debug(
`${chargingStation.logPrefix()} Charging profile(s) set at remote start transaction on ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
chargingStation.stationInfo?.chargingStationId
- }#${connectorId}`,
+ }#${connectorId.toString()}`,
chargingProfile
)
return true
const { transactionId } = commandPayload
if (chargingStation.getConnectorIdByTransactionId(transactionId) != null) {
logger.debug(
- `${chargingStation.logPrefix()} Remote stop transaction ACCEPTED for transactionId '${transactionId}'`
+ `${chargingStation.logPrefix()} Remote stop transaction ACCEPTED for transactionId '${transactionId.toString()}'`
)
return OCPP16Constants.OCPP_RESPONSE_ACCEPTED
}
logger.debug(
- `${chargingStation.logPrefix()} Remote stop transaction REJECTED for transactionId '${transactionId}'`
+ `${chargingStation.logPrefix()} Remote stop transaction REJECTED for transactionId '${transactionId.toString()}'`
)
return OCPP16Constants.OCPP_RESPONSE_REJECTED
}
}
}
await chargingStation.ocppRequestService.requestHandler<
- OCPP16FirmwareStatusNotificationRequest,
- OCPP16FirmwareStatusNotificationResponse
+ OCPP16FirmwareStatusNotificationRequest,
+ OCPP16FirmwareStatusNotificationResponse
>(chargingStation, OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION, {
- status: OCPP16FirmwareStatus.Downloading
+ status: OCPP16FirmwareStatus.Downloading,
})
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
chargingStation.stationInfo!.firmwareStatus = OCPP16FirmwareStatus.Downloading
) {
await sleep(secondsToMilliseconds(randomInt(minDelay, maxDelay)))
await chargingStation.ocppRequestService.requestHandler<
- OCPP16FirmwareStatusNotificationRequest,
- OCPP16FirmwareStatusNotificationResponse
+ OCPP16FirmwareStatusNotificationRequest,
+ OCPP16FirmwareStatusNotificationResponse
>(chargingStation, OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION, {
- status: chargingStation.stationInfo.firmwareUpgrade.failureStatus
+ status: chargingStation.stationInfo.firmwareUpgrade.failureStatus,
})
chargingStation.stationInfo.firmwareStatus =
chargingStation.stationInfo.firmwareUpgrade.failureStatus
}
await sleep(secondsToMilliseconds(randomInt(minDelay, maxDelay)))
await chargingStation.ocppRequestService.requestHandler<
- OCPP16FirmwareStatusNotificationRequest,
- OCPP16FirmwareStatusNotificationResponse
+ OCPP16FirmwareStatusNotificationRequest,
+ OCPP16FirmwareStatusNotificationResponse
>(chargingStation, OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION, {
- status: OCPP16FirmwareStatus.Downloaded
+ status: OCPP16FirmwareStatus.Downloaded,
})
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
chargingStation.stationInfo!.firmwareStatus = OCPP16FirmwareStatus.Downloaded
if (runningTransactions > 0) {
const waitTime = secondsToMilliseconds(15)
logger.debug(
- `${chargingStation.logPrefix()} ${moduleName}.updateFirmwareSimulation: ${runningTransactions} transaction(s) in progress, waiting ${formatDurationMilliSeconds(
+ `${chargingStation.logPrefix()} ${moduleName}.updateFirmwareSimulation: ${runningTransactions.toString()} transaction(s) in progress, waiting ${formatDurationMilliSeconds(
waitTime
)} before continuing firmware update simulation`
)
return
}
await chargingStation.ocppRequestService.requestHandler<
- OCPP16FirmwareStatusNotificationRequest,
- OCPP16FirmwareStatusNotificationResponse
+ OCPP16FirmwareStatusNotificationRequest,
+ OCPP16FirmwareStatusNotificationResponse
>(chargingStation, OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION, {
- status: OCPP16FirmwareStatus.Installing
+ status: OCPP16FirmwareStatus.Installing,
})
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
chargingStation.stationInfo!.firmwareStatus = OCPP16FirmwareStatus.Installing
) {
await sleep(secondsToMilliseconds(randomInt(minDelay, maxDelay)))
await chargingStation.ocppRequestService.requestHandler<
- OCPP16FirmwareStatusNotificationRequest,
- OCPP16FirmwareStatusNotificationResponse
+ OCPP16FirmwareStatusNotificationRequest,
+ OCPP16FirmwareStatusNotificationResponse
>(chargingStation, OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION, {
- status: chargingStation.stationInfo.firmwareUpgrade.failureStatus
+ status: chargingStation.stationInfo.firmwareUpgrade.failureStatus,
})
chargingStation.stationInfo.firmwareStatus =
chargingStation.stationInfo.firmwareUpgrade.failureStatus
.filter(file => file.endsWith(extname(logConfiguration.file!)))
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
.map(file => join(dirname(logConfiguration.file!), file))
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
const diagnosticsArchive = `${chargingStation.stationInfo?.chargingStationId}_logs.tar.gz`
create({ gzip: true }, logFiles).pipe(createWriteStream(diagnosticsArchive))
ftpClient = new Client()
host: uri.hostname,
...(isNotEmptyString(uri.port) && { port: convertToInt(uri.port) }),
...(isNotEmptyString(uri.username) && { user: uri.username }),
- ...(isNotEmptyString(uri.password) && { password: uri.password })
+ ...(isNotEmptyString(uri.password) && { password: uri.password }),
})
let uploadResponse: FTPResponse | undefined
if (accessResponse.code === 220) {
ftpClient.trackProgress(info => {
logger.info(
`${chargingStation.logPrefix()} ${moduleName}.handleRequestGetDiagnostics: ${
- info.bytes / 1024
+ (info.bytes / 1024).toString()
} bytes transferred from diagnostics archive ${info.name}`
)
chargingStation.ocppRequestService
.requestHandler<
- OCPP16DiagnosticsStatusNotificationRequest,
- OCPP16DiagnosticsStatusNotificationResponse
- >(chargingStation, OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, {
- status: OCPP16DiagnosticsStatus.Uploading
- })
+ OCPP16DiagnosticsStatusNotificationRequest,
+ OCPP16DiagnosticsStatusNotificationResponse
+ >(chargingStation, OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, {
+ status: OCPP16DiagnosticsStatus.Uploading,
+ })
.catch((error: unknown) => {
logger.error(
`${chargingStation.logPrefix()} ${moduleName}.handleRequestGetDiagnostics: Error while sending '${
)
if (uploadResponse.code === 226) {
await chargingStation.ocppRequestService.requestHandler<
- OCPP16DiagnosticsStatusNotificationRequest,
- OCPP16DiagnosticsStatusNotificationResponse
+ OCPP16DiagnosticsStatusNotificationRequest,
+ OCPP16DiagnosticsStatusNotificationResponse
>(chargingStation, OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, {
- status: OCPP16DiagnosticsStatus.Uploaded
+ status: OCPP16DiagnosticsStatus.Uploaded,
})
ftpClient.close()
return { fileName: diagnosticsArchive }
}
throw new OCPPError(
ErrorType.GENERIC_ERROR,
- `Diagnostics transfer failed with error code ${accessResponse.code}|${uploadResponse.code}`,
+ `Diagnostics transfer failed with error code ${accessResponse.code.toString()}|${uploadResponse.code.toString()}`,
OCPP16IncomingRequestCommand.GET_DIAGNOSTICS
)
}
throw new OCPPError(
ErrorType.GENERIC_ERROR,
- `Diagnostics transfer failed with error code ${accessResponse.code}|${uploadResponse?.code}`,
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ `Diagnostics transfer failed with error code ${accessResponse.code.toString()}|${uploadResponse?.code.toString()}`,
OCPP16IncomingRequestCommand.GET_DIAGNOSTICS
)
} catch (error) {
await chargingStation.ocppRequestService.requestHandler<
- OCPP16DiagnosticsStatusNotificationRequest,
- OCPP16DiagnosticsStatusNotificationResponse
+ OCPP16DiagnosticsStatusNotificationRequest,
+ OCPP16DiagnosticsStatusNotificationResponse
>(chargingStation, OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, {
- status: OCPP16DiagnosticsStatus.UploadFailed
+ status: OCPP16DiagnosticsStatus.UploadFailed,
})
ftpClient?.close()
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
} to transfer the diagnostic logs archive`
)
await chargingStation.ocppRequestService.requestHandler<
- OCPP16DiagnosticsStatusNotificationRequest,
- OCPP16DiagnosticsStatusNotificationResponse
+ OCPP16DiagnosticsStatusNotificationRequest,
+ OCPP16DiagnosticsStatusNotificationResponse
>(chargingStation, OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, {
- status: OCPP16DiagnosticsStatus.UploadFailed
+ status: OCPP16DiagnosticsStatus.UploadFailed,
})
return OCPP16Constants.OCPP_RESPONSE_EMPTY
}
const { reservationId, idTag, connectorId } = commandPayload
if (!chargingStation.hasConnector(connectorId)) {
logger.error(
- `${chargingStation.logPrefix()} Trying to reserve a non existing connector id ${connectorId}`
+ `${chargingStation.logPrefix()} Trying to reserve a non existing connector id ${connectorId.toString()}`
)
return OCPP16Constants.OCPP_RESERVATION_RESPONSE_REJECTED
}
}
await chargingStation.addReservation({
id: commandPayload.reservationId,
- ...commandPayload
+ ...commandPayload,
})
response = OCPP16Constants.OCPP_RESERVATION_RESPONSE_ACCEPTED
break
const reservation = chargingStation.getReservationBy('reservationId', reservationId)
if (reservation == null) {
logger.debug(
- `${chargingStation.logPrefix()} Reservation with id ${reservationId} does not exist on charging station`
+ `${chargingStation.logPrefix()} Reservation with id ${reservationId.toString()} does not exist on charging station`
)
return OCPP16Constants.OCPP_CANCEL_RESERVATION_RESPONSE_REJECTED
}
OCPP16IncomingRequestCommand.CANCEL_RESERVATION,
error as Error,
{
- errorResponse: OCPP16Constants.OCPP_CANCEL_RESERVATION_RESPONSE_REJECTED
+ errorResponse: OCPP16Constants.OCPP_CANCEL_RESERVATION_RESPONSE_REJECTED,
}
)!
}
type OCPP16StatusNotificationRequest,
type OCPP16StopTransactionRequest,
OCPPVersion,
- type RequestParams
+ type RequestParams,
} from '../../../types/index.js'
import { Constants, generateUUID } from '../../../utils/index.js'
import { OCPPRequestService } from '../OCPPRequestService.js'
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16RequestCommand.BOOT_NOTIFICATION,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16RequestCommand.HEARTBEAT,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16RequestCommand.METER_VALUES,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16RequestCommand.STATUS_NOTIFICATION,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16RequestCommand.START_TRANSACTION,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16RequestCommand.STOP_TRANSACTION,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16RequestCommand.DATA_TRANSFER,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION,
'constructor'
)
)
- .bind(this)
- ]
+ .bind(this),
+ ],
])
this.buildRequestPayload = this.buildRequestPayload.bind(this)
}
case OCPP16RequestCommand.AUTHORIZE:
return {
idTag: Constants.DEFAULT_IDTAG,
- ...commandParams
+ ...commandParams,
} as unknown as Request
case OCPP16RequestCommand.HEARTBEAT:
return OCPP16Constants.OCPP_REQUEST_EMPTY as unknown as Request
chargingStation.getConnectorStatus(0)?.status === OCPP16ChargePointStatus.Reserved
? 0
: (commandParams.connectorId as number)
- )!.reservationId
+ )!.reservationId,
}),
- ...commandParams
+ ...commandParams,
} as unknown as Request
case OCPP16RequestCommand.STOP_TRANSACTION:
chargingStation.stationInfo?.transactionDataMeterValues === true &&
connectorId!,
energyActiveImportRegister
)
- )
+ ),
}),
- ...commandParams
+ ...commandParams,
} as unknown as Request
default:
// OCPPError usage here is debatable: it's an error in the OCPP stack but not targeted to sendError().
type ChargingStation,
getConfigurationKey,
hasReservationExpired,
- resetConnectorStatus
+ resetConnectorStatus,
} from '../../../charging-station/index.js'
import { OCPPError } from '../../../exception/index.js'
import {
ReservationTerminationReason,
type ResponseHandler,
type SetChargingProfileResponse,
- type UnlockConnectorResponse
+ type UnlockConnectorResponse,
} from '../../../types/index.js'
import { Constants, convertToInt, isAsyncFunction, logger } from '../../../utils/index.js'
import { OCPPResponseService } from '../OCPPResponseService.js'
export class OCPP16ResponseService extends OCPPResponseService {
public incomingRequestResponsePayloadValidateFunctions: Map<
- OCPP16IncomingRequestCommand,
- ValidateFunction<JsonType>
+ OCPP16IncomingRequestCommand,
+ ValidateFunction<JsonType>
>
protected payloadValidateFunctions: Map<OCPP16RequestCommand, ValidateFunction<JsonType>>
this.responseHandlers = new Map<OCPP16RequestCommand, ResponseHandler>([
[
OCPP16RequestCommand.BOOT_NOTIFICATION,
- this.handleResponseBootNotification.bind(this) as ResponseHandler
+ this.handleResponseBootNotification.bind(this) as ResponseHandler,
],
[OCPP16RequestCommand.HEARTBEAT, this.emptyResponseHandler],
[OCPP16RequestCommand.AUTHORIZE, this.handleResponseAuthorize.bind(this) as ResponseHandler],
[
OCPP16RequestCommand.START_TRANSACTION,
- this.handleResponseStartTransaction.bind(this) as ResponseHandler
+ this.handleResponseStartTransaction.bind(this) as ResponseHandler,
],
[
OCPP16RequestCommand.STOP_TRANSACTION,
- this.handleResponseStopTransaction.bind(this) as ResponseHandler
+ this.handleResponseStopTransaction.bind(this) as ResponseHandler,
],
[
OCPP16RequestCommand.STATUS_NOTIFICATION,
- this.emptyResponseHandler.bind(this) as ResponseHandler
+ this.emptyResponseHandler.bind(this) as ResponseHandler,
],
[OCPP16RequestCommand.METER_VALUES, this.emptyResponseHandler],
[
OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION,
- this.emptyResponseHandler.bind(this) as ResponseHandler
+ this.emptyResponseHandler.bind(this) as ResponseHandler,
],
[OCPP16RequestCommand.DATA_TRANSFER, this.emptyResponseHandler],
- [OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION, this.emptyResponseHandler]
+ [OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION, this.emptyResponseHandler],
])
this.payloadValidateFunctions = new Map<OCPP16RequestCommand, ValidateFunction<JsonType>>([
[
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16RequestCommand.HEARTBEAT,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16RequestCommand.AUTHORIZE,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16RequestCommand.START_TRANSACTION,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16RequestCommand.STOP_TRANSACTION,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16RequestCommand.STATUS_NOTIFICATION,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16RequestCommand.METER_VALUES,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16RequestCommand.DATA_TRANSFER,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION,
'constructor'
)
)
- .bind(this)
- ]
+ .bind(this),
+ ],
])
this.incomingRequestResponsePayloadValidateFunctions = new Map<
- OCPP16IncomingRequestCommand,
- ValidateFunction<JsonType>
+ OCPP16IncomingRequestCommand,
+ ValidateFunction<JsonType>
>([
[
OCPP16IncomingRequestCommand.RESET,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.CLEAR_CACHE,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.GET_CONFIGURATION,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.GET_COMPOSITE_SCHEDULE,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.GET_DIAGNOSTICS,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.TRIGGER_MESSAGE,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.DATA_TRANSFER,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.UPDATE_FIRMWARE,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.RESERVE_NOW,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP16IncomingRequestCommand.CANCEL_RESERVATION,
'constructor'
)
)
- .bind(this)
- ]
+ .bind(this),
+ ],
])
this.validatePayload = this.validatePayload.bind(this)
}
if (isAsyncFunction(responseHandler)) {
await responseHandler(chargingStation, payload, requestPayload)
} else {
- (
+ ;(
responseHandler as (
chargingStation: ChargingStation,
payload: JsonType,
logger.debug(
`${chargingStation.logPrefix()} idTag '${
requestPayload.idTag
- }' accepted on connector id ${authorizeConnectorId}`
+ }' accepted on connector id ${authorizeConnectorId.toString()}`
)
} else {
authorizeConnectorStatus.idTagAuthorized = false
const { connectorId } = requestPayload
if (connectorId === 0 || !chargingStation.hasConnector(connectorId)) {
logger.error(
- `${chargingStation.logPrefix()} Trying to start a transaction on a non existing connector id ${connectorId}`
+ `${chargingStation.logPrefix()} Trying to start a transaction on a non existing connector id ${connectorId.toString()}`
)
return
}
) {
logger.error(
`${chargingStation.logPrefix()} Trying to start a transaction with a not local authorized idTag ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
connectorStatus.localAuthorizeIdTag
- } on connector id ${connectorId}`
+ } on connector id ${connectorId.toString()}`
)
await this.resetConnectorOnStartTransactionError(chargingStation, connectorId)
return
) {
logger.error(
`${chargingStation.logPrefix()} Trying to start a transaction with a not authorized idTag ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
connectorStatus.authorizeIdTag
- } on connector id ${connectorId}`
+ } on connector id ${connectorId.toString()}`
)
await this.resetConnectorOnStartTransactionError(chargingStation, connectorId)
return
requestPayload.idTag
} different from the authorize request one ${
connectorStatus.authorizeIdTag
- } on connector id ${connectorId}`
+ } on connector id ${connectorId.toString()}`
)
await this.resetConnectorOnStartTransactionError(chargingStation, connectorId)
return
requestPayload.idTag
} different from the local authorized one ${
connectorStatus.localAuthorizeIdTag
- } on connector id ${connectorId}`
+ } on connector id ${connectorId.toString()}`
)
await this.resetConnectorOnStartTransactionError(chargingStation, connectorId)
return
}
if (connectorStatus?.transactionStarted === true) {
logger.error(
- `${chargingStation.logPrefix()} Trying to start a transaction on an already used connector id ${connectorId} by idTag ${
+ `${chargingStation.logPrefix()} Trying to start a transaction on an already used connector id ${connectorId.toString()} by idTag ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
connectorStatus.transactionIdTag
}`
)
for (const [id, status] of evseStatus.connectors) {
if (id !== connectorId && status.transactionStarted === true) {
logger.error(
- `${chargingStation.logPrefix()} Trying to start a transaction on an already used evse id ${evseId} by connector id ${id} with idTag ${
+ `${chargingStation.logPrefix()} Trying to start a transaction on an already used evse id ${evseId.toString()} by connector id ${id.toString()} with idTag ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
status.transactionIdTag
}`
)
connectorStatus?.status !== OCPP16ChargePointStatus.Preparing
) {
logger.error(
- `${chargingStation.logPrefix()} Trying to start a transaction on connector id ${connectorId} with status ${
+ `${chargingStation.logPrefix()} Trying to start a transaction on connector id ${connectorId.toString()} with status ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
connectorStatus?.status
}`
)
}
if (!Number.isSafeInteger(payload.transactionId)) {
logger.warn(
- `${chargingStation.logPrefix()} Trying to start a transaction on connector id ${connectorId} with a non integer transaction id ${
- payload.transactionId
+ `${chargingStation.logPrefix()} Trying to start a transaction on connector id ${connectorId.toString()} with a non integer transaction id ${
+ payload.transactionId.toString()
}, converting to integer`
)
payload.transactionId = convertToInt(payload.transactionId)
if (reservation.idTag !== requestPayload.idTag) {
logger.warn(
`${chargingStation.logPrefix()} Reserved transaction ${
- payload.transactionId
+ payload.transactionId.toString()
} started with a different idTag ${
requestPayload.idTag
} than the reservation one ${reservation.idTag}`
if (hasReservationExpired(reservation)) {
logger.warn(
`${chargingStation.logPrefix()} Reserved transaction ${
- payload.transactionId
+ payload.transactionId.toString()
} started with expired reservation ${
- requestPayload.reservationId
+ requestPayload.reservationId.toString()
} (expiry date: ${reservation.expiryDate.toISOString()}))`
)
}
} else {
logger.warn(
`${chargingStation.logPrefix()} Reserved transaction ${
- payload.transactionId
- } started with unknown reservation ${requestPayload.reservationId}`
+ payload.transactionId.toString()
+ } started with unknown reservation ${requestPayload.reservationId.toString()}`
)
}
}
chargingStation.stationInfo?.beginEndMeterValues === true &&
(await chargingStation.ocppRequestService.requestHandler<
- OCPP16MeterValuesRequest,
- OCPP16MeterValuesResponse
+ OCPP16MeterValuesRequest,
+ OCPP16MeterValuesResponse
>(chargingStation, OCPP16RequestCommand.METER_VALUES, {
connectorId,
transactionId: payload.transactionId,
- meterValue: [connectorStatus.transactionBeginMeterValue]
+ meterValue: [connectorStatus.transactionBeginMeterValue],
} satisfies OCPP16MeterValuesRequest))
await OCPP16ServiceUtils.sendAndSetConnectorStatus(
chargingStation,
OCPP16ChargePointStatus.Charging
)
logger.info(
- `${chargingStation.logPrefix()} Transaction with id ${payload.transactionId} STARTED on ${
+ `${chargingStation.logPrefix()} Transaction with id ${payload.transactionId.toString()} STARTED on ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
chargingStation.stationInfo?.chargingStationId
- }#${connectorId} for idTag '${requestPayload.idTag}'`
+ }#${connectorId.toString()} for idTag '${requestPayload.idTag}'`
)
if (chargingStation.stationInfo?.powerSharedByConnectors === true) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
} else {
logger.warn(
`${chargingStation.logPrefix()} Starting transaction with id ${
- payload.transactionId
+ payload.transactionId.toString()
} REJECTED on ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
chargingStation.stationInfo?.chargingStationId
- }#${connectorId} with status '${payload.idTagInfo.status}', idTag '${
+ }#${connectorId.toString()} with status '${payload.idTagInfo.status}', idTag '${
requestPayload.idTag
}'${
OCPP16ServiceUtils.hasReservation(chargingStation, connectorId, requestPayload.idTag)
- ? `, reservationId '${requestPayload.reservationId}'`
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ ? `, reservationId '${requestPayload.reservationId?.toString()}'`
: ''
}`
)
if (transactionConnectorId == null) {
logger.error(
`${chargingStation.logPrefix()} Trying to stop a non existing transaction with id ${
- requestPayload.transactionId
+ requestPayload.transactionId.toString()
}`
)
return
chargingStation.stationInfo.ocppStrictCompliance === false &&
chargingStation.stationInfo.outOfOrderEndMeterValues === true &&
(await chargingStation.ocppRequestService.requestHandler<
- OCPP16MeterValuesRequest,
- OCPP16MeterValuesResponse
+ OCPP16MeterValuesRequest,
+ OCPP16MeterValuesResponse
>(chargingStation, OCPP16RequestCommand.METER_VALUES, {
connectorId: transactionConnectorId,
transactionId: requestPayload.transactionId,
chargingStation,
transactionConnectorId,
requestPayload.meterStop
- )
- ]
+ ),
+ ],
}))
if (
!chargingStation.isChargingStationAvailable() ||
resetConnectorStatus(chargingStation.getConnectorStatus(transactionConnectorId))
chargingStation.stopMeterValues(transactionConnectorId)
const logMsg = `${chargingStation.logPrefix()} Transaction with id ${
- requestPayload.transactionId
+ requestPayload.transactionId.toString()
} STOPPED on ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
chargingStation.stationInfo?.chargingStationId
- }#${transactionConnectorId} with status '${payload.idTagInfo?.status}'`
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ }#${transactionConnectorId.toString()} with status '${payload.idTagInfo?.status}'`
if (
payload.idTagInfo == null ||
payload.idTagInfo.status === OCPP16AuthorizationStatus.ACCEPTED
type Interval,
isAfter,
isBefore,
- isWithinInterval
+ isWithinInterval,
} from 'date-fns'
import {
type ChargingStation,
hasFeatureProfile,
- hasReservationExpired
+ hasReservationExpired,
} from '../../../charging-station/index.js'
import {
type ConfigurationKey,
OCPP16StandardParametersKey,
OCPP16StopTransactionReason,
type OCPP16SupportedFeatureProfiles,
- OCPPVersion
+ OCPPVersion,
} from '../../../types/index.js'
import { convertToDate, isNotEmptyArray, logger, roundTo } from '../../../utils/index.js'
import { OCPPServiceUtils } from '../OCPPServiceUtils.js'
): OCPP16MeterValue {
const meterValue: OCPP16MeterValue = {
timestamp: new Date(),
- sampledValue: []
+ sampledValue: [],
}
// Energy.Active.Import.Register measurand (default)
const sampledValueTemplate = OCPP16ServiceUtils.getSampledValueTemplate(
): void {
if (chargingStation.getConnectorStatus(connectorId)?.chargingProfiles == null) {
logger.error(
- `${chargingStation.logPrefix()} Trying to set a charging profile on connector id ${connectorId} with an uninitialized charging profiles array attribute, applying deferred initialization`
+ `${chargingStation.logPrefix()} Trying to set a charging profile on connector id ${connectorId.toString()} with an uninitialized charging profiles array attribute, applying deferred initialization`
)
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
chargingStation.getConnectorStatus(connectorId)!.chargingProfiles = []
}
if (!Array.isArray(chargingStation.getConnectorStatus(connectorId)?.chargingProfiles)) {
logger.error(
- `${chargingStation.logPrefix()} Trying to set a charging profile on connector id ${connectorId} with an improper attribute type for the charging profiles array, applying proper type deferred initialization`
+ `${chargingStation.logPrefix()} Trying to set a charging profile on connector id ${connectorId.toString()} with an improper attribute type for the charging profiles array, applying proper type deferred initialization`
)
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
chargingStation.getConnectorStatus(connectorId)!.chargingProfiles = []
compositeChargingScheduleHigher!.startSchedule!,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
compositeChargingScheduleHigher!.duration!
- )
+ ),
}
const compositeChargingScheduleLowerInterval: Interval = {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
compositeChargingScheduleLower!.startSchedule!,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
compositeChargingScheduleLower!.duration!
- )
+ ),
}
const higherFirst = isBefore(
compositeChargingScheduleHigherInterval.start,
differenceInSeconds(
compositeChargingScheduleHigherInterval.start,
compositeChargingScheduleLowerInterval.start
- )
+ ),
}
}),
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
compositeChargingScheduleLowerInterval.start,
compositeChargingScheduleHigherInterval.start
)
- : 0
+ : 0,
}
- })
- ].sort((a, b) => a.startPeriod - b.startPeriod)
+ }),
+ ].sort((a, b) => a.startPeriod - b.startPeriod),
}
}
return {
differenceInSeconds(
compositeChargingScheduleHigherInterval.start,
compositeChargingScheduleLowerInterval.start
- )
+ ),
}
}),
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
),
{
start: compositeChargingScheduleLowerInterval.start,
- end: compositeChargingScheduleHigherInterval.end
+ end: compositeChargingScheduleHigherInterval.end,
}
)
) {
),
{
start: compositeChargingScheduleLowerInterval.start,
- end: compositeChargingScheduleHigherInterval.end
+ end: compositeChargingScheduleHigherInterval.end,
}
) &&
isWithinInterval(
),
{
start: compositeChargingScheduleLowerInterval.start,
- end: compositeChargingScheduleHigherInterval.end
+ end: compositeChargingScheduleHigherInterval.end,
}
)
) {
),
{
start: compositeChargingScheduleHigherInterval.start,
- end: compositeChargingScheduleLowerInterval.end
+ end: compositeChargingScheduleLowerInterval.end,
}
)
) {
compositeChargingScheduleLowerInterval.start,
compositeChargingScheduleHigherInterval.start
)
- : 0
+ : 0,
}
- })
- ].sort((a, b) => a.startPeriod - b.startPeriod)
+ }),
+ ].sort((a, b) => a.startPeriod - b.startPeriod),
}
}
chargingStationReservation.idTag === idTag)
) {
logger.debug(
- `${chargingStation.logPrefix()} Connector id ${connectorId} has a valid reservation for idTag ${idTag}: %j`,
+ `${chargingStation.logPrefix()} Connector id ${connectorId.toString()} has a valid reservation for idTag ${idTag}: %j`,
connectorReservation ?? chargingStationReservation
)
return true
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
start: chargingSchedule.startSchedule!,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- end: addSeconds(chargingSchedule.startSchedule!, chargingSchedule.duration!)
+ end: addSeconds(chargingSchedule.startSchedule!, chargingSchedule.duration!),
}
if (areIntervalsOverlapping(chargingScheduleInterval, compositeInterval)) {
chargingSchedule.chargingSchedulePeriod.sort((a, b) => a.startPeriod - b.startPeriod)
schedulePeriod.startPeriod = 0
}
return schedulePeriod
- })
+ }),
}
}
if (isAfter(chargingScheduleInterval.end, compositeInterval.end)) {
addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod),
compositeInterval
)
- )
+ ),
}
}
return chargingSchedule
import {
type ConnectorStatusTransition,
- OCPP20ConnectorStatusEnumType
+ OCPP20ConnectorStatusEnumType,
} from '../../../types/index.js'
import { OCPPConstants } from '../OCPPConstants.js'
// { from: OCPP20ConnectorStatusEnumType.Available, to: OCPP20ConnectorStatusEnumType.Available },
{
from: OCPP20ConnectorStatusEnumType.Available,
- to: OCPP20ConnectorStatusEnumType.Unavailable
+ to: OCPP20ConnectorStatusEnumType.Unavailable,
},
{
from: OCPP20ConnectorStatusEnumType.Available,
- to: OCPP20ConnectorStatusEnumType.Faulted
+ to: OCPP20ConnectorStatusEnumType.Faulted,
},
{ to: OCPP20ConnectorStatusEnumType.Unavailable },
{
from: OCPP20ConnectorStatusEnumType.Unavailable,
- to: OCPP20ConnectorStatusEnumType.Available
+ to: OCPP20ConnectorStatusEnumType.Available,
},
// {
// from: OCPP20ConnectorStatusEnumType.Unavailable,
// },
{
from: OCPP20ConnectorStatusEnumType.Unavailable,
- to: OCPP20ConnectorStatusEnumType.Faulted
+ to: OCPP20ConnectorStatusEnumType.Faulted,
},
{ to: OCPP20ConnectorStatusEnumType.Faulted },
{
from: OCPP20ConnectorStatusEnumType.Faulted,
- to: OCPP20ConnectorStatusEnumType.Available
+ to: OCPP20ConnectorStatusEnumType.Available,
},
{
from: OCPP20ConnectorStatusEnumType.Faulted,
- to: OCPP20ConnectorStatusEnumType.Unavailable
- }
+ to: OCPP20ConnectorStatusEnumType.Unavailable,
+ },
// { from: OCPP20ConnectorStatusEnumType.Faulted, to: OCPP20ConnectorStatusEnumType.Faulted }
])
// { from: OCPP20ConnectorStatusEnumType.Available, to: OCPP20ConnectorStatusEnumType.Available },
{
from: OCPP20ConnectorStatusEnumType.Available,
- to: OCPP20ConnectorStatusEnumType.Occupied
+ to: OCPP20ConnectorStatusEnumType.Occupied,
},
{
from: OCPP20ConnectorStatusEnumType.Available,
- to: OCPP20ConnectorStatusEnumType.Reserved
+ to: OCPP20ConnectorStatusEnumType.Reserved,
},
{
from: OCPP20ConnectorStatusEnumType.Available,
- to: OCPP20ConnectorStatusEnumType.Unavailable
+ to: OCPP20ConnectorStatusEnumType.Unavailable,
},
{
from: OCPP20ConnectorStatusEnumType.Available,
- to: OCPP20ConnectorStatusEnumType.Faulted
+ to: OCPP20ConnectorStatusEnumType.Faulted,
},
// { to: OCPP20ConnectorStatusEnumType.Occupied },
{
from: OCPP20ConnectorStatusEnumType.Occupied,
- to: OCPP20ConnectorStatusEnumType.Available
+ to: OCPP20ConnectorStatusEnumType.Available,
},
// { from: OCPP20ConnectorStatusEnumType.Occupied, to: OCPP20ConnectorStatusEnumType.Occupied },
// { from: OCPP20ConnectorStatusEnumType.Occupied, to: OCPP20ConnectorStatusEnumType.Reserved },
{
from: OCPP20ConnectorStatusEnumType.Occupied,
- to: OCPP20ConnectorStatusEnumType.Unavailable
+ to: OCPP20ConnectorStatusEnumType.Unavailable,
},
{
from: OCPP20ConnectorStatusEnumType.Occupied,
- to: OCPP20ConnectorStatusEnumType.Faulted
+ to: OCPP20ConnectorStatusEnumType.Faulted,
},
// { to: OCPP20ConnectorStatusEnumType.Reserved },
{
from: OCPP20ConnectorStatusEnumType.Reserved,
- to: OCPP20ConnectorStatusEnumType.Available
+ to: OCPP20ConnectorStatusEnumType.Available,
},
{
from: OCPP20ConnectorStatusEnumType.Reserved,
- to: OCPP20ConnectorStatusEnumType.Occupied
+ to: OCPP20ConnectorStatusEnumType.Occupied,
},
// { from: OCPP20ConnectorStatusEnumType.Reserved, to: OCPP20ConnectorStatusEnumType.Reserved },
{
from: OCPP20ConnectorStatusEnumType.Reserved,
- to: OCPP20ConnectorStatusEnumType.Unavailable
+ to: OCPP20ConnectorStatusEnumType.Unavailable,
},
{
from: OCPP20ConnectorStatusEnumType.Reserved,
- to: OCPP20ConnectorStatusEnumType.Faulted
+ to: OCPP20ConnectorStatusEnumType.Faulted,
},
{ to: OCPP20ConnectorStatusEnumType.Unavailable },
{
from: OCPP20ConnectorStatusEnumType.Unavailable,
- to: OCPP20ConnectorStatusEnumType.Available
+ to: OCPP20ConnectorStatusEnumType.Available,
},
{
from: OCPP20ConnectorStatusEnumType.Unavailable,
- to: OCPP20ConnectorStatusEnumType.Occupied
+ to: OCPP20ConnectorStatusEnumType.Occupied,
},
// { from: OCPP20ConnectorStatusEnumType.Unavailable, to: OCPP20ConnectorStatusEnumType.Reserved },
// { from: OCPP20ConnectorStatusEnumType.Unavailable, to: OCPP20ConnectorStatusEnumType.Unavailable },
{
from: OCPP20ConnectorStatusEnumType.Unavailable,
- to: OCPP20ConnectorStatusEnumType.Faulted
+ to: OCPP20ConnectorStatusEnumType.Faulted,
},
{ to: OCPP20ConnectorStatusEnumType.Faulted },
{
from: OCPP20ConnectorStatusEnumType.Faulted,
- to: OCPP20ConnectorStatusEnumType.Available
+ to: OCPP20ConnectorStatusEnumType.Available,
},
{
from: OCPP20ConnectorStatusEnumType.Faulted,
- to: OCPP20ConnectorStatusEnumType.Occupied
+ to: OCPP20ConnectorStatusEnumType.Occupied,
},
{
from: OCPP20ConnectorStatusEnumType.Faulted,
- to: OCPP20ConnectorStatusEnumType.Reserved
+ to: OCPP20ConnectorStatusEnumType.Reserved,
},
{
from: OCPP20ConnectorStatusEnumType.Faulted,
- to: OCPP20ConnectorStatusEnumType.Unavailable
- }
+ to: OCPP20ConnectorStatusEnumType.Unavailable,
+ },
// { from: OCPP20ConnectorStatusEnumType.Faulted, to: OCPP20ConnectorStatusEnumType.Faulted }
])
}
type JsonType,
type OCPP20ClearCacheRequest,
OCPP20IncomingRequestCommand,
- OCPPVersion
+ OCPPVersion,
} from '../../../types/index.js'
import { isAsyncFunction, logger } from '../../../utils/index.js'
import { OCPPIncomingRequestService } from '../OCPPIncomingRequestService.js'
protected payloadValidateFunctions: Map<OCPP20IncomingRequestCommand, ValidateFunction<JsonType>>
private readonly incomingRequestHandlers: Map<
- OCPP20IncomingRequestCommand,
- IncomingRequestHandler
+ OCPP20IncomingRequestCommand,
+ IncomingRequestHandler
>
public constructor () {
// }
super(OCPPVersion.VERSION_201)
this.incomingRequestHandlers = new Map<OCPP20IncomingRequestCommand, IncomingRequestHandler>([
- [OCPP20IncomingRequestCommand.CLEAR_CACHE, this.handleRequestClearCache.bind(this)]
+ [OCPP20IncomingRequestCommand.CLEAR_CACHE, this.handleRequestClearCache.bind(this)],
])
this.payloadValidateFunctions = new Map<
- OCPP20IncomingRequestCommand,
- ValidateFunction<JsonType>
+ OCPP20IncomingRequestCommand,
+ ValidateFunction<JsonType>
>([
[
OCPP20IncomingRequestCommand.CLEAR_CACHE,
'constructor'
)
)
- .bind(this)
- ]
+ .bind(this),
+ ],
])
this.validatePayload = this.validatePayload.bind(this)
}
OCPP20RequestCommand,
type OCPP20StatusNotificationRequest,
OCPPVersion,
- type RequestParams
+ type RequestParams,
} from '../../../types/index.js'
import { generateUUID } from '../../../utils/index.js'
import { OCPPRequestService } from '../OCPPRequestService.js'
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP20RequestCommand.HEARTBEAT,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP20RequestCommand.STATUS_NOTIFICATION,
'constructor'
)
)
- .bind(this)
- ]
+ .bind(this),
+ ],
])
this.buildRequestPayload = this.buildRequestPayload.bind(this)
}
case OCPP20RequestCommand.STATUS_NOTIFICATION:
return {
timestamp: new Date(),
- ...commandParams
+ ...commandParams,
} as unknown as Request
default:
// OCPPError usage here is debatable: it's an error in the OCPP stack but not targeted to sendError().
type OCPP20StatusNotificationResponse,
OCPPVersion,
RegistrationStatusEnumType,
- type ResponseHandler
+ type ResponseHandler,
} from '../../../types/index.js'
import { isAsyncFunction, logger } from '../../../utils/index.js'
import { OCPPResponseService } from '../OCPPResponseService.js'
export class OCPP20ResponseService extends OCPPResponseService {
public incomingRequestResponsePayloadValidateFunctions: Map<
- OCPP20IncomingRequestCommand,
- ValidateFunction<JsonType>
+ OCPP20IncomingRequestCommand,
+ ValidateFunction<JsonType>
>
protected payloadValidateFunctions: Map<OCPP20RequestCommand, ValidateFunction<JsonType>>
this.responseHandlers = new Map<OCPP20RequestCommand, ResponseHandler>([
[
OCPP20RequestCommand.BOOT_NOTIFICATION,
- this.handleResponseBootNotification.bind(this) as ResponseHandler
+ this.handleResponseBootNotification.bind(this) as ResponseHandler,
],
[OCPP20RequestCommand.HEARTBEAT, this.emptyResponseHandler],
- [OCPP20RequestCommand.STATUS_NOTIFICATION, this.emptyResponseHandler]
+ [OCPP20RequestCommand.STATUS_NOTIFICATION, this.emptyResponseHandler],
])
this.payloadValidateFunctions = new Map<OCPP20RequestCommand, ValidateFunction<JsonType>>([
[
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP20RequestCommand.HEARTBEAT,
'constructor'
)
)
- .bind(this)
+ .bind(this),
],
[
OCPP20RequestCommand.STATUS_NOTIFICATION,
'constructor'
)
)
- .bind(this)
- ]
+ .bind(this),
+ ],
])
this.incomingRequestResponsePayloadValidateFunctions = new Map<
- OCPP20IncomingRequestCommand,
- ValidateFunction<JsonType>
+ OCPP20IncomingRequestCommand,
+ ValidateFunction<JsonType>
>([
[
OCPP20IncomingRequestCommand.CLEAR_CACHE,
'constructor'
)
)
- .bind(this)
- ]
+ .bind(this),
+ ],
])
this.validatePayload = this.validatePayload.bind(this)
}
if (isAsyncFunction(responseHandler)) {
await responseHandler(chargingStation, payload, requestPayload)
} else {
- (
+ ;(
responseHandler as (
chargingStation: ChargingStation,
payload: JsonType,
MeterValueMeasurand,
ReservationStatus,
TriggerMessageStatus,
- UnlockStatus
+ UnlockStatus,
} from '../../types/index.js'
import { Constants } from '../../utils/index.js'
MeterValueMeasurand.VOLTAGE,
MeterValueMeasurand.POWER_ACTIVE_IMPORT,
MeterValueMeasurand.CURRENT_IMPORT,
- MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER
+ MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER,
])
static readonly OCPP_REQUEST_EMPTY = Constants.EMPTY_FROZEN_OBJECT
static readonly OCPP_RESPONSE_EMPTY = Constants.EMPTY_FROZEN_OBJECT
static readonly OCPP_RESPONSE_ACCEPTED = Object.freeze({
- status: GenericStatus.Accepted
+ status: GenericStatus.Accepted,
})
static readonly OCPP_RESPONSE_REJECTED = Object.freeze({
- status: GenericStatus.Rejected
+ status: GenericStatus.Rejected,
})
static readonly OCPP_CONFIGURATION_RESPONSE_ACCEPTED = Object.freeze({
- status: ConfigurationStatus.ACCEPTED
+ status: ConfigurationStatus.ACCEPTED,
})
static readonly OCPP_CONFIGURATION_RESPONSE_REJECTED = Object.freeze({
- status: ConfigurationStatus.REJECTED
+ status: ConfigurationStatus.REJECTED,
})
static readonly OCPP_CONFIGURATION_RESPONSE_REBOOT_REQUIRED = Object.freeze({
- status: ConfigurationStatus.REBOOT_REQUIRED
+ status: ConfigurationStatus.REBOOT_REQUIRED,
})
static readonly OCPP_CONFIGURATION_RESPONSE_NOT_SUPPORTED = Object.freeze({
- status: ConfigurationStatus.NOT_SUPPORTED
+ status: ConfigurationStatus.NOT_SUPPORTED,
})
static readonly OCPP_SET_CHARGING_PROFILE_RESPONSE_ACCEPTED = Object.freeze({
- status: ChargingProfileStatus.ACCEPTED
+ status: ChargingProfileStatus.ACCEPTED,
})
static readonly OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED = Object.freeze({
- status: ChargingProfileStatus.REJECTED
+ status: ChargingProfileStatus.REJECTED,
})
static readonly OCPP_SET_CHARGING_PROFILE_RESPONSE_NOT_SUPPORTED = Object.freeze({
- status: ChargingProfileStatus.NOT_SUPPORTED
+ status: ChargingProfileStatus.NOT_SUPPORTED,
})
static readonly OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_ACCEPTED = Object.freeze({
- status: ClearChargingProfileStatus.ACCEPTED
+ status: ClearChargingProfileStatus.ACCEPTED,
})
static readonly OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN = Object.freeze({
- status: ClearChargingProfileStatus.UNKNOWN
+ status: ClearChargingProfileStatus.UNKNOWN,
})
static readonly OCPP_RESPONSE_UNLOCKED = Object.freeze({
- status: UnlockStatus.UNLOCKED
+ status: UnlockStatus.UNLOCKED,
})
static readonly OCPP_RESPONSE_UNLOCK_FAILED = Object.freeze({
- status: UnlockStatus.UNLOCK_FAILED
+ status: UnlockStatus.UNLOCK_FAILED,
})
static readonly OCPP_RESPONSE_UNLOCK_NOT_SUPPORTED = Object.freeze({
- status: UnlockStatus.NOT_SUPPORTED
+ status: UnlockStatus.NOT_SUPPORTED,
})
static readonly OCPP_AVAILABILITY_RESPONSE_ACCEPTED = Object.freeze({
- status: AvailabilityStatus.ACCEPTED
+ status: AvailabilityStatus.ACCEPTED,
})
static readonly OCPP_AVAILABILITY_RESPONSE_REJECTED = Object.freeze({
- status: AvailabilityStatus.REJECTED
+ status: AvailabilityStatus.REJECTED,
})
static readonly OCPP_AVAILABILITY_RESPONSE_SCHEDULED = Object.freeze({
- status: AvailabilityStatus.SCHEDULED
+ status: AvailabilityStatus.SCHEDULED,
})
static readonly OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED = Object.freeze({
- status: TriggerMessageStatus.ACCEPTED
+ status: TriggerMessageStatus.ACCEPTED,
})
static readonly OCPP_TRIGGER_MESSAGE_RESPONSE_REJECTED = Object.freeze({
- status: TriggerMessageStatus.REJECTED
+ status: TriggerMessageStatus.REJECTED,
})
static readonly OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED = Object.freeze({
- status: TriggerMessageStatus.NOT_IMPLEMENTED
+ status: TriggerMessageStatus.NOT_IMPLEMENTED,
})
static readonly OCPP_DATA_TRANSFER_RESPONSE_ACCEPTED = Object.freeze({
- status: DataTransferStatus.ACCEPTED
+ status: DataTransferStatus.ACCEPTED,
})
static readonly OCPP_DATA_TRANSFER_RESPONSE_REJECTED = Object.freeze({
- status: DataTransferStatus.REJECTED
+ status: DataTransferStatus.REJECTED,
})
static readonly OCPP_DATA_TRANSFER_RESPONSE_UNKNOWN_VENDOR_ID = Object.freeze({
- status: DataTransferStatus.UNKNOWN_VENDOR_ID
+ status: DataTransferStatus.UNKNOWN_VENDOR_ID,
})
static readonly OCPP_RESERVATION_RESPONSE_ACCEPTED = Object.freeze({
- status: ReservationStatus.ACCEPTED
+ status: ReservationStatus.ACCEPTED,
}) // Reservation has been made
static readonly OCPP_RESERVATION_RESPONSE_FAULTED = Object.freeze({
- status: ReservationStatus.FAULTED
+ status: ReservationStatus.FAULTED,
}) // Reservation has not been made, because of connector in FAULTED state
static readonly OCPP_RESERVATION_RESPONSE_OCCUPIED = Object.freeze({
- status: ReservationStatus.OCCUPIED
+ status: ReservationStatus.OCCUPIED,
}) // Reservation has not been made, because all connectors are OCCUPIED
static readonly OCPP_RESERVATION_RESPONSE_REJECTED = Object.freeze({
- status: ReservationStatus.REJECTED
+ status: ReservationStatus.REJECTED,
}) // Reservation has not been made, because charging station is not configured to accept reservations
static readonly OCPP_RESERVATION_RESPONSE_UNAVAILABLE = Object.freeze({
- status: ReservationStatus.UNAVAILABLE
+ status: ReservationStatus.UNAVAILABLE,
}) // Reservation has not been made, because connector is in UNAVAILABLE state
static readonly OCPP_CANCEL_RESERVATION_RESPONSE_ACCEPTED = Object.freeze({
- status: GenericStatus.Accepted
+ status: GenericStatus.Accepted,
}) // Reservation for id has been cancelled
static readonly OCPP_CANCEL_RESERVATION_RESPONSE_REJECTED = Object.freeze({
- status: GenericStatus.Rejected
+ status: GenericStatus.Rejected,
}) // Reservation could not be cancelled, because there is no reservation active for id
protected constructor () {
ClearCacheResponse,
IncomingRequestCommand,
JsonType,
- OCPPVersion
+ OCPPVersion,
} from '../../types/index.js'
import { logger } from '../../utils/index.js'
import { OCPPConstants } from './OCPPConstants.js'
private readonly version: OCPPVersion
protected readonly ajv: Ajv
protected abstract payloadValidateFunctions: Map<
- IncomingRequestCommand,
- ValidateFunction<JsonType>
+ IncomingRequestCommand,
+ ValidateFunction<JsonType>
>
protected constructor (version: OCPPVersion) {
this.version = version
this.ajv = new Ajv({
keywords: ['javaType'],
- multipleOfPrecision: 2
+ multipleOfPrecision: 2,
})
ajvFormats(this.ajv)
this.incomingRequestHandler = this.incomingRequestHandler.bind(this)
type RequestParams,
type Response,
type ResponseCallback,
- type ResponseType
+ type ResponseType,
} from '../../types/index.js'
import {
clone,
formatDurationMilliSeconds,
handleSendMessageError,
- logger
+ logger,
} from '../../utils/index.js'
import { OCPPConstants } from './OCPPConstants.js'
import type { OCPPResponseService } from './OCPPResponseService.js'
import {
ajvErrorsToErrorType,
convertDateToISOString,
- getMessageTypeString
+ getMessageTypeString,
} from './OCPPServiceUtils.js'
type Ajv = _Ajv.default
// eslint-disable-next-line @typescript-eslint/no-redeclare
const defaultRequestParams: RequestParams = {
skipBufferingOnError: false,
triggerMessage: false,
- throwError: false
+ throwError: false,
}
export abstract class OCPPRequestService {
this.version = version
this.ajv = new Ajv({
keywords: ['javaType'],
- multipleOfPrecision: 2
+ multipleOfPrecision: 2,
})
ajvFormats(this.ajv)
this.ocppResponseService = ocppResponseService
MessageType.CALL_RESULT_MESSAGE,
error as Error,
{
- throwError: true
+ throwError: true,
}
)
return null
): Promise<ResponseType> {
params = {
...defaultRequestParams,
- ...params
+ ...params,
}
try {
return await this.internalSendMessage(
MessageType.CALL_MESSAGE,
error as Error,
{
- throwError: params.throwError
+ throwError: params.throwError,
}
)
return null
): Promise<ResponseType> {
params = {
...defaultRequestParams,
- ...params
+ ...params,
}
if (
(chargingStation.inUnknownState() && commandName === RequestCommand.BOOT_NOTIFICATION) ||
return await new Promise<ResponseType>((resolve, reject: (reason?: unknown) => void) => {
/**
* Function that will receive the request's response
- *
* @param payload -
* @param requestPayload -
*/
)
.then(() => {
resolve(payload)
+ return undefined
})
- .catch(reject)
.finally(() => {
chargingStation.requests.delete(messageId)
chargingStation.emit(ChargingStationEvents.updated)
})
+ .catch(reject)
}
/**
* Function that will receive the request's error response
- *
* @param ocppError -
* @param requestStatistic -
*/
{
name: error.name,
message: error.message,
- stack: error.stack
+ stack: error.stack,
}
)
)
}
throw new OCPPError(
ErrorType.SECURITY_ERROR,
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`Cannot send command ${commandName} PDU when the charging station is in ${chargingStation.bootNotificationResponse?.status} state on the central server`,
commandName
)
messageType,
messageId,
commandName as RequestCommand,
- messagePayload as JsonType
+ messagePayload as JsonType,
] satisfies OutgoingRequest)
break
// Response
messageToSend = JSON.stringify([
messageType,
messageId,
- messagePayload as JsonType
+ messagePayload as JsonType,
] satisfies Response)
break
// Error Message
(messagePayload as OCPPError).code,
(messagePayload as OCPPError).message,
(messagePayload as OCPPError).details ?? {
- command: (messagePayload as OCPPError).command
- }
+ command: (messagePayload as OCPPError).command,
+ },
] satisfies ErrorResponse)
break
}
responseCallback,
errorCallback,
commandName,
- messagePayload
+ messagePayload,
])
}
IncomingRequestCommand,
JsonType,
OCPPVersion,
- RequestCommand
+ RequestCommand,
} from '../../types/index.js'
import { Constants, logger } from '../../utils/index.js'
import { ajvErrorsToErrorType } from './OCPPServiceUtils.js'
protected readonly ajvIncomingRequest: Ajv
protected abstract payloadValidateFunctions: Map<RequestCommand, ValidateFunction<JsonType>>
public abstract incomingRequestResponsePayloadValidateFunctions: Map<
- IncomingRequestCommand,
- ValidateFunction<JsonType>
+ IncomingRequestCommand,
+ ValidateFunction<JsonType>
>
protected constructor (version: OCPPVersion) {
this.version = version
this.ajv = new Ajv({
keywords: ['javaType'],
- multipleOfPrecision: 2
+ multipleOfPrecision: 2,
})
ajvFormats(this.ajv)
this.ajvIncomingRequest = new Ajv({
keywords: ['javaType'],
- multipleOfPrecision: 2
+ multipleOfPrecision: 2,
})
ajvFormats(this.ajvIncomingRequest)
this.responseHandler = this.responseHandler.bind(this)
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
-import type { DefinedError, ErrorObject, JSONSchemaType } from 'ajv'
+import type { ErrorObject, JSONSchemaType } from 'ajv'
import { isDate } from 'date-fns'
import {
type ChargingStation,
getConfigurationKey,
- getIdTagsFile
+ getIdTagsFile,
} from '../../charging-station/index.js'
import { BaseError, OCPPError } from '../../exception/index.js'
import {
type SampledValueTemplate,
StandardParametersKey,
type StatusNotificationRequest,
- type StatusNotificationResponse
+ type StatusNotificationResponse,
} from '../../types/index.js'
import {
ACElectricUtils,
logPrefix,
max,
min,
- roundTo
+ roundTo,
} from '../../utils/index.js'
import { OCPP16Constants } from './1.6/OCPP16Constants.js'
import { OCPP20Constants } from './2.0/OCPP20Constants.js'
return {
connectorId,
status: status as OCPP16ChargePointStatus,
- errorCode: ChargePointErrorCode.NO_ERROR
+ errorCode: ChargePointErrorCode.NO_ERROR,
} satisfies OCPP16StatusNotificationRequest
case OCPPVersion.VERSION_20:
case OCPPVersion.VERSION_201:
connectorStatus: status as OCPP20ConnectorStatusEnumType,
connectorId,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- evseId: evseId!
+ evseId: evseId!,
} satisfies OCPP20StatusNotificationRequest
default:
throw new BaseError('Cannot build status notification payload: OCPP version not supported')
chargingStation,
RequestCommand.AUTHORIZE,
{
- idTag
+ idTag,
}
)
).idTagInfo.status === AuthorizationStatus.ACCEPTED
if (options.send) {
checkConnectorStatusTransition(chargingStation, connectorId, status)
await chargingStation.ocppRequestService.requestHandler<
- StatusNotificationRequest,
- StatusNotificationResponse
+ StatusNotificationRequest,
+ StatusNotificationResponse
>(
chargingStation,
RequestCommand.STATUS_NOTIFICATION,
chargingStation.getConnectorStatus(connectorId)!.status = status
chargingStation.emit(ChargingStationEvents.connectorStatusChanged, {
connectorId,
- ...chargingStation.getConnectorStatus(connectorId)
+ ...chargingStation.getConnectorStatus(connectorId),
})
}
break
default:
throw new BaseError(
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`Cannot check connector status transition: OCPP version ${chargingStation.stationInfo?.ocppVersion} not supported`
)
}
logger.warn(
`${chargingStation.logPrefix()} OCPP ${
chargingStation.stationInfo.ocppVersion
- } connector id ${connectorId} status transition from '${
+ } connector id ${connectorId.toString()} status transition from '${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
chargingStation.getConnectorStatus(connectorId)?.status
}' to '${status}' is not allowed`
)
export const ajvErrorsToErrorType = (errors: ErrorObject[] | undefined | null): ErrorType => {
if (isNotEmptyArray(errors)) {
- for (const error of errors as DefinedError[]) {
+ for (const error of errors) {
switch (error.keyword) {
case 'type':
return ErrorType.TYPE_CONSTRAINT_VIOLATION
for (const key in object) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion, @typescript-eslint/no-non-null-assertion
if (isDate(object![key])) {
+ ;(object[key] as unknown as string) = (object[key] as Date).toISOString()
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion, @typescript-eslint/no-non-null-assertion
- (object![key] as string) = (object![key] as Date).toISOString()
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion, @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unnecessary-condition
- } else if (typeof object![key] === 'object' && object![key] !== null) {
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion, @typescript-eslint/no-non-null-assertion
- convertDateToISOString<T>(object![key] as T)
+ } else if (typeof object![key] === 'object' && object[key] !== null) {
+ convertDateToISOString<T>(object[key] as T)
}
}
}
case OCPPVersion.VERSION_16:
meterValue = {
timestamp: new Date(),
- sampledValue: []
+ sampledValue: [],
}
// SoC measurand
socSampledValueTemplate = getSampledValueTemplate(
`${chargingStation.logPrefix()} MeterValues measurand ${
meterValue.sampledValue[sampledValuesIndex].measurand ??
MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER
- }: connector id ${connectorId}, transaction id ${
- connector?.transactionId
- }, value: ${socMinimumValue}/${
+ }: connector id ${connectorId.toString()}, transaction id ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ connector?.transactionId?.toString()
+ }, value: ${socMinimumValue.toString()}/${
meterValue.sampledValue[sampledValuesIndex].value
- }/${socMaximumValue}`
+ }/${socMaximumValue.toString()}`
)
}
}
chargingStation.getNumberOfPhases() === 3 && phase <= chargingStation.getNumberOfPhases();
phase++
) {
- const phaseLineToNeutralValue = `L${phase}-N`
+ const phaseLineToNeutralValue = `L${phase.toString()}-N`
const voltagePhaseLineToNeutralSampledValueTemplate = getSampledValueTemplate(
chargingStation,
connectorId,
)
)
if (chargingStation.stationInfo.phaseLineToLineVoltageMeterValues === true) {
- const phaseLineToLineValue = `L${phase}-L${
+ const phaseLineToLineValue = `L${phase.toString()}-L${
(phase + 1) % chargingStation.getNumberOfPhases() !== 0
- ? (phase + 1) % chargingStation.getNumberOfPhases()
- : chargingStation.getNumberOfPhases()
+ ? ((phase + 1) % chargingStation.getNumberOfPhases()).toString()
+ : chargingStation.getNumberOfPhases().toString()
}`
const voltagePhaseLineToLineValueRounded = roundTo(
Math.sqrt(chargingStation.getNumberOfPhases()) *
connectorId,
MeterValueMeasurand.POWER_ACTIVE_IMPORT,
MeterValuePhase.L3_N
- )
+ ),
}
}
if (powerSampledValueTemplate != null) {
checkMeasurandPowerDivider(chargingStation, powerSampledValueTemplate.measurand)
const errMsg = `MeterValues measurand ${
powerSampledValueTemplate.measurand ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
}: Unknown ${chargingStation.stationInfo.currentOutType} currentOutType in template file ${
chargingStation.templateFile
}, cannot calculate ${
powerSampledValueTemplate.measurand ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER
} measurand value`
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
const powerMeasurandValues: MeasurandValues = {} as MeasurandValues
const unitDivider = powerSampledValueTemplate.unit === MeterValueUnit.KILO_WATT ? 1000 : 1
connectorMaximumAvailablePower =
{
limitationEnabled:
chargingStation.stationInfo.customValueLimitationMeterValues,
- fallbackValue: connectorMinimumPower / unitDivider
+ fallbackValue: connectorMinimumPower / unitDivider,
}
) / chargingStation.getNumberOfPhases(),
powerSampledValueTemplate.fluctuationPercent ??
{
limitationEnabled:
chargingStation.stationInfo.customValueLimitationMeterValues,
- fallbackValue: connectorMinimumPowerPerPhase / unitDivider
+ fallbackValue: connectorMinimumPowerPerPhase / unitDivider,
}
),
powerPerPhaseSampledValueTemplates.L1.fluctuationPercent ??
{
limitationEnabled:
chargingStation.stationInfo.customValueLimitationMeterValues,
- fallbackValue: connectorMinimumPowerPerPhase / unitDivider
+ fallbackValue: connectorMinimumPowerPerPhase / unitDivider,
}
),
powerPerPhaseSampledValueTemplates.L2.fluctuationPercent ??
{
limitationEnabled:
chargingStation.stationInfo.customValueLimitationMeterValues,
- fallbackValue: connectorMinimumPowerPerPhase / unitDivider
+ fallbackValue: connectorMinimumPowerPerPhase / unitDivider,
}
),
powerPerPhaseSampledValueTemplates.L3.fluctuationPercent ??
{
limitationEnabled:
chargingStation.stationInfo.customValueLimitationMeterValues,
- fallbackValue: connectorMinimumPower / unitDivider
+ fallbackValue: connectorMinimumPower / unitDivider,
}
),
powerSampledValueTemplate.fluctuationPercent ??
{
limitationEnabled:
chargingStation.stationInfo.customValueLimitationMeterValues,
- fallbackValue: connectorMinimumPower / unitDivider
+ fallbackValue: connectorMinimumPower / unitDivider,
}
),
powerSampledValueTemplate.fluctuationPercent ??
`${chargingStation.logPrefix()} MeterValues measurand ${
meterValue.sampledValue[sampledValuesIndex].measurand ??
MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER
- }: connector id ${connectorId}, transaction id ${
- connector?.transactionId
- }, value: ${connectorMinimumPowerRounded}/${
+ }: connector id ${connectorId.toString()}, transaction id ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ connector?.transactionId?.toString()
+ }, value: ${connectorMinimumPowerRounded.toString()}/${
meterValue.sampledValue[sampledValuesIndex].value
- }/${connectorMaximumPowerRounded}`
+ }/${connectorMaximumPowerRounded.toString()}`
)
}
for (
chargingStation.getNumberOfPhases() === 3 && phase <= chargingStation.getNumberOfPhases();
phase++
) {
- const phaseValue = `L${phase}-N`
+ const phaseValue = `L${phase.toString()}-N`
meterValue.sampledValue.push(
buildSampledValue(
powerPerPhaseSampledValueTemplates[
- `L${phase}` as keyof MeasurandPerPhaseSampledValueTemplates
+ `L${phase.toString()}` as keyof MeasurandPerPhaseSampledValueTemplates
] ?? powerSampledValueTemplate,
- powerMeasurandValues[`L${phase}` as keyof MeasurandPerPhaseSampledValueTemplates],
+ powerMeasurandValues[`L${phase.toString()}` as keyof MeasurandPerPhaseSampledValueTemplates],
undefined,
phaseValue as MeterValuePhase
)
meterValue.sampledValue[sampledValuesPerPhaseIndex].measurand ??
MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER
}: phase ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
meterValue.sampledValue[sampledValuesPerPhaseIndex].phase
- }, connector id ${connectorId}, transaction id ${
- connector?.transactionId
- }, value: ${connectorMinimumPowerPerPhaseRounded}/${
+ }, connector id ${connectorId.toString()}, transaction id ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ connector?.transactionId?.toString()
+ }, value: ${connectorMinimumPowerPerPhaseRounded.toString()}/${
meterValue.sampledValue[sampledValuesPerPhaseIndex].value
- }/${connectorMaximumPowerPerPhaseRounded}`
+ }/${connectorMaximumPowerPerPhaseRounded.toString()}`
)
}
}
connectorId,
MeterValueMeasurand.CURRENT_IMPORT,
MeterValuePhase.L3
- )
+ ),
}
}
if (currentSampledValueTemplate != null) {
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
checkMeasurandPowerDivider(chargingStation, currentSampledValueTemplate.measurand)
const errMsg = `MeterValues measurand ${
currentSampledValueTemplate.measurand ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
}: Unknown ${chargingStation.stationInfo.currentOutType} currentOutType in template file ${
chargingStation.templateFile
}, cannot calculate ${
currentSampledValueTemplate.measurand ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER
} measurand value`
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
const currentMeasurandValues: MeasurandValues = {} as MeasurandValues
connectorMaximumAvailablePower == null &&
(connectorMaximumAvailablePower =
{
limitationEnabled:
chargingStation.stationInfo.customValueLimitationMeterValues,
- fallbackValue: connectorMinimumAmperage
+ fallbackValue: connectorMinimumAmperage,
}
),
currentSampledValueTemplate.fluctuationPercent ??
{
limitationEnabled:
chargingStation.stationInfo.customValueLimitationMeterValues,
- fallbackValue: connectorMinimumAmperage
+ fallbackValue: connectorMinimumAmperage,
}
),
currentPerPhaseSampledValueTemplates.L1.fluctuationPercent ??
{
limitationEnabled:
chargingStation.stationInfo.customValueLimitationMeterValues,
- fallbackValue: connectorMinimumAmperage
+ fallbackValue: connectorMinimumAmperage,
}
),
currentPerPhaseSampledValueTemplates.L2.fluctuationPercent ??
{
limitationEnabled:
chargingStation.stationInfo.customValueLimitationMeterValues,
- fallbackValue: connectorMinimumAmperage
+ fallbackValue: connectorMinimumAmperage,
}
),
currentPerPhaseSampledValueTemplates.L3.fluctuationPercent ??
{
limitationEnabled:
chargingStation.stationInfo.customValueLimitationMeterValues,
- fallbackValue: connectorMinimumAmperage
+ fallbackValue: connectorMinimumAmperage,
}
),
currentSampledValueTemplate.fluctuationPercent ??
{
limitationEnabled:
chargingStation.stationInfo.customValueLimitationMeterValues,
- fallbackValue: connectorMinimumAmperage
+ fallbackValue: connectorMinimumAmperage,
}
),
currentSampledValueTemplate.fluctuationPercent ??
`${chargingStation.logPrefix()} MeterValues measurand ${
meterValue.sampledValue[sampledValuesIndex].measurand ??
MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER
- }: connector id ${connectorId}, transaction id ${
- connector?.transactionId
- }, value: ${connectorMinimumAmperage}/${
+ }: connector id ${connectorId.toString()}, transaction id ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ connector?.transactionId?.toString()
+ }, value: ${connectorMinimumAmperage.toString()}/${
meterValue.sampledValue[sampledValuesIndex].value
- }/${connectorMaximumAmperage}`
+ }/${connectorMaximumAmperage.toString()}`
)
}
for (
chargingStation.getNumberOfPhases() === 3 && phase <= chargingStation.getNumberOfPhases();
phase++
) {
- const phaseValue = `L${phase}`
+ const phaseValue = `L${phase.toString()}`
meterValue.sampledValue.push(
buildSampledValue(
currentPerPhaseSampledValueTemplates[
meterValue.sampledValue[sampledValuesPerPhaseIndex].measurand ??
MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER
}: phase ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
meterValue.sampledValue[sampledValuesPerPhaseIndex].phase
- }, connector id ${connectorId}, transaction id ${
- connector?.transactionId
- }, value: ${connectorMinimumAmperage}/${
+ }, connector id ${connectorId.toString()}, transaction id ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ connector?.transactionId?.toString()
+ }, value: ${connectorMinimumAmperage.toString()}/${
meterValue.sampledValue[sampledValuesPerPhaseIndex].value
- }/${connectorMaximumAmperage}`
+ }/${connectorMaximumAmperage.toString()}`
)
}
}
{
limitationEnabled: chargingStation.stationInfo.customValueLimitationMeterValues,
fallbackValue: connectorMinimumEnergyRounded,
- unitMultiplier: unitDivider
+ unitMultiplier: unitDivider,
}
),
energySampledValueTemplate.fluctuationPercent ?? Constants.DEFAULT_FLUCTUATION_PERCENT
`${chargingStation.logPrefix()} MeterValues measurand ${
meterValue.sampledValue[sampledValuesIndex].measurand ??
MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER
- }: connector id ${connectorId}, transaction id ${
- connector?.transactionId
- }, value: ${connectorMinimumEnergyRounded}/${energyValueRounded}/${connectorMaximumEnergyRounded}, duration: ${interval}ms`
+ }: connector id ${connectorId.toString()}, transaction id ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ connector?.transactionId?.toString()
+ }, value: ${connectorMinimumEnergyRounded.toString()}/${energyValueRounded.toString()}/${connectorMaximumEnergyRounded.toString()}, duration: ${interval.toString()}ms`
)
}
}
case OCPPVersion.VERSION_201:
default:
throw new BaseError(
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`Cannot build meterValue: OCPP version ${chargingStation.stationInfo?.ocppVersion} not supported`
)
}
case OCPPVersion.VERSION_16:
meterValue = {
timestamp: new Date(),
- sampledValue: []
+ sampledValue: [],
}
// Energy.Active.Import.Register measurand (default)
sampledValueTemplate = getSampledValueTemplate(chargingStation, connectorId)
case OCPPVersion.VERSION_201:
default:
throw new BaseError(
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`Cannot build meterValue: OCPP version ${chargingStation.stationInfo?.ocppVersion} not supported`
)
}
} else if (chargingStation.powerDivider <= 0) {
const errMsg = `MeterValues measurand ${
measurandType ?? MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER
- }: powerDivider have zero or below value ${chargingStation.powerDivider}`
+ }: powerDivider have zero or below value ${chargingStation.powerDivider.toString()}`
logger.error(`${chargingStation.logPrefix()} ${errMsg}`)
throw new OCPPError(ErrorType.INTERNAL_ERROR, errMsg, RequestCommand.METER_VALUES)
}
...{
limitationEnabled: false,
unitMultiplier: 1,
- fallbackValue: 0
+ fallbackValue: 0,
},
- ...options
+ ...options,
}
const parsedValue = Number.parseInt(value ?? '')
- if (options.limitationEnabled === true) {
+ if (options.limitationEnabled) {
return max(
min(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const onPhaseStr = phase != null ? `on phase ${phase} ` : ''
if (!OCPPConstants.OCPP_MEASURANDS_SUPPORTED.includes(measurand)) {
logger.warn(
- `${chargingStation.logPrefix()} Trying to get unsupported MeterValues measurand '${measurand}' ${onPhaseStr}in template on connector id ${connectorId}`
+ `${chargingStation.logPrefix()} Trying to get unsupported MeterValues measurand '${measurand}' ${onPhaseStr}in template on connector id ${connectorId.toString()}`
)
return
}
)?.value?.includes(measurand) === false
) {
logger.debug(
- `${chargingStation.logPrefix()} Trying to get MeterValues measurand '${measurand}' ${onPhaseStr}in template on connector id ${connectorId} not found in '${
+ `${chargingStation.logPrefix()} Trying to get MeterValues measurand '${measurand}' ${onPhaseStr}in template on connector id ${connectorId.toString()} not found in '${
StandardParametersKey.MeterValuesSampledData
}' OCPP parameter`
)
)
) {
logger.warn(
- `${chargingStation.logPrefix()} Unsupported MeterValues measurand '${measurand}' ${onPhaseStr}in template on connector id ${connectorId}`
+ `${chargingStation.logPrefix()} Unsupported MeterValues measurand '${measurand}' ${onPhaseStr}in template on connector id ${connectorId.toString()}`
)
} else if (
phase != null &&
}
}
if (measurand === MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER) {
- const errorMsg = `Missing MeterValues for default measurand '${measurand}' in template on connector id ${connectorId}`
+ const errorMsg = `Missing MeterValues for default measurand '${measurand}' in template on connector id ${connectorId.toString()}`
logger.error(`${chargingStation.logPrefix()} ${errorMsg}`)
throw new BaseError(errorMsg)
}
logger.debug(
- `${chargingStation.logPrefix()} No MeterValues for measurand '${measurand}' ${onPhaseStr}in template on connector id ${connectorId}`
+ `${chargingStation.logPrefix()} No MeterValues for measurand '${measurand}' ${onPhaseStr}in template on connector id ${connectorId.toString()}`
)
}
const sampledValuePhase = phase ?? sampledValueTemplate.phase
return {
...(sampledValueTemplate.unit != null && {
- unit: sampledValueTemplate.unit
+ unit: sampledValueTemplate.unit,
}),
...(sampledValueContext != null && { context: sampledValueContext }),
...(sampledValueTemplate.measurand != null && {
- measurand: sampledValueTemplate.measurand
+ measurand: sampledValueTemplate.measurand,
}),
...(sampledValueLocation != null && { location: sampledValueLocation }),
...{ value: value.toString() },
- ...(sampledValuePhase != null && { phase: sampledValuePhase })
+ ...(sampledValuePhase != null && { phase: sampledValuePhase }),
} satisfies SampledValue
}
): boolean {
if (connectorId < 0) {
logger.error(
- `${chargingStation.logPrefix()} ${ocppCommand} incoming request received with invalid connector id ${connectorId}`
+ `${chargingStation.logPrefix()} ${ocppCommand} incoming request received with invalid connector id ${connectorId.toString()}`
)
return false
}
OCPPServiceUtils.logPrefix(ocppVersion, moduleName, methodName),
{ throwError: false }
)
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
return {} as JSONSchemaType<T>
}
}
buildTransactionEndMeterValue,
getMessageTypeString,
isIdTagAuthorized,
- sendAndSetConnectorStatus
+ sendAndSetConnectorStatus,
} from './OCPPServiceUtils.js'
ProtocolVersion,
type RequestPayload,
type ResponsePayload,
- type UIServerConfiguration
+ type UIServerConfiguration,
} from '../../types/index.js'
import { logger } from '../../utils/index.js'
import type { AbstractUIService } from './ui-services/AbstractUIService.js'
protected readonly httpServer: Server | Http2Server
protected readonly responseHandlers: Map<
`${string}-${string}-${string}-${string}-${string}`,
- ServerResponse | WebSocket
+ ServerResponse | WebSocket
>
protected readonly uiServices: Map<ProtocolVersion, AbstractUIService>
break
default:
throw new BaseError(
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`Unsupported application protocol version ${this.uiServerConfiguration.version} in '${ConfigurationSection.uiServer}' configuration section`
)
}
this.responseHandlers = new Map<
`${string}-${string}-${string}-${string}-${string}`,
- ServerResponse | WebSocket
+ ServerResponse | WebSocket
>()
this.uiServices = new Map<ProtocolVersion, AbstractUIService>()
}
private isValidProtocolBasicAuth (req: IncomingMessage, next: (err?: Error) => void): boolean {
const authorizationProtocol = req.headers['sec-websocket-protocol']?.split(/,\s+/).pop()
const [username, password] = getUsernameAndPasswordFromAuthorizationToken(
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/restrict-template-expressions
`${authorizationProtocol}${Array(((4 - (authorizationProtocol!.length % 4)) % 4) + 1).join(
'='
)}`
type ProtocolVersion,
type RequestPayload,
ResponseStatus,
- type UIServerConfiguration
+ type UIServerConfiguration,
} from '../../types/index.js'
import {
Constants,
isNotEmptyString,
JSONStringify,
logger,
- logPrefix
+ logPrefix,
} from '../../utils/index.js'
import { AbstractUIServer } from './AbstractUIServer.js'
import { isProtocolAndVersionSupported } from './UIServerUtils.js'
const res = this.responseHandlers.get(uuid) as ServerResponse
res
.writeHead(this.responseStatusToStatusCode(payload.status), {
- 'Content-Type': 'application/json'
+ 'Content-Type': 'application/json',
})
.end(JSONStringify(payload, undefined, MapStringifyFormat.object))
} else {
res
.writeHead(StatusCodes.UNAUTHORIZED, {
'Content-Type': 'text/plain',
- 'WWW-Authenticate': 'Basic realm=users'
+ 'WWW-Authenticate': 'Basic realm=users',
})
- .end(`${StatusCodes.UNAUTHORIZED} Unauthorized`)
+ .end(`${StatusCodes.UNAUTHORIZED.toString()} Unauthorized`)
res.destroy()
req.destroy()
}
this.buildProtocolResponse(uuid, {
status: ResponseStatus.FAILURE,
errorMessage: (error as Error).message,
- errorStack: (error as Error).stack
+ errorStack: (error as Error).stack,
})
)
return
if (protocolResponse != null) {
this.sendResponse(protocolResponse)
}
+ return undefined
})
.catch(Constants.EMPTY_FUNCTION)
})
} else {
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
throw new BaseError(`Unsupported HTTP method: '${req.method}'`)
}
} catch (error) {
ApplicationProtocolVersion,
AuthenticationType,
ConfigurationSection,
- type UIServerConfiguration
+ type UIServerConfiguration,
} from '../../types/index.js'
import { logger, logPrefix } from '../../utils/index.js'
import type { AbstractUIServer } from './AbstractUIServer.js'
uiServerConfiguration.type as ApplicationProtocol
)
) {
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
const logMsg = `Unknown application protocol type '${uiServerConfiguration.type}' in '${
ConfigurationSection.uiServer
- // eslint-disable-next-line @typescript-eslint/no-base-to-string
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
}' configuration section from values '${ApplicationProtocol.toString()}', defaulting to '${
ApplicationProtocol.WS
}'`
logger.error(
`${logPrefix(
' UI WebSocket Server |'
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
)} Unsupported protocol: '${protocol}' or protocol version: '${version}'`
)
return false
type ProtocolRequest,
type ProtocolResponse,
type UIServerConfiguration,
- WebSocketCloseEventStatusCode
+ WebSocketCloseEventStatusCode,
} from '../../types/index.js'
import {
Constants,
JSONStringify,
logger,
logPrefix,
- validateUUID
+ validateUUID,
} from '../../utils/index.js'
import { AbstractUIServer } from './AbstractUIServer.js'
import {
getProtocolAndVersion,
handleProtocols,
- isProtocolAndVersionSupported
+ isProtocolAndVersionSupported,
} from './UIServerUtils.js'
const moduleName = 'UIWebSocketServer'
super(uiServerConfiguration)
this.webSocketServer = new WebSocketServer({
handleProtocols,
- noServer: true
+ noServer: true,
})
}
if (protocolResponse != null) {
this.sendResponse(protocolResponse)
}
+ return undefined
})
.catch(Constants.EMPTY_FUNCTION)
})
})
this.httpServer.on('connect', (req: IncomingMessage, socket: Duplex, _head: Buffer) => {
if (req.headers.connection !== 'Upgrade' || req.headers.upgrade !== 'websocket') {
- socket.write(`HTTP/1.1 ${StatusCodes.BAD_REQUEST} Bad Request\r\n\r\n`)
+ socket.write(`HTTP/1.1 ${StatusCodes.BAD_REQUEST.toString()} Bad Request\r\n\r\n`)
socket.destroy()
}
})
socket.on('error', onSocketError)
this.authenticate(req, err => {
if (err != null) {
- socket.write(`HTTP/1.1 ${StatusCodes.UNAUTHORIZED} Unauthorized\r\n\r\n`)
+ socket.write(`HTTP/1.1 ${StatusCodes.UNAUTHORIZED.toString()} Unauthorized\r\n\r\n`)
socket.destroy()
return
}
moduleName,
'sendResponse'
)} Error at sending response id '${responseId}', WebSocket is not open: ${
- ws.readyState
+ ws.readyState.toString()
}`
)
}
`${this.logPrefix(
moduleName,
'validateRawDataRequest'
- // eslint-disable-next-line @typescript-eslint/no-base-to-string
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
)} UI protocol request is not valid JSON: ${rawData.toString()}`
)
return false
type RequestPayload,
type ResponsePayload,
ResponseStatus,
- type StorageConfiguration
+ type StorageConfiguration,
} from '../../../types/index.js'
import { Configuration, isAsyncFunction, isNotEmptyArray, logger } from '../../../utils/index.js'
import { Bootstrap } from '../../Bootstrap.js'
export abstract class AbstractUIService {
protected static readonly ProcedureNameToBroadCastChannelProcedureNameMapping = new Map<
- ProcedureName,
- BroadcastChannelProcedureName
+ ProcedureName,
+ BroadcastChannelProcedureName
>([
[ProcedureName.START_CHARGING_STATION, BroadcastChannelProcedureName.START_CHARGING_STATION],
[ProcedureName.STOP_CHARGING_STATION, BroadcastChannelProcedureName.STOP_CHARGING_STATION],
[
ProcedureName.DELETE_CHARGING_STATIONS,
- BroadcastChannelProcedureName.DELETE_CHARGING_STATIONS
+ BroadcastChannelProcedureName.DELETE_CHARGING_STATIONS,
],
[ProcedureName.CLOSE_CONNECTION, BroadcastChannelProcedureName.CLOSE_CONNECTION],
[ProcedureName.OPEN_CONNECTION, BroadcastChannelProcedureName.OPEN_CONNECTION],
[
ProcedureName.START_AUTOMATIC_TRANSACTION_GENERATOR,
- BroadcastChannelProcedureName.START_AUTOMATIC_TRANSACTION_GENERATOR
+ BroadcastChannelProcedureName.START_AUTOMATIC_TRANSACTION_GENERATOR,
],
[
ProcedureName.STOP_AUTOMATIC_TRANSACTION_GENERATOR,
- BroadcastChannelProcedureName.STOP_AUTOMATIC_TRANSACTION_GENERATOR
+ BroadcastChannelProcedureName.STOP_AUTOMATIC_TRANSACTION_GENERATOR,
],
[ProcedureName.SET_SUPERVISION_URL, BroadcastChannelProcedureName.SET_SUPERVISION_URL],
[ProcedureName.START_TRANSACTION, BroadcastChannelProcedureName.START_TRANSACTION],
[ProcedureName.DATA_TRANSFER, BroadcastChannelProcedureName.DATA_TRANSFER],
[
ProcedureName.DIAGNOSTICS_STATUS_NOTIFICATION,
- BroadcastChannelProcedureName.DIAGNOSTICS_STATUS_NOTIFICATION
+ BroadcastChannelProcedureName.DIAGNOSTICS_STATUS_NOTIFICATION,
],
[
ProcedureName.FIRMWARE_STATUS_NOTIFICATION,
- BroadcastChannelProcedureName.FIRMWARE_STATUS_NOTIFICATION
- ]
+ BroadcastChannelProcedureName.FIRMWARE_STATUS_NOTIFICATION,
+ ],
])
protected readonly requestHandlers: Map<ProcedureName, ProtocolRequestHandler>
private readonly uiServiceWorkerBroadcastChannel: UIServiceWorkerBroadcastChannel
private readonly broadcastChannelRequests: Map<
`${string}-${string}-${string}-${string}-${string}`,
- number
+ number
>
constructor (uiServer: AbstractUIServer, version: ProtocolVersion) {
[ProcedureName.PERFORMANCE_STATISTICS, this.handlePerformanceStatistics.bind(this)],
[ProcedureName.SIMULATOR_STATE, this.handleSimulatorState.bind(this)],
[ProcedureName.START_SIMULATOR, this.handleStartSimulator.bind(this)],
- [ProcedureName.STOP_SIMULATOR, this.handleStopSimulator.bind(this)]
+ [ProcedureName.STOP_SIMULATOR, this.handleStopSimulator.bind(this)],
])
this.uiServiceWorkerBroadcastChannel = new UIServiceWorkerBroadcastChannel(this)
this.broadcastChannelRequests = new Map<
`${string}-${string}-${string}-${string}-${string}`,
- number
+ number
>()
}
let requestPayload: RequestPayload | undefined
let responsePayload: ResponsePayload | undefined
try {
- [uuid, command, requestPayload] = request
+ ;[uuid, command, requestPayload] = request
if (!this.requestHandlers.has(command)) {
throw new BaseError(
responsePayload,
errorMessage: (error as OCPPError).message,
errorStack: (error as OCPPError).stack,
- errorDetails: (error as OCPPError).details
+ errorDetails: (error as OCPPError).details,
} satisfies ResponsePayload
}
if (responsePayload != null) {
private handleListTemplates (): ResponsePayload {
return {
status: ResponseStatus.SUCCESS,
- templates: [...this.uiServer.chargingStationTemplates.values()] as JsonType[]
+ templates: [...this.uiServer.chargingStationTemplates.values()],
} satisfies ResponsePayload
}
private handleListChargingStations (): ResponsePayload {
return {
status: ResponseStatus.SUCCESS,
- chargingStations: [...this.uiServer.chargingStations.values()] as JsonType[]
+ chargingStations: [...this.uiServer.chargingStations.values()],
} satisfies ResponsePayload
}
return {
status: ResponseStatus.FAILURE,
errorMessage:
- 'Cannot add charging station(s) while the charging stations simulator is not started'
+ 'Cannot add charging station(s) while the charging stations simulator is not started',
} satisfies ResponsePayload
}
if (typeof template !== 'string' || typeof numberOfStations !== 'number') {
return {
status: ResponseStatus.FAILURE,
- errorMessage: 'Invalid request payload'
+ errorMessage: 'Invalid request payload',
} satisfies ResponsePayload
}
if (!this.uiServer.chargingStationTemplates.has(template)) {
return {
status: ResponseStatus.FAILURE,
- errorMessage: `Template '${template}' not found`
+ errorMessage: `Template '${template}' not found`,
} satisfies ResponsePayload
}
const succeededStationInfos: ChargingStationInfo[] = []
return {
status: err != null ? ResponseStatus.FAILURE : ResponseStatus.SUCCESS,
...(succeededStationInfos.length > 0 && {
- hashIdsSucceeded: succeededStationInfos.map(stationInfo => stationInfo.hashId)
+ hashIdsSucceeded: succeededStationInfos.map(stationInfo => stationInfo.hashId),
}),
...(failedStationInfos.length > 0 && {
- hashIdsFailed: failedStationInfos.map(stationInfo => stationInfo.hashId)
+ hashIdsFailed: failedStationInfos.map(stationInfo => stationInfo.hashId),
}),
- ...(err != null && { errorMessage: err.message, errorStack: err.stack })
+ ...(err != null && { errorMessage: err.message, errorStack: err.stack }),
} satisfies ResponsePayload
}
) {
return {
status: ResponseStatus.FAILURE,
- errorMessage: 'Performance statistics storage is not enabled'
+ errorMessage: 'Performance statistics storage is not enabled',
} satisfies ResponsePayload
}
try {
status: ResponseStatus.SUCCESS,
performanceStatistics: [
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- ...Bootstrap.getInstance().getPerformanceStatistics()!
- ] as JsonType[]
+ ...Bootstrap.getInstance().getPerformanceStatistics()!,
+ ] as JsonType[],
} satisfies ResponsePayload
} catch (error) {
return {
status: ResponseStatus.FAILURE,
errorMessage: (error as Error).message,
- errorStack: (error as Error).stack
+ errorStack: (error as Error).stack,
} satisfies ResponsePayload
}
}
try {
return {
status: ResponseStatus.SUCCESS,
- state: Bootstrap.getInstance().getState() as unknown as JsonObject
+ state: Bootstrap.getInstance().getState() as unknown as JsonObject,
} satisfies ResponsePayload
} catch (error) {
return {
status: ResponseStatus.FAILURE,
errorMessage: (error as Error).message,
- errorStack: (error as Error).stack
+ errorStack: (error as Error).stack,
} satisfies ResponsePayload
}
}
return {
status: ResponseStatus.FAILURE,
errorMessage: (error as Error).message,
- errorStack: (error as Error).stack
+ errorStack: (error as Error).stack,
} satisfies ResponsePayload
}
}
return {
status: ResponseStatus.FAILURE,
errorMessage: (error as Error).message,
- errorStack: (error as Error).stack
+ errorStack: (error as Error).stack,
} satisfies ResponsePayload
}
}
type Statistics,
type StatisticsData,
type StorageConfiguration,
- type TimestampedData
+ type TimestampedData,
} from '../types/index.js'
import {
buildPerformanceStatisticsMessage,
max,
min,
nthPercentile,
- stdDeviation
+ stdDeviation,
} from '../utils/index.js'
export class PerformanceStatistics {
private static readonly instances: Map<string, PerformanceStatistics> = new Map<
- string,
- PerformanceStatistics
+ string,
+ PerformanceStatistics
>()
private readonly objId: string | undefined
name: this.objName,
uri: uri.toString(),
createdAt: new Date(),
- statisticsData: new Map()
+ statisticsData: new Map(),
}
}
} else {
this.statistics.statisticsData.set(command, {
...this.statistics.statisticsData.get(command),
- requestCount: 1
+ requestCount: 1,
})
}
break
} else {
this.statistics.statisticsData.set(command, {
...this.statistics.statisticsData.get(command),
- responseCount: 1
+ responseCount: 1,
})
}
break
} else {
this.statistics.statisticsData.set(command, {
...this.statistics.statisticsData.get(command),
- errorCount: 1
+ errorCount: 1,
})
}
break
if (performanceStorageConfiguration.enabled === true) {
logger.info(
`${this.logPrefix()} storage enabled: type ${
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
performanceStorageConfiguration.type
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
}, uri: ${performanceStorageConfiguration.uri}`
)
}
...this.statistics,
statisticsData: JSON.parse(
JSONStringify(this.statistics.statisticsData, undefined, MapStringifyFormat.object)
- ) as Map<string | RequestCommand | IncomingRequestCommand, StatisticsData>
+ ) as Map<string | RequestCommand | IncomingRequestCommand, StatisticsData>,
})
}
)
} else if (logConfiguration.enabled === true) {
logger.info(
- `${this.logPrefix()} log interval is set to ${logStatisticsInterval}. Not logging statistics`
+ `${this.logPrefix()} log interval is set to ${logStatisticsInterval.toString()}. Not logging statistics`
)
}
}
}
this.statistics.statisticsData.get(entry.name)?.measurementTimeSeries?.push({
timestamp: entry.startTime,
- value: entry.duration
+ value: entry.duration,
})
const timeMeasurementValues = extractTimeSeriesValues(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
}
private readonly logPrefix = (): string => {
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
return logPrefix(` ${this.objName} | Performance statistics`)
}
}
...performanceStatistics,
statisticsData: Array.from(performanceStatistics.statisticsData, ([name, value]) => ({
name,
- ...value
- }))
+ ...value,
+ })),
} satisfies PerformanceRecord)
} catch (error) {
this.handleDBStorageError(
dbName: this.dbName,
entities: ['./dist/types/orm/entities/*.js'],
entitiesTs: ['./src/types/orm/entities/*.ts'],
- clientUrl: this.getClientUrl()
+ clientUrl: this.getClientUrl(),
}
}
?.db(this.dbName)
.collection<Statistics>(Constants.PERFORMANCE_RECORDS_TABLE)
.replaceOne({ id: performanceStatistics.id }, performanceStatistics, {
- upsert: true
+ upsert: true,
})
} catch (error) {
this.handleDBStorageError(
private checkDBConnection (): void {
if (this.client == null) {
throw new BaseError(
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`${this.logPrefix} ${this.getDBNameFromStorageType(
StorageType.MONGO_DB
)} client initialization failed while trying to issue a request`
}
if (!this.connected) {
throw new BaseError(
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`${this.logPrefix} ${this.getDBNameFromStorageType(
StorageType.MONGO_DB
)} connection not opened while trying to issue a request`
type EmptyObject,
type HandleErrorParams,
type Statistics,
- StorageType
+ StorageType,
} from '../../types/index.js'
import { logger } from '../../utils/index.js'
table?: string,
params: HandleErrorParams<EmptyObject> = {
throwError: false,
- consoleOut: false
+ consoleOut: false,
}
): void {
params = {
...{
throwError: false,
- consoleOut: false
+ consoleOut: false,
},
- ...params
+ ...params,
}
const inTableOrCollectionStr = table != null && ` in table or collection '${table}'`
logger.error(
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`${this.logPrefix} ${this.getDBNameFromStorageType(type)} error '${
error.message
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
}'${inTableOrCollectionStr}:`,
error
)
// Mongo Connection and Query
if (config?.mongoConnectionString) {
- // eslint-disable-next-line n/handle-callback-err
MongoClient.connect(config.mongoConnectionString, async (_err, client) => {
const db = client.db()
// Mongo Connection and Query
if (config?.mongoConnectionString) {
- // eslint-disable-next-line n/handle-callback-err
MongoClient.connect(config.mongoConnectionString, async (_err, client) => {
const db = client.db()
}
export type ChargingStationConfiguration = ChargingStationInfoConfiguration &
-ChargingStationOcppConfiguration &
-ChargingStationAutomaticTransactionGeneratorConfiguration &
-ConnectorsConfiguration &
-EvsesConfiguration & {
- configurationHash?: string
-}
+ ChargingStationOcppConfiguration &
+ ChargingStationAutomaticTransactionGeneratorConfiguration &
+ ConnectorsConfiguration &
+ EvsesConfiguration & {
+ configurationHash?: string
+ }
import type { FirmwareStatus } from './ocpp/Requests.js'
export type ChargingStationInfo = Omit<
-ChargingStationTemplate,
-| 'Connectors'
-| 'Evses'
-| 'Configuration'
-| 'AutomaticTransactionGenerator'
-| 'numberOfConnectors'
-| 'power'
-| 'powerUnit'
-| 'chargeBoxSerialNumberPrefix'
-| 'chargePointSerialNumberPrefix'
-| 'meterSerialNumberPrefix'
+ ChargingStationTemplate,
+ | 'Connectors'
+ | 'Evses'
+ | 'Configuration'
+ | 'AutomaticTransactionGenerator'
+ | 'numberOfConnectors'
+ | 'power'
+ | 'powerUnit'
+ | 'chargeBoxSerialNumberPrefix'
+ | 'chargePointSerialNumberPrefix'
+ | 'meterSerialNumberPrefix'
> & {
hashId: string
templateIndex: number
FirmwareStatus,
IncomingRequestCommand,
MessageTrigger,
- RequestCommand
+ RequestCommand,
} from './ocpp/Requests.js'
export enum CurrentType {
export const ChargingStationWorkerMessageEvents = {
...ChargingStationEvents,
- ...ChargingStationMessageEvents
+ ...ChargingStationMessageEvents,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type ChargingStationWorkerMessageEvents =
1012: 'Service Restart',
1013: 'Try Again Later',
1014: 'Bad Gateway',
- 1015: 'TLS Handshake'
+ 1015: 'TLS Handshake',
})
export enum WebSocketCloseEventStatusCode {
type AutomaticTransactionGeneratorConfiguration,
type ChargingStationAutomaticTransactionGeneratorConfiguration,
IdTagDistribution,
- type Status
+ type Status,
} from './AutomaticTransactionGenerator.js'
export type {
ChargingStationConfiguration,
- EvseStatusConfiguration
+ EvseStatusConfiguration,
} from './ChargingStationConfiguration.js'
export { ChargingStationEvents } from './ChargingStationEvents.js'
export type { ChargingStationInfo } from './ChargingStationInfo.js'
export type {
ChargingStationOcppConfiguration,
- ConfigurationKey
+ ConfigurationKey,
} from './ChargingStationOcppConfiguration.js'
export {
AmpereUnits,
type FirmwareUpgrade,
PowerUnits,
Voltage,
- type WsOptions
+ type WsOptions,
} from './ChargingStationTemplate.js'
export {
type ChargingStationData,
type ChargingStationWorkerMessage,
type ChargingStationWorkerMessageData,
ChargingStationWorkerMessageEvents,
- type EvseStatusWorkerType
+ type EvseStatusWorkerType,
} from './ChargingStationWorker.js'
export {
ApplicationProtocolVersion,
type StorageConfiguration,
SupervisionUrlDistribution,
type UIServerConfiguration,
- type WorkerConfiguration
+ type WorkerConfiguration,
} from './ConfigurationData.js'
export type { ConnectorStatus } from './ConnectorStatus.js'
export type { EmptyObject } from './EmptyObject.js'
export { MapStringifyFormat } from './MapStringifyFormat.js'
export type {
MeasurandPerPhaseSampledValueTemplates,
- SampledValueTemplate
+ SampledValueTemplate,
} from './MeasurandPerPhaseSampledValueTemplates.js'
export type { MeasurandValues } from './MeasurandValues.js'
export { OCPP16ChargePointErrorCode } from './ocpp/1.6/ChargePointErrorCode.js'
OCPP16ChargingProfilePurposeType,
OCPP16ChargingRateUnitType,
type OCPP16ChargingSchedule,
- type OCPP16ChargingSchedulePeriod
+ type OCPP16ChargingSchedulePeriod,
} from './ocpp/1.6/ChargingProfile.js'
export {
OCPP16StandardParametersKey,
- OCPP16SupportedFeatureProfiles
+ OCPP16SupportedFeatureProfiles,
} from './ocpp/1.6/Configuration.js'
export { OCPP16DiagnosticsStatus } from './ocpp/1.6/DiagnosticsStatus.js'
export {
type OCPP16MeterValuesRequest,
type OCPP16MeterValuesResponse,
OCPP16MeterValueUnit,
- type OCPP16SampledValue
+ type OCPP16SampledValue,
} from './ocpp/1.6/MeterValues.js'
export {
type ChangeConfigurationRequest,
type RemoteStopTransactionRequest,
type ResetRequest,
type SetChargingProfileRequest,
- type UnlockConnectorRequest
+ type UnlockConnectorRequest,
} from './ocpp/1.6/Requests.js'
export {
type ChangeConfigurationResponse,
OCPP16TriggerMessageStatus,
type OCPP16UpdateFirmwareResponse,
type SetChargingProfileResponse,
- type UnlockConnectorResponse
+ type UnlockConnectorResponse,
} from './ocpp/1.6/Responses.js'
export {
OCPP16AuthorizationStatus,
type OCPP16StartTransactionResponse,
OCPP16StopTransactionReason,
type OCPP16StopTransactionRequest,
- type OCPP16StopTransactionResponse
+ type OCPP16StopTransactionResponse,
} from './ocpp/1.6/Transaction.js'
export { BootReasonEnumType, OCPP20ConnectorStatusEnumType } from './ocpp/2.0/Common.js'
export {
type OCPP20HeartbeatRequest,
OCPP20IncomingRequestCommand,
OCPP20RequestCommand,
- type OCPP20StatusNotificationRequest
+ type OCPP20StatusNotificationRequest,
} from './ocpp/2.0/Requests.js'
export type {
OCPP20BootNotificationResponse,
OCPP20ClearCacheResponse,
OCPP20HeartbeatResponse,
- OCPP20StatusNotificationResponse
+ OCPP20StatusNotificationResponse,
} from './ocpp/2.0/Responses.js'
export { OCPP20OptionalVariableName } from './ocpp/2.0/Variables.js'
export { ChargePointErrorCode } from './ocpp/ChargePointErrorCode.js'
ChargingProfilePurposeType,
ChargingRateUnitType,
type ChargingSchedulePeriod,
- RecurrencyKindType
+ RecurrencyKindType,
} from './ocpp/ChargingProfile.js'
export { type GenericResponse, GenericStatus, RegistrationStatusEnumType } from './ocpp/Common.js'
export {
type OCPPConfigurationKey,
StandardParametersKey,
SupportedFeatureProfiles,
- VendorParametersKey
+ VendorParametersKey,
} from './ocpp/Configuration.js'
export { ConnectorStatusEnum, type ConnectorStatusTransition } from './ocpp/ConnectorStatusEnum.js'
export { ErrorType } from './ocpp/ErrorType.js'
MeterValueMeasurand,
MeterValuePhase,
MeterValueUnit,
- type SampledValue
+ type SampledValue,
} from './ocpp/MeterValues.js'
export { OCPPVersion } from './ocpp/OCPPVersion.js'
export {
type RequestParams,
type ResponseCallback,
type ResponseType,
- type StatusNotificationRequest
+ type StatusNotificationRequest,
} from './ocpp/Requests.js'
export {
type Reservation,
type ReservationKey,
- ReservationTerminationReason
+ ReservationTerminationReason,
} from './ocpp/Reservation.js'
export {
AvailabilityStatus,
type ResponseHandler,
type StatusNotificationResponse,
TriggerMessageStatus,
- UnlockStatus
+ UnlockStatus,
} from './ocpp/Responses.js'
export {
AuthorizationStatus,
type StartTransactionResponse,
StopTransactionReason,
type StopTransactionRequest,
- type StopTransactionResponse
+ type StopTransactionResponse,
} from './ocpp/Transaction.js'
export { PerformanceRecord } from './orm/entities/PerformanceRecord.js'
export type { SimulatorState } from './SimulatorState.js'
Statistics,
StatisticsData,
TemplateStatistics,
- TimestampedData
+ TimestampedData,
} from './Statistics.js'
export { DBName, StorageType } from './Storage.js'
export {
ProtocolVersion,
type RequestPayload,
type ResponsePayload,
- ResponseStatus
+ ResponseStatus,
} from './UIProtocol.js'
export {
WebSocketCloseEventStatusCode,
WebSocketCloseEventStatusString,
- type WSError
+ type WSError,
} from './WebSocket.js'
export {
BroadcastChannelProcedureName,
type BroadcastChannelRequestPayload,
type BroadcastChannelResponse,
type BroadcastChannelResponsePayload,
- type MessageEvent
+ type MessageEvent,
} from './WorkerBroadcastChannel.js'
import type {
OCPP16ChargingProfile,
OCPP16ChargingProfilePurposeType,
- OCPP16ChargingRateUnitType
+ OCPP16ChargingRateUnitType,
} from './ChargingProfile.js'
import type { OCPP16StandardParametersKey, OCPP16VendorParametersKey } from './Configuration.js'
import type { OCPP16DiagnosticsStatus } from './DiagnosticsStatus.js'
import type {
BootReasonEnumType,
InstallCertificateUseEnumType,
- OCPP20ConnectorStatusEnumType
+ OCPP20ConnectorStatusEnumType,
} from './Common.js'
import type { OCPP20SetVariableDataType } from './Variables.js'
import type {
GenericStatusEnumType,
InstallCertificateStatusEnumType,
- StatusInfoType
+ StatusInfoType,
} from './Common.js'
import type { OCPP20SetVariableResultType } from './Variables.js'
import { OCPP16ChargePointErrorCode } from './1.6/ChargePointErrorCode.js'
export const ChargePointErrorCode = {
- ...OCPP16ChargePointErrorCode
+ ...OCPP16ChargePointErrorCode,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type ChargePointErrorCode = OCPP16ChargePointErrorCode
OCPP16ChargingProfilePurposeType,
OCPP16ChargingRateUnitType,
type OCPP16ChargingSchedulePeriod,
- OCPP16RecurrencyKindType
+ OCPP16RecurrencyKindType,
} from './1.6/ChargingProfile.js'
export type ChargingProfile = OCPP16ChargingProfile
export type ChargingSchedulePeriod = OCPP16ChargingSchedulePeriod
export const ChargingProfilePurposeType = {
- ...OCPP16ChargingProfilePurposeType
+ ...OCPP16ChargingProfilePurposeType,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type ChargingProfilePurposeType = OCPP16ChargingProfilePurposeType
export const ChargingProfileKindType = {
- ...OCPP16ChargingProfileKindType
+ ...OCPP16ChargingProfileKindType,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type ChargingProfileKindType = OCPP16ChargingProfileKindType
export const RecurrencyKindType = {
- ...OCPP16RecurrencyKindType
+ ...OCPP16RecurrencyKindType,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type RecurrencyKindType = OCPP16RecurrencyKindType
export const ChargingRateUnitType = {
- ...OCPP16ChargingRateUnitType
+ ...OCPP16ChargingRateUnitType,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type ChargingRateUnitType = OCPP16ChargingRateUnitType
import {
OCPP16StandardParametersKey,
OCPP16SupportedFeatureProfiles,
- OCPP16VendorParametersKey
+ OCPP16VendorParametersKey,
} from './1.6/Configuration.js'
import {
OCPP20OptionalVariableName,
OCPP20RequiredVariableName,
- OCPP20VendorVariableName
+ OCPP20VendorVariableName,
} from './2.0/Variables.js'
export const StandardParametersKey = {
...OCPP16StandardParametersKey,
...OCPP20RequiredVariableName,
- ...OCPP20OptionalVariableName
+ ...OCPP20OptionalVariableName,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type StandardParametersKey = OCPP16StandardParametersKey
export const VendorParametersKey = {
...OCPP16VendorParametersKey,
- ...OCPP20VendorVariableName
+ ...OCPP20VendorVariableName,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type VendorParametersKey = OCPP16VendorParametersKey
export const SupportedFeatureProfiles = {
- ...OCPP16SupportedFeatureProfiles
+ ...OCPP16SupportedFeatureProfiles,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type SupportedFeatureProfiles = OCPP16SupportedFeatureProfiles
export const ConnectorStatusEnum = {
...OCPP16ChargePointStatus,
- ...OCPP20ConnectorStatusEnumType
+ ...OCPP20ConnectorStatusEnumType,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type ConnectorStatusEnum = OCPP16ChargePointStatus | OCPP20ConnectorStatusEnumType
OCPP16MeterValueMeasurand,
OCPP16MeterValuePhase,
OCPP16MeterValueUnit,
- type OCPP16SampledValue
+ type OCPP16SampledValue,
} from './1.6/MeterValues.js'
export const MeterValueUnit = {
- ...OCPP16MeterValueUnit
+ ...OCPP16MeterValueUnit,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type MeterValueUnit = OCPP16MeterValueUnit
export const MeterValueContext = {
- ...OCPP16MeterValueContext
+ ...OCPP16MeterValueContext,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type MeterValueContext = OCPP16MeterValueContext
export const MeterValueMeasurand = {
- ...OCPP16MeterValueMeasurand
+ ...OCPP16MeterValueMeasurand,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type MeterValueMeasurand = OCPP16MeterValueMeasurand
export const MeterValueLocation = {
- ...OCPP16MeterValueLocation
+ ...OCPP16MeterValueLocation,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type MeterValueLocation = OCPP16MeterValueLocation
export const MeterValuePhase = {
- ...OCPP16MeterValuePhase
+ ...OCPP16MeterValuePhase,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type MeterValuePhase = OCPP16MeterValuePhase
OCPP16MessageTrigger,
OCPP16RequestCommand,
type OCPP16ReserveNowRequest,
- type OCPP16StatusNotificationRequest
+ type OCPP16StatusNotificationRequest,
} from './1.6/Requests.js'
import { OperationalStatusEnumType } from './2.0/Common.js'
import {
type OCPP20BootNotificationRequest,
OCPP20IncomingRequestCommand,
OCPP20RequestCommand,
- type OCPP20StatusNotificationRequest
+ type OCPP20StatusNotificationRequest,
} from './2.0/Requests.js'
import type { MessageType } from './MessageType.js'
export const RequestCommand = {
...OCPP16RequestCommand,
- ...OCPP20RequestCommand
+ ...OCPP20RequestCommand,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type RequestCommand = OCPP16RequestCommand | OCPP20RequestCommand
export const IncomingRequestCommand = {
...OCPP16IncomingRequestCommand,
- ...OCPP20IncomingRequestCommand
+ ...OCPP20IncomingRequestCommand,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type IncomingRequestCommand = OCPP16IncomingRequestCommand | OCPP20IncomingRequestCommand
export type ErrorCallback = (ocppError: OCPPError, requestStatistic?: boolean) => void
-export type CachedRequest = [
- ResponseCallback,
- ErrorCallback,
- RequestCommand | IncomingRequestCommand,
- JsonType
-]
+export type CachedRequest = [ResponseCallback, ErrorCallback, RequestCommand, JsonType]
export const MessageTrigger = {
- ...OCPP16MessageTrigger
+ ...OCPP16MessageTrigger,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type MessageTrigger = OCPP16MessageTrigger
export const AvailabilityType = {
...OCPP16AvailabilityType,
- ...OperationalStatusEnumType
+ ...OperationalStatusEnumType,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type AvailabilityType = OCPP16AvailabilityType | OperationalStatusEnumType
export const DiagnosticsStatus = {
- ...OCPP16DiagnosticsStatus
+ ...OCPP16DiagnosticsStatus,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type DiagnosticsStatus = OCPP16DiagnosticsStatus
export const FirmwareStatus = {
- ...OCPP16FirmwareStatus
+ ...OCPP16FirmwareStatus,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type FirmwareStatus = OCPP16FirmwareStatus
OCPP16ReservationStatus,
type OCPP16StatusNotificationResponse,
OCPP16TriggerMessageStatus,
- OCPP16UnlockStatus
+ OCPP16UnlockStatus,
} from './1.6/Responses.js'
import type { OCPP20BootNotificationResponse, OCPP20ClearCacheResponse } from './2.0/Responses.js'
import { type GenericResponse, GenericStatus } from './Common.js'
export type FirmwareStatusNotificationResponse = OCPP16FirmwareStatusNotificationResponse
export const AvailabilityStatus = {
- ...OCPP16AvailabilityStatus
+ ...OCPP16AvailabilityStatus,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type AvailabilityStatus = OCPP16AvailabilityStatus
export const ChargingProfileStatus = {
- ...OCPP16ChargingProfileStatus
+ ...OCPP16ChargingProfileStatus,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type ChargingProfileStatus = OCPP16ChargingProfileStatus
export const ClearChargingProfileStatus = {
- ...OCPP16ClearChargingProfileStatus
+ ...OCPP16ClearChargingProfileStatus,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type ClearChargingProfileStatus = OCPP16ClearChargingProfileStatus
export const ConfigurationStatus = {
- ...OCPP16ConfigurationStatus
+ ...OCPP16ConfigurationStatus,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type ConfigurationStatus = OCPP16ConfigurationStatus
export const UnlockStatus = {
- ...OCPP16UnlockStatus
+ ...OCPP16UnlockStatus,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type UnlockStatus = OCPP16UnlockStatus
export const TriggerMessageStatus = {
- ...OCPP16TriggerMessageStatus
+ ...OCPP16TriggerMessageStatus,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type TriggerMessageStatus = OCPP16TriggerMessageStatus
export const DataTransferStatus = {
- ...OCPP16DataTransferStatus
+ ...OCPP16DataTransferStatus,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type DataTransferStatus = OCPP16DataTransferStatus
export type ReservationStatus = OCPP16ReservationStatus
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const ReservationStatus = {
- ...OCPP16ReservationStatus
+ ...OCPP16ReservationStatus,
} as const
export type CancelReservationStatus = GenericStatus
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const CancelReservationStatus = {
- ...GenericStatus
+ ...GenericStatus,
} as const
export type CancelReservationResponse = GenericResponse
type OCPP16StartTransactionResponse,
OCPP16StopTransactionReason,
type OCPP16StopTransactionRequest,
- type OCPP16StopTransactionResponse
+ type OCPP16StopTransactionResponse,
} from './1.6/Transaction.js'
export const AuthorizationStatus = {
- ...OCPP16AuthorizationStatus
+ ...OCPP16AuthorizationStatus,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type AuthorizationStatus = OCPP16AuthorizationStatus
export type AuthorizeResponse = OCPP16AuthorizeResponse
export const StopTransactionReason = {
- ...OCPP16StopTransactionReason
+ ...OCPP16StopTransactionReason,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type StopTransactionReason = OCPP16StopTransactionReason
responseCount: number
errorCount: number
timeMeasurementCount: number
- measurementTimeSeries: Array<{
+ measurementTimeSeries: {
timestamp: number
value: number
- }>
+ }[]
currentTimeMeasurement: number
minTimeMeasurement: number
maxTimeMeasurement: number
@Entity()
export class PerformanceRecord {
@PrimaryKey()
- id!: string
+ id!: string
@Property()
- name!: string
+ name!: string
@Property()
- uri!: string
+ uri!: string
@Property()
- createdAt!: Date
+ createdAt!: Date
@Property()
- updatedAt?: Date
+ updatedAt?: Date
@Property()
- statisticsData!: Array<Partial<StatisticsData>>
+ statisticsData!: Partial<StatisticsData>[]
}
ChargingStationAutomaticTransactionGeneratorConfiguration,
ConnectorStatus,
EvseStatusConfiguration,
- EvseStatusWorkerType
+ EvseStatusWorkerType,
} from '../types/index.js'
export const buildChargingStationAutomaticTransactionGeneratorConfiguration = (
automaticTransactionGenerator: chargingStation.getAutomaticTransactionGeneratorConfiguration(),
...(chargingStation.automaticTransactionGenerator?.connectorsStatus != null && {
automaticTransactionGeneratorStatuses: [
- ...chargingStation.automaticTransactionGenerator.connectorsStatus.values()
- ]
- })
+ ...chargingStation.automaticTransactionGenerator.connectorsStatus.values(),
+ ],
+ }),
}
}
export const buildEvsesStatus = (
chargingStation: ChargingStation,
outputFormat: OutputFormat = OutputFormat.configuration
-): Array<EvseStatusWorkerType | EvseStatusConfiguration> => {
+): (EvseStatusWorkerType | EvseStatusConfiguration)[] => {
// eslint-disable-next-line array-callback-return
return [...chargingStation.evses.values()].map(evseStatus => {
const connectorsStatus = [...evseStatus.connectors.values()].map(
case OutputFormat.worker:
return {
...evseStatus,
- connectors: connectorsStatus
+ connectors: connectorsStatus,
}
case OutputFormat.configuration:
status = {
...evseStatus,
- connectorsStatus
+ connectorsStatus,
}
delete (status as EvseStatusWorkerType).connectors
return status
StorageType,
SupervisionUrlDistribution,
type UIServerConfiguration,
- type WorkerConfiguration
+ type WorkerConfiguration,
} from '../types/index.js'
import {
DEFAULT_ELEMENT_ADD_DELAY,
DEFAULT_POOL_MAX_SIZE,
DEFAULT_POOL_MIN_SIZE,
DEFAULT_WORKER_START_DELAY,
- WorkerProcessType
+ WorkerProcessType,
} from '../worker/index.js'
import {
buildPerformanceUriFilePath,
checkWorkerProcessType,
getDefaultPerformanceStorageUri,
handleFileException,
- logPrefix
+ logPrefix,
} from './ConfigurationUtils.js'
import { Constants } from './Constants.js'
import { hasOwnProp, isCFEnvironment } from './Utils.js'
version: ApplicationProtocolVersion.VERSION_11,
options: {
host: Constants.DEFAULT_UI_SERVER_HOST,
- port: Constants.DEFAULT_UI_SERVER_PORT
- }
+ port: Constants.DEFAULT_UI_SERVER_PORT,
+ },
}
const defaultStorageConfiguration: StorageConfiguration = {
enabled: true,
- type: StorageType.NONE
+ type: StorageType.NONE,
}
const defaultLogConfiguration: LogConfiguration = {
statisticsInterval: Constants.DEFAULT_LOG_STATISTICS_INTERVAL,
level: 'info',
format: 'simple',
- rotate: true
+ rotate: true,
}
const defaultWorkerConfiguration: WorkerConfiguration = {
elementsPerWorker: 'auto',
elementAddDelay: DEFAULT_ELEMENT_ADD_DELAY,
poolMinSize: DEFAULT_POOL_MIN_SIZE,
- poolMaxSize: DEFAULT_POOL_MAX_SIZE
+ poolMaxSize: DEFAULT_POOL_MAX_SIZE,
}
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
stationTemplateUrls: [
{
file: 'siemens.station-template.json',
- numberOfStations: 1
- }
+ numberOfStations: 1,
+ },
],
supervisionUrls: 'ws://localhost:8180/steve/websocket/CentralSystemService',
supervisionUrlDistribution: SupervisionUrlDistribution.ROUND_ROBIN,
uiServer: defaultUIServerConfiguration,
performanceStorage: defaultStorageConfiguration,
log: defaultLogConfiguration,
- worker: defaultWorkerConfiguration
+ worker: defaultWorkerConfiguration,
}
}
Configuration.configurationSectionCache = new Map<
- ConfigurationSection,
- ConfigurationSectionType
+ ConfigurationSection,
+ ConfigurationSectionType
>([
[ConfigurationSection.log, Configuration.buildLogSection()],
[ConfigurationSection.performanceStorage, Configuration.buildPerformanceStorageSection()],
[ConfigurationSection.worker, Configuration.buildWorkerSection()],
- [ConfigurationSection.uiServer, Configuration.buildUIServerSection()]
+ [ConfigurationSection.uiServer, Configuration.buildUIServerSection()],
])
}
storageConfiguration = {
enabled: false,
type: StorageType.SQLITE,
- uri: getDefaultPerformanceStorageUri(StorageType.SQLITE)
+ uri: getDefaultPerformanceStorageUri(StorageType.SQLITE),
}
break
case StorageType.JSON_FILE:
storageConfiguration = {
enabled: false,
type: StorageType.JSON_FILE,
- uri: getDefaultPerformanceStorageUri(StorageType.JSON_FILE)
+ uri: getDefaultPerformanceStorageUri(StorageType.JSON_FILE),
}
break
case StorageType.NONE:
uri: buildPerformanceUriFilePath(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
new URL(Configuration.getConfigurationData()!.performanceStorage!.uri!).pathname
- )
- })
+ ),
+ }),
}
}
return storageConfiguration
private static buildLogSection (): LogConfiguration {
const deprecatedLogConfiguration: LogConfiguration = {
...(hasOwnProp(Configuration.getConfigurationData(), 'logEnabled') && {
- enabled: Configuration.getConfigurationData()?.logEnabled
+ enabled: Configuration.getConfigurationData()?.logEnabled,
}),
...(hasOwnProp(Configuration.getConfigurationData(), 'logFile') && {
- file: Configuration.getConfigurationData()?.logFile
+ file: Configuration.getConfigurationData()?.logFile,
}),
...(hasOwnProp(Configuration.getConfigurationData(), 'logErrorFile') && {
- errorFile: Configuration.getConfigurationData()?.logErrorFile
+ errorFile: Configuration.getConfigurationData()?.logErrorFile,
}),
...(hasOwnProp(Configuration.getConfigurationData(), 'logStatisticsInterval') && {
- statisticsInterval: Configuration.getConfigurationData()?.logStatisticsInterval
+ statisticsInterval: Configuration.getConfigurationData()?.logStatisticsInterval,
}),
...(hasOwnProp(Configuration.getConfigurationData(), 'logLevel') && {
- level: Configuration.getConfigurationData()?.logLevel
+ level: Configuration.getConfigurationData()?.logLevel,
}),
...(hasOwnProp(Configuration.getConfigurationData(), 'logConsole') && {
- console: Configuration.getConfigurationData()?.logConsole
+ console: Configuration.getConfigurationData()?.logConsole,
}),
...(hasOwnProp(Configuration.getConfigurationData(), 'logFormat') && {
- format: Configuration.getConfigurationData()?.logFormat
+ format: Configuration.getConfigurationData()?.logFormat,
}),
...(hasOwnProp(Configuration.getConfigurationData(), 'logRotate') && {
- rotate: Configuration.getConfigurationData()?.logRotate
+ rotate: Configuration.getConfigurationData()?.logRotate,
}),
...(hasOwnProp(Configuration.getConfigurationData(), 'logMaxFiles') && {
- maxFiles: Configuration.getConfigurationData()?.logMaxFiles
+ maxFiles: Configuration.getConfigurationData()?.logMaxFiles,
}),
...(hasOwnProp(Configuration.getConfigurationData(), 'logMaxSize') && {
- maxSize: Configuration.getConfigurationData()?.logMaxSize
- })
+ maxSize: Configuration.getConfigurationData()?.logMaxSize,
+ }),
}
const logConfiguration: LogConfiguration = {
...defaultLogConfiguration,
...deprecatedLogConfiguration,
...(hasOwnProp(Configuration.getConfigurationData(), ConfigurationSection.log) &&
- Configuration.getConfigurationData()?.log)
+ Configuration.getConfigurationData()?.log),
}
return logConfiguration
}
private static buildWorkerSection (): WorkerConfiguration {
const deprecatedWorkerConfiguration: WorkerConfiguration = {
...(hasOwnProp(Configuration.getConfigurationData(), 'workerProcess') && {
- processType: Configuration.getConfigurationData()?.workerProcess
+ processType: Configuration.getConfigurationData()?.workerProcess,
}),
...(hasOwnProp(Configuration.getConfigurationData(), 'workerStartDelay') && {
- startDelay: Configuration.getConfigurationData()?.workerStartDelay
+ startDelay: Configuration.getConfigurationData()?.workerStartDelay,
}),
...(hasOwnProp(Configuration.getConfigurationData(), 'chargingStationsPerWorker') && {
- elementsPerWorker: Configuration.getConfigurationData()?.chargingStationsPerWorker
+ elementsPerWorker: Configuration.getConfigurationData()?.chargingStationsPerWorker,
}),
...(hasOwnProp(Configuration.getConfigurationData(), 'elementAddDelay') && {
- elementAddDelay: Configuration.getConfigurationData()?.elementAddDelay
+ elementAddDelay: Configuration.getConfigurationData()?.elementAddDelay,
}),
...(hasOwnProp(Configuration.getConfigurationData()?.worker, 'elementStartDelay') && {
- elementAddDelay: Configuration.getConfigurationData()?.worker?.elementStartDelay
+ elementAddDelay: Configuration.getConfigurationData()?.worker?.elementStartDelay,
}),
...(hasOwnProp(Configuration.getConfigurationData(), 'workerPoolMinSize') && {
- poolMinSize: Configuration.getConfigurationData()?.workerPoolMinSize
+ poolMinSize: Configuration.getConfigurationData()?.workerPoolMinSize,
}),
...(hasOwnProp(Configuration.getConfigurationData(), 'workerPoolMaxSize') && {
- poolMaxSize: Configuration.getConfigurationData()?.workerPoolMaxSize
- })
+ poolMaxSize: Configuration.getConfigurationData()?.workerPoolMaxSize,
+ }),
}
hasOwnProp(Configuration.getConfigurationData(), 'workerPoolStrategy') &&
delete Configuration.getConfigurationData()?.workerPoolStrategy
...defaultWorkerConfiguration,
...deprecatedWorkerConfiguration,
...(hasOwnProp(Configuration.getConfigurationData(), ConfigurationSection.worker) &&
- Configuration.getConfigurationData()?.worker)
+ Configuration.getConfigurationData()?.worker),
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
checkWorkerProcessType(workerConfiguration.processType!)
] as StationTemplateUrl[])
Configuration.getConfigurationData()?.stationTemplateUrls.forEach(
(stationTemplateUrl: StationTemplateUrl) => {
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (stationTemplateUrl['numberOfStation' as keyof StationTemplateUrl] != null) {
console.error(
`${chalk.green(logPrefix())} ${chalk.red(
const consoleWarnOnce = once(console.warn)
consoleWarnOnce(
`${chalk.green(logPrefix())} ${chalk.yellow(
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`${FileType.Configuration} ${this.configurationFile} file have changed, reload`
)}`
)
Configuration.configurationSectionCache.clear()
if (Configuration.configurationChangeCallback != null) {
Configuration.configurationChangeCallback()
- .catch((error: unknown) => {
- throw typeof error === 'string' ? new Error(error) : error
- })
.finally(() => {
Configuration.configurationFileReloading = false
})
+ .catch((error: unknown) => {
+ throw typeof error === 'string' ? new Error(error) : error
+ })
} else {
Configuration.configurationFileReloading = false
}
!Number.isSafeInteger(elementsPerWorker)
) {
throw new SyntaxError(
- `Invalid number of elements per worker '${elementsPerWorker}' defined in configuration`
+ `Invalid number of elements per worker '${elementsPerWorker.toString()}' defined in configuration`
)
}
if (Number.isSafeInteger(elementsPerWorker) && (elementsPerWorker as number) <= 0) {
throw RangeError(
- `Invalid negative or zero number of elements per worker '${elementsPerWorker}' defined in configuration`
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
+ `Invalid negative or zero number of elements per worker '${elementsPerWorker?.toString()}' defined in configuration`
)
}
}
type IncomingRequestCommand,
OCPPVersion,
type RequestCommand,
- VendorParametersKey
+ VendorParametersKey,
} from '../types/index.js'
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
firmwareVersionPattern: Constants.SEMVER_PATTERN,
firmwareUpgrade: {
versionUpgrade: {
- step: 1
+ step: 1,
},
- reset: true
+ reset: true,
},
ocppPersistentConfiguration: true,
stationInfoPersistentConfiguration: true,
autoReconnectMaxRetries: -1,
registrationMaxRetries: -1,
reconnectExponentialDelay: false,
- stopTransactionsOnStopped: true
+ stopTransactionsOnStopped: true,
})
static readonly DEFAULT_BOOT_NOTIFICATION_INTERVAL = 60000 // Ms
maxDelayBetweenTwoTransactions: 30,
probabilityOfStart: 1,
stopAfterHours: 0.25,
- stopAbsoluteDuration: false
+ stopAbsoluteDuration: false,
})
static readonly DEFAULT_CIRCULAR_BUFFER_CAPACITY = 386
IncomingRequestCommand,
JsonType,
MessageType,
- RequestCommand
+ RequestCommand,
} from '../types/index.js'
import { logger } from './Logger.js'
import { isNotEmptyString } from './Utils.js'
params = {
...{
throwError: true,
- consoleOut: false
+ consoleOut: false,
},
- ...params
+ ...params,
}
const prefix = isNotEmptyString(logPrefix) ? `${logPrefix} ` : ''
let logMsg: string
params = {
...{
throwError: false,
- consoleOut: false
+ consoleOut: false,
},
- ...params
+ ...params,
}
logger.error(
`${chargingStation.logPrefix()} ${moduleName}.handleSendMessageError: Send ${getMessageTypeString(messageType)} command '${commandName}' error:`,
params = {
...{
throwError: true,
- consoleOut: false
+ consoleOut: false,
},
- ...params
+ ...params,
}
logger.error(
`${chargingStation.logPrefix()} ${moduleName}.handleIncomingRequestError: Incoming request command '${commandName}' error:`,
(refreshedVariable = JSON.parse(readFileSync(file, 'utf8')) as T)
} catch (error) {
handleFileException(file, fileType, error as NodeJS.ErrnoException, logPrefix, {
- throwError: false
+ throwError: false,
})
}
}
return watch(file, listener)
} catch (error) {
handleFileException(file, fileType, error as NodeJS.ErrnoException, logPrefix, {
- throwError: false
+ throwError: false,
})
}
} else {
),
level: 'error',
...(logMaxFiles != null && { maxFiles: logMaxFiles }),
- ...(logMaxSize != null && { maxSize: logMaxSize })
+ ...(logMaxSize != null && { maxSize: logMaxSize }),
}),
new DailyRotateFile({
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
filename: insertAt(logConfiguration.file!, '-%DATE%', logConfiguration.file!.indexOf('.log')),
...(logMaxFiles != null && { maxFiles: logMaxFiles }),
- ...(logMaxSize != null && { maxSize: logMaxSize })
- })
+ ...(logMaxSize != null && { maxSize: logMaxSize }),
+ }),
]
} else {
transports = [
new TransportType.File({
filename: logConfiguration.errorFile,
- level: 'error'
+ level: 'error',
}),
new TransportType.File({
- filename: logConfiguration.file
- })
+ filename: logConfiguration.file,
+ }),
]
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
(format[logConfiguration.format! as keyof FormatWrap] as FormatWrap)()
),
- transports
+ transports,
})
//
format.splat(),
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
(format[logConfiguration.format! as keyof FormatWrap] as FormatWrap)()
- )
+ ),
})
)
}
type ChargingStationWorkerMessage,
ChargingStationWorkerMessageEvents,
type Statistics,
- type TimestampedData
+ type TimestampedData,
} from '../types/index.js'
import {
buildChargingStationAutomaticTransactionGeneratorConfiguration,
buildConnectorsStatus,
buildEvsesStatus,
- OutputFormat
+ OutputFormat,
} from './ChargingStationConfigurationUtils.js'
export const buildAddedMessage = (
): ChargingStationWorkerMessage<ChargingStationData> => {
return {
event: ChargingStationWorkerMessageEvents.added,
- data: buildChargingStationDataPayload(chargingStation)
+ data: buildChargingStationDataPayload(chargingStation),
}
}
): ChargingStationWorkerMessage<ChargingStationData> => {
return {
event: ChargingStationWorkerMessageEvents.deleted,
- data: buildChargingStationDataPayload(chargingStation)
+ data: buildChargingStationDataPayload(chargingStation),
}
}
): ChargingStationWorkerMessage<ChargingStationData> => {
return {
event: ChargingStationWorkerMessageEvents.started,
- data: buildChargingStationDataPayload(chargingStation)
+ data: buildChargingStationDataPayload(chargingStation),
}
}
): ChargingStationWorkerMessage<ChargingStationData> => {
return {
event: ChargingStationWorkerMessageEvents.stopped,
- data: buildChargingStationDataPayload(chargingStation)
+ data: buildChargingStationDataPayload(chargingStation),
}
}
): ChargingStationWorkerMessage<ChargingStationData> => {
return {
event: ChargingStationWorkerMessageEvents.updated,
- data: buildChargingStationDataPayload(chargingStation)
+ data: buildChargingStationDataPayload(chargingStation),
}
}
uri: statistics.uri,
createdAt: statistics.createdAt,
updatedAt: statistics.updatedAt,
- statisticsData
- }
+ statisticsData,
+ },
}
}
bootNotificationResponse: chargingStation.bootNotificationResponse,
...(chargingStation.automaticTransactionGenerator != null && {
automaticTransactionGenerator:
- buildChargingStationAutomaticTransactionGeneratorConfiguration(chargingStation)
- })
+ buildChargingStationAutomaticTransactionGeneratorConfiguration(chargingStation),
+ }),
}
}
/**
* Computes the sample standard deviation of the given data set.
- *
* @param dataSet - Data set.
* @param dataSetAverage - Average of the data set.
* @returns The sample standard deviation of the given data set.
millisecondsToMinutes,
millisecondsToSeconds,
minutesToSeconds,
- secondsToMilliseconds
+ secondsToMilliseconds,
} from 'date-fns'
import type { CircularBuffer } from 'mnemonist'
import { is } from 'rambda'
type JsonType,
MapStringifyFormat,
type TimestampedData,
- WebSocketCloseEventStatusString
+ WebSocketCloseEventStatusString,
} from '../types/index.js'
export const logPrefix = (prefixString = ''): string => {
days,
hours,
minutes,
- seconds
+ seconds,
})
}
if (typeof value === 'string' || typeof value === 'number') {
const valueToDate = new Date(value)
if (isNaN(valueToDate.getTime())) {
- throw new Error(`Cannot convert to date: '${value}'`)
+ throw new Error(`Cannot convert to date: '${value.toString()}'`)
}
return valueToDate
}
/**
* Rounds the given number to the given scale.
* The rounding is done using the "round half away from zero" method.
- *
* @param numberValue - The number to round.
* @param scale - The scale to round to.
* @returns The rounded number.
): number => {
if (fluctuationPercent < 0 || fluctuationPercent > 100) {
throw new RangeError(
- `Fluctuation percent must be between 0 and 100. Actual value: ${fluctuationPercent}`
+ `Fluctuation percent must be between 0 and 100. Actual value: ${fluctuationPercent.toString()}`
)
}
if (fluctuationPercent === 0) {
/**
* Detects whether the given value is an asynchronous function or not.
- *
* @param fn - Unknown value.
* @returns `true` if `fn` was an asynchronous function, otherwise `false`.
* @internal
/**
* Computes the retry delay in milliseconds using an exponential backoff algorithm.
- *
* @param retryNumber - the number of retries that have already been attempted
* @param delayFactor - the base delay factor in milliseconds
* @returns delay in milliseconds
/**
* Generates a cryptographically secure random number in the [0,1[ range
- *
* @returns A number in the [0,1[ range
*/
export const secureRandom = (): number => {
export const JSONStringify = <
T extends
- | JsonType
- | Array<Record<string, unknown>>
- | Set<Record<string, unknown>>
- | Map<string, Record<string, unknown>>
+ | JsonType
+ | Record<string, unknown>[]
+ | Set<Record<string, unknown>>
+ | Map<string, Record<string, unknown>>
>(
object: T,
space?: string | number,
switch (mapFormat) {
case MapStringifyFormat.object:
return {
- ...Object.fromEntries<Map<string, Record<string, unknown>>>(value.entries())
+ ...Object.fromEntries<Map<string, Record<string, unknown>>>(value.entries()),
}
case MapStringifyFormat.array:
default:
return [...value]
}
} else if (is(Set, value)) {
- return [...value] as JsonType[]
+ return [...value]
}
return value
},
/**
* Converts websocket error code to human readable string message
- *
* @param code - websocket error code
* @returns human readable string message
*/
buildChargingStationAutomaticTransactionGeneratorConfiguration,
buildConnectorsStatus,
buildEvsesStatus,
- OutputFormat
+ OutputFormat,
} from './ChargingStationConfigurationUtils.js'
export { Configuration } from './Configuration.js'
export { Constants } from './Constants.js'
handleIncomingRequestError,
handleSendMessageError,
handleUncaughtException,
- handleUnhandledRejection
+ handleUnhandledRejection,
} from './ErrorUtils.js'
export { watchJsonFile } from './FileUtils.js'
export { logger } from './Logger.js'
buildPerformanceStatisticsMessage,
buildStartedMessage,
buildStoppedMessage,
- buildUpdatedMessage
+ buildUpdatedMessage,
} from './MessageChannelUtils.js'
export { max, min, nthPercentile, stdDeviation } from './StatisticUtils.js'
export {
roundTo,
secureRandom,
sleep,
- validateUUID
+ validateUUID,
} from './Utils.js'
/**
* `WorkerAbstract` constructor.
- *
* @param workerScript -
* @param workerOptions -
*/
public abstract stop (): Promise<void>
/**
* Adds a task element to the worker pool/set.
- *
* @param elementData -
*/
public abstract addElement (elementData: D): Promise<R>
enableEvents: true,
restartWorkerOnError: true,
errorHandler: defaultErrorHandler,
- exitHandler: defaultExitHandler
- }
+ exitHandler: defaultExitHandler,
+ },
})
import { randomizeDelay, sleep } from './WorkerUtils.js'
export class WorkerDynamicPool<D extends WorkerData, R extends WorkerData> extends WorkerAbstract<
-D,
-R
+ D,
+ R
> {
private readonly pool: DynamicThreadPool<D, R>
/**
* Creates a new `WorkerDynamicPool`.
- *
* @param workerScript -
* @param workerOptions -
*/
import { randomizeDelay, sleep } from './WorkerUtils.js'
export class WorkerFixedPool<D extends WorkerData, R extends WorkerData> extends WorkerAbstract<
-D,
-R
+ D,
+ R
> {
private readonly pool: FixedThreadPool<D, R>
/**
* Creates a new `WorkerFixedPool`.
- *
* @param workerScript -
* @param workerOptions -
*/
WorkerMessageEvents,
type WorkerOptions,
type WorkerSetElement,
- WorkerSetEvents
+ WorkerSetEvents,
} from './WorkerTypes.js'
import { randomizeDelay, sleep } from './WorkerUtils.js'
private readonly workerSet: Set<WorkerSetElement>
private readonly promiseResponseMap: Map<
`${string}-${string}-${string}-${string}`,
- ResponseWrapper<R>
+ ResponseWrapper<R>
>
private started: boolean
/**
* Creates a new `WorkerSet`.
- *
* @param workerScript -
* @param workerOptions -
*/
this.workerSet = new Set<WorkerSetElement>()
this.promiseResponseMap = new Map<
`${string}-${string}-${string}-${string}`,
- ResponseWrapper<R>
+ ResponseWrapper<R>
>()
if (this.workerOptions.poolOptions?.enableEvents === true) {
this.emitter = new EventEmitterAsyncResource({ name: 'workerset' })
0
),
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- elementsPerWorker: this.maxElementsPerWorker!
+ elementsPerWorker: this.maxElementsPerWorker!,
}
}
const message = {
uuid: randomUUID(),
event: WorkerMessageEvents.addWorkerElement,
- data: elementData
+ data: elementData,
} satisfies WorkerMessage<D>
workerSetElement.worker.postMessage(message)
this.promiseResponseMap.set(message.uuid, {
resolve,
reject,
- workerSetElement
+ workerSetElement,
})
})
const response = await sendMessageToWorker
/**
* Adds a new `WorkerSetElement`.
+ * @returns The new `WorkerSetElement`.
*/
private addWorkerSetElement (): WorkerSetElement {
this.workerStartup = true
const worker = new Worker(this.workerScript, {
env: SHARE_ENV,
- ...this.workerOptions.poolOptions?.workerOptions
+ ...this.workerOptions.poolOptions?.workerOptions,
})
worker.on('message', this.workerOptions.poolOptions?.messageHandler ?? EMPTY_FUNCTION)
worker.on('message', (message: WorkerMessage<R>) => {
this.addWorkerSetElement()
}
worker.unref()
+ // eslint-disable-next-line promise/no-promise-in-callback
worker.terminate().catch((error: unknown) => this.emitter?.emit(WorkerSetEvents.error, error))
})
worker.on('online', this.workerOptions.poolOptions?.onlineHandler ?? EMPTY_FUNCTION)
})
const workerSetElement: WorkerSetElement = {
worker,
- numberOfWorkerElements: 0
+ numberOfWorkerElements: 0,
}
this.workerSet.add(workerSetElement)
this.workerStartup = false
export const WorkerEvents = {
...PoolEvents,
- ...WorkerSetEvents
+ ...WorkerSetEvents,
} as const
// eslint-disable-next-line @typescript-eslint/no-redeclare
export type WorkerEvents = PoolEvent | WorkerSetEvents
/**
* Generates a cryptographically secure random number in the [0,1[ range
- *
* @returns A number in the [0,1[ range
* @internal
*/
DEFAULT_ELEMENTS_PER_WORKER,
DEFAULT_POOL_MAX_SIZE,
DEFAULT_POOL_MIN_SIZE,
- DEFAULT_WORKER_START_DELAY
+ DEFAULT_WORKER_START_DELAY,
} from './WorkerConstants.js'
export { WorkerFactory } from './WorkerFactory.js'
export {
WorkerEvents,
type WorkerMessage,
WorkerMessageEvents,
- WorkerProcessType
+ WorkerProcessType,
} from './WorkerTypes.js'
import {
ApplicationProtocolVersion,
ConfigurationSection,
- SupervisionUrlDistribution
+ SupervisionUrlDistribution,
} from '../../src/types/ConfigurationData.js'
await describe('ConfigurationData test suite', async () => {
GenericStatus,
IncomingRequestCommand,
MessageType,
- RequestCommand
+ RequestCommand,
} from '../../src/types/index.js'
import {
handleFileException,
handleIncomingRequestError,
- handleSendMessageError
+ handleSendMessageError,
} from '../../src/utils/ErrorUtils.js'
import { logger } from '../../src/utils/Logger.js'
await describe('ErrorUtils test suite', async () => {
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
const chargingStation = {
- logPrefix: () => 'CS-TEST |'
+ logPrefix: () => 'CS-TEST |',
} as ChargingStation
await it('Verify handleFileException()', t => {
}).toThrow(error)
expect(() => {
handleFileException('path/to/module.js', FileType.Authorization, error, 'log prefix |', {
- throwError: false
+ throwError: false,
})
}).not.toThrow()
expect(logger.warn.mock.calls.length).toBe(1)
expect(logger.error.mock.calls.length).toBe(1)
expect(() => {
handleFileException('path/to/module.js', FileType.Authorization, error, 'log prefix |', {
- consoleOut: true
+ consoleOut: true,
})
}).toThrow(error)
expect(() => {
handleFileException('path/to/module.js', FileType.Authorization, error, 'log prefix |', {
throwError: false,
- consoleOut: true
+ consoleOut: true,
})
}).not.toThrow()
expect(console.warn.mock.calls.length).toBe(1)
}).toThrow(error)
expect(() => {
handleIncomingRequestError(chargingStation, IncomingRequestCommand.CLEAR_CACHE, error, {
- throwError: false
+ throwError: false,
})
}).not.toThrow()
const errorResponse = {
- status: GenericStatus.Rejected
+ status: GenericStatus.Rejected,
}
expect(
handleIncomingRequestError(chargingStation, IncomingRequestCommand.CLEAR_CACHE, error, {
throwError: false,
- errorResponse
+ errorResponse,
})
).toStrictEqual(errorResponse)
expect(chargingStation.logPrefix.mock.calls.length).toBe(3)
roundTo,
secureRandom,
sleep,
- validateUUID
+ validateUUID,
} from '../../src/utils/Utils.js'
import { runtime, runtimes } from '../../utils/runtime.js'
expect(isAsyncFunction('')).toBe(false)
expect(isAsyncFunction([])).toBe(false)
expect(isAsyncFunction(new Date())).toBe(false)
- // eslint-disable-next-line prefer-regex-literals
expect(isAsyncFunction(/[a-z]/i)).toBe(false)
expect(isAsyncFunction(new Error())).toBe(false)
expect(isAsyncFunction(new Map())).toBe(false)
deno: 'deno',
node: 'node',
workerd: 'workerd',
- browser: 'browser'
+ browser: 'browser',
}
const isBun = !!globalThis.Bun || !!globalThis.process?.versions?.bun