rest-client-sdk
Advanced tools
Comparing version 2.0.0-rc.13 to 2.0.0-rc.14
@@ -5,2 +5,5 @@ # Changelog | ||
## 2.0.0-rc.14 | ||
Check relations in `isValidMapping` | ||
## 2.0.0-rc.13 | ||
@@ -7,0 +10,0 @@ Fix issue when setting a ManyToOne relatossue when setting a ManyToOne relation to `null`n to `null` |
{ | ||
"name": "rest-client-sdk", | ||
"version": "2.0.0-rc.13", | ||
"version": "2.0.0-rc.14", | ||
"description": "Rest Client SDK for API", | ||
@@ -43,2 +43,3 @@ "main": "dist/index.js", | ||
"lint-staged": "^6.0.0", | ||
"pluralize": "^7.0.0", | ||
"prettier": "^1.9.2", | ||
@@ -51,2 +52,5 @@ "rimraf": "^2.6.2", | ||
}, | ||
"optionalDependencies": { | ||
"pluralize": "^7.0.0" | ||
}, | ||
"repository": { | ||
@@ -53,0 +57,0 @@ "type": "git", |
@@ -55,12 +55,45 @@ const DEFAULT_CONFIG = { | ||
// relation name seems weird | ||
if ( | ||
relation.isManyToOne() && | ||
attribute.attributeName.endsWith('List') | ||
) { | ||
return `"${classMetadata.key}.${ | ||
attribute.serializedKey | ||
} is defined as a MANY_TO_ONE relation, but the attribute name ends with "List".`; | ||
} | ||
if (relation.isOneToMany()) { | ||
const message = `"${classMetadata.key}.${ | ||
attribute.serializedKey | ||
} is defined as a ONE_TO_MANY relation, but the attribute name is nor plural not ends with "List".`; | ||
const endsWithList = attribute.attributeName.endsWith('List'); | ||
try { | ||
// eslint-disable-next-line global-require, import/no-extraneous-dependencies | ||
const pluralize = require('pluralize'); | ||
if ( | ||
!endsWithList && | ||
!pluralize.isPlural(attribute.attributeName) | ||
) { | ||
return message; | ||
} | ||
} catch (e) { | ||
if (!endsWithList) { | ||
return message; | ||
} | ||
} | ||
} | ||
// no error if there is metadata linked | ||
if (relationMetadata) { | ||
return false; | ||
if (!relationMetadata) { | ||
return `"${classMetadata.key}.${ | ||
attribute.serializedKey | ||
}" defined a relation to the metadata named "${ | ||
relation.targetMetadataKey | ||
}" but this metadata is not knowned by the mapping`; | ||
} | ||
return `"${classMetadata.key}.${ | ||
attribute.serializedKey | ||
}" defined a relation to the metadata named "${ | ||
relation.targetMetadataKey | ||
}" but this metadata is not knowned by the mapping`; | ||
return false; | ||
} | ||
@@ -67,0 +100,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
1870227
19954
4
25