Skip to content
This repository has been archived by the owner on Nov 5, 2020. It is now read-only.

uStudioCompany/ts4ocds

Repository files navigation

logo

npm npm npm peer dependency version code style: prettier

TS4OCDS

Important notice!

We've just released a full and official 1.0.0 version!

Being a release candidate for so long was not easy, but we've come to many conclusions while using this rc version and decided to completely rewrite it and move to the monorepo structure. We've also updated our docs, they seem to be more fancy and useful (at least for now).

Be sure to check out this new version. If you decide to proceed with this release candidate – be cautious, as it was completely rethought and redone.


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.