1.0.0-rc.1 • Published 4 years ago

ts4ocds v1.0.0-rc.1

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

logo

npm npm npm peer dependency version code style: prettier

TS4OCDS

ts4ocds is a library of TypeScript interfaces that takes an approach to befriend large OCDS JSONs with your per-project routine of writing whole lotta interfaces for them.

It consists of two main parts: standard and extensions.

Installation

$ npm i -D ts4ocds
# or
$ yarn add -D ts4ocds

Usage

Standard

This includes all types and interfaces from bare OCDS v1.1.4 standard.

import { Item } from 'ts4ocds';

Note, that some top-level entities like Tender or Planning are not included here as they sometimes depend on a context they are used in.

Extensions

import { Observation } from 'ts4ocds/extensions/metrics';

import { Requirement } from 'ts4ocds/extensions/requirements';

Please note, that all the extensions are imported from their respective folder under the extensions module.

Also, take into consideration that extensions can populate some entities from the standard with new properties. Here we extend such interfaces from their standard counterparts and add new properties so, for example, you can find Item in both standard and some of the extensions.

Validators

Validators help you better differentiate interface with relatable fields. For example, Requirement's value field depends on its dataType, which could easily be checked with a validator function:

import { isOfTypeString } from 'ts4ocds/validators';

const stringRequirement = isOfTypeString(requirement);

// Asserts that requirement's dataType is 'string',
// so that its value should also be of type string

Contributing

We are open to receive any contributings to our project. If you are willing to contribute, please make sure to read our contributing guide.

If you have noticed bugs or want to propose a new feature/improvement, you should check out our issues section. Every properly written issue will be attended and reviewed by our team.