Skip to content

Commit c2f589f

Browse files
style(prettier): prettify all files with new style changes
1 parent eec6ece commit c2f589f

File tree

50 files changed

+188
-195
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+188
-195
lines changed

src/decorator/impl/index/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export interface IndexData {
2020
*/
2121
export function initOrUpdateIndex(indexType: IndexType, indexData: IndexData, target: any, propertyKey: string): void {
2222
const properties: Array<PropertyMetadata<any>> = Reflect.getMetadata(KEY_PROPERTY, target.constructor) || []
23-
const existingProperty = properties.find(property => property.name === propertyKey)
23+
const existingProperty = properties.find((property) => property.name === propertyKey)
2424

2525
let propertyMetadata: Partial<PropertyMetadata<any>>
2626
switch (indexType) {

src/decorator/impl/key/partition-key.decorator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ export function PartitionKey(): PropertyDecorator {
1414
// check for existing properties marked as partition key
1515
const properties: Array<PropertyMetadata<any>> = Reflect.getMetadata(KEY_PROPERTY, target.constructor) || []
1616
if (properties && properties.length) {
17-
const existingPartitionKeys = properties.filter(property => property.key && property.key.type === 'HASH')
17+
const existingPartitionKeys = properties.filter((property) => property.key && property.key.type === 'HASH')
1818
if (existingPartitionKeys.length) {
19-
if (properties.find(property => property.name === propertyKey)) {
19+
if (properties.find((property) => property.name === propertyKey)) {
2020
// just ignore this and go on, somehow the partition key gets defined two times
2121
logger.warn(
2222
`this is the second execution to define the partitionKey for property ${propertyKey}`,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function Model(opts: ModelData = {}): ClassDecorator {
2828
: Reflect.getMetadata(KEY_PROPERTY, constructor)) || []
2929

3030
// get partition key
31-
const partitionKeys = properties.filter(property => property.key && property.key.type === 'HASH')
31+
const partitionKeys = properties.filter((property) => property.key && property.key.type === 'HASH')
3232

3333
const partitionKeyName: string | null = partitionKeys.length ? partitionKeys[0].nameDb : null
3434

@@ -40,7 +40,7 @@ export function Model(opts: ModelData = {}): ClassDecorator {
4040
const indexes: Map<string, SecondaryIndex<any>> = new Map([...globalSecondaryIndexes, ...localSecondaryIndexes])
4141

4242
const transientProperties = properties.length
43-
? properties.filter(property => property.transient === true).map(property => property.name)
43+
? properties.filter((property) => property.transient === true).map((property) => property.name)
4444
: []
4545

4646
const metaData: ModelMetadata<any> = {
@@ -80,7 +80,7 @@ function testForLSI<T>(property: PropertyMetadata<T>): property is PropertyMetad
8080
function getGlobalSecondaryIndexes(properties: Array<PropertyMetadata<any>>): Map<string, SecondaryIndex<any>> {
8181
return properties.filter(testForGSI).reduce((map, property): Map<string, SecondaryIndex<any>> => {
8282
let gsi: SecondaryIndex<any>
83-
Object.keys(property.keyForGSI).forEach(indexName => {
83+
Object.keys(property.keyForGSI).forEach((indexName) => {
8484
if (map.has(indexName)) {
8585
gsi = map.get(indexName)
8686
} else {
@@ -119,7 +119,7 @@ function getLocalSecondaryIndexes(
119119
return properties.filter(testForLSI).reduce((map, property): Map<string, SecondaryIndex<any>> => {
120120
let lsi: SecondaryIndex<any>
121121

122-
property.sortKeyForLSI.forEach(indexName => {
122+
property.sortKeyForLSI.forEach((indexName) => {
123123
if (map.has(indexName)) {
124124
throw new Error(modelErrors.lsiMultipleSk(indexName, property.nameDb))
125125
}

src/decorator/impl/property/init-or-update-property.function.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ export function initOrUpdateProperty(
2020

2121
// Update the attribute array
2222
let properties: Array<PropertyMetadata<any>> = Reflect.getMetadata(KEY_PROPERTY, target.constructor) || []
23-
const existingProperty = properties.find(p => p.name === propertyKey)
23+
const existingProperty = properties.find((p) => p.name === propertyKey)
2424
if (existingProperty) {
2525
// create new property with merged options
2626
property = { ...existingProperty, ...propertyMetadata }
2727
// remove existing from array
28-
properties = properties.filter(p => p !== existingProperty)
28+
properties = properties.filter((p) => p !== existingProperty)
2929
} else {
3030
// add new options
3131
property = createNewProperty(propertyMetadata, target, propertyKey)

src/decorator/metadata/metadata.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class Metadata<T> {
3232
modelOpts: ModelMetadata<M>,
3333
propertyName: keyof M,
3434
): PropertyMetadata<M> | undefined {
35-
return modelOpts.properties.find(property => property.name === propertyName || property.nameDb === propertyName)
35+
return modelOpts.properties.find((property) => property.name === propertyName || property.nameDb === propertyName)
3636
}
3737

3838
constructor(modelConstructor: ModelConstructor<T>) {
@@ -73,7 +73,7 @@ export class Metadata<T> {
7373
* @returns {Array<PropertyMetadata<any>>} Returns all the properties property the @PartitionKeyUUID decorator is present, returns an empty array by default
7474
*/
7575
getKeysWithUUID(): Array<PropertyMetadata<any>> {
76-
return filterBy(this.modelOptions, p => !!(p.key && p.key.uuid), [])
76+
return filterBy(this.modelOptions, (p) => !!(p.key && p.key.uuid), [])
7777
}
7878

7979
/**
@@ -95,7 +95,7 @@ export class Metadata<T> {
9595
throw new Error(`there is no index defined for name ${indexName}`)
9696
}
9797
} else {
98-
const property = filterByFirst(this.modelOptions, p => !!(p.key && p.key.type === 'HASH'))
98+
const property = filterByFirst(this.modelOptions, (p) => !!(p.key && p.key.type === 'HASH'))
9999

100100
if (property) {
101101
return property.name
@@ -123,7 +123,7 @@ export class Metadata<T> {
123123
throw new Error(`there is no index defined for name ${indexName}`)
124124
}
125125
} else {
126-
const property = filterByFirst(this.modelOptions, p => !!(p.key && p.key.type === 'RANGE'))
126+
const property = filterByFirst(this.modelOptions, (p) => !!(p.key && p.key.type === 'RANGE'))
127127
return property ? property.name : null
128128
}
129129
}

src/dynamo/batchget/batch-get-utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ export function batchGetItemsFetchAll(
2020
backoffTimer: IterableIterator<number>,
2121
throttleTimeSlot: number,
2222
): Promise<DynamoDB.BatchGetItemOutput> {
23-
return dynamoDBWrapper.batchGetItems(params).then(response => {
23+
return dynamoDBWrapper.batchGetItems(params).then((response) => {
2424
if (hasUnprocessedKeys(response)) {
2525
// in case of unprocessedKeys do a follow-up requests
2626
return (
2727
Promise.resolve(response.UnprocessedKeys)
2828
// delay before doing the follow-up request
2929
.then(promiseDelay(backoffTimer.next().value * throttleTimeSlot))
30-
.then(UnprocessedKeys => {
30+
.then((UnprocessedKeys) => {
3131
const nextParams = { ...params, RequestItems: UnprocessedKeys }
3232
// call recursively batchGetItemsFetchAll with the returned UnprocessedItems params
3333
return batchGetItemsFetchAll(dynamoDBWrapper, nextParams, backoffTimer, throttleTimeSlot)
@@ -56,7 +56,7 @@ export function hasUnprocessedKeys(
5656
if (!response.UnprocessedKeys) {
5757
return false
5858
}
59-
return Object.values(response.UnprocessedKeys).some(t => !!t && t.Keys && t.Keys.length > 0)
59+
return Object.values(response.UnprocessedKeys).some((t) => !!t && t.Keys && t.Keys.length > 0)
6060
}
6161

6262
/**
@@ -68,8 +68,8 @@ export function combineBatchGetResponses(response1: DynamoDB.BatchGetItemOutput)
6868
const tableNames: string[] = Object.keys(response1.Responses || {})
6969

7070
Object.keys(response2.Responses || {})
71-
.filter(tn => !tableNames.includes(tn))
72-
.forEach(tn => tableNames.push(tn))
71+
.filter((tn) => !tableNames.includes(tn))
72+
.forEach((tn) => tableNames.push(tn))
7373

7474
const Responses = tableNames.reduce(
7575
(u, tableName) => ({

src/dynamo/batchget/batch-get.request.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export class BatchGetRequest {
112112
): Promise<BatchGetResponse> {
113113
return this.fetch(backoffTimer, throttleTimeSlot)
114114
.then(this.mapResponse)
115-
.then(r => r.Responses)
115+
.then((r) => r.Responses)
116116
}
117117

118118
private fetch(backoffTimer = randomExponentialBackoffTimer, throttleTimeSlot = BATCH_GET_DEFAULT_TIME_SLOT) {
@@ -124,7 +124,7 @@ export class BatchGetRequest {
124124

125125
if (response.Responses && Object.keys(response.Responses).length) {
126126
Responses = Object.entries(response.Responses).reduce((u: BatchGetResponse, [key, val]) => {
127-
u[key] = val.map(attributes => fromDb(<Attributes>attributes, this.tables.get(key)))
127+
u[key] = val.map((attributes) => fromDb(<Attributes>attributes, this.tables.get(key)))
128128
return u
129129
}, {})
130130
}

src/dynamo/batchwrite/batch-write-utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ export function batchWriteItemsWriteAll(
2020
backoffTimer: IterableIterator<number>,
2121
throttleTimeSlot: number,
2222
): Promise<DynamoDB.BatchGetItemOutput> {
23-
return dynamoDBWrapper.batchWriteItem(params).then(response => {
23+
return dynamoDBWrapper.batchWriteItem(params).then((response) => {
2424
if (hasUnprocessedItems(response)) {
2525
// in case of unprocessedItems do a follow-up requests
2626
return (
2727
Promise.resolve(response.UnprocessedItems)
2828
// delay before doing the follow-up request
2929
.then(promiseDelay(backoffTimer.next().value * throttleTimeSlot))
30-
.then(unprocessedKeys => {
30+
.then((unprocessedKeys) => {
3131
const nextParams: DynamoDB.BatchWriteItemInput = { ...params, RequestItems: unprocessedKeys }
3232
// call recursively batchWriteItemsWriteAll with the returned UnprocessedItems params
3333
return batchWriteItemsWriteAll(dynamoDBWrapper, nextParams, backoffTimer, throttleTimeSlot)
@@ -56,5 +56,5 @@ export function hasUnprocessedItems(
5656
if (!response.UnprocessedItems) {
5757
return false
5858
}
59-
return Object.values(response.UnprocessedItems).some(t => !!t && t.length > 0)
59+
return Object.values(response.UnprocessedItems).some((t) => !!t && t.length > 0)
6060
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('expressions', () => {
4545
new Set(arr),
4646
]
4747

48-
const filteredObj = deepFilter(obj, item => item !== undefined)
48+
const filteredObj = deepFilter(obj, (item) => item !== undefined)
4949
expect(filteredObj).toEqual([{ street: 'street', zip: 1524 }, [{ age: 25 }], new Set([arr[0], arr[1]])])
5050
})
5151

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

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type BuildFilterFn = (
4949
export function deepFilter(obj: any, filterFn: (value: any) => boolean): any {
5050
if (Array.isArray(obj)) {
5151
const returnArr: any[] = []
52-
obj.forEach(i => {
52+
obj.forEach((i) => {
5353
const item = deepFilter(i, filterFn)
5454
if (item !== null) {
5555
returnArr.push(item)
@@ -59,7 +59,7 @@ export function deepFilter(obj: any, filterFn: (value: any) => boolean): any {
5959
return returnArr.length ? returnArr : null
6060
} else if (obj instanceof Set) {
6161
const returnArr: any[] = []
62-
Array.from(obj).forEach(i => {
62+
Array.from(obj).forEach((i) => {
6363
const item = deepFilter(i, filterFn)
6464
if (item !== null) {
6565
returnArr.push(item)
@@ -110,7 +110,7 @@ export function buildFilterExpression(
110110
metadata: Metadata<any> | undefined,
111111
): Expression {
112112
// metadata get rid of undefined values
113-
values = deepFilter(values, value => value !== undefined)
113+
values = deepFilter(values, (value) => value !== undefined)
114114

115115
// check if provided values are valid for given operator
116116
validateForOperator(operator, values)
@@ -179,17 +179,14 @@ function buildInConditionExpression(
179179
propertyMetadata: PropertyMetadata<any> | undefined,
180180
): Expression {
181181
const attributeValues: Attributes<any> = (<any[]>values[0])
182-
.map(value => toDbOne(value, propertyMetadata))
183-
.reduce(
184-
(result, mappedValue: Attribute | null, index: number) => {
185-
if (mappedValue !== null) {
186-
validateAttributeType('IN condition', mappedValue, 'S', 'N', 'B')
187-
result[`${valuePlaceholder}_${index}`] = mappedValue
188-
}
189-
return result
190-
},
191-
<Attributes<any>>{},
192-
)
182+
.map((value) => toDbOne(value, propertyMetadata))
183+
.reduce((result, mappedValue: Attribute | null, index: number) => {
184+
if (mappedValue !== null) {
185+
validateAttributeType('IN condition', mappedValue, 'S', 'N', 'B')
186+
result[`${valuePlaceholder}_${index}`] = mappedValue
187+
}
188+
return result
189+
}, <Attributes<any>>{})
193190

194191
const inStatement = (<any[]>values[0]).map((value: any, index: number) => `${valuePlaceholder}_${index}`).join(', ')
195192

@@ -219,7 +216,7 @@ function buildBetweenConditionExpression(
219216
if (mappedValue1 === null || mappedValue2 === null) {
220217
throw new Error('make sure to provide an actual value for te BETWEEN operator')
221218
}
222-
;[mappedValue1, mappedValue2].forEach(mv => validateAttributeType('between', mv, 'S', 'N', 'B'))
219+
;[mappedValue1, mappedValue2].forEach((mv) => validateAttributeType('between', mv, 'S', 'N', 'B'))
223220

224221
const value2Placeholder = uniqueAttributeValueName(attributePath, [valuePlaceholder].concat(existingValueNames || []))
225222

0 commit comments

Comments
 (0)