rest-client-sdk
Advanced tools
Comparing version 2.0.0-rc.11 to 2.0.0-rc.12
{ | ||
"name": "rest-client-sdk", | ||
"version": "2.0.0-rc.11", | ||
"version": "2.0.0-rc.12", | ||
"description": "Rest Client SDK for API", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -38,4 +38,52 @@ const DEFAULT_CONFIG = { | ||
} | ||
isMappingValid() { | ||
return !this._classMetadataList.some(classMetadata => { | ||
// check that the relations exists | ||
const errorList = Object.values(classMetadata.getAttributeList()).map( | ||
attribute => { | ||
const relation = classMetadata.getRelation(attribute.serializedKey); | ||
if (!relation) { | ||
// attribute can not be "invalid" (for now ?) | ||
return false; | ||
} | ||
const relationMetadata = this.getClassMetadataByKey( | ||
relation.targetMetadataKey | ||
); | ||
// no error if there is metadata linked | ||
if (relationMetadata) { | ||
return false; | ||
} | ||
return `"${classMetadata.key}.${ | ||
attribute.serializedKey | ||
}" defined a relation to the metadata named "${ | ||
relation.targetMetadataKey | ||
}" but this metadata is not knowned by the mapping`; | ||
} | ||
); | ||
if (!classMetadata.getIdentifierAttribute()) { | ||
errorList.push( | ||
`"${classMetadata.key}" has no identifier attribute set` | ||
); | ||
} | ||
const nbError = errorList.filter(error => { | ||
if (error) { | ||
// eslint-disable-next-line no-console | ||
console.warn(error); | ||
} | ||
return error; | ||
}); | ||
return nbError.length > 0; | ||
}); | ||
} | ||
} | ||
export default Mapping; |
@@ -34,2 +34,3 @@ import AbstractClient from '../client/AbstractClient'; | ||
this._attributeList = {}; | ||
this._identifierAttribute = null; | ||
@@ -45,3 +46,7 @@ attributeList.forEach(attribute => { | ||
if (!this._identifierAttribute) { | ||
throw new TypeError('attributeList must contain a identifier attribute'); | ||
throw new TypeError( | ||
`"${ | ||
this.key | ||
}" has no identifier attribute set. You must set all your attributes in one time and send an attribute with "isIdentifier=true"` | ||
); | ||
} | ||
@@ -48,0 +53,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1862580
19875