diff --git a/src/aws-sdk-v2.types.ts b/src/aws-sdk-v2.types.ts index 544986435..84c2f1df5 100644 --- a/src/aws-sdk-v2.types.ts +++ b/src/aws-sdk-v2.types.ts @@ -13,3 +13,9 @@ export type ExpressionAttributeValueMap = { [key: string]: AttributeValue /* was export type AttributeMap = { [key: string]: AttributeValue } export type Key = { [key: string]: AttributeValue } + +// FIXME somehow the import of KeyType from @aws-sdk/client-dynamodb does not work at runtime +export enum KeyType { + HASH = 'HASH', + RANGE = 'RANGE', +} diff --git a/src/decorator/impl/index/gsi-partition-key.decorator.ts b/src/decorator/impl/index/gsi-partition-key.decorator.ts index 914c70641..e401c199c 100644 --- a/src/decorator/impl/index/gsi-partition-key.decorator.ts +++ b/src/decorator/impl/index/gsi-partition-key.decorator.ts @@ -1,7 +1,7 @@ /** * @module decorators */ -import { KeyType } from '@aws-sdk/client-dynamodb' +import { KeyType } from '../../../aws-sdk-v2.types' import { IndexType } from './index-type.enum' import { initOrUpdateIndex } from './util' diff --git a/src/decorator/impl/index/gsi-sort-key.decorator.ts b/src/decorator/impl/index/gsi-sort-key.decorator.ts index ee21026e3..89e5c2ae7 100644 --- a/src/decorator/impl/index/gsi-sort-key.decorator.ts +++ b/src/decorator/impl/index/gsi-sort-key.decorator.ts @@ -1,7 +1,7 @@ /** * @module decorators */ -import { KeyType } from '@aws-sdk/client-dynamodb' +import { KeyType } from '../../../aws-sdk-v2.types' import { IndexType } from './index-type.enum' import { initOrUpdateIndex } from './util' diff --git a/src/decorator/impl/index/lsi-sort-key.decorator.ts b/src/decorator/impl/index/lsi-sort-key.decorator.ts index ee79c26ef..a0295b006 100644 --- a/src/decorator/impl/index/lsi-sort-key.decorator.ts +++ b/src/decorator/impl/index/lsi-sort-key.decorator.ts @@ -1,7 +1,7 @@ /** * @module decorators */ -import { KeyType } from '@aws-sdk/client-dynamodb' +import { KeyType } from '../../../aws-sdk-v2.types' import { IndexType } from './index-type.enum' import { initOrUpdateIndex } from './util' diff --git a/src/decorator/impl/index/util.ts b/src/decorator/impl/index/util.ts index a1bd6fbfb..b212f57a6 100644 --- a/src/decorator/impl/index/util.ts +++ b/src/decorator/impl/index/util.ts @@ -1,7 +1,7 @@ /** * @module decorators */ -import * as DynamoDB from '@aws-sdk/client-dynamodb' +import { KeyType } from '../../../aws-sdk-v2.types' import { PropertyMetadata } from '../../metadata/property-metadata.model' import { initOrUpdateProperty } from '../property/init-or-update-property.function' import { KEY_PROPERTY } from '../property/key-property.const' @@ -12,7 +12,7 @@ import { IndexType } from './index-type.enum' */ export interface IndexData { name: string - keyType: DynamoDB.KeyType + keyType: KeyType } /** @@ -47,10 +47,7 @@ export function initOrUpdateIndex(indexType: IndexType, indexData: IndexData, ta /** * @hidden */ -function initOrUpdateGSI( - indexes: Record, - indexData: IndexData, -): Partial> { +function initOrUpdateGSI(indexes: Record, indexData: IndexData): Partial> { if (indexes[indexData.name]) { // TODO INVESTIGATE when we throw an error we have a problem where multiple different classes extend one base class, this will be executed multiple times // throw new Error( diff --git a/src/decorator/impl/key/partition-key.decorator.ts b/src/decorator/impl/key/partition-key.decorator.ts index 3391d014f..528830feb 100644 --- a/src/decorator/impl/key/partition-key.decorator.ts +++ b/src/decorator/impl/key/partition-key.decorator.ts @@ -1,7 +1,7 @@ /** * @module decorators */ -import { KeyType } from '@aws-sdk/client-dynamodb' +import { KeyType } from '../../../aws-sdk-v2.types' import { createOptModelLogger } from '../../../logger/logger' import { PropertyMetadata } from '../../metadata/property-metadata.model' import { initOrUpdateProperty } from '../property/init-or-update-property.function' diff --git a/src/decorator/impl/key/sort-key.decorator.ts b/src/decorator/impl/key/sort-key.decorator.ts index ba1a88fdd..2ca6e35f5 100644 --- a/src/decorator/impl/key/sort-key.decorator.ts +++ b/src/decorator/impl/key/sort-key.decorator.ts @@ -1,7 +1,7 @@ /** * @module decorators */ -import { KeyType } from '@aws-sdk/client-dynamodb' +import { KeyType } from '../../../aws-sdk-v2.types' import { initOrUpdateProperty } from '../property/init-or-update-property.function' export function SortKey(): PropertyDecorator { diff --git a/src/decorator/impl/model/model.decorator.ts b/src/decorator/impl/model/model.decorator.ts index 20f25da79..a809cd70c 100644 --- a/src/decorator/impl/model/model.decorator.ts +++ b/src/decorator/impl/model/model.decorator.ts @@ -1,7 +1,7 @@ /** * @module decorators */ -import * as DynamoDB from '@aws-sdk/client-dynamodb' +import { KeyType } from '../../../aws-sdk-v2.types' import { kebabCase } from '../../../helper/kebab-case.function' import { ModelMetadata } from '../../metadata/model-metadata.model' import { PropertyMetadata } from '../../metadata/property-metadata.model' @@ -63,7 +63,7 @@ export function Model(opts: ModelData = {}): ClassDecorator { */ function testForGSI( property: PropertyMetadata, -): property is PropertyMetadata & { keyForGSI: Record } { +): property is PropertyMetadata & { keyForGSI: Record } { return !!(property.keyForGSI && Object.keys(property.keyForGSI).length) } diff --git a/src/decorator/metadata/property-metadata.model.ts b/src/decorator/metadata/property-metadata.model.ts index 105a8af75..ab7e5de6d 100644 --- a/src/decorator/metadata/property-metadata.model.ts +++ b/src/decorator/metadata/property-metadata.model.ts @@ -1,7 +1,7 @@ /** * @module metadata */ -import * as DynamoDB from '@aws-sdk/client-dynamodb' +import { KeyType } from '../../aws-sdk-v2.types' import { MapperForType } from '../../mapper/for-type/base.mapper' import { Attribute } from '../../mapper/type/attribute.type' import { ModelConstructor } from '../../model/model-constructor' @@ -12,7 +12,7 @@ export interface TypeInfo { } export interface Key { - type: DynamoDB.KeyType + type: KeyType } export interface PropertyMetadata { @@ -41,7 +41,7 @@ export interface PropertyMetadata { mapperForSingleItem?: () => MapperForType // maps the index name to the key type to describe for which GSI this property describes a key attribute - keyForGSI?: Record + keyForGSI?: Record // holds all the the index names for which this property describes the sort key attribute sortKeyForLSI?: string[] diff --git a/tools/tslint/test/test.ts.lint b/tools/tslint/test/test.ts.lint index 421dd30d2..0493a4a11 100644 --- a/tools/tslint/test/test.ts.lint +++ b/tools/tslint/test/test.ts.lint @@ -2,4 +2,4 @@ import * as moment from 'moment' import * as DynamoDB from 'aws-sdk' import { Config } from 'aws-sdk' import { Key } from 'aws-sdk/clients/dynamodb' -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [only wildcard import (import * as DynamoDB from 'aws-sdk/clients/dynamodb') is allowed for this module] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [only wildcard import (import * as DynamoDB from '@aws-sdk/client-dynamodb') is allowed for this module]