@travetto/model-dynamodb 5.0.0-rc.0 → 5.0.0-rc.10

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.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/src/service.ts +6 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/model-dynamodb",
3
- "version": "5.0.0-rc.0",
3
+ "version": "5.0.0-rc.10",
4
4
  "description": "DynamoDB backing for the travetto model module.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -26,11 +26,11 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@aws-sdk/client-dynamodb": "^3.609.0",
29
- "@travetto/config": "^5.0.0-rc.0",
30
- "@travetto/model": "^5.0.0-rc.0"
29
+ "@travetto/config": "^5.0.0-rc.10",
30
+ "@travetto/model": "^5.0.0-rc.10"
31
31
  },
32
32
  "peerDependencies": {
33
- "@travetto/command": "^5.0.0-rc.0"
33
+ "@travetto/command": "^5.0.0-rc.9"
34
34
  },
35
35
  "peerDependenciesMeta": {
36
36
  "@travetto/command": {
package/src/service.ts CHANGED
@@ -3,8 +3,7 @@ import {
3
3
  KeySchemaElement, PutItemCommandInput, PutItemCommandOutput
4
4
  } from '@aws-sdk/client-dynamodb';
5
5
 
6
- import { ShutdownManager, TimeUtil, type Class } from '@travetto/base';
7
- import { DeepPartial } from '@travetto/schema';
6
+ import { asFull, ShutdownManager, TimeUtil, type Class, type DeepPartial } from '@travetto/runtime';
8
7
  import { Injectable } from '@travetto/di';
9
8
  import {
10
9
  ModelCrudSupport, ModelExpirySupport, ModelRegistry, ModelStorageSupport,
@@ -25,13 +24,12 @@ function simpleName(idx: string): string {
25
24
  return idx.replace(/[^A-Za-z0-9]/g, '');
26
25
  }
27
26
 
28
- function toValue(val: string | number | boolean | Date | undefined | null, forceString?: boolean): AttributeValue;
29
- function toValue(val: unknown, forceString?: boolean): AttributeValue | undefined {
27
+ function toValue(val: string | number | boolean | Date | undefined | null): AttributeValue;
28
+ function toValue(val: unknown): AttributeValue | undefined {
30
29
  if (val === undefined || val === null || val === '') {
31
30
  return { NULL: true };
32
- } else if (typeof val === 'string' || forceString) {
33
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
34
- return { S: val as string };
31
+ } else if (typeof val === 'string') {
32
+ return { S: val };
35
33
  } else if (typeof val === 'number') {
36
34
  return { N: `${val}` };
37
35
  } else if (typeof val === 'boolean') {
@@ -311,8 +309,7 @@ export class DynamoDBModelService implements ModelCrudSupport, ModelExpirySuppor
311
309
  ModelCrudUtil.ensureNotSubType(cls);
312
310
  const id = item.id;
313
311
  item = await ModelCrudUtil.naivePartialUpdate(cls, item, view, (): Promise<T> => this.get(cls, id));
314
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
315
- const itemAsT = item as T;
312
+ const itemAsT = asFull<T>(item);
316
313
  await this.#putItem(cls, id, itemAsT, 'update');
317
314
  return itemAsT;
318
315
  }