@open-charging-cloud/chargy-core 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,30 +1,107 @@
1
1
  # Chargy Core
2
2
 
3
- The ChargyCore TypeScript library shared between Chargy Desktop, Web & Mobile applications.
3
+ Chargy Core is a transparency software library for the validation of secure and transparent e-mobility charging processes, as defined by the *German Calibration Law ("Eichrecht")* in combination with the [Alternative Fuels Infrastructure Regulation (AFIR)](https://transport.ec.europa.eu/transport-themes/clean-transport/alternative-fuels-sustainable-mobility-europe/alternative-fuels-infrastructure_en) and the new [Measuring instruments (MID)](https://single-market-economy.ec.europa.eu/single-market/goods/european-standards/harmonised-standards/measuring-instruments-mid_en) of the European Commission and the [European Digital Quality Infrastructure](https://www.qi-digital.de/en/). The software allows you to verify the cryptographic signatures of energy measurements within charge detail records and comes with a couple of useful extentions to simplify the entire process for endusers and operators.
4
+
5
+ This software is written as a modern ESM TypeScript package with generated declaration files, providing shared core functionality for the Chargy Desktop, Web & Mobile applications.
6
+
7
+
8
+ ## Benefits of Chargy
9
+
10
+ 1. Chargy comes with __*meta data*__. True charging transparency is more than just signed smart meter values. Chargy allows you to group multiple signed smart meter values to entire charging sessions and to add additional meta data like EVSE information, geo coordinates, tariffs, ... within your backend in order to improve the user experience for the ev drivers.
11
+ 2. Chargy is __*secure*__. Chargy implements a public key infrastructure for managing certificates of smart meters, EVSEs, charging stations, charging station operators and e-mobility providers. By this the ev driver will always retrieve the correct public key to verify a charging process automatically and without complicated manual lookups in external databases.
12
+ 3. Chargy is __*Open Source*__. In contrast to other vendors in e-mobility, we belief that true transparency is only trustworthy if the entire process and the required software is open and reusable under a fair copyleft license (AGPL).
13
+ 4. Chargy is __*open for your contributions*__. We currently support adapters for the protocols of different charging station vendors like chargeIT mobility, ABL (OCMF), chargepoint. The certification at the Physikalisch-Technische Bundesanstalt (PTB) is provided by chargeIT mobility. If you want to add your protocol or a protocol adapter feel free to read the contributor license agreement and to send us a pull request.
14
+
15
+
16
+ ## Supported Charge Transparency Data Formats
17
+
18
+ - Alfen
19
+ - Bauer energy meters
20
+ - EMH energy meters
21
+ - Mennekes XML
22
+ - OCMF v1.1 - v1.4
23
+ - Porsche
24
+ - chargeIT (2 versions)
25
+ - chargepoint
26
+
4
27
 
5
28
  ## Usage
6
29
 
7
30
  ```ts
8
31
  import { Chargy } from "@open-charging-cloud/chargy-core";
9
- import { OCMF } from "@open-charging-cloud/chargy-core";
10
32
  ```
11
33
 
12
- The package is published as modern ESM and ships generated TypeScript declarations.
34
+
35
+ ## Runtime Architecture
36
+
37
+ ChargyCore is consumed in different JavaScript runtimes. The browser-based Chargy WebApp and Electron renderer processes have Web APIs such as `DOMParser`, `Blob`, `TextEncoder`, `ImageData`, `DOMMatrix`, `Path2D`, and browser worker loading semantics. Node.js-based tests, command line tools, server-side verification, and build-time checks do not provide the same environment.
38
+
39
+ For that reason the package ships two JavaScript builds behind one public import:
40
+
41
+ ```text
42
+ dist/browser/index.js
43
+ dist/node/index.js
44
+ ```
45
+
46
+ The runtime-specific file is selected through conditional package exports in `package.json`. Browser bundlers should resolve the `browser` condition and receive `dist/browser/index.js`. Node.js resolves the `node` condition and receives `dist/node/index.js`.
47
+
48
+ This split is especially important for PDF.js. Browser contexts should use the normal `pdfjs-dist` build, because the browser already provides the canvas and DOM APIs PDF.js expects. Node.js should use `pdfjs-dist/legacy/build/pdf.mjs`, because the legacy build contains Node-oriented setup for the missing canvas-related globals and avoids the modern browser-only assumptions.
49
+
50
+ Keeping these paths separate has several advantages:
51
+
52
+ - Browser bundles do not include the Node/legacy PDF.js path as an unused lazy chunk.
53
+ - Node tests and CLI-style usage do not depend on browser-only PDF.js behavior.
54
+ - Chargy apps do not need local Webpack aliases or test polyfills for ChargyCore internals.
55
+ - Bundle checks can verify that the browser build only references browser PDF.js imports and the Node build only references legacy PDF.js imports.
56
+
57
+ When adding runtime-sensitive dependencies, avoid branching on runtime inside shared source code if that would make bundlers see both implementations. Prefer a small adapter under `src/` and let the build or conditional exports select the runtime-specific implementation.
58
+
13
59
 
14
60
  ## Development
15
61
 
16
62
  ```bash
17
63
  npm install
18
64
  npm run typecheck
19
- npm test
65
+ npm run lint
20
66
  npm run build
67
+ npm run test:node
68
+ npm run test:bundle
69
+ npm run test:browser
70
+ npm test
71
+ npm run verify
21
72
  ```
22
73
 
23
74
  The build emits the package into `dist/`.
24
75
 
25
76
 
77
+ ### Expected Test Flow
78
+
79
+ For code changes, use the full verification flow before publishing or handing a package to the Chargy apps:
80
+
81
+ ```bash
82
+ npm run verify
83
+ ```
84
+
85
+ `verify` runs the following checks:
86
+
87
+ - `npm run typecheck`: validates the TypeScript sources and test/config TypeScript files.
88
+ - `npm run lint`: runs the strict type-aware ESLint setup. Existing migration findings are warnings, new unused variables are errors.
89
+ - `npm test`: runs all runtime checks:
90
+ - `npm run test:node`: runs the Chargy fixture tests in Vitest's Node environment and uses the Node PDF.js adapter.
91
+ - `npm run build`: creates both package builds.
92
+ - `npm run test:bundle`: checks the generated bundles so the browser build only references the browser PDF.js path and the Node build only references the legacy PDF.js path.
93
+ - `npm run test:browser`: imports `dist/browser/index.js` in headless Chromium via Vitest Browser Mode and verifies the public browser entry can be loaded and instantiated.
94
+ - `npm run build`: recreates the final publishable `dist/` output.
95
+
96
+ For dependency, build, export, PDF.js, or browser-facing changes, run the individual steps while iterating and finish with `npm run verify`. The browser test requires Playwright's Chromium browser; if it is missing locally, run:
97
+
98
+ ```bash
99
+ npx playwright install chromium
100
+ ```
101
+
102
+
26
103
  ```bash
27
- npm version 0.3.0 --no-git-tag-version
104
+ npm version 0.5.0 --no-git-tag-version
28
105
  npm run verify
29
106
  npm pack --dry-run
30
107
  npm pack
@@ -1 +1 @@
1
- {"version":3,"file":"BSMCrypt01.d.ts","sourceRoot":"","sources":["../src/BSMCrypt01.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,MAAM,EAAE,MAA0B,UAAU,CA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