0.0.5 • Published 3 years ago

joint-normalizer v0.0.5

Weekly downloads
6
License
MIT
Repository
github
Last release
3 years ago

Joint Normalizer

Normalization logic for common HTTP response payloads.

Currently supports JSON API Spec only.

Table of Contents

Introduction

TBC

How to Use

Install

$ yarn add joint-normalizer

API

Constructor

Constructor Options

NameRequired?Description
debugInitNoSet to true to log debug messages during instantiation. Defaults to false.
debugToModelNoSet to true to log debug messages during Model object hydration. Defaults to false.
debugNoSet to true to log debug messages during instance utilization. Defaults to false.
payloadSpecNoThe output specification of the Joint payload. Defaults to 'json-api'.
fieldForModelTypeNoThe property name in the payload that identifies the name of the Model type. Defaults to 'type'.
toFieldFormatNoThe target format (case) for normalized fields. Supported formats: 'snake', 'kebab', 'camel'. Defaults to 'snake'.
fromFieldFormatNoThe source format (case) of the payload\'s fields. This declaration is not necessary for functional correctness, but will merely suppress unnecessary transformations (and loops) when the source and target match. Supported formats: 'snake', 'kebab', 'camel'. Defaults to 'snake'.
relationNameMapNoTBC
modelsNoThe Model object definitions (shapes) that the normalizer will build and return (if instructed). Provide the model definitions as an Object.

Instance

Instance Properties

NameTypeDescription
......TBC - List all properties from constructor options
ModelFunctionThe Model factory that is constructed with the models provided at instantiation. If a payload type is handled by the normalizer, and a valid Model definition cannot be determined, the normalizer will simply return the generic normalized shape.

Instance Functions

All functions are synchronous.

NameParametersReturnsDescription
normalizePayloadpayload - the payload to normalize. asModel - whether or not to return a Model object.The normalized payload (generic object -or- Model object)Perform the normalization of a provided Joint payload.

Errors

TBC

For Developers

Dev Lint

The plugin uses ESLint for source code linting. The linting will run automatically on git commit.

$ yarn lint

You can run with flag --fix, or shortcut command flint, to trigger auto fixing (e.g. yarn flint).

Dev Test

The plugin uses Mocha for the testing framework, and Chai for its assertions.

$ yarn test

To build the plugin before running the test, you can use:

$ yarn build-test

Dev Build

The plugin is automatically built on yarn publish. But, you can manually build the plugin using:

$ yarn build

License

MIT

0.0.5

3 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago