@@ -4,7 +4,7 @@ import { RegisteredAttribute } from "./interfaces/RegisteredAttribute";
4
4
import { RegisteredProperty } from "./interfaces/RegisteredProperty" ;
5
5
import { Model } from "./Model" ;
6
6
import { $registeredAttributes , $registeredModels , $registeredRelationships } from "./data" ;
7
- import { debug } from "./utils" ;
7
+ import { debug , DEBUG } from "./utils" ;
8
8
import { RegisteredModel } from "./interfaces/RegisteredModel" ;
9
9
10
10
export class Parser {
@@ -100,7 +100,7 @@ export class Parser {
100
100
{
101
101
get : function < T extends object > ( target : T , prop : keyof T ) {
102
102
if ( prop === "$_partial" ) {
103
- return target [ prop ] ;
103
+ return true ;
104
104
}
105
105
if ( prop in target ) {
106
106
return target [ prop ] ;
@@ -109,7 +109,7 @@ export class Parser {
109
109
debug ( 'error' , `Trying to call property "${ propString } " to a model that is not included. Add "${ loadedElement . type } " to included models.` , {
110
110
model : instance ,
111
111
property : propString ,
112
- type : ' ACCESSING_NOT_INCLUDED_MODEL'
112
+ type : DEBUG . ACCESSING_NOT_INCLUDED_MODEL
113
113
} ) ;
114
114
return target [ prop ] ;
115
115
} ,
@@ -126,7 +126,10 @@ export class Parser {
126
126
) ;
127
127
} else {
128
128
( instance as any ) [ key ] = this . parse ( relation , included ) ;
129
- debug ( 'warn' , `Undeclared relationship "${ key } " in "${ loadedElement . type } "` ) ;
129
+ debug ( 'warn' , `Undeclared relationship "${ key } " in "${ loadedElement . type } "` , {
130
+ relationship : key ,
131
+ type : DEBUG . UNDECLARED_RELATIONSHOP
132
+ } ) ;
130
133
}
131
134
}
132
135
@@ -137,7 +140,10 @@ export class Parser {
137
140
if ( "default" in parser ) {
138
141
( instance as any ) [ parser . key ] = parser . default ;
139
142
} else {
140
- debug ( 'warn' , `Missing relationships "${ key } " in "${ loadedElement . type } "` ) ;
143
+ debug ( 'warn' , `Missing relationships "${ key } " in "${ loadedElement . type } "` , {
144
+ relationship : key ,
145
+ type : DEBUG . MISSING_RELATIONSHIP ,
146
+ } ) ;
141
147
}
142
148
}
143
149
}
@@ -153,7 +159,10 @@ export class Parser {
153
159
) ;
154
160
} else {
155
161
( instance as any ) [ key ] = loadedElement . attributes [ key ] ;
156
- debug ( 'warn' , `Undeclared key "${ key } " in "${ loadedElement . type } "` ) ;
162
+ debug ( 'warn' , `Undeclared @Attr() "${ key } " in model "${ loadedElement . type } "` , {
163
+ attribute : key ,
164
+ type : DEBUG . UNDECLARED_ATTRIBUTE
165
+ } ) ;
157
166
}
158
167
}
159
168
@@ -164,7 +173,10 @@ export class Parser {
164
173
if ( "default" in parser ) {
165
174
( instance as any ) [ parser . key ] = parser . default ;
166
175
} else {
167
- debug ( 'warn' , `Missing attribute "${ key } " in "${ loadedElement . type } "` ) ;
176
+ debug ( 'warn' , `Missing attribute "${ key } " in "${ loadedElement . type } "` , {
177
+ attribute : key ,
178
+ type : DEBUG . MISSING_ATTRIBUTE ,
179
+ } ) ;
168
180
}
169
181
}
170
182
}
@@ -177,7 +189,11 @@ export class Parser {
177
189
) ;
178
190
if ( ! found ) {
179
191
debug (
180
- 'info' , `Relationship with type ${ element . type } with id ${ element . id } not present in included`
192
+ 'info' , `Relationship with type ${ element . type } with id ${ element . id } not present in included. Skipping...` ,
193
+ {
194
+ model : element ,
195
+ type : DEBUG . SKIPPED_INCLUDED_RELATIONSHIP
196
+ }
181
197
) ;
182
198
}
183
199
0 commit comments