Skip to content

Commit 6338668

Browse files
test(misc): remove TODOs and update tests
1 parent 07c67c6 commit 6338668

File tree

13 files changed

+23
-93
lines changed

13 files changed

+23
-93
lines changed

src/decorator/impl/property/property.decorator.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ function createNewProperty(
103103
let propertyType: AttributeModelType = getMetadataType(target, propertyKey)
104104
let customType = isCustomType(propertyType)
105105

106-
// FIXME model metadata is not accessible here, need to know the model data for metadatintorspection
107-
// let modelMetadata: ModelMetadata = Reflect.getMetadata(KEY_MODEL, target.constructor);
108106
const typeByConvention = Util.typeByConvention(propertyKey)
109107
if (typeByConvention) {
110108
customType = true
@@ -147,8 +145,7 @@ function createNewProperty(
147145
}
148146

149147
/**
150-
* FIXME fix typing
151-
* FIXME make sure to implement the context dependant details of Binary (Buffer vs. Uint8Array)
148+
* TODO BINARY make sure to implement the context dependant details of Binary (Buffer vs. Uint8Array)
152149
* @returns {boolean} true if the type cannot be mapped by dynamo document client
153150
*/
154151
function isCustomType(type: AttributeModelTypes): boolean {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ModelConstructor } from '../../model/model-constructor'
55

66
export interface TypeInfo {
77
type: ModelConstructor<any>
8-
// TODO define what custom means
8+
// TODO define what custom means, maybe remove it
99
// true if we use a non native type for dynamo document client
1010
isCustom?: boolean
1111
genericType?: ModelConstructor<any>

src/dynamo-easy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//
55
// MomentJs locales
66
//
7-
// FIXME we should import other locals (should we just import all locales for now?)
7+
// TODO MOMENT we should import other locals (should we just import all locales for now?)
88
import 'moment/locale/de-ch'
99
import 'reflect-metadata'
1010
//

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { ConditionExpressionBuilder } from './condition-expression-builder'
88

99
@Model()
1010
class MyModel {
11-
// FIXME TEST if the db name is used for requests
1211
@Property({ name: 'myId' })
1312
@PartitionKey()
1413
id: string
@@ -260,7 +259,7 @@ describe('expressions', () => {
260259
)
261260
expect(condition.statement).toBe('#myCollection IN (:myCollection)')
262261
expect(condition.attributeNames).toEqual({ '#myCollection': 'myCollection' })
263-
// TODO review not sure if the attribute should be L(ist) or S(et) or if both are supported, they both executed successfuly against dynamodb when testing but with wrong result
262+
// TODO review not sure if the attribute should be L(ist) or S(et) or if both are supported, they both executed successfuly against dynamodb when testing but with unexpected result
264263
// expect(condition.attributeValues).toEqual({
265264
// ':myCollection': { L: [{ S: 'myCollection' }, { S: 'myOtherValue' }] },
266265
// })

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { ConditionOperator } from './type/condition-operator.type'
1414
import { Expression } from './type/expression.type'
1515

1616
/**
17-
* TODO complete doc
1817
* see http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ConditionExpressions.html
1918
*/
2019
export class ConditionExpressionBuilder {
@@ -38,6 +37,7 @@ export class ConditionExpressionBuilder {
3837
): Expression {
3938
// TODO investigate is there a use case for undefined desired to be a value
4039
// get rid of undefined values
40+
// TODO should this not be a deep filter?
4141
values = values.filter(value => value !== undefined)
4242

4343
// check if provided values are valid for given operator

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ export class RequestExpressionBuilder {
104104
return RequestExpressionBuilder.addSortKeyCondition(keyName, request, metadata).equals(keyValue)
105105
}
106106

107-
// FIXME attributePath could also be a simple string for nested paths
108107
static updateDefinitionFunction(attributePath: string): UpdateExpressionDefinitionChain
109108
static updateDefinitionFunction<T>(attributePath: keyof T): UpdateExpressionDefinitionChain
110109

@@ -147,7 +146,7 @@ export class RequestExpressionBuilder {
147146
* for all the values included in operators
148147
*
149148
* @param {(operator: ConditionOperator) => any} impl The function which is called with the operator and returns a function which expects the value
150-
* for the condition. when executed the implementation defines what todo with the condition, just return it for example or add the condition to the request
149+
* for the condition. when executed the implementation defines what to do with the condition, just return it for example or add the condition to the request
151150
* parameters as another example
152151
*/
153152
private static createUpdateFunctions<T>(impl: (operation: UpdateActionDef) => any): T {
@@ -166,7 +165,7 @@ export class RequestExpressionBuilder {
166165
* for all the values included in operators
167166
*
168167
* @param {(operator: ConditionOperator) => any} impl The function which is called with the operator and returns a function which expects the value
169-
* for the condition. when executed the implementation defines what todo with the condition, just return it for example or add the condition to the request
168+
* for the condition. when executed the implementation defines what to do with the condition, just return it for example or add the condition to the request
170169
* parameters as another example
171170
*/
172171
private static createConditionFunctions<T>(

src/dynamo/request/put/put.request.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export class PutRequest<T> extends BaseRequest<T, any> {
2323
*/
2424
ifNotExists(predicate?: boolean): PutRequest<T> {
2525
// FIXME should we check for sort key too?
26-
// FIXME add test for predicate
2726
if (predicate === undefined || (predicate !== undefined && predicate === true)) {
2827
this.whereAttribute(this.metaData.getPartitionKey()).null()
2928
}

src/dynamo/request/query/query.request.ts

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -77,32 +77,6 @@ export class QueryRequest<T> extends Request<T, QueryRequest<T>, QueryInput, Que
7777
return this
7878
}
7979

80-
/**
81-
* multiple conditions will be combined using the AND operator by default
82-
* @param {Expression[]} conditions
83-
* @returns {QueryRequest<T>}
84-
*
85-
* TODO remove after investigation
86-
*/
87-
// implementation with overload won't work perfectly with ide support, so we add two different methods
88-
// property(keyName: keyof T): RequestConditionFunction<QueryRequest<T>>
89-
// property(...conditionDefFns: ConditionExpressionDefinitionFunction[]): QueryRequest<T>
90-
//
91-
// // (keyof T)[] | ConditionExpressionDefinitionFunction[]
92-
// property(...args: any[]): RequestConditionFunction<QueryRequest<T>> | QueryRequest<T> {
93-
// if (args.length === 1 && typeof args[0] === 'string') {
94-
//
95-
// } else {
96-
// const conditions: Expression[] = args.map((conditionDefFn: ConditionExpressionDefinitionFunction) => {
97-
// return conditionDefFn(undefined, this.metaData)
98-
// })
99-
//
100-
// const condition = and(...conditions)
101-
// ParamUtil.addFilterExpression(condition, this.params)
102-
// return this
103-
// }
104-
// }
105-
10680
ascending(): QueryRequest<T> {
10781
this.params.ScanIndexForward = true
10882
return this
@@ -130,12 +104,9 @@ export class QueryRequest<T> extends Request<T, QueryRequest<T>, QueryInput, Que
130104
}
131105

132106
exec(): Observable<T[]> {
133-
return (
134-
this.dynamoRx
135-
.query(this.params)
136-
// TODO check if Items is always defined
137-
.map(response => response.Items!.map(item => Mapper.fromDb(item, this.modelClazz)))
138-
)
107+
return this.dynamoRx
108+
.query(this.params)
109+
.map(response => response.Items!.map(item => Mapper.fromDb(item, this.modelClazz)))
139110
}
140111

141112
execSingle(): Observable<T | null> {

src/dynamo/request/update/update.request.ts

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { BaseRequest } from '../base.request'
2222

2323
export type Bla = { [key in UpdateActionKeyword]: Expression[] }
2424

25-
// TODO add if no operations are defined, don't execute
2625
export class UpdateRequest<T> extends BaseRequest<T, any> {
2726
constructor(
2827
dynamoRx: DynamoRx,
@@ -74,33 +73,6 @@ export class UpdateRequest<T> extends BaseRequest<T, any> {
7473
return this
7574
}
7675

77-
/*
78-
* update()
79-
* //////////// SET ACTION ////////////
80-
* - add one or more attributes to an item
81-
* .set('attrPath', value)
82-
* - increment / decrement number value (incrementBy(), decrementBy())
83-
* .set('attr', value) SET Attr = Attr +- :value
84-
* - add a new list / map
85-
* .set('attrPath', collectionValue)
86-
* - add elements to a list
87-
* .set('listAttrPath', itemValue)
88-
* - add nested map attributes
89-
* .set('', )
90-
* /////////// /////////////
91-
*
92-
* //
93-
* .
94-
* //
95-
* .
96-
* //
97-
* .
98-
*
99-
*/
100-
101-
/**
102-
*
103-
*/
10476
operations(...updateDefFns: UpdateExpressionDefinitionFunction[]): UpdateRequest<T> {
10577
if (updateDefFns && updateDefFns.length) {
10678
const sortedByActionKeyWord: Bla = updateDefFns
@@ -119,11 +91,6 @@ export class UpdateRequest<T> extends BaseRequest<T, any> {
11991
<Bla>{}
12092
)
12193

122-
/*
123-
* {
124-
* SET: [updateExpression, updateExpression]
125-
* }
126-
*/
12794
const actionStatements: string[] = []
12895
let attributeValues: AttributeMap = {}
12996
let attributeNames: { [key: string]: string } = {}
@@ -177,7 +144,6 @@ export class UpdateRequest<T> extends BaseRequest<T, any> {
177144
}
178145

179146
exec(): Observable<void> {
180-
// TODO maybe we should map the returned Attributes to the given model type, needs some more investigation
181147
return this.dynamoRx.updateItem(this.params).map(response => {
182148
return
183149
})

src/mapper/for-type/collection.mapper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class CollectionMapper implements MapperForType<any[] | Set<any>> {
9595
propertyValue = Array.from(propertyValue)
9696
}
9797

98-
// empty value is not allowed for Set and List (TODO check if true for lists)
98+
// empty value is not allowed for S(et) (supported for L(ist))
9999
if (propertyValue.length === 0) {
100100
return null
101101
} else {

0 commit comments

Comments
 (0)