Comparing version 1.1.12 to 1.1.13
@@ -90,13 +90,18 @@ "use strict"; | ||
var relationLength = relation.length; | ||
var uniqueRelationKeys = []; | ||
for (var i = 0; i < relationLength; i++) { | ||
var item = { | ||
id: _this.propertiesMapper.getId(relation[i]), | ||
type: _this.propertiesMapper.getType(relation[i]) | ||
}; | ||
if (item.id && item.type) { | ||
relationshipData.push(item); | ||
var id = _this.propertiesMapper.getId(relation[i]); | ||
var type = _this.propertiesMapper.getType(relation[i]); | ||
var itemKey = type + id; | ||
var item = { id: id, type: type }; | ||
if (uniqueRelationKeys.indexOf(itemKey) !== -1) { | ||
console.warn("Duplicate relation model found", { model: model, relations: relations }); | ||
} | ||
else { | ||
else if (!item.id || !item.type) { | ||
console.error("Can't create data item[" + i + "] for relationship " + k + ",\n it doesn't have 'id' or 'type', it was skipped", relation[i]); | ||
} | ||
else { | ||
uniqueRelationKeys.push(itemKey); | ||
relationshipData.push(item); | ||
} | ||
} | ||
@@ -103,0 +108,0 @@ relationships[k] = { |
{ | ||
"name": "jsona", | ||
"description": "Provide data formatters (data model builder & json builder) to work with JSON API specification v1.0 in your JavaScript / TypeScript code", | ||
"version": "1.1.12", | ||
"version": "1.1.13", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "json-api", |
@@ -133,12 +133,13 @@ import { | ||
const relationLength = relation.length; | ||
const uniqueRelationKeys = []; | ||
for (let i = 0; i < relationLength; i++) { | ||
const item = { | ||
id: this.propertiesMapper.getId(relation[i]), | ||
type: this.propertiesMapper.getType(relation[i]) | ||
}; | ||
const id = this.propertiesMapper.getId(relation[i]); | ||
const type = this.propertiesMapper.getType(relation[i]); | ||
const itemKey = type + id; | ||
const item = {id, type}; | ||
if (item.id && item.type) { | ||
relationshipData.push(item); | ||
} else { | ||
if (uniqueRelationKeys.indexOf(itemKey) !== -1) { | ||
console.warn(`Duplicate relation model found`, { model, relations }); | ||
} else if (!item.id || !item.type) { | ||
console.error( | ||
@@ -149,2 +150,5 @@ `Can't create data item[${i}] for relationship ${k}, | ||
); | ||
} else { | ||
uniqueRelationKeys.push(itemKey); | ||
relationshipData.push(item); | ||
} | ||
@@ -151,0 +155,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
127625
2004