Skip to content

Commit 9db04d4

Browse files
author
Simon Mumenthaler
authored
Merge pull request #120 from shiftcode/#85-cleanup
#85 cleanup
2 parents fda6045 + e38e555 commit 9db04d4

29 files changed

+46
-150
lines changed

.lintstagedrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ linters:
55
- git add
66
"(src/**/*.spec.ts|test/**/*.ts)":
77
- prettier --write --config ./.prettierrc.yml
8-
# FIXME tslint will not work because of the following error
8+
# TODO LOW tslint will not work because of the following error
99
# ✖ tslint --project ./tsconfig.jest.json -t codeFrame --fix found some errors. Please fix them and try committing again.
1010
#'/Users/michaelwittwer/dev/shiftcode/dynamo-easy/test/models/complex.model.ts' is not included in project.
1111
# - tslint --project ./tsconfig.jest.json -t codeFrame --fix

src/decorator/decorators.spec.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ import {
1313
ModelWithABunchOfIndexes,
1414
ModelWithCustomMapperModel,
1515
ModelWithEnum,
16-
ModelWithEnumDeclared,
1716
ModelWithGSI,
1817
NestedObject,
1918
SimpleModel,
2019
} from '../../test/models'
2120
import { Form } from '../../test/models/real-world'
22-
import { EnumType } from '../mapper'
2321
import { GSIPartitionKey, GSISortKey, LSISortKey, PartitionKey, Property, SortedSet, SortKey, Transient } from './impl'
2422
import { Model } from './impl/model/model.decorator'
2523
import { Metadata, metadataForClass, metadataForModel, ModelMetadata } from './index'
@@ -336,20 +334,6 @@ describe('Decorators should add correct metadata', () => {
336334
})
337335
})
338336

339-
describe('enum', () => {
340-
let metadata: Metadata<ModelWithEnumDeclared>
341-
342-
beforeEach(() => {
343-
metadata = metadataForClass(ModelWithEnumDeclared)
344-
})
345-
346-
it('should add enum type to property', () => {
347-
const enumPropertyMetadata = metadata.forProperty('type')!
348-
expect(enumPropertyMetadata.typeInfo).toBeDefined()
349-
expect(enumPropertyMetadata.typeInfo).toEqual({ type: EnumType, isCustom: true })
350-
})
351-
})
352-
353337
describe('with inheritance', () => {
354338
it('should override the table name', () => {
355339
@Model({ tableName: 'super-table-name' })

src/decorator/impl/enum/enum.decorator.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/decorator/impl/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ export * from './collection/typed-set.decorator'
44
export * from './collection/typed-array.decorator'
55
// date
66
export * from './date/date.decorator'
7-
// enum
8-
export * from './enum/enum.decorator'
97
// index
108
export * from './index/secondary-index'
119
export * from './index/gsi-partition-key.decorator'

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ export interface PropertyMetadata<T, R extends Attribute = Attribute> {
5050
transient?: boolean
5151
}
5252

53-
// todo: fixme
54-
// export function hasSortKey(propertyMetadata: PropertyMetadata<any, any>): propertyMetadata is PropertyMetadata<any, any> & {} {
55-
// return propertyMetadata.getSortKey() !== null
56-
// }
57-
5853
export function hasGenericType(
5954
propertyMetadata?: PropertyMetadata<any, any>,
6055
): propertyMetadata is PropertyMetadata<any, any> & { typeInfo: { genericType: ModelConstructor<any> } } {

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ export function buildFilterExpression(
8181
existingValueNames: string[] | undefined,
8282
metadata: Metadata<any> | undefined,
8383
): Expression {
84-
// TODO LOW:INVESTIGATE is there a use case for undefined desired to be a value
85-
// metadata rid of undefined values
84+
// metadata get rid of undefined values
8685
values = deepFilter(values, value => value !== undefined)
8786

8887
// check if provided values are valid for given operator
@@ -229,7 +228,7 @@ function buildDefaultConditionExpression(
229228
let attribute: Attribute | null
230229
switch (operator) {
231230
case 'contains':
232-
// TODO think about validation
231+
// TODO LOW:VALIDATION think about concept
233232
// validateValueForContains(values[0], propertyMetadata)
234233
attribute = toDbOne(values[0], propertyMetadata)
235234
break
@@ -301,14 +300,14 @@ function validateValues(operator: ConditionOperator, values?: any[]) {
301300
}
302301
}
303302

304-
// TODO should we support other types than String, Number, Binary (can we search a boolean set for example with boolean as string?)
303+
// TODO LOW:VALIDATION should we support other types than String, Number, Binary (can we search a boolean set for example with boolean as string?)
305304
// private static validateValueForContains(value: any, propertyMetadata?: PropertyMetadata<any>): { S: string } {
306305
// let finalValue: { S: string }
307306
// if (propertyMetadata && propertyMetadata.typeInfo) {
308307
// switch (propertyMetadata.typeInfo.type) {
309308
// case Array:
310309
// case Set:
311-
// // FIXME REVIEW the validation logic
310+
// // TODO LOW:VALIDATION REVIEW the validation logic
312311
// // const genericType = propertyMetadata.typeInfo.genericType
313312
// // if ((!genericType && (typeof value === 'number' || typeof value === 'string' || typeof value === '')) || (
314313
// // genericType &&

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { ConditionOperator } from './type/condition-operator.type'
1212
import { ExpressionType } from './type/expression-type.type'
1313
import { Expression } from './type/expression.type'
1414
import { RequestConditionFunction } from './type/request-condition-function'
15-
import { RequestSortKeyConditionFunction } from './type/sort-key-condition-function'
15+
import { SortKeyConditionFunction } from './type/sort-key-condition-function'
1616
import { UpdateActionDef } from './type/update-action-def'
1717
import { UPDATE_ACTION_DEFS } from './type/update-action-defs.const'
1818
import {
@@ -44,19 +44,19 @@ export function addCondition<R extends ConditionalParamsHost>(
4444
export function addSortKeyCondition<R extends ConditionalParamsHost>(
4545
keyName: keyof any,
4646
request: R,
47-
): RequestSortKeyConditionFunction<R>
47+
): SortKeyConditionFunction<R>
4848

4949
export function addSortKeyCondition<T, R extends ConditionalParamsHost>(
5050
keyName: keyof T,
5151
request: R,
5252
metadata: Metadata<T>,
53-
): RequestSortKeyConditionFunction<R>
53+
): SortKeyConditionFunction<R>
5454

5555
export function addSortKeyCondition<T, R extends ConditionalParamsHost>(
5656
keyName: keyof T,
5757
request: R,
5858
metadata?: Metadata<T>,
59-
): RequestSortKeyConditionFunction<R> {
59+
): SortKeyConditionFunction<R> {
6060
const f = (operator: ConditionOperator) => {
6161
return (...values: any[]): R => {
6262
return doAddCondition('KeyConditionExpression', <string>keyName, request, metadata, operator, ...values)

src/dynamo/expression/type/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export * from './expression-type.type'
1010
export * from './function-operator.type'
1111
export * from './request-condition-function'
1212
export * from './sort-key-condition-function'
13-
export * from './sort-key-condition-function.type'
1413
export * from './update-action.type'
1514
export * from './update-action-def'
1615
export * from './update-action-defs.const'

src/dynamo/expression/type/sort-key-condition-function.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ import { ConditionalParamsHost } from '../../operation-params.type'
1111
* begins_with ( sortKeyName, :sortkeyval ) - true if the sort key value begins with a particular operand.
1212
* (You cannot use this function with a sort key that is of formType Number.) Note that the function name begins_with is case-sensitive.
1313
*/
14-
15-
export interface RequestSortKeyConditionFunction<R extends ConditionalParamsHost> {
16-
// TODO LOW:TYPINGS narrow typing when possible -> https://github.com/Microsoft/TypeScript/issues/13573
17-
// [key in OperatorAlias]: (...value: any[]) => R;
18-
[key: string]: (...value: any[]) => R
14+
export interface SortKeyConditionFunction<R extends ConditionalParamsHost> {
1915
equals: (value: any) => R
2016
eq: (value: any) => R
2117
lt: (value: any) => R

src/dynamo/expression/type/sort-key-condition-function.type.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)