@@ -4,7 +4,7 @@ import { RegisteredAttribute } from "./interfaces/RegisteredAttribute";
44import { RegisteredProperty } from "./interfaces/RegisteredProperty" ;
55import { Model } from "./Model" ;
66import { $registeredAttributes , $registeredModels , $registeredRelationships } from "./data" ;
7- import { debug } from "./utils" ;
7+ import { debug , DEBUG } from "./utils" ;
88import { RegisteredModel } from "./interfaces/RegisteredModel" ;
99
1010export class Parser {
@@ -100,7 +100,7 @@ export class Parser {
100100 {
101101 get : function < T extends object > ( target : T , prop : keyof T ) {
102102 if ( prop === "$_partial" ) {
103- return target [ prop ] ;
103+ return true ;
104104 }
105105 if ( prop in target ) {
106106 return target [ prop ] ;
@@ -109,7 +109,7 @@ export class Parser {
109109 debug ( 'error' , `Trying to call property "${ propString } " to a model that is not included. Add "${ loadedElement . type } " to included models.` , {
110110 model : instance ,
111111 property : propString ,
112- type : ' ACCESSING_NOT_INCLUDED_MODEL'
112+ type : DEBUG . ACCESSING_NOT_INCLUDED_MODEL
113113 } ) ;
114114 return target [ prop ] ;
115115 } ,
@@ -126,7 +126,10 @@ export class Parser {
126126 ) ;
127127 } else {
128128 ( 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+ } ) ;
130133 }
131134 }
132135
@@ -137,7 +140,10 @@ export class Parser {
137140 if ( "default" in parser ) {
138141 ( instance as any ) [ parser . key ] = parser . default ;
139142 } 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+ } ) ;
141147 }
142148 }
143149 }
@@ -153,7 +159,10 @@ export class Parser {
153159 ) ;
154160 } else {
155161 ( 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+ } ) ;
157166 }
158167 }
159168
@@ -164,7 +173,10 @@ export class Parser {
164173 if ( "default" in parser ) {
165174 ( instance as any ) [ parser . key ] = parser . default ;
166175 } 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+ } ) ;
168180 }
169181 }
170182 }
@@ -177,7 +189,11 @@ export class Parser {
177189 ) ;
178190 if ( ! found ) {
179191 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+ }
181197 ) ;
182198 }
183199
0 commit comments