@pa-media-group/iptc-ninjs-2-type
v1.1.0
Published
A typescript definition of IPTCs public NinJS 2.0 library.
Downloads
7
Readme
IPTC NinJS V2.0 Type Definition
Typescript type definition of IPTCs NinJS V2.0 standard (https://github.com/iptc/newsinjson).
Installation
npm i @pa-media-group/iptc-ninjs-2-type
Usage
IPTC Ninjs 2.0 Type
import { NinjsItem } from '@pa-media-group/iptc-ninjs-2-type';
const typed: NinjsItem = {
"uri": "https://myuri.com/test/1"
};
Validating JSON
Included is a validator which can be used to ensure JSON conforms to the IPTC Ninjs 2.0 schema it can be used as follows: -
import { NinjsItem, NinjsValidator } from 'iptc-ninjs-2-type';
const validator: NinjsValidator = new NinjsValidator();
const typed: NinjsItem = {
"uri": "https://myuri.com/test/1"
};
const valid: boolean = validator.validate(typed);
Tech
- typeScript - TypeScript is a typed superset of JavaScript
- node.js - Evented I/O for the backend
- jest - Mocking/testing framework
- nvm - Node Version Manager
Installation
You need node.js installed globally to run the validator and tests. We recommend you manage your Node versions with nvm.
nvmrc
You need node.js installed to run the service. It is recommended that you use nvm for managing the complexity of Node versions. Using nvm, run:
nvm use
This will select the appropriate version of the Node installed on your machine upon the .nvmrc file.
Then to install the dependencies:
npm install
To install the dependencies specified by package-lock.json
:
npm ci
Lint
A default typescript style lint (tslint.json) has been included in this build. To ensure that the TS files conform to the lint, run:
npm run lint
Additionally the package.json can be linted by running
npm run lint:package
Commit messages themselves are linted and Husky enforces this an example of an acceptable commit message would be
feat(initial): Define product schema confirming to Ninjs 2.0 standards
Initial commit including validator, linting, testing
[EN-1790](https://alamy.atlassian.net/browse/EN-1790)
Git hooks
In order to set up git hooks for development, please run npm run prepare
after installing the dependencies
Unit Tests
Tests are run using the jest framework and include a coverage check as default. They can be executed by running
npm run test
Semantic Release - Commit style
It is recommended for clarity that the ticket reference is included in the commit message body, the format should be as follows:
fix|feat|perf(<short_feature_name>): <ticket> - <description_of_change>
Here is an example of the release type that will be done based on a commit messages.
| Commit message | Release type |
| -------------------------------------------------------------------------------------------------------------------- | -------------------------- |
| fix(logging): TICKET-1234 - Additional logging
| Patch Release |
| feat(publish-endpoint): TICKET-2345 - Addition of the /publish endpoint to the API
| ~~Minor~~ Feature Release |
| perf(event-model): TICKET-3456 - Event model update
BREAKING CHANGE: The time attribute has been removed.
| ~~Major~~ Breaking Release |