Namespace: _internal

pinia-jsonapi._internal

Documentation for internal functions etc. These are not available when the module is imported, and are documented for module developers only.

Source:

Members

(static) hasProperty

Shorthand for the 'safe' hasOwnProperty as described here: eslint: no-prototype-builtins

Source:

Methods

(static) Utils#_copy(data) → {object}

Parameters:
Name Type Description
data object

An object to be deep copied

Source:
Returns:

A deep copied object

Type
object

(static) Utils#checkAndFollowRelationships(state, getters, records, seen) → {object}

If followRelationshipData is set, call followRelationships for either an item or a collection See Configuration

Parameters:
Name Type Description
state object

Vuex state object

getters object

Vuex getters object

records object

Record(s) to follow relationships for.

seen array

internal recursion state-tracking

Source:
Returns:

records with relationships followed

Type
object

(static) Utils#followRelationships(state, getters, record, seen) → {object}

A thin wrapper around `getRelationships, making a copy of the object. We can't add rels to the original object, otherwise Vue's watchers spot the potential for loops (which we are guarding against) and throw an error

Parameters:
Name Type Description
state object

Vuex state object

getters object

Vuex getters object

record object

Record to get relationships for.

seen array

internal recursion state-tracking

Source:
Returns:

records with relationships followed and helper functions added (see module:pinia-jsonapi.utils.addJvHelpers)

Type
object

(static) Utils#getIncludedRecords(results)

Restructure all records in 'included' (using module:pinia-jsonapi._internal.jsonapiToNormItem) and add to the store.

Parameters:
Name Type Description
results object

JSONAPI record

Source:

(static) Utils#getRelationships(getters, parent, seen) → {object}

Make a copy of a restructured object, adding (js) getters for its relationships That call the (vuex) get getter to fetch that record from the store

Already seen objects are tracked using the 'seen' param to avoid loops.

Parameters:
Name Type Description
getters object

Vuex getters object

parent object

The object whose relationships should be fetched

seen array

Internal recursion state tracking

Source:
Returns:

A copy of the object with getter relationships added

Type
object

(static) Utils#jsonapiToNormItem(data, recordType) → {object}

Restructure a single jsonapi item. Used internally by module:pinia-jsonapi.utils.jsonapiToNorm

Parameters:
Name Type Default Description
data object

JSONAPI record

recordType boolean isData

Set a key in _jv which reflects if this came 'direct' from 'data' or via 'included'

Source:
Returns:

Restructured data

Type
object

(static) Utils#normToJsonapiItem(data) → {object}

Convert a single restructured item to JSONAPI. Used internally by module:pinia-jsonapi.utils.normToJsonapi

Parameters:
Name Type Description
data object

Restructured data

Source:
Returns:

JSONAPI record

Type
object

(static) Utils#preserveJSON(data, json) → {object}

If preserveJSON is set, add the returned JSONAPI in a get action to _jv.json See Configuration

Parameters:
Name Type Description
data object

Restructured record

json object

JSONAPI record

Source:
Returns:

data record, with JSONAPI added in _jv.json

Type
object

(static) Utils#unpackArgs(args) → {array}

Transform args to always be an array (data and config options). See module:pinia-jsonapi.actions for an explanation of why this function is needed.

Parameters:
Name Type Description
args string | array

Array of data and configuration info

Source:
Returns:

Array of data and config options

Type
array

(static) Utils#updateRecords(state, records, merging)

A single function to encapsulate the different merge approaches of the record mutations. See module:pinia-jsonapi.mutations to see the mutations that use this function.

Parameters:
Name Type Description
state object

Vuex state object

records object

Restructured records to be updated

merging boolean

Whether or not to merge or overwrite records

Source: