Namespace

_internal

jsonapi-vuex._internal

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

View Source lib.js, line 23

Members

# static hasProperty

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

View Source lib.js, line 350

Methods

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

Parameters:
Name Type Description
data object

An object to be deep copied

View Source lib.js, line 43

A deep copied object

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

View Source lib.js, line 136

records with relationships followed

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

View Source lib.js, line 229

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

object

# 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

View Source lib.js, line 252

A copy of the object with getter relationships added

object

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

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

Parameters:
Name Type Description
data object

JSONAPI record

View Source lib.js, line 388

Restructured data

object

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

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

Parameters:
Name Type Description
data object

Restructured data

View Source lib.js, line 429

JSONAPI record

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

View Source lib.js, line 482

data record, with JSONAPI added in _jv.json

object

# static Utils#processIncludedRecords(context, results)

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

Parameters:
Name Type Description
context object

Vuex actions context object

results object

JSONAPI record

View Source lib.js, line 500

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

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

Parameters:
Name Type Description
args string | array

Array of data and configuration info

View Source lib.js, line 515

Array of data and config options

array

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

A single function to encapsulate the different merge approaches of the record mutations. See module:jsonapi-vuex.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

View Source lib.js, line 531