diff --git a/.lintstagedrc.yml b/.lintstagedrc.yml index 0d3aec350..4d47e871a 100644 --- a/.lintstagedrc.yml +++ b/.lintstagedrc.yml @@ -5,7 +5,7 @@ linters: - git add "(src/**/*.spec.ts|test/**/*.ts)": - prettier --write --config ./.prettierrc.yml - # FIXME tslint will not work because of the following error + # TODO LOW tslint will not work because of the following error # ✖ tslint --project ./tsconfig.jest.json -t codeFrame --fix found some errors. Please fix them and try committing again. #'/Users/michaelwittwer/dev/shiftcode/dynamo-easy/test/models/complex.model.ts' is not included in project. # - tslint --project ./tsconfig.jest.json -t codeFrame --fix diff --git a/src/decorator/decorators.spec.ts b/src/decorator/decorators.spec.ts index 7b422c635..0a5f90e08 100644 --- a/src/decorator/decorators.spec.ts +++ b/src/decorator/decorators.spec.ts @@ -13,13 +13,11 @@ import { ModelWithABunchOfIndexes, ModelWithCustomMapperModel, ModelWithEnum, - ModelWithEnumDeclared, ModelWithGSI, NestedObject, SimpleModel, } from '../../test/models' import { Form } from '../../test/models/real-world' -import { EnumType } from '../mapper' import { GSIPartitionKey, GSISortKey, LSISortKey, PartitionKey, Property, SortedSet, SortKey, Transient } from './impl' import { Model } from './impl/model/model.decorator' import { Metadata, metadataForClass, metadataForModel, ModelMetadata } from './index' @@ -336,20 +334,6 @@ describe('Decorators should add correct metadata', () => { }) }) - describe('enum', () => { - let metadata: Metadata - - beforeEach(() => { - metadata = metadataForClass(ModelWithEnumDeclared) - }) - - it('should add enum type to property', () => { - const enumPropertyMetadata = metadata.forProperty('type')! - expect(enumPropertyMetadata.typeInfo).toBeDefined() - expect(enumPropertyMetadata.typeInfo).toEqual({ type: EnumType, isCustom: true }) - }) - }) - describe('with inheritance', () => { it('should override the table name', () => { @Model({ tableName: 'super-table-name' }) diff --git a/src/decorator/impl/enum/enum.decorator.ts b/src/decorator/impl/enum/enum.decorator.ts deleted file mode 100644 index 377cb39d6..000000000 --- a/src/decorator/impl/enum/enum.decorator.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { EnumType } from '../../../mapper/type/enum.type' -import { initOrUpdateProperty } from '../property/init-or-update-property.function' - -// FIXME remove unused -export function Enum(enumType?: T): PropertyDecorator { - return (target: any, propertyKey: string | symbol) => { - if (typeof propertyKey === 'string') { - initOrUpdateProperty({ typeInfo: { type: EnumType, isCustom: true } }, target, propertyKey) - } - } -} diff --git a/src/decorator/impl/index.ts b/src/decorator/impl/index.ts index 171b49c82..1ac9dec5c 100644 --- a/src/decorator/impl/index.ts +++ b/src/decorator/impl/index.ts @@ -4,8 +4,6 @@ export * from './collection/typed-set.decorator' export * from './collection/typed-array.decorator' // date export * from './date/date.decorator' -// enum -export * from './enum/enum.decorator' // index export * from './index/secondary-index' export * from './index/gsi-partition-key.decorator' diff --git a/src/decorator/metadata/property-metadata.model.ts b/src/decorator/metadata/property-metadata.model.ts index aaf154b5c..a1640d601 100644 --- a/src/decorator/metadata/property-metadata.model.ts +++ b/src/decorator/metadata/property-metadata.model.ts @@ -50,11 +50,6 @@ export interface PropertyMetadata { transient?: boolean } -// todo: fixme -// export function hasSortKey(propertyMetadata: PropertyMetadata): propertyMetadata is PropertyMetadata & {} { -// return propertyMetadata.getSortKey() !== null -// } - export function hasGenericType( propertyMetadata?: PropertyMetadata, ): propertyMetadata is PropertyMetadata & { typeInfo: { genericType: ModelConstructor } } { diff --git a/src/dynamo/expression/condition-expression-builder.ts b/src/dynamo/expression/condition-expression-builder.ts index c41174624..ad39b2c38 100644 --- a/src/dynamo/expression/condition-expression-builder.ts +++ b/src/dynamo/expression/condition-expression-builder.ts @@ -81,8 +81,7 @@ export function buildFilterExpression( existingValueNames: string[] | undefined, metadata: Metadata | undefined, ): Expression { - // TODO LOW:INVESTIGATE is there a use case for undefined desired to be a value - // metadata rid of undefined values + // metadata get rid of undefined values values = deepFilter(values, value => value !== undefined) // check if provided values are valid for given operator @@ -229,7 +228,7 @@ function buildDefaultConditionExpression( let attribute: Attribute | null switch (operator) { case 'contains': - // TODO think about validation + // TODO LOW:VALIDATION think about concept // validateValueForContains(values[0], propertyMetadata) attribute = toDbOne(values[0], propertyMetadata) break @@ -301,14 +300,14 @@ function validateValues(operator: ConditionOperator, values?: any[]) { } } -// TODO should we support other types than String, Number, Binary (can we search a boolean set for example with boolean as string?) +// TODO LOW:VALIDATION should we support other types than String, Number, Binary (can we search a boolean set for example with boolean as string?) // private static validateValueForContains(value: any, propertyMetadata?: PropertyMetadata): { S: string } { // let finalValue: { S: string } // if (propertyMetadata && propertyMetadata.typeInfo) { // switch (propertyMetadata.typeInfo.type) { // case Array: // case Set: -// // FIXME REVIEW the validation logic +// // TODO LOW:VALIDATION REVIEW the validation logic // // const genericType = propertyMetadata.typeInfo.genericType // // if ((!genericType && (typeof value === 'number' || typeof value === 'string' || typeof value === '')) || ( // // genericType && diff --git a/src/dynamo/expression/request-expression-builder.ts b/src/dynamo/expression/request-expression-builder.ts index 7d8ec9916..1357a1c09 100644 --- a/src/dynamo/expression/request-expression-builder.ts +++ b/src/dynamo/expression/request-expression-builder.ts @@ -12,7 +12,7 @@ import { ConditionOperator } from './type/condition-operator.type' import { ExpressionType } from './type/expression-type.type' import { Expression } from './type/expression.type' import { RequestConditionFunction } from './type/request-condition-function' -import { RequestSortKeyConditionFunction } from './type/sort-key-condition-function' +import { SortKeyConditionFunction } from './type/sort-key-condition-function' import { UpdateActionDef } from './type/update-action-def' import { UPDATE_ACTION_DEFS } from './type/update-action-defs.const' import { @@ -44,19 +44,19 @@ export function addCondition( export function addSortKeyCondition( keyName: keyof any, request: R, -): RequestSortKeyConditionFunction +): SortKeyConditionFunction export function addSortKeyCondition( keyName: keyof T, request: R, metadata: Metadata, -): RequestSortKeyConditionFunction +): SortKeyConditionFunction export function addSortKeyCondition( keyName: keyof T, request: R, metadata?: Metadata, -): RequestSortKeyConditionFunction { +): SortKeyConditionFunction { const f = (operator: ConditionOperator) => { return (...values: any[]): R => { return doAddCondition('KeyConditionExpression', keyName, request, metadata, operator, ...values) diff --git a/src/dynamo/expression/type/index.ts b/src/dynamo/expression/type/index.ts index 384a626c4..1eeb5c382 100644 --- a/src/dynamo/expression/type/index.ts +++ b/src/dynamo/expression/type/index.ts @@ -10,7 +10,6 @@ export * from './expression-type.type' export * from './function-operator.type' export * from './request-condition-function' export * from './sort-key-condition-function' -export * from './sort-key-condition-function.type' export * from './update-action.type' export * from './update-action-def' export * from './update-action-defs.const' diff --git a/src/dynamo/expression/type/sort-key-condition-function.ts b/src/dynamo/expression/type/sort-key-condition-function.ts index 9250d1be4..2260b2667 100644 --- a/src/dynamo/expression/type/sort-key-condition-function.ts +++ b/src/dynamo/expression/type/sort-key-condition-function.ts @@ -11,11 +11,7 @@ import { ConditionalParamsHost } from '../../operation-params.type' * begins_with ( sortKeyName, :sortkeyval ) - true if the sort key value begins with a particular operand. * (You cannot use this function with a sort key that is of formType Number.) Note that the function name begins_with is case-sensitive. */ - -export interface RequestSortKeyConditionFunction { - // TODO LOW:TYPINGS narrow typing when possible -> https://github.com/Microsoft/TypeScript/issues/13573 - // [key in OperatorAlias]: (...value: any[]) => R; - [key: string]: (...value: any[]) => R +export interface SortKeyConditionFunction { equals: (value: any) => R eq: (value: any) => R lt: (value: any) => R diff --git a/src/dynamo/expression/type/sort-key-condition-function.type.ts b/src/dynamo/expression/type/sort-key-condition-function.type.ts deleted file mode 100644 index 6cace30cb..000000000 --- a/src/dynamo/expression/type/sort-key-condition-function.type.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Expression } from './expression.type' - -export interface SortKeyConditionFunction { - // TODO LOW:TYPINGS narrow typing when possible -> https://github.com/Microsoft/TypeScript/issues/13573 - // [key in OperatorAlias]: (...value: any[]) => R; - [key: string]: (...value: any[]) => Expression - equals: (value: any) => Expression - eq: (value: any) => Expression - lt: (value: any) => Expression - lte: (value: any) => Expression - gt: (value: any) => Expression - gte: (value: any) => Expression - between: (value1: any, value2: any) => Expression - beginsWith: (value: any) => Expression -} diff --git a/src/dynamo/expression/type/update-expression-definition-chain.ts b/src/dynamo/expression/type/update-expression-definition-chain.ts index 2e437ea3c..67b30faf4 100644 --- a/src/dynamo/expression/type/update-expression-definition-chain.ts +++ b/src/dynamo/expression/type/update-expression-definition-chain.ts @@ -5,7 +5,7 @@ import { UpdateExpressionDefinitionFunction } from './update-expression-definiti */ export interface UpdateExpressionDefinitionChainTyped { /* ---------------------------------------------------------------- - SET operation TODO add support for ifNotExists + SET operation TODO add support for ifNotExists (#16) ---------------------------------------------------------------- */ incrementBy: (value: number) => UpdateExpressionDefinitionFunction decrementBy: (value: number) => UpdateExpressionDefinitionFunction @@ -67,7 +67,7 @@ export interface UpdateExpressionDefinitionChainTyped { */ export interface UpdateExpressionDefinitionChain { /* ---------------------------------------------------------------- - SET operation TODO add support for ifNotExists + SET operation TODO add support for ifNotExists (#16) ---------------------------------------------------------------- */ incrementBy: (value: number) => UpdateExpressionDefinitionFunction decrementBy: (value: number) => UpdateExpressionDefinitionFunction diff --git a/src/dynamo/expression/update-expression-builder.ts b/src/dynamo/expression/update-expression-builder.ts index 7ae90a92f..9fe4fdee0 100644 --- a/src/dynamo/expression/update-expression-builder.ts +++ b/src/dynamo/expression/update-expression-builder.ts @@ -25,14 +25,13 @@ export function buildUpdateExpression( existingValueNames: string[] | undefined, metadata: Metadata | undefined, ): UpdateExpression { - // TODO LOW:INVESTIGATE is there a use case for undefined desired to be a value - // metadata rid of undefined values + // metadata get rid of undefined values values = deepFilter(values, value => value !== undefined) - // TODO check if provided values are valid for given operation + // TODO LOW:VALIDATION check if provided values are valid for given operation // validateValues(operation, values) - // load property metadat if model metadata was provided + // load property metadata if model metadata was provided let propertyMetadata: PropertyMetadata | undefined if (metadata) { propertyMetadata = metadata.forProperty(attributePath) @@ -107,9 +106,9 @@ function buildDefaultExpression( statement = values.map(pos => `${namePlaceholder}[${pos}]`).join(', ') break case 'add': - // TODO add validation to make sure expressionAttributeValue to be N(umber) or S(et) + // TODO LOW:VALIDATION add validation to make sure expressionAttributeValue to be N(umber) or S(et) statement = `${namePlaceholder} ${valuePlaceholder}` - // TODO won't work for numbers, is always gonna be mapped to a collection type + // TODO LOW:VALIDATION won't work for numbers, is always gonna be mapped to a collection type if ((values.length === 1 && Array.isArray(values[0])) || isSet(values[0])) { // dealing with arr | set as single argument } else { @@ -118,7 +117,7 @@ function buildDefaultExpression( } break case 'removeFromSet': - // TODO add validation to make sure expressionAttributeValue to be S(et) + // TODO LOW:VALIDATION add validation to make sure expressionAttributeValue to be S(et) statement = `${namePlaceholder} ${valuePlaceholder}` if ((values.length === 1 && Array.isArray(values[0])) || isSet(values[0])) { // dealing with arr | set as single argument diff --git a/src/dynamo/request/batchgetsingletable/batch-get-single-table.request.ts b/src/dynamo/request/batchgetsingletable/batch-get-single-table.request.ts index f7c0d423a..0abbbeea4 100644 --- a/src/dynamo/request/batchgetsingletable/batch-get-single-table.request.ts +++ b/src/dynamo/request/batchgetsingletable/batch-get-single-table.request.ts @@ -15,7 +15,6 @@ import { BatchGetSingleTableResponse } from './batch-get-single-table.response' const MAX_REQUEST_ITEM_COUNT = 100 const DEFAULT_TIME_SLOT = 1000 -// TODO add support for indexes export class BatchGetSingleTableRequest { readonly dynamoRx: DynamoRx readonly params: BatchGetItemInput diff --git a/src/dynamo/request/query/query.request.ts b/src/dynamo/request/query/query.request.ts index 8e96b653a..edc65c6c3 100644 --- a/src/dynamo/request/query/query.request.ts +++ b/src/dynamo/request/query/query.request.ts @@ -6,7 +6,7 @@ import { Attributes, fromDb } from '../../../mapper' import { ModelConstructor } from '../../../model' import { DynamoRx } from '../../dynamo-rx' import { addSortKeyCondition } from '../../expression/request-expression-builder' -import { RequestSortKeyConditionFunction } from '../../expression/type' +import { SortKeyConditionFunction } from '../../expression/type' import { Request } from '../request.model' import { QueryResponse } from './query.response' @@ -41,7 +41,7 @@ export class QueryRequest extends Request, QueryInput, Que * used to define some condition for the sort key, use the secondary index to query based on a custom index * @returns {RequestConditionFunction} */ - whereSortKey(): RequestSortKeyConditionFunction> { + whereSortKey(): SortKeyConditionFunction> { let sortKey: keyof T | null if (this.params.IndexName) { const index = this.metadata.getIndex(this.params.IndexName) diff --git a/src/dynamo/request/request.model.ts b/src/dynamo/request/request.model.ts index 2eac24efb..bbebf4a39 100644 --- a/src/dynamo/request/request.model.ts +++ b/src/dynamo/request/request.model.ts @@ -74,7 +74,7 @@ export abstract class Requestthis } - // TODO TYPING how can we improve the typing to define the accepted value for condition function (see + // TODO LOW:TYPING how can we improve the typing to define the accepted value for condition function (see // update2.function) whereAttribute(attributePath: keyof T): RequestConditionFunction { return addCondition('FilterExpression', attributePath, this, this.metadata) diff --git a/src/dynamo/request/scan/scan.request.spec.ts b/src/dynamo/request/scan/scan.request.spec.ts index f24a5a691..a0a4fcd8b 100644 --- a/src/dynamo/request/scan/scan.request.spec.ts +++ b/src/dynamo/request/scan/scan.request.spec.ts @@ -83,10 +83,9 @@ describe('scan request', () => { it('execSingle', async () => { const res = await scanRequest.execSingle().toPromise() - // todo: uncomment when todo in scanRequest::execSingle was done - // expect(scanSpy).toHaveBeenCalled() - // expect(scanSpy.calls.mostRecent().args[0]).toBeDefined() - // expect(scanSpy.calls.mostRecent().args[0].Limit).toBe(1) + expect(scanSpy).toHaveBeenCalled() + expect(scanSpy.calls.mostRecent().args[0]).toBeDefined() + expect(scanSpy.calls.mostRecent().args[0].Limit).toBe(1) expect(res).toEqual(jsItem) }) diff --git a/src/dynamo/request/scan/scan.request.ts b/src/dynamo/request/scan/scan.request.ts index 8407e78c7..eb17e1569 100644 --- a/src/dynamo/request/scan/scan.request.ts +++ b/src/dynamo/request/scan/scan.request.ts @@ -48,7 +48,7 @@ export class ScanRequest extends Request, ScanInput, ScanRe } this.logger.debug('single request', params) - return this.dynamoRx.scan(this.params).pipe( + return this.dynamoRx.scan(params).pipe( tap(response => this.logger.debug('response', response)), map(this.mapFromDb), map(r => r.Items && r.Items.length ? r.Items[0] : null), diff --git a/src/mapper/index.ts b/src/mapper/index.ts index ae15dd8ce..a0d7d436a 100644 --- a/src/mapper/index.ts +++ b/src/mapper/index.ts @@ -2,7 +2,6 @@ export * from './type/attribute.type' export * from './type/attribute-value-type.type' export * from './type/attribute-type.type' export * from './mapper' -export * from './type/enum.type' export * from './type/null.type' export * from './type/undefined.type' export * from './type/binary.type' diff --git a/src/mapper/mapper.spec.ts b/src/mapper/mapper.spec.ts index 320362b61..e6f38a4cb 100644 --- a/src/mapper/mapper.spec.ts +++ b/src/mapper/mapper.spec.ts @@ -24,6 +24,7 @@ import { OrganizationEvent, Product, ProductNested, + StringType, Type, } from '../../test/models' import { IdMapper } from '../../test/models/model-with-custom-mapper.model' @@ -45,7 +46,6 @@ import { StringAttribute, StringSetAttribute, } from './type/attribute.type' -import { EnumType } from './type/enum.type' describe('Mapper', () => { describe('should map single values', () => { @@ -83,13 +83,20 @@ describe('Mapper', () => { expect(attrValue.NULL).toBe(true) }) - it('enum (no enum decorator)', () => { + it('enum (number)', () => { const attrValue = toDbOne(Type.FirstType)! expect(attrValue).toBeDefined() expect(keyOf(attrValue)).toBe('N') expect(attrValue.N).toBe('0') }) + it('enum (string)', () => { + const attrValue = toDbOne(StringType.FirstType)! + expect(attrValue).toBeDefined() + expect(keyOf(attrValue)).toBe('S') + expect(attrValue.S).toBe('first') + }) + it('enum (propertyMetadata -> no enum decorator)', () => { const attrValue: Attribute = toDbOne(Type.FirstType, { typeInfo: { type: Object, isCustom: true }, @@ -99,15 +106,6 @@ describe('Mapper', () => { expect(attrValue.M).toEqual({}) }) - it('enum (with decorator)', () => { - const attrValue = toDbOne(Type.FirstType, { - typeInfo: { type: EnumType, isCustom: true }, - })! - expect(attrValue).toBeDefined() - expect(keyOf(attrValue)).toBe('N') - expect(attrValue.N).toBe('0') - }) - it('array -> SS (homogen, no duplicates)', () => { const attrValue = toDbOne(['foo', 'bar'])! expect(attrValue).toBeDefined() diff --git a/src/mapper/mapper.ts b/src/mapper/mapper.ts index ae6fc9192..6cd2a66e8 100644 --- a/src/mapper/mapper.ts +++ b/src/mapper/mapper.ts @@ -1,4 +1,4 @@ -import {v4 as uuidv4} from 'uuid' +import { v4 as uuidv4 } from 'uuid' import { Metadata } from '../decorator/metadata/metadata' import { metadataForClass, metadataForProperty } from '../decorator/metadata/metadata-helper' import { Key, PropertyMetadata } from '../decorator/metadata/property-metadata.model' @@ -6,7 +6,6 @@ import { ModelConstructor } from '../model' import { MapperForType } from './for-type/base.mapper' import { BooleanMapper } from './for-type/boolean.mapper' import { CollectionMapper } from './for-type/collection.mapper' -import { EnumMapper } from './for-type/enum.mapper' import { NullMapper } from './for-type/null.mapper' import { NumberMapper } from './for-type/number.mapper' import { ObjectMapper } from './for-type/object.mapper' @@ -14,7 +13,6 @@ import { StringMapper } from './for-type/string.mapper' import { AttributeValueType } from './type/attribute-value-type.type' import { Attribute, Attributes } from './type/attribute.type' import { Binary } from './type/binary.type' -import { EnumType } from './type/enum.type' import { NullType } from './type/null.type' import { UndefinedType } from './type/undefined.type' import { typeOf, typeOfFromDb } from './util' @@ -48,7 +46,6 @@ export function toDb(item: T, modelConstructor?: ModelConstructor): Attrib let attributeValue: Attribute | undefined | null - // TODO concept maybe make this configurable how to map undefined & null values if (propertyValue === undefined || propertyValue === null) { // noop ignore because we can't map it } else { @@ -159,8 +156,7 @@ export function createToKeyFn(modelConstructor: ModelConstructor): (item: throw new Error(`there is no value for property ${propMeta.name.toString()} but is ${propMeta.key.type} key`) } - // fixme: typings - ;(key)[propMeta.name] = toDbOne(propertyValue, propMeta) + key[propMeta.name] = toDbOne(propertyValue, propMeta) return key }, >{}, @@ -257,9 +253,6 @@ export function forType(type: AttributeValueType): MapperForType case Boolean: mapper = BooleanMapper break - case EnumType: - mapper = EnumMapper - break case Map: // Maps support complex types as keys, we only support String & Number as Keys, otherwise a .toString() method should be implemented, // so we now how to save a key @@ -278,7 +271,6 @@ export function forType(type: AttributeValueType): MapperForType mapper = NullMapper break case Binary: - // TODO LOW:BINARY add binary mapper throw new Error('no mapper for binary type implemented yet') case UndefinedType: mapper = ObjectMapper diff --git a/src/mapper/type/enum.type.ts b/src/mapper/type/enum.type.ts deleted file mode 100644 index 89b612062..000000000 --- a/src/mapper/type/enum.type.ts +++ /dev/null @@ -1,2 +0,0 @@ -// tslint:disable:no-unnecessary-class -export class EnumType {} diff --git a/test/data/organization-dynamodb.data.ts b/test/data/organization-dynamodb.data.ts index 7fc2788e9..1d9480acd 100644 --- a/test/data/organization-dynamodb.data.ts +++ b/test/data/organization-dynamodb.data.ts @@ -6,7 +6,6 @@ export const organization1LastUpdated = new Date('2017-07-25') export const organization1Employee1CreatedAt = new Date('2015-02-15') export const organization1Employee2CreatedAt = new Date('2015-07-03') -// FIXME: transient should not be included in Attributes, make use of Transient Marker Type and build new type export const organizationFromDb: Attributes = { name: { S: 'myOrganization' }, id: { S: 'myId' }, diff --git a/test/models/index.ts b/test/models/index.ts index fa8877e9e..98f8779a2 100644 --- a/test/models/index.ts +++ b/test/models/index.ts @@ -6,10 +6,8 @@ export * from './model-with-custom-mapper.model' export * from './model-with-custom-mapper-for-sort-key.model' export * from './model-with-date.model' export * from './model-with-enum.model' -export * from './model-with-enum-declared.model' export * from './model-with-indexes.model' export * from './model-with-date-as-key.model' -export * from './model-with-typed-enum-declared.model' export * from './model-without-custom-mapper.model' export * from './nested-complex.model' export * from './nested-object.model' diff --git a/test/models/model-with-enum-declared.model.ts b/test/models/model-with-enum-declared.model.ts deleted file mode 100644 index 026ecb503..000000000 --- a/test/models/model-with-enum-declared.model.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Enum, Model, PartitionKey } from '../../src/dynamo-easy' -import { Type } from './types.enum' - -@Model() -export class ModelWithEnumDeclared { - @PartitionKey() - id: string - - @Enum() - type: Type -} diff --git a/test/models/model-with-typed-enum-declared.model.ts b/test/models/model-with-typed-enum-declared.model.ts deleted file mode 100644 index 03ec36f51..000000000 --- a/test/models/model-with-typed-enum-declared.model.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Enum, Model, PartitionKey } from '../../src/dynamo-easy' -import { Type } from './types.enum' - -@Model() -export class ModelWithTypedEnumDeclared { - @PartitionKey() - id: string - - @Enum(Type) - type: Type -} diff --git a/test/models/organization.model.ts b/test/models/organization.model.ts index fd1eb0784..22a9a5a22 100644 --- a/test/models/organization.model.ts +++ b/test/models/organization.model.ts @@ -46,9 +46,6 @@ export class OrganizationEvent { } } -// TODO LOW maybe we can map the transient fields to be optional in Attributes -// export type Transient = T - @Model({ tableName: 'Organization' }) export class Organization { // String diff --git a/test/models/real-world/index.ts b/test/models/real-world/index.ts index ad795d919..aa458d36e 100644 --- a/test/models/real-world/index.ts +++ b/test/models/real-world/index.ts @@ -3,7 +3,6 @@ export * from './extended-form.model' export * from './form.model' export * from './form-id.model' export * from './form-type.enum' -export * from './number-enum.mapper' export * from './order.model' export * from './order-id.model' export * from './product-base-form.model' diff --git a/test/models/real-world/number-enum.mapper.ts b/test/models/real-world/number-enum.mapper.ts deleted file mode 100644 index 4145abf89..000000000 --- a/test/models/real-world/number-enum.mapper.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { MapperForType, NumberSetAttribute } from '../../../src/dynamo-easy' - -// FIXME investigate: if the extra enum mapper makes sence, don't think so -export const NumberEnumMapper: MapperForType = { - fromDb(attributeValue: NumberSetAttribute): any[] { - return attributeValue.NS.map(numberEnumValue => parseInt(numberEnumValue, 10)) - }, - - toDb(propertyValues: any[]): NumberSetAttribute { - return { NS: propertyValues.map(propertyValue => propertyValue.toString()) } - }, -} diff --git a/test/models/real-world/order.model.ts b/test/models/real-world/order.model.ts index 5c14ce9b3..bf871312c 100644 --- a/test/models/real-world/order.model.ts +++ b/test/models/real-world/order.model.ts @@ -1,6 +1,14 @@ // tslint:disable:max-classes-per-file -import { CustomMapper, DateProperty, GSIPartitionKey, GSISortKey, Model, PartitionKey } from '../../../src/dynamo-easy' +import { + CustomMapper, + DateProperty, + GSIPartitionKey, + GSISortKey, + Model, + PartitionKey, + Transient, +} from '../../../src/dynamo-easy' import { FormId, FormIdsMapper } from './form-id.model' import { FormType } from './form-type.enum' import { OrderId, OrderIdMapper } from './order-id.model' @@ -21,8 +29,8 @@ export class BaseOrder { @CustomMapper(FormIdsMapper) formIds: FormId[] - // FIXME DE check if persisted // internal use for UI only, should not be persisted + @Transient() isNew?: boolean }