66 TJsonaNormalizedIncludeNamesTree ,
77 TJsonaUniqueIncluded ,
88 IModelPropertiesMapper ,
9- IModelsSerializer
9+ IModelsSerializer ,
10+ TJsonaRelationshipDataItem ,
1011} from '../JsonaTypes' ;
1112
1213import { createIncludeNamesTree } from '../utils' ;
@@ -27,7 +28,7 @@ export class ModelsSerializer implements IModelsSerializer {
2728 this . propertiesMapper = propertiesMapper ;
2829 }
2930
30- setStuff ( stuff ) {
31+ setStuff ( stuff : TJsonaModel | TJsonaModel [ ] ) {
3132 this . stuff = stuff ;
3233 }
3334
@@ -61,13 +62,13 @@ export class ModelsSerializer implements IModelsSerializer {
6162
6263 for ( let i = 0 ; i < collectionLength ; i ++ ) {
6364 data . push (
64- this . buildDataByModel ( stuff [ i ] )
65+ this . buildDataByModel ( stuff [ i ] )
6566 ) ;
6667
6768 this . buildIncludedByModel (
68- stuff [ i ] ,
69- this . includeNamesTree ,
70- uniqueIncluded
69+ stuff [ i ] ,
70+ this . includeNamesTree ,
71+ uniqueIncluded
7172 ) ;
7273 }
7374
@@ -77,9 +78,9 @@ export class ModelsSerializer implements IModelsSerializer {
7778 body [ 'data' ] = this . buildDataByModel ( stuff ) ;
7879
7980 this . buildIncludedByModel (
80- stuff ,
81- this . includeNamesTree ,
82- uniqueIncluded
81+ stuff ,
82+ this . includeNamesTree ,
83+ uniqueIncluded
8384 ) ;
8485 } else if ( stuff === null ) {
8586 body [ 'data' ] = null ;
@@ -115,7 +116,7 @@ export class ModelsSerializer implements IModelsSerializer {
115116 return data ;
116117 }
117118
118- buildResourceObjectPart ( relation : TJsonaModel ) {
119+ buildResourceObjectPart ( relation : TJsonaModel ) : TJsonaRelationshipDataItem {
119120 const id = this . propertiesMapper . getId ( relation ) ;
120121 const type = this . propertiesMapper . getType ( relation ) ;
121122
@@ -147,9 +148,9 @@ export class ModelsSerializer implements IModelsSerializer {
147148 relationshipData . push ( relationshipDataItem ) ;
148149 } else {
149150 console . error (
150- `Can't create data item for relationship ${ k } ,
151+ `Can't create data item for relationship ${ k } ,
151152 it doesn't have 'id' or 'type', it was skipped` ,
152- relationItem
153+ relationItem
153154 ) ;
154155 }
155156 }
@@ -166,8 +167,8 @@ export class ModelsSerializer implements IModelsSerializer {
166167 } ;
167168 } else {
168169 console . error (
169- `Can't create data for relationship ${ k } , it doesn't have 'type', it was skipped` ,
170- relation
170+ `Can't create data for relationship ${ k } , it doesn't have 'type', it was skipped` ,
171+ relation
171172 ) ;
172173 }
173174 } else {
@@ -181,9 +182,9 @@ export class ModelsSerializer implements IModelsSerializer {
181182 }
182183
183184 buildIncludedByModel (
184- model : TJsonaModel ,
185- includeTree : TJsonaNormalizedIncludeNamesTree ,
186- builtIncluded : TJsonaUniqueIncluded = { }
185+ model : TJsonaModel ,
186+ includeTree : TJsonaNormalizedIncludeNamesTree ,
187+ builtIncluded : TJsonaUniqueIncluded = { }
187188 ) : void {
188189 if ( ! includeTree || ! Object . keys ( includeTree ) . length ) {
189190 return ;
@@ -217,9 +218,9 @@ export class ModelsSerializer implements IModelsSerializer {
217218 }
218219
219220 buildIncludedItem (
220- relationModel : TJsonaModel ,
221- subIncludeTree : TJsonaNormalizedIncludeNamesTree ,
222- builtIncluded : TJsonaUniqueIncluded
221+ relationModel : TJsonaModel ,
222+ subIncludeTree : TJsonaNormalizedIncludeNamesTree ,
223+ builtIncluded : TJsonaUniqueIncluded
223224 ) {
224225 const id = this . propertiesMapper . getId ( relationModel ) ;
225226 const type = this . propertiesMapper . getType ( relationModel ) ;
0 commit comments