Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dvsa/cvs-type-definitions
json schema definitions and .ts type definitions for cvs vta application
https://github.com/dvsa/cvs-type-definitions
Last synced: 13 days ago
JSON representation
json schema definitions and .ts type definitions for cvs vta application
- Host: GitHub
- URL: https://github.com/dvsa/cvs-type-definitions
- Owner: dvsa
- Created: 2022-10-17T14:52:36.000Z (about 2 years ago)
- Default Branch: develop
- Last Pushed: 2024-11-26T15:03:55.000Z (about 1 month ago)
- Last Synced: 2024-11-26T16:21:55.758Z (about 1 month ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@dvsa/cvs-type-definitions
- Size: 19.9 MB
- Stars: 1
- Watchers: 6
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cvs-type-definitions
[json schema](https://json-schema.org/) and .ts type definitions for cvs vta application
# Usage
## Install GitHub package:
- install GitHub package: `npm install @dvsa/cvs-type-definitions@latest`
## Example usage (TS types):
`import { CommercialVehicleTestSchema } from @dvsa/cvs-type-definitions/types/test`
## Example usage (json schemas)
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);`
# Updating a schema
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.
1. Navigate into the relevant schema (e.g. `./json-definitions/test/index.json`)
2. Edit file
3. Generate the new TypeScript and de-referenced json schema definitions using `npm run generate`
4. Bump the version of the package using `npm version {major|minor|patch}`
5. Publish updates# Adding a new schema
1. Create a new subdirectory with an appropriate name within the `json-defininitions` directory (e.g. `my-new-schema`)
2. 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`)
3. Generate the new TypeScript definitions using `npm run generate`
4. Bump the version of the package using `npm version {major|minor|patch}`
5. Publish updates# Creating a new enum
1. Add (or update) the enum to a file marked `*.enum.json` in the `enum` folder in `json-definitions`
2. Make sure you give it both `enum` and `tsEnumNames` properties on the object
3. Then update the `json-definitions` to use the new file name
4. Run the generate and you should have just a new file in the enum folder of types, which is exportable and useable.# Publishing a new version
- Raise a PR
- The PR title should start with `major`, `minor` or `patch` 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