@truststack/untp-types
v0.0.6
Published
UNTP Types
Readme
@truststack/untp-types
TypeScript type definitions for UN/CEFACT UNTP schemas.
Overview
This package provides TypeScript type definitions for working with UNTP schemas, including:
- DPP (Digital Product Passport)
- DCC (Digital Conformity Credential)
- DTE (Digital Traceability Event)
- DFR (Digital Facility Profile)
Installation
pnpm install @truststack/untp-types
npm install @truststack/untp-types
yarn install @truststack/untp-typesUsage
Imported types will default to the latest UNTP version available:
import { DPP, DCC, DTE, DFR } from '@truststack/untp-types';If required, you specify a specific version to import:
import { DPP, DCC, DTE, DFR } from '@truststack/untp-types/0.5.0';Development
Fetching Schema Files
The package includes a script to fetch the latest UNTP schema files from the UN/CEFACT repository:
pnpm run fetchThis will:
- Download JSON schemas from
https://test.uncefact.org/vocabulary/untp/ - Save them in the
src/<version>directory - Currently fetches version 0.5.0 of:
- DPP (Digital Product Passport)
- DCC (Digital Conformity Credential)
- DTE (Digital Traceability Event)
- DFR (Digital Facility Profile)
Generating Types
To generate TypeScript types from the JSON schemas:
pnpm run generateThis script:
- Finds all JSON schema files in the
srcdirectory - Generates corresponding TypeScript type definitions using
json-schema-to-typescript - Places the generated
.tsfiles alongside the JSON files
Package Structure
packages/untp-types/
├── src/
│ ├── 0.5.0/ # Schema version directory
│ │ ├── DPP.json # JSON schemas
│ │ ├── DPP.ts # Generated types
│ │ └── ...
│ └── index.ts # Type exports
├── scripts/
│ ├── fetch.sh # Schema fetching script
│ └── generate.sh # Type generation script
└── package.jsonLicense
MIT
