@@ -161,14 +161,20 @@ export class EnhancedResource<T extends ResourceShape<any>> {
161
161
}
162
162
163
163
/**
164
- * An semi-ordered set of interfaces the resource.
164
+ * A semi-ordered set of interfaces the resource.
165
165
*/
166
166
@Once ( )
167
167
get interfaces ( ) : ReadonlySet < EnhancedResource < any > > {
168
168
return new Set (
169
- getParentTypes ( this . type )
170
- . slice ( 1 ) // not self
171
- . filter ( isResourceClass )
169
+ getParentTypes ( this . type , [ ] )
170
+ . filter (
171
+ ( cls ) : cls is ResourceShape < any > =>
172
+ // Is declared as interface. i.e. avoids DataObject.
173
+ GqlClassType . get ( cls ) === 'interface' &&
174
+ // Avoid intersected classes.
175
+ // getParentTypes will give us the intersect-ees directly.
176
+ ! cls . name . startsWith ( 'Intersection' ) ,
177
+ )
172
178
. map ( EnhancedResource . of ) ,
173
179
) ;
174
180
}
@@ -246,8 +252,9 @@ export class EnhancedResource<T extends ResourceShape<any>> {
246
252
const type : ResourceShape < any > | undefined = list
247
253
? rawType [ 0 ] !
248
254
: rawType ;
249
- const resource : EnhancedResource < any > | undefined =
250
- type && isResourceClass ( type ) ? EnhancedResource . of ( type ) : undefined ;
255
+ const resource : EnhancedResource < any > | undefined = type ?. prototype
256
+ ? EnhancedResource . of ( type )
257
+ : undefined ;
251
258
const rel : EnhancedRelation < T > = { name, list, type, resource } ;
252
259
return [ name , rel ] ;
253
260
} ) ,
@@ -330,11 +337,6 @@ export interface EnhancedRelation<TResourceStatic extends ResourceShape<any>> {
330
337
readonly resource ?: EnhancedResource < any > ;
331
338
}
332
339
333
- export const isResourceClass = < T > (
334
- cls : AbstractClassType < T > ,
335
- ) : cls is ResourceShape < T > =>
336
- 'Props' in cls && Array . isArray ( cls . Props ) && cls . Props . length > 0 ;
337
-
338
340
export type DBType < TResourceStatic extends ResourceShape < any > > =
339
341
ResourceShape < any > extends TResourceStatic
340
342
? typeof e . Resource // short-circuit non-specific types
0 commit comments