Skip to content

Commit 820600a

Browse files
Merge branch 'master' into #91-default-value-provider
2 parents 097b4cc + 7b6c477 commit 820600a

26 files changed

+387
-31
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors)
88

99

10-
A dynamoDB client which provides an easy to use fluent api to execute requests. It supports typescript decorators, to define the necessary metadata for your models. You don't need to care about the mapping of javascript types to their dynamo types any more. We got you covered.
10+
A DynamoDB client which provides an easy to use fluent api to execute requests. It supports TypeScript decorators to define the necessary metadata for your models. You don't need to care about the mapping of JavaScript types to their DynamoDB types any more. We've got you covered.
1111

1212
Built with :heart: by [shiftcode](https://www.shiftcode.ch).
1313

@@ -33,10 +33,10 @@ personStore
3333

3434
```
3535

36-
## Ressources
36+
## Resources
3737
- 🤓 Learn more visiting the [docs](https://shiftcode.gitbook.io/dynamo-easy)
3838
- 📖 Checkout the technical API documentation [api docs](https://shiftcode.github.io/dynamo-easy/)
39-
- 🚀 Check the running sample on [Stackblitz](https://stackblitz.com/edit/dynamo-easy-node-sample)
39+
- 🚀 Check the running sample on [StackBlitz](https://stackblitz.com/edit/dynamo-easy-node-sample)
4040
- [demo git repository](https://github.com/shiftcode/dynamo-easy-demo)
4141

4242
## Credits

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,13 @@
5959
"@commitlint/config-conventional": "^8.1.0",
6060
"@commitlint/prompt-cli": "^8.1.0",
6161
"@types/jest": "^24.0.18",
62-
"@types/lodash": "^4.14.137",
6362
"@types/node": "8.10.40",
6463
"aws-sdk": "^2.401.0",
6564
"colors": "^1.3.3",
6665
"coveralls": "^3.0.6",
6766
"husky": "^3.0.4",
6867
"jest": "^24.9.0",
6968
"lint-staged": "^9.2.3",
70-
"lodash": "^4.17.11",
7169
"lodash.camelcase": "^4.3.0",
7270
"prettier": "^1.18.2",
7371
"reflect-metadata": "^0.1.13",
@@ -85,7 +83,6 @@
8583
},
8684
"peerDependencies": {
8785
"aws-sdk": "^2.401.0",
88-
"lodash": "^4.17.11",
8986
"reflect-metadata": "^0.1.12",
9087
"tslib": "^1.10.0"
9188
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @module decorators
33
*/
44
import * as DynamoDB from 'aws-sdk/clients/dynamodb'
5-
import { kebabCase } from 'lodash'
5+
import { kebabCase } from '../../../helper/kebab-case.function'
66
import { ModelMetadata } from '../../metadata/model-metadata.model'
77
import { PropertyMetadata } from '../../metadata/property-metadata.model'
88
import { SecondaryIndex } from '../index/secondary-index'

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// tslint:disable:max-classes-per-file
2-
import { has } from 'lodash'
32
import { ComplexModel } from '../../../test/models'
43
import { Form, FormId, formIdMapper, FormType } from '../../../test/models/real-world'
54
import { CollectionProperty } from '../../decorator/impl/collection/collection-property.decorator'
@@ -304,9 +303,9 @@ describe('expressions', () => {
304303

305304
expect(condition.attributeValues).toBeDefined()
306305
expect(Object.keys(condition.attributeValues).length).toBe(2)
307-
expect(has(condition.attributeValues, ':counter')).toBeTruthy()
306+
expect(':counter' in condition.attributeValues).toBeTruthy()
308307
expect(condition.attributeValues[':counter']).toEqual({ N: '2' })
309-
expect(has(condition.attributeValues, ':counter_2')).toBeTruthy()
308+
expect(':counter_2' in condition.attributeValues).toBeTruthy()
310309
expect(condition.attributeValues[':counter_2']).toEqual({ N: '5' })
311310
})
312311

@@ -331,9 +330,9 @@ describe('expressions', () => {
331330

332331
expect(condition.attributeValues).toBeDefined()
333332
expect(Object.keys(condition.attributeValues).length).toBe(2)
334-
expect(has(condition.attributeValues, ':creationDate')).toBeTruthy()
333+
expect(':creationDate' in condition.attributeValues).toBeTruthy()
335334
expect(condition.attributeValues[':creationDate']).toEqual({ S: date1.toISOString() })
336-
expect(has(condition.attributeValues, ':creationDate_2')).toBeTruthy()
335+
expect(':creationDate_2' in condition.attributeValues).toBeTruthy()
337336
expect(condition.attributeValues[':creationDate_2']).toEqual({ S: date2.toISOString() })
338337
})
339338
})

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/**
22
* @module expression
33
*/
4-
import { curry, isPlainObject } from 'lodash'
54
import { Metadata } from '../../decorator/metadata/metadata'
65
import {
76
alterCollectionPropertyMetadataForSingleItem,
87
PropertyMetadata,
98
} from '../../decorator/metadata/property-metadata.model'
9+
import { curry } from '../../helper/curry.function'
10+
import { isPlainObject } from '../../helper/is-plain-object.function'
1011
import { toDbOne } from '../../mapper/mapper'
1112
import { Attribute, Attributes } from '../../mapper/type/attribute.type'
1213
import { typeOf } from '../../mapper/util'

src/dynamo/expression/param-util.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
* @module expression
33
*/
44
import * as DynamoDB from 'aws-sdk/clients/dynamodb'
5-
import { isEmpty, isString } from 'lodash'
5+
import { isEmpty } from '../../helper/is-empty.function'
6+
import { isString } from '../../helper/is-string.function'
67
import { ConditionalParams } from '../operation-params.type'
78
import { resolveAttributeValueNameConflicts } from './functions/resolve-attribute-value-name-conflicts.function'
89
import { Expression } from './type/expression.type'
910
import { UpdateActionKeyword } from './type/update-action-keyword.type'
11+
1012
/**
1113
* @hidden
1214
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
* @module expression
33
*/
4-
import { curry } from 'lodash'
54
import { Metadata } from '../../decorator/metadata/metadata'
5+
import { curry } from '../../helper/curry.function'
66
import { ConditionalParamsHost, UpdateParamsHost } from '../operation-params.type'
77
import { StandardRequest } from '../request/standard.request'
88
import { buildFilterExpression } from './condition-expression-builder'

src/helper/curry.function.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { curry } from './curry.function'
2+
3+
function a(x: number, y: string, z: boolean | null) {
4+
return [x, y, z]
5+
}
6+
7+
describe('curry', () => {
8+
it('should work (w/o arity)', () => {
9+
expect(curry(a)(2)('ok')(true)).toEqual([2, 'ok', true])
10+
expect(curry(a)(4, 'NOK')(false)).toEqual([4, 'NOK', false])
11+
expect(curry(a)(6, 'FOO', null)).toEqual([6, 'FOO', null])
12+
})
13+
14+
it('should work (w/ arity)', () => {
15+
expect(typeof curry(a, 4)(6, 'FOO', null)).toEqual('function')
16+
})
17+
})

src/helper/curry.function.ts

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
// copied from just-curry-it
2+
3+
interface CurriedFunction1<T1, R> {
4+
(): CurriedFunction1<T1, R>
5+
6+
(t1: T1): R
7+
}
8+
9+
interface CurriedFunction2<T1, T2, R> {
10+
(): CurriedFunction2<T1, T2, R>
11+
12+
(t1: T1): CurriedFunction1<T2, R>
13+
14+
(t1: T1, t2: T2): R
15+
}
16+
17+
interface CurriedFunction3<T1, T2, T3, R> {
18+
(): CurriedFunction3<T1, T2, T3, R>
19+
20+
(t1: T1): CurriedFunction2<T2, T3, R>
21+
22+
(t1: T1, t2: T2): CurriedFunction1<T3, R>
23+
24+
(t1: T1, t2: T2, t3: T3): R
25+
}
26+
27+
interface CurriedFunction4<T1, T2, T3, T4, R> {
28+
(): CurriedFunction4<T1, T2, T3, T4, R>
29+
30+
(t1: T1): CurriedFunction3<T2, T3, T4, R>
31+
32+
(t1: T1, t2: T2): CurriedFunction2<T3, T4, R>
33+
34+
(t1: T1, t2: T2, t3: T3): CurriedFunction1<T4, R>
35+
36+
(t1: T1, t2: T2, t3: T3, t4: T4): R
37+
}
38+
39+
interface CurriedFunction5<T1, T2, T3, T4, T5, R> {
40+
(): CurriedFunction5<T1, T2, T3, T4, T5, R>
41+
42+
(t1: T1): CurriedFunction4<T2, T3, T4, T5, R>
43+
44+
(t1: T1, t2: T2): CurriedFunction3<T3, T4, T5, R>
45+
46+
(t1: T1, t2: T2, t3: T3): CurriedFunction2<T4, T5, R>
47+
48+
(t1: T1, t2: T2, t3: T3, t4: T4): CurriedFunction1<T5, R>
49+
50+
(t1: T1, t2: T2, t3: T3, t4: T4, t5: T5): R
51+
}
52+
53+
interface CurriedFunction6<T1, T2, T3, T4, T5, T6, R> {
54+
(): CurriedFunction6<T1, T2, T3, T4, T5, T6, R>
55+
56+
(t1: T1): CurriedFunction5<T2, T3, T4, T5, T6, R>
57+
58+
(t1: T1, t2: T2): CurriedFunction4<T3, T4, T5, T6, R>
59+
60+
(t1: T1, t2: T2, t3: T3): CurriedFunction3<T4, T5, T6, R>
61+
62+
(t1: T1, t2: T2, t3: T3, t4: T4): CurriedFunction2<T5, T6, R>
63+
64+
(t1: T1, t2: T2, t3: T3, t4: T4, t5: T5): CurriedFunction1<T6, R>
65+
66+
(t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6): R
67+
}
68+
69+
interface CurriedFunction7<T1, T2, T3, T4, T5, T6, T7, R> {
70+
(): CurriedFunction7<T1, T2, T3, T4, T5, T6, T7, R>
71+
72+
(t1: T1): CurriedFunction6<T2, T3, T4, T5, T6, T7, R>
73+
74+
(t1: T1, t2: T2): CurriedFunction5<T3, T4, T5, T6, T7, R>
75+
76+
(t1: T1, t2: T2, t3: T3): CurriedFunction4<T4, T5, T6, T7, R>
77+
78+
(t1: T1, t2: T2, t3: T3, t4: T4): CurriedFunction3<T5, T6, T7, R>
79+
80+
(t1: T1, t2: T2, t3: T3, t4: T4, t5: T5): CurriedFunction2<T6, T7, R>
81+
82+
(t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6): CurriedFunction1<T7, R>
83+
84+
(t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7): R
85+
}
86+
87+
interface CurriedFunction8<T1, T2, T3, T4, T5, T6, T7, T8, R> {
88+
(): CurriedFunction8<T1, T2, T3, T4, T5, T6, T7, T8, R>
89+
90+
(t1: T1): CurriedFunction7<T2, T3, T4, T5, T6, T7, T8, R>
91+
92+
(t1: T1, t2: T2): CurriedFunction6<T3, T4, T5, T6, T7, T8, R>
93+
94+
(t1: T1, t2: T2, t3: T3): CurriedFunction5<T4, T5, T6, T7, T8, R>
95+
96+
(t1: T1, t2: T2, t3: T3, t4: T4): CurriedFunction4<T5, T6, T7, T8, R>
97+
98+
(t1: T1, t2: T2, t3: T3, t4: T4, t5: T5): CurriedFunction3<T6, T7, T8, R>
99+
100+
(t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6): CurriedFunction2<T7, T8, R>
101+
102+
(t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7): CurriedFunction1<T8, R>
103+
104+
(t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8): R
105+
}
106+
107+
/**
108+
* Creates a function that accepts one or more arguments of func that when called either invokes func returning
109+
* its result, if all func arguments have been provided, or returns a function that accepts one or more of the
110+
* remaining func arguments, and so on. The arity of func may be specified if func.length is not sufficient.
111+
* @param func The function to curry.
112+
* @param arity The arity of func.
113+
* @return Returns the new curried function.
114+
*/
115+
export function curry<T1, R>(func: (t1: T1) => R, arity?: number): CurriedFunction1<T1, R>
116+
export function curry<T1, T2, R>(func: (t1: T1, t2: T2) => R, arity?: number): CurriedFunction2<T1, T2, R>
117+
export function curry<T1, T2, T3, R>(
118+
func: (t1: T1, t2: T2, t3: T3) => R,
119+
arity?: number,
120+
): CurriedFunction3<T1, T2, T3, R>
121+
export function curry<T1, T2, T3, T4, R>(
122+
func: (t1: T1, t2: T2, t3: T3, t4: T4) => R,
123+
arity?: number,
124+
): CurriedFunction4<T1, T2, T3, T4, R>
125+
export function curry<T1, T2, T3, T4, T5, R>(
126+
func: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5) => R,
127+
arity?: number,
128+
): CurriedFunction5<T1, T2, T3, T4, T5, R>
129+
export function curry<T1, T2, T3, T4, T5, T6, R>(
130+
func: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6) => R,
131+
arity?: number,
132+
): CurriedFunction6<T1, T2, T3, T4, T5, T6, R>
133+
export function curry<T1, T2, T3, T4, T5, T6, T7, R>(
134+
func: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7) => R,
135+
arity?: number,
136+
): CurriedFunction7<T1, T2, T3, T4, T5, T6, T7, R>
137+
export function curry<T1, T2, T3, T4, T5, T6, T7, T8, R>(
138+
func: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8) => R,
139+
arity?: number,
140+
): CurriedFunction8<T1, T2, T3, T4, T5, T6, T7, T8, R>
141+
export function curry(fn: (...args: any[]) => any, arity?: number) {
142+
return function curried() {
143+
if (arity == null) {
144+
arity = fn.length
145+
}
146+
const args = [].slice.call(arguments)
147+
if (args.length >= arity) {
148+
// @ts-ignore
149+
return fn.apply(this, args)
150+
} else {
151+
return function() {
152+
// @ts-ignore
153+
return curried.apply(this, args.concat([].slice.call(arguments)))
154+
}
155+
}
156+
}
157+
}

src/helper/get-tag.function.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Tag } from './tag.enum'
2+
3+
/**
4+
* @return Returns the value (we call it tag) returned by function call `value.toString`,
5+
*/
6+
export function getTag(value: any): Tag | string {
7+
return Object.prototype.toString.call(value)
8+
}

0 commit comments

Comments
 (0)