1
1
import { Field , InterfaceType } from '@nestjs/graphql' ;
2
- import { cached , FnLike } from '@seedcompany/common' ;
2
+ import { cached , FnLike , mapValues } from '@seedcompany/common' ;
3
3
import { LazyGetter as Once } from 'lazy-get-decorator' ;
4
4
import { DateTime } from 'luxon' ;
5
5
import { keys as keysOf } from 'ts-transformer-keys' ;
@@ -15,12 +15,11 @@ import { DateTimeField } from './luxon.graphql';
15
15
import { getParentTypes } from './parent-types' ;
16
16
import { MaybeSecured , SecuredProps } from './secured-property' ;
17
17
import { AbstractClassType } from './types' ;
18
- import { has , mapFromList } from './util' ;
19
18
20
19
const hasTypename = ( value : unknown ) : value is { __typename : string } =>
21
20
value != null &&
22
21
typeof value === 'object' &&
23
- has ( '__typename' , value ) &&
22
+ '__typename' in value &&
24
23
typeof value . __typename === 'string' ;
25
24
26
25
export const resolveByTypename =
@@ -245,11 +244,12 @@ export class EnhancedResource<T extends ResourceShape<any>> {
245
244
return this . dbLabels [ 0 ] ;
246
245
}
247
246
@Once ( )
248
- get dbPropLabels ( ) {
249
- return mapFromList ( this . props , ( prop ) => {
250
- const labels = getDbPropertyLabels ( this . type , prop ) ;
251
- return [ prop , labels ] ;
252
- } ) ;
247
+ get dbPropLabels ( ) : {
248
+ readonly [ K in keyof T [ 'prototype' ] & string ] ?: readonly string [ ] ;
249
+ } {
250
+ return mapValues . fromList ( this . props , ( prop ) =>
251
+ getDbPropertyLabels ( this . type , prop ) ,
252
+ ) . asRecord ;
253
253
}
254
254
}
255
255
@@ -265,7 +265,7 @@ export interface EnhancedRelation<TResourceStatic extends ResourceShape<any>> {
265
265
export const isResourceClass = < T > (
266
266
cls : AbstractClassType < T > ,
267
267
) : cls is ResourceShape < T > =>
268
- has ( 'Props' , cls ) && Array . isArray ( cls . Props ) && cls . Props . length > 0 ;
268
+ 'Props' in cls && Array . isArray ( cls . Props ) && cls . Props . length > 0 ;
269
269
270
270
export type MaybeUnsecuredInstance < TResourceStatic extends ResourceShape < any > > =
271
271
MaybeSecured < InstanceType < TResourceStatic > > ;
0 commit comments