json schema and .ts type definitions for cvs vta application
- install GitHub package:
npm install @dvsa/cvs-type-definitions@latest
import { CommercialVehicleTestSchema } from @dvsa/cvs-type-definitions/types/test
The package exports an isValidObject()
function which can be used to validate an object against a specified schema. e.g:
import { isValidObject } from '@dvsa/cvs-type-definitions/lib/src/schema-validation../../schema-validator';
const isValidVisit: boolean = isValidObject('visit', myVisitObject);
Edits should only be made to json
schema definitions within json-definitions
directory.
TypeScript interfaces will be generated from these files and saved to types
directory. De-referenced json schema definitions will be saved to json-schemas
directory. Only these two directories are published in the npm package.
- Navigate into the relevant schema (e.g.
./json-definitions/test/index.json
) - Edit file
- Generate the new TypeScript and de-referenced json schema definitions using
npm run generate
- Bump the version of the package using
npm version {major|minor|patch}
- Publish updates
- Create a new subdirectory with an appropriate name within the
json-defininitions
directory (e.g.my-new-schema
) - If you do not wish for a type file and a de-referenced schema to be generated for a schema, add
.ignore
in the name of the file (e.g.my-new-schema.ignore.json
) - Generate the new TypeScript definitions using
npm run generate
- Bump the version of the package using
npm version {major|minor|patch}
- Publish updates
- Add (or update) the enum to a file marked
*.enum.json
in theenum
folder injson-definitions
- Make sure you give it both
enum
andtsEnumNames
properties on the object - Then update the
json-definitions
to use the new file name - Run the generate and you should have just a new file in the enum folder of types, which is exportable and useable.
- Raise a PR
- The PR title should start with
major
,minor
orpatch
and be followed by the character(
. Doing this ensure the correct version of the package is published to npm. A Github action should enforce the PR title format. - Add a description of the changes in the
Changelog
section of the PR description - Once merged to develop, a github action should create a release and publish a new version of that release on npm