@@ -361,21 +361,20 @@ const Utils = class {
361361 * Convert JSONAPI record(s) to restructured data
362362 * @memberof module:jsonapi-vuex.utils
363363 * @param {object } data - The `data` object from a JSONAPI record
364- * @param {boolean } isIncluded - Flag which if true, will mark these records as coming from 'included' not via 'data'
365364 * @return {object } Restructured data
366365 */
367- jsonapiToNorm ( data , isIncluded ) {
366+ jsonapiToNorm ( data ) {
368367 const norm = { }
369368 if ( Array . isArray ( data ) ) {
370369 data . forEach ( ( item ) => {
371370 let { id } = item
372371 if ( ! this . hasProperty ( norm , id ) ) {
373372 norm [ id ] = { }
374373 }
375- Object . assign ( norm [ id ] , this . jsonapiToNormItem ( item , isIncluded ) )
374+ Object . assign ( norm [ id ] , this . jsonapiToNormItem ( item ) )
376375 } )
377376 } else {
378- Object . assign ( norm , this . jsonapiToNormItem ( data , isIncluded ) )
377+ Object . assign ( norm , this . jsonapiToNormItem ( data ) )
379378 }
380379 return norm
381380 }
@@ -384,10 +383,10 @@ const Utils = class {
384383 * Restructure a single jsonapi item. Used internally by {@link module:jsonapi-vuex.utils.jsonapiToNorm}
385384 * @memberof module:jsonapi-vuex._internal
386385 * @param {object } data - JSONAPI record
387- * @param {boolean } isIncluded - Flag, which if true will mark this record as coming from 'included', not via 'data '
386+ * @param {boolean } recordType=isData - Set a key in _jv which reflects if this came 'direct' from 'data' or via 'included '
388387 * @return {object } Restructured data
389388 */
390- jsonapiToNormItem ( data , isIncluded = false ) {
389+ jsonapiToNormItem ( data , recordType = 'isData' ) {
391390 if ( ! data ) {
392391 return { }
393392 }
@@ -396,9 +395,8 @@ const Utils = class {
396395 // Create a new object omitting attributes
397396 const { attributes, ...normNoAttrs } = norm [ this . jvtag ] // eslint-disable-line no-unused-vars
398397 norm [ this . jvtag ] = normNoAttrs
399- if ( isIncluded ) {
400- norm [ this . jvtag ] . isIncluded = isIncluded
401- }
398+ // Set recordType (either isData or isIncluded) to true
399+ norm [ this . jvtag ] [ recordType ] = true
402400 return norm
403401 }
404402
@@ -504,9 +502,8 @@ const Utils = class {
504502 */
505503 processIncludedRecords ( context , results ) {
506504 for ( let item of get ( results , [ 'data' , 'included' ] , [ ] ) ) {
507- //Mark record as coming from included
508- let isIncluded = true
509- const includedItem = this . jsonapiToNormItem ( item , isIncluded )
505+ // Mark record as coming from included
506+ const includedItem = this . jsonapiToNormItem ( item , 'isIncluded' )
510507 context . commit ( 'mergeRecords' , includedItem )
511508 }
512509 }
0 commit comments