@travetto/model-dynamodb 5.0.0-rc.8 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/src/service.ts +6 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-dynamodb",
|
|
3
|
-
"version": "5.0.0
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "DynamoDB backing for the travetto model module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"directory": "module/model-dynamodb"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aws-sdk/client-dynamodb": "^3.
|
|
29
|
-
"@travetto/config": "^5.0.0
|
|
30
|
-
"@travetto/model": "^5.0.0
|
|
28
|
+
"@aws-sdk/client-dynamodb": "^3.631.0",
|
|
29
|
+
"@travetto/config": "^5.0.0",
|
|
30
|
+
"@travetto/model": "^5.0.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@travetto/command": "^5.0.0
|
|
33
|
+
"@travetto/command": "^5.0.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependenciesMeta": {
|
|
36
36
|
"@travetto/command": {
|
package/src/service.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
KeySchemaElement, PutItemCommandInput, PutItemCommandOutput
|
|
4
4
|
} from '@aws-sdk/client-dynamodb';
|
|
5
5
|
|
|
6
|
-
import { ShutdownManager, TimeUtil, type Class, type DeepPartial } from '@travetto/runtime';
|
|
6
|
+
import { asFull, ShutdownManager, TimeUtil, type Class, type DeepPartial } from '@travetto/runtime';
|
|
7
7
|
import { Injectable } from '@travetto/di';
|
|
8
8
|
import {
|
|
9
9
|
ModelCrudSupport, ModelExpirySupport, ModelRegistry, ModelStorageSupport,
|
|
@@ -24,13 +24,12 @@ function simpleName(idx: string): string {
|
|
|
24
24
|
return idx.replace(/[^A-Za-z0-9]/g, '');
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
function toValue(val: string | number | boolean | Date | undefined | null
|
|
28
|
-
function toValue(val: unknown
|
|
27
|
+
function toValue(val: string | number | boolean | Date | undefined | null): AttributeValue;
|
|
28
|
+
function toValue(val: unknown): AttributeValue | undefined {
|
|
29
29
|
if (val === undefined || val === null || val === '') {
|
|
30
30
|
return { NULL: true };
|
|
31
|
-
} else if (typeof val === 'string'
|
|
32
|
-
|
|
33
|
-
return { S: val as string };
|
|
31
|
+
} else if (typeof val === 'string') {
|
|
32
|
+
return { S: val };
|
|
34
33
|
} else if (typeof val === 'number') {
|
|
35
34
|
return { N: `${val}` };
|
|
36
35
|
} else if (typeof val === 'boolean') {
|
|
@@ -310,8 +309,7 @@ export class DynamoDBModelService implements ModelCrudSupport, ModelExpirySuppor
|
|
|
310
309
|
ModelCrudUtil.ensureNotSubType(cls);
|
|
311
310
|
const id = item.id;
|
|
312
311
|
item = await ModelCrudUtil.naivePartialUpdate(cls, item, view, (): Promise<T> => this.get(cls, id));
|
|
313
|
-
|
|
314
|
-
const itemAsT = item as T;
|
|
312
|
+
const itemAsT = asFull<T>(item);
|
|
315
313
|
await this.#putItem(cls, id, itemAsT, 'update');
|
|
316
314
|
return itemAsT;
|
|
317
315
|
}
|