Documentation for internal functions etc. These are not available when the module is imported, and are documented for module developers only.
Members
# static hasProperty
Shorthand for the 'safe' hasOwnProperty
as described here:
eslint: no-prototype-builtins
Methods
# static Utils#_copy(data) → {object}
Parameters:
Name | Type | Description |
---|---|---|
data |
object | An object to be deep copied |
A deep copied 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 |
records with relationships followed
# 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 |
records with relationships followed and helper functions added (see module:jsonapi-vuex.utils.addJvHelpers
)
# 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 |
A copy of the object with getter relationships added
# 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 |
Restructured data
# 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 |
JSONAPI record
# 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 |
data record, with JSONAPI added in _jv.json
# 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 |
# 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 |
Array of data and config options
# 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 |