Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

transformalizer

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

transformalizer

## API

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10
decreased by-98.57%
Maintainers
1
Weekly downloads
 
Created
Source

transformalizer

API

Transformalizer()

transformalizer.register({ type, schema })

Parameters
NameTypeDescription
type*Stringjson api type
schema*Objectmappings for type

transformalizer.transform({ type, source, options }) => Object

Schema

A schema object defines a set of functions used to transform your raw data into a valid JSON API document.

type({ source, options, data }) => String

A function that should return the type of the resource being processed. If this returns a type other than the schema type, the other schema will be used in place of the current schema.

Parameters
NameTypeDescription
sourceObject[],Objectthe source data passed to the #transform function
optionsObjectany options passed to the #transform function
dataObjectthe current item being processed when source is an array, or the source itself if not an array

id({ source, options, data }) => String

A function that should return the id of the resource being processed.

Parameters
NameTypeDescription
sourceObject[],Objectthe source data passed to the #transform function
optionsObjectany options passed to the #transform function
dataObjectthe current item being processed when source is an array, or the source itself if not an array

attributes({ source, options, data, id }) => Object

A function that should return the attributes portion of the resource being processed. If a null or undefined value is returned, no attributes will be included on the resource.

Parameters
NameTypeDescription
sourceObject[],Objectthe source data passed to the #transform function
optionsObjectany options passed to the #transform function
dataObjectthe current item being processed when source is an array, or the source itself if not an array
idStringthe id of the current resource

relationships.[key]({ source, options, data, id, attributes, include }) => Object

A map of relationship keys to functions that should return a valid relationship object. If a null or undefined value is returned, that relationship will be excluded from the resulting object.

Parameters
NameTypeDescription
sourceObject[],Objectthe source data passed to the #transform function
optionsObjectany options passed to the #transform function
dataObjectthe current item being processed when source is an array, or the source itself if not an array
idStringthe id of the current resource
attributesObjectthe attributes object for the resource being processed
includeFunctionTODO

A function that should return the links portion of the resource being processed. If a null or undefined value is returned, no attributes will be included on the resource.

Parameters
NameTypeDescription
sourceObject[],Objectthe source data passed to the #transform function
optionsObjectany options passed to the #transform function
dataObjectthe current item being processed when source is an array, or the source itself if not an array
idStringthe id of the current resource
attributesObjectthe attributes object for the resource being processed
relationshipsObjectthe relationships object for the resource being processed

A function that should return the meta portion of the resource being processed. If a null or undefined value is returned, no attributes will be included on the resource.

Parameters
NameTypeDescription
sourceObject[],Objectthe source data passed to the #transform function
optionsObjectany options passed to the #transform function
dataObjectthe current item being processed when source is an array, or the source itself if not an array
idStringthe id of the current resource
attributesObjectthe attributes object for the resource being processed
relationshipsObjectthe relationships object for the resource being processed
linksObjectthe links object of the resource being processed

A function that should return the top level links for the current document.

Parameters
NameTypeDescription
sourceObject[],Objectthe source data passed to the #transform function
optionsObjectany options passed to the #transform function
documentObjectthe current json api document

topLevelMeta({ source, options, document }) => Object

A function that should return the top level meta for the current document.

Parameters
NameTypeDescription
sourceObject[],Objectthe source data passed to the #transform function
optionsObjectany options passed to the #transform function
documentObjectthe current json api document

FAQs

Package last updated on 07 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc