{"id":27888194,"url":"https://github.com/romfrolov/ocpp-util","last_synced_at":"2025-05-05T09:06:15.181Z","repository":{"id":36071443,"uuid":"221253907","full_name":"romfrolov/ocpp-util","owner":"romfrolov","description":"OCPP utility library","archived":false,"fork":false,"pushed_at":"2022-12-30T19:04:35.000Z","size":536,"stargazers_count":0,"open_issues_count":10,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-05T09:06:11.649Z","etag":null,"topics":["ev","ocpp","ocpp16","ocpp20","utility"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/romfrolov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-12T15:46:17.000Z","updated_at":"2021-05-05T11:17:18.000Z","dependencies_parsed_at":"2023-01-16T12:47:59.285Z","dependency_job_id":null,"html_url":"https://github.com/romfrolov/ocpp-util","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romfrolov%2Focpp-util","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romfrolov%2Focpp-util/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romfrolov%2Focpp-util/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romfrolov%2Focpp-util/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/romfrolov","download_url":"https://codeload.github.com/romfrolov/ocpp-util/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252470770,"owners_count":21753047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ev","ocpp","ocpp16","ocpp20","utility"],"created_at":"2025-05-05T09:06:14.464Z","updated_at":"2025-05-05T09:06:15.173Z","avatar_url":"https://github.com/romfrolov.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OCPP Util\n\n![](https://github.com/romfrolov/ocpp-util/workflows/build/badge.svg) [![npm version](https://badge.fury.io/js/ocpp-util.svg)](https://badge.fury.io/js/ocpp-util) [![Coverage Status](https://coveralls.io/repos/github/romfrolov/ocpp-util/badge.svg?branch=master)](https://coveralls.io/github/romfrolov/ocpp-util?branch=master) [![install size](https://packagephobia.now.sh/badge?p=ocpp-util)](https://packagephobia.now.sh/result?p=ocpp-util)\n\nOCPP utility library.\n\n## Table of Contents\n\n- [Quick start](#quick-start)\n - [checkCardinality](#checkcardinality)\n - [checkType](#checkType)\n - [enums](#enums)\n- [Documentation](#documentation)\n- [Testing](#testing)\n- [License](#license)\n\n## Quick start\n\nInstall:\n\n```bash\nnpm i ocpp-util\n```\n\nImport:\n\n```js\nconst ocppUtil = require('ocpp-util');\n```\n\n### checkCardinality\n\nThe `checkCardinality()` method verifies that the input has a correct cardinality.\n\n```js\nocppUtil.checkCardinality(card, input);\n```\n\n**Parameters**\n\n- `card` {String} - expected cardinality.\n- `input` {Any} - input value to check.\n\n**Return value**\n\nBoolean. `true` if input has passed the check.\n\n**Supported cardinalities:**\n- `0..1`, `0..2`, ..., `0..*`\n- `1..1`, `1..2`, ..., `1..*`\n\n### checkType\n\nThe `checkType()` method verifies that the input meets the requirements of the OCPP Primitive Datatypes.\n\n```js\nocppUtil.checkType(type, input, length);\n```\n\n**Parameters**\n\n- `type` {String} - expected type.\n- `input` {Any} - input value to check.\n- `length` {Number} *optional* - maximal length of the value.\n\n**Return value**\n\nBoolean. `true` if input has passed the check.\n\n**Supported types:**\n- `AnyType` - Text, data without specified length or format.\n- `string` - The characters defined in the [Unicode](http://www.unicode.org/versions/Unicode10.0.0/) character set are allowed to be used.\n- `identifierString` - Only the following character set is allowed: `a-z, A-Z, 0-9, '*', '-', '_', '=', ':', '+', '|', '@', '.'`.\n- `integer` - 32 bit (31 bit resolution, 1 sign bit).\n- `decimal` - For data being reported by the Charging Station, the full resolution of the source data must be\npreserved. The decimal sent towards the Charging Station SHALL NOT have more than six\ndecimal places.\n- `dateTime` - All time values exchanged between CSMS and Charging Station SHALL be formatted as\ndefined in [[RFC3339]](https://tools.ietf.org/html/rfc3339). Additionally fractional seconds have been given an extra limit. The\nnumber of decimal places SHALL NOT exceed the maximum of 3.\n- `boolean` - Only allowed values: `false` and `true`.\n\n### enums\n\nThis library provides an access to all enumeration types of OCPP 1.6 and OCPP 2.0.\n\n```js\nocppUtil.enums(version);\n```\n\n**Parameters**\n\n`version` {String} - desired version of the OCPP protocol.\n\n**Return value**\n\nArray of objects. Returns all enums of the specified version of the protocol.\n\n**Example:**\n\n```js\nconst enums = ocppUtil.enums('2.0');\n\nconsole.log(enums.TRANSACTION_EVENT); // [ 'Ended', 'Started', 'Updated' ]\n```\n\n## Documentation\n\n```bash\nnpm run docs      # generate docs\nnpm run http-docs # start HTTP server serving docs\n```\n\n## Testing\n\n```bash\nnpm test\n```\n\n## License\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromfrolov%2Focpp-util","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fromfrolov%2Focpp-util","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromfrolov%2Focpp-util/lists"}