Skip to content
Snippets Groups Projects

dcc-js

A typed JavaScript library for parsing and writing DCCs


Heads-Up

This library does not validate the given DCC. It expects them to be valid against the supported DCC schema. If you are looking for a way to validate xml against a xsd in the browser, have a look at the GEMIMEG Tool.

Getting Started

The module is currently published to a public registry on this GitLab instance.

npm Instructions

To install it you have to create a .npmrc in the root of your project with the following content.

@d-ptb:registry=https://gitlab1.ptb.de/api/v4/packages/npm/

After that you can run npm install @d-ptb/dcc-js.

yarn Instructions

To install it you have to create a .yarnrc.yml in the root of your project with the following content.

npmScopes:
  d-ptb:
    npmRegistryServer: "https://gitlab1.ptb.de/api/v4/packages/npm/"

After that you can run yarn add @d-ptb/dcc-js.

Example

import { DCCDocument } from "@d-ptb/dcc-js";

// parse the xml
const xml = "<valid dcc xml>";
const doc = DCCDocument.fromXml(xml);

// access the properties of the DCC
// _attr contains all the attributes of a given element
doc.digitalCalibrationCertificate._attr.schemaVersion // => 3.2.0
// _text is used to access the value of the given element
doc.digitalCalibrationCertificate.administrativeData.coreData.uniqueIdentifier._text

// serialize the DCC
console.log(doc.toXML()); // => <valid dcc xml>

License

Copyright 2021 - 2023 Physikalisch-Technische Bundesanstalt, Bundesallee 100, 38116 Braunschweig, GERMANY Licensed under the EUPL, Version 1.2 or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");

You may not use this work except in compliance with the Licence.

You may obtain a copy of the Licence at: https://joinup.ec.europa.eu/software/page/eupl

Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the Licence for the specific language governing permissions and limitations under the Licence.

Publishing the package

  1. Commit all changes
  2. Bump the version with yarn version [major | minor | patch | ...], e.g. yarn version patch (if the script is not installed, type yarn plugin import version)
  3. Push all commits to the remote
  4. Create a tag with the following name: v<version> (e.g. v1.0.0) (https://www.jetbrains.com/help/webstorm/use-tags-to-mark-specific-commits.html#tag_commit)
  5. Push the tag to the remote, the CI will create a release and publish the package