module import * as DynamoDB from 'aws-sdk/clients/dynamodb' ; import { MapperForType } from '../../mapper/for-type/base.mapper' ; import { Attribute } from '../../mapper/type/attribute.type' ; import { ModelConstructor } from '../../model/model-constructor' ; export interface TypeInfo { type : ModelConstructor < any > ; genericType ? : ModelConstructor < any > ; } export interface Key { type : DynamoDB . KeyType ; } export interface PropertyMetadata < T , R extends Attribute = Attribute > { key ? : Key ; name : keyof T ; nameDb : string ; typeInfo ? : TypeInfo ; isSortedCollection ? : boolean ; mapper ? : ( ) => MapperForType < any , R > ; mapperForSingleItem ? : ( ) => MapperForType < any , any > ; keyForGSI ? : Record < string , DynamoDB . KeyType > ; sortKeyForLSI ? : string [ ] ; transient ? : boolean ; defaultValueProvider ? : ( ) => any ; } hidden export function hasGenericType ( propertyMetadata ? ) { return ! ! ( propertyMetadata && propertyMetadata . typeInfo && propertyMetadata . typeInfo . genericType ) ; } hidden export function hasType ( propertyMetadata ? ) { return ! ! ( propertyMetadata && propertyMetadata . typeInfo && propertyMetadata . typeInfo . type ) ; } hidden export function alterCollectionPropertyMetadataForSingleItem < T > ( propertyMeta ? ) { if ( ! propertyMeta ) { return ; } if ( propertyMeta . mapper && propertyMeta . mapperForSingleItem ) { return { ... propertyMeta , mapper : propertyMeta . mapperForSingleItem } ; } if ( propertyMeta . typeInfo && ( propertyMeta . typeInfo . type === Set || propertyMeta . typeInfo . type === Array ) ) { if ( hasGenericType ( propertyMeta ) ) { return < PropertyMetadata < T > > { ... propertyMeta , typeInfo : { type : propertyMeta . typeInfo . genericType } } ; } else { return ; } } return { ... propertyMeta } ; }