@nori-dot-com/project
v1.6.2
Published
Nori supplier project specification and utilities
Downloads
19
Readme
@nori-dot-com/project
Schema and utilities for nori supplier projects
Installation
via yarn
yarn add @nori-dot-com/project
or via npm
npm i @nori-dot-com/project
Docs
Nori Croplands Project Specification v4 - Nori "v4" croplands project data import specification documentation
Nori Croplands Project specification v3 - Nori "v3" project data specification documentation lives here
validation - documentation on how to use the validation module to validate Nori project data (i.e. data that was exported from a data platform to conform with the latest project data specification)
convertFromV3ToV4 - Basic conversion logic to transform v3 files to v4. Not thorougly tested yet.
convertFromV2ToV1 - documentation on how to use the script to convert "v2" project data files into "v1" project data files (neither version are what is specified in the specification files as that is referred to as "v3")
Validation CLI
There is a very simple CLI entrypoint to the V4 project schema validation that's used as follows:
yarn validate < myV4Import.json > myOutput.json
Developers
Summary
This module consists of three primary artifacts (a TypeScript specification, a JSON schema, and validation functions), all of which depend on one another.
The TypeScript specification
This is the most important file in the module. This file accomplishes a few things:
TypeScript interface declarations
These interfaces are exported for use in TS/JS applications
Inline documentation, examples, and validation parameter definitions
This module makes use of TypeDoc to define documentation and examples.
It then makes use of typedoc-plugin-markdown to auto-generate documentation (i.e., those found in the docs folder)
Documentation for the spec such as why certain fields are optional, when they're optional. Such documentation is auto-generated from the specification's inline JSDoc style comments so as to prevent the documentation from becoming out of sync with the specification itself.
The JSON schema
This module makes use of typescript-json-schema to parse the typescript interfaces (and associated comments) into JSON schema format. This is eventually and primarily consumed by the validation functions
Validation functions
These functions contain a validation functions that makes use of AJV to create extremely robust validation functions.
The validation functions allow partners and data managers to start creating import files prior to us having the full import flow finished and integrated in the app. This way, once the new specification is supported in the app, partners and data managers can be confident that importing their files won't result in an error.
The validation functions can be used to validate project data in a given file. If the data is valid, the validation functions will say such. If the data is invalid, the functions will not only say that the data is invalid, but it will give detailed information as to why the data is invalid.
Development
Generate docs
yarn make:docs
Generate JSON schema
yarn make:schema
Run tests
From the root of the nori-dot-com monorepo
yarn run test