@travetto/model-dynamodb 7.1.4 → 8.0.0-alpha.1

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/README.md CHANGED
@@ -36,7 +36,7 @@ export class Init {
36
36
  }
37
37
  ```
38
38
 
39
- where the [DynamoDBModelConfig](https://github.com/travetto/travetto/tree/main/module/model-dynamodb/src/config.ts#L7) is defined by:
39
+ where the [DynamoDBModelConfig](https://github.com/travetto/travetto/tree/main/module/model-dynamodb/src/config.ts#L8) is defined by:
40
40
 
41
41
  **Code: Structure of DynamoDBModelConfig**
42
42
  ```typescript
@@ -48,7 +48,8 @@ export class DynamoDBModelConfig {
48
48
  modifyStorage?: boolean;
49
49
  namespace?: string;
50
50
 
51
- postConstruct(): void {
51
+ @PostConstruct()
52
+ finalizeConfig(): void {
52
53
  if (!Runtime.production) {
53
54
  this.client.endpoint ??= 'http://localhost:8000'; // From docker
54
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/model-dynamodb",
3
- "version": "7.1.4",
3
+ "version": "8.0.0-alpha.1",
4
4
  "type": "module",
5
5
  "description": "DynamoDB backing for the travetto model module.",
6
6
  "keywords": [
@@ -26,12 +26,12 @@
26
26
  "directory": "module/model-dynamodb"
27
27
  },
28
28
  "dependencies": {
29
- "@aws-sdk/client-dynamodb": "^3.966.0",
30
- "@travetto/config": "^7.1.4",
31
- "@travetto/model": "^7.1.4"
29
+ "@aws-sdk/client-dynamodb": "^3.1004.0",
30
+ "@travetto/config": "^8.0.0-alpha.1",
31
+ "@travetto/model": "^8.0.0-alpha.1"
32
32
  },
33
33
  "peerDependencies": {
34
- "@travetto/cli": "^7.1.4"
34
+ "@travetto/cli": "^8.0.0-alpha.1"
35
35
  },
36
36
  "peerDependenciesMeta": {
37
37
  "@travetto/cli": {
package/src/config.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type dynamodb from '@aws-sdk/client-dynamodb';
2
2
 
3
3
  import { Config } from '@travetto/config';
4
+ import { PostConstruct } from '@travetto/di';
4
5
  import { Runtime } from '@travetto/runtime';
5
6
 
6
7
  @Config('model.dynamodb')
@@ -11,7 +12,8 @@ export class DynamoDBModelConfig {
11
12
  modifyStorage?: boolean;
12
13
  namespace?: string;
13
14
 
14
- postConstruct(): void {
15
+ @PostConstruct()
16
+ finalizeConfig(): void {
15
17
  if (!Runtime.production) {
16
18
  this.client.endpoint ??= 'http://localhost:8000'; // From docker
17
19
  }
package/src/service.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { type AttributeValue, DynamoDB, type PutItemCommandInput, type PutItemCommandOutput } from '@aws-sdk/client-dynamodb';
2
2
 
3
- import { ShutdownManager, TimeUtil, type Class, type DeepPartial } from '@travetto/runtime';
4
- import { Injectable } from '@travetto/di';
3
+ import { JSONUtil, ShutdownManager, TimeUtil, type Class, type DeepPartial } from '@travetto/runtime';
4
+ import { Injectable, PostConstruct } from '@travetto/di';
5
5
  import {
6
6
  type ModelCrudSupport, type ModelExpirySupport, ModelRegistryIndex, type ModelStorageSupport,
7
7
  type ModelIndexedSupport, type ModelType, NotFoundError, ExistsError,
@@ -41,7 +41,7 @@ export class DynamoDBModelService implements ModelCrudSupport, ModelExpirySuppor
41
41
  if (config.expiresAt) {
42
42
  const { expiresAt } = ModelExpiryUtil.getExpiryState(cls, item);
43
43
  if (expiresAt) {
44
- expiry = TimeUtil.asSeconds(expiresAt);
44
+ expiry = TimeUtil.duration(expiresAt.getTime(), 's');
45
45
  }
46
46
  }
47
47
 
@@ -61,7 +61,7 @@ export class DynamoDBModelService implements ModelCrudSupport, ModelExpirySuppor
61
61
  ConditionExpression: 'attribute_not_exists(body)',
62
62
  Item: {
63
63
  id: DynamoDBUtil.toValue(item.id),
64
- body: DynamoDBUtil.toValue(JSON.stringify(item)),
64
+ body: DynamoDBUtil.toValue(JSONUtil.toUTF8(item)),
65
65
  ...(expiry !== undefined ? { [EXP_ATTR]: DynamoDBUtil.toValue(expiry) } : {}),
66
66
  ...indices
67
67
  },
@@ -92,7 +92,7 @@ export class DynamoDBModelService implements ModelCrudSupport, ModelExpirySuppor
92
92
  ...expr
93
93
  ].filter(part => !!part).join(', ')}`,
94
94
  ExpressionAttributeValues: {
95
- ':body': DynamoDBUtil.toValue(JSON.stringify(item)),
95
+ ':body': DynamoDBUtil.toValue(JSONUtil.toUTF8(item)),
96
96
  ...(expiry !== undefined ? { ':expr': DynamoDBUtil.toValue(expiry) } : {}),
97
97
  ...indices
98
98
  },
@@ -111,7 +111,8 @@ export class DynamoDBModelService implements ModelCrudSupport, ModelExpirySuppor
111
111
  }
112
112
  }
113
113
 
114
- async postConstruct(): Promise<void> {
114
+ @PostConstruct()
115
+ async initializeClient(): Promise<void> {
115
116
  this.client = new DynamoDB({ ...this.config.client });
116
117
  await ModelStorageUtil.storageInitialization(this);
117
118
  ShutdownManager.signal.addEventListener('abort', async () => this.client.destroy());
@@ -1,6 +1,6 @@
1
1
  import type { ServiceDescriptor } from '@travetto/cli';
2
2
 
3
- const version = process.env.DYNAMODB_VERSION || '3.1.0';
3
+ const version = process.env.DYNAMODB_VERSION || '3.3.0';
4
4
 
5
5
  export const service: ServiceDescriptor = {
6
6
  name: 'dynamodb',