Normalization logic for common HTTP response payloads.
Currently supports JSON API Spec only.
[TBC]
$ yarn add joint-normalizer| Name | Required? | Description |
|---|---|---|
| debugInit | No | Set to true to log debug messages during instantiation. Defaults to false. |
| debugToModel | No | Set to true to log debug messages during Model object hydration. Defaults to false. |
| debug | No | Set to true to log debug messages during instance utilization. Defaults to false. |
| payloadSpec | No | The output specification of the Joint payload. Defaults to 'json-api'. |
| fieldForModelType | No | The property name in the payload that identifies the name of the Model type. Defaults to 'type'. |
| toFieldFormat | No | The target format (case) for normalized fields. Supported formats: 'snake', 'kebab', 'camel'. Defaults to 'snake'. |
| fromFieldFormat | No | The 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'. |
| relationNameMap | No | [TBC] |
| models | No | The Model object definitions (shapes) that the normalizer will build and return (if instructed). Provide the model definitions as an Object. |
| Name | Type | Description |
|---|---|---|
| ... | ... | [TBC - List all properties from constructor options] |
| Model | Function | The 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. |
All functions are synchronous.
| Name | Parameters | Returns | Description |
|---|---|---|---|
| normalizePayload | payload - 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. |
[TBC]
The plugin uses ESLint for source code linting. The linting will run automatically on git commit.
$ yarn lintYou can run with flag
--fix, or shortcut command flint, to trigger auto fixing (e.g.yarn flint).
The plugin uses Mocha for the testing framework, and Chai for its assertions.
$ yarn testTo build the plugin before running the test, you can use:
$ yarn build-testThe plugin is automatically built on yarn publish. But, you can manually build the plugin using:
$ yarn build