Repository: jeremydaly/dynamodb-toolbox (ts)

Issue:
[v0.4.0  Typescript] Allow null attributes in Put queries, if they are optional
Tested version : v0.4.0-alpha.2

Issue :
The type `PutItem` type does not allow `null` attributes, but it should be possible for optional attributes.

Suggestion :
Add the possibility to put `null` attributes if they are optional.
The work has already done for [`UpdateItem`](https://github.com/jeremydaly/dynamodb-toolbox/blob/676a42f510bbd7ca0e6598a65d0eeab730784425/src/classes/Entity.ts#L467), but not for [`PutItem`](https://github.com/jeremydaly/dynamodb-toolbox/blob/676a42f510bbd7ca0e6598a65d0eeab730784425/src/classes/Entity.ts#L418)


Pull request:
fix(Entity/PutItem): allow null values for optional attributes
closes #243

Patch:
diff --git a/src/classes/Entity/types.ts b/src/classes/Entity/types.ts
index cc3b0591..61f761e7 100644
--- a/src/classes/Entity/types.ts
+++ b/src/classes/Entity/types.ts
@@ -346,9 +346,9 @@ export type PutItem<MethodItemOverlay extends Overlay,
   A.Compute<CompositePrimaryKey &
     O.Pick<Item, Attributes['always']['input'] | Attributes['required']['input']> &
     O.Partial<O.Pick<Item,
-      | Attributes['always']['default']
-      | Attributes['required']['default']
-      | Attributes['optional']>>>
+    | Attributes['always']['default']
+    | Attributes['required']['default']> & 
+     O.Update<Item,  Attributes['optional'], A.x | null>>>
 ]>
 
 export type UpdateOptionsReturnValues = 'NONE' | 'UPDATED_OLD' | 'UPDATED_NEW' | 'ALL_OLD' | 'ALL_NEW'


Test patch:
diff --git a/src/__tests__/entity.put.unit.test.ts b/src/__tests__/entity.put.unit.test.ts
index d61f3999..465fb6a5 100644
--- a/src/__tests__/entity.put.unit.test.ts
+++ b/src/__tests__/entity.put.unit.test.ts
@@ -180,6 +180,25 @@ describe('put', () => {
     expect(Item).not.toHaveProperty('test_composite')
   })
 
+  it('accepts null values for optional attributes', () => {
+    let { Item } = TestEntity3.putParams({
+      email: 'test-pk',
+      test: 'hello',
+      test2: null,
+    })
+    expect(Item.pk).toBe('test-pk')
+    expect(Item.test).toBe('hello')
+    //Attributes with NULL values are removed (by default)
+    expect(Item).not.toHaveProperty('test2')
+  })
+
+  it('fails with null values for non-optional attributes', () => {
+    expect(()=>TestEntity3.putParams({
+      email: 'test-pk',
+      test: null,
+    })).toThrow(`'test' is a required field`)
+  })
+
   it('creates item that overrides composite key', () => {
     let { Item } = TestEntity2.putParams({
       email: 'test-pk',