Skip to content

Commit b384b14

Browse files
Merge pull request #135 from shiftcode/#133-use-ts-record-type
#133 use ts record type
2 parents 02d6e1b + 0b5b027 commit b384b14

File tree

13 files changed

+22
-22
lines changed

13 files changed

+22
-22
lines changed

src/decorator/impl/index/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function initOrUpdateIndex(indexType: IndexType, indexData: IndexData, ta
3434
initOrUpdateProperty(propertyMetadata, target, propertyKey)
3535
}
3636

37-
function initOrUpdateGSI(indexes: { [key: string]: KeyType }, indexData: IndexData): Partial<PropertyMetadata<any>> {
37+
function initOrUpdateGSI(indexes: Record<string, KeyType>, indexData: IndexData): Partial<PropertyMetadata<any>> {
3838
if (indexes[indexData.name]) {
3939
// TODO LOW:INVESTIGATE when we throw an error we have a problem where multiple different classes extend one base class, this will be executed by multiple times
4040
// throw new Error(

src/decorator/impl/model/model.decorator.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function Model(opts: ModelData = {}): ClassDecorator {
5757

5858
function testForGSI<T>(
5959
property: PropertyMetadata<T>,
60-
): property is PropertyMetadata<T> & { keyForGSI: { [key: string]: KeyType } } {
60+
): property is PropertyMetadata<T> & { keyForGSI: Record<string, KeyType> } {
6161
return !!(property.keyForGSI && Object.keys(property.keyForGSI).length)
6262
}
6363

@@ -82,7 +82,7 @@ function getGlobalSecondaryIndexes(properties: Array<PropertyMetadata<any>>): Ma
8282
throw new Error(
8383
`there is already a partition key defined for global secondary index ${indexName} (property name: ${
8484
property.nameDb
85-
})`,
85+
})`,
8686
)
8787
}
8888

@@ -93,7 +93,7 @@ function getGlobalSecondaryIndexes(properties: Array<PropertyMetadata<any>>): Ma
9393
throw new Error(
9494
`there is already a sort key defined for global secondary index ${indexName} (property name: ${
9595
property.nameDb
96-
})`,
96+
})`,
9797
)
9898
}
9999

@@ -133,7 +133,7 @@ function getLocalSecondaryIndexes(
133133
throw new Error(
134134
`only one sort key can be defined for the same local secondary index, ${
135135
property.nameDb
136-
} is already defined as sort key for index ${indexName}`,
136+
} is already defined as sort key for index ${indexName}`,
137137
)
138138
}
139139

src/decorator/metadata/property-metadata.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export interface PropertyMetadata<T, R extends Attribute = Attribute> {
4141
mapper?: () => MapperForType<any, R>
4242

4343
// maps the index name to the key type to describe for which GSI this property describes a key attribute
44-
keyForGSI?: { [key: string]: KeyType }
44+
keyForGSI?: Record<string, KeyType>
4545

4646
// holds all the the index names for which this property describes the sort key attribute
4747
sortKeyForLSI?: string[]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
// tslint:disable-next-line:interface-over-type-literal
2-
export type BatchGetResponse = { [tableName: string]: any[] }
2+
export type BatchGetResponse = Record<string /* tableName */ , any[]>

src/dynamo/dynamo-rx.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ export class DynamoRx {
7676
.pipe(switchMap(() => from(this.dynamoDb.query(params).promise())))
7777
}
7878

79-
makeRequest(operation: string, params?: { [key: string]: any }): Observable<any> {
79+
makeRequest(operation: string, params?: Record<string, any>): Observable<any> {
8080
return dynamoEasyConfig.sessionValidityEnsurer()
8181
.pipe(switchMap(() => from(this.dynamoDb.makeRequest(operation, params).promise())),
82-
)
82+
)
8383
}
8484
}

src/dynamo/dynamo-store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class DynamoStore<T> {
8383
return new TransactGetSingleTableRequest(this.dynamoRx, this.modelClazz, keys)
8484
}
8585

86-
makeRequest<Z>(operation: DynamoApiOperations, params?: { [key: string]: any }): Observable<Z> {
86+
makeRequest<Z>(operation: DynamoApiOperations, params?: Record<string, any>): Observable<Z> {
8787
this.logger.debug('request', params)
8888
return this.dynamoRx.makeRequest(operation, params).pipe(tap(response => this.logger.debug('response', response)))
8989
}

src/dynamo/expression/condition-expression-builder.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type BuildFilterFn = (
1717
attributePath: string,
1818
namePlaceholder: string,
1919
valuePlaceholder: string,
20-
attributeNames: { [key: string]: string },
20+
attributeNames: Record<string, string>,
2121
values: any[],
2222
existingValueNames: string[] | undefined,
2323
propertyMetadata: PropertyMetadata<any> | undefined,
@@ -56,7 +56,7 @@ export function deepFilter(obj: any, filterFn: (value: any) => boolean): any {
5656

5757
return returnArr.length ? new Set(returnArr) : null
5858
} else if (isPlainObject(obj)) {
59-
const returnObj: { [key: string]: any } = {}
59+
const returnObj: Record<string, any> = {}
6060

6161
forEach(obj, (value: any, key: string) => {
6262
const item = deepFilter(value, filterFn)
@@ -156,7 +156,7 @@ function buildInConditionExpression(
156156
attributePath: string,
157157
namePlaceholder: string,
158158
valuePlaceholder: string,
159-
attributeNames: { [key: string]: string },
159+
attributeNames: Record<string, string>,
160160
values: any[],
161161
existingValueNames: string[] | undefined,
162162
propertyMetadata: PropertyMetadata<any> | undefined,
@@ -189,7 +189,7 @@ function buildBetweenConditionExpression(
189189
attributePath: string,
190190
namePlaceholder: string,
191191
valuePlaceholder: string,
192-
attributeNames: { [key: string]: string },
192+
attributeNames: Record<string, string>,
193193
values: string[],
194194
existingValueNames: string[] | undefined,
195195
propertyMetadata: PropertyMetadata<any> | undefined,
@@ -222,7 +222,7 @@ function buildDefaultConditionExpression(
222222
attributePath: string,
223223
namePlaceholder: string,
224224
valuePlaceholder: string,
225-
attributeNames: { [key: string]: string },
225+
attributeNames: Record<string, string>,
226226
values: any[],
227227
existingValueNames: string[] | undefined,
228228
propertyMetadata: PropertyMetadata<any> | undefined,

src/dynamo/expression/functions/attribute-names.function.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ const NESTED_ATTR_PATH_REGEX = /^.+((\[(\d+)])|(\.)).*$/
66
export function resolveAttributeNames(
77
attributePath: string,
88
propertyMetadata?: PropertyMetadata<any>,
9-
): { placeholder: string; attributeNames: { [key: string]: string } } {
9+
): { placeholder: string; attributeNames: Record<string, string> } {
1010
let placeholder: string
1111
// tslint:disable-next-line:no-shadowed-variable
12-
const attributeNames: { [key: string]: string } = {}
12+
const attributeNames: Record<string, string> = {}
1313
if (NESTED_ATTR_PATH_REGEX.test(attributePath)) {
1414
// nested attribute with document path (map or list)
1515
let re

src/dynamo/expression/prepare-and-add-update-expressions.function.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function prepareAndAddUpdateExpressions(
3030

3131
const actionStatements: string[] = []
3232
let attributeValues: Attributes = {}
33-
let attributeNames: { [key: string]: string } = {}
33+
let attributeNames: Record<string, string> = {}
3434

3535
forEach(sortedByActionKeyWord, (value, key) => {
3636
const statements: string[] = []
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Attributes } from '../../../mapper/type/attribute.type'
22

33
export interface Expression {
4-
attributeNames: { [key: string]: string }
4+
attributeNames: Record<string, string>
55
attributeValues: Attributes<any>
66
statement: string
77
}

0 commit comments

Comments
 (0)