@travetto/model-dynamodb 6.0.0-rc.1 → 6.0.0-rc.3

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
@@ -16,9 +16,10 @@ yarn add @travetto/model-dynamodb
16
16
  This module provides an [DynamoDB](https://aws.amazon.com/dynamodb/)-based implementation for the [Data Modeling Support](https://github.com/travetto/travetto/tree/main/module/model#readme "Datastore abstraction for core operations."). This source allows the [Data Modeling Support](https://github.com/travetto/travetto/tree/main/module/model#readme "Datastore abstraction for core operations.") module to read, write and query against [DynamoDB](https://aws.amazon.com/dynamodb/). The entire document is stored as a single value, so nothing is needed to handle schema updates in real time. Indices on the other hand are more complicated, and will not be retroactively computed for new values.
17
17
 
18
18
  Supported features:
19
- * [CRUD](https://github.com/travetto/travetto/tree/main/module/model/src/service/crud.ts#L11)
20
- * [Expiry](https://github.com/travetto/travetto/tree/main/module/model/src/service/expiry.ts#L11)
21
- * [Indexed](https://github.com/travetto/travetto/tree/main/module/model/src/service/indexed.ts#L12)
19
+ * [CRUD](https://github.com/travetto/travetto/tree/main/module/model/src/types/crud.ts#L11)
20
+ * [Expiry](https://github.com/travetto/travetto/tree/main/module/model/src/types/expiry.ts#L10)
21
+ * [Indexed](https://github.com/travetto/travetto/tree/main/module/model/src/types/indexed.ts#L11)
22
+
22
23
  Out of the box, by installing the module, everything should be wired up by default.If you need to customize any aspect of the source or config, you can override and register it with the [Dependency Injection](https://github.com/travetto/travetto/tree/main/module/di#readme "Dependency registration/management and injection support.") module.
23
24
 
24
25
  **Code: Wiring up a custom Model Source**
@@ -39,11 +40,6 @@ where the [DynamoDBModelConfig](https://github.com/travetto/travetto/tree/main/m
39
40
 
40
41
  **Code: Structure of DynamoDBModelConfig**
41
42
  ```typescript
42
- import type dynamodb from '@aws-sdk/client-dynamodb';
43
-
44
- import { Config } from '@travetto/config';
45
- import { Field } from '@travetto/schema';
46
-
47
43
  @Config('model.dynamodb')
48
44
  export class DynamoDBModelConfig {
49
45
  @Field(Object)
package/__index__.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './src/service';
2
- export * from './src/config';
1
+ export * from './src/service.ts';
2
+ export * from './src/config.ts';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/model-dynamodb",
3
- "version": "6.0.0-rc.1",
3
+ "version": "6.0.0-rc.3",
4
4
  "description": "DynamoDB backing for the travetto model module.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -25,10 +25,10 @@
25
25
  "directory": "module/model-dynamodb"
26
26
  },
27
27
  "dependencies": {
28
- "@aws-sdk/client-dynamodb": "^3.738.0",
29
- "@travetto/cli": "^6.0.0-rc.1",
30
- "@travetto/config": "^6.0.0-rc.1",
31
- "@travetto/model": "^6.0.0-rc.1"
28
+ "@aws-sdk/client-dynamodb": "^3.796.0",
29
+ "@travetto/cli": "^6.0.0-rc.3",
30
+ "@travetto/config": "^6.0.0-rc.2",
31
+ "@travetto/model": "^6.0.0-rc.2"
32
32
  },
33
33
  "travetto": {
34
34
  "displayName": "DynamoDB Model Support"
package/src/service.ts CHANGED
@@ -8,15 +8,11 @@ import { Injectable } from '@travetto/di';
8
8
  import {
9
9
  ModelCrudSupport, ModelExpirySupport, ModelRegistry, ModelStorageSupport,
10
10
  ModelIndexedSupport, ModelType, NotFoundError, ExistsError,
11
- IndexNotSupported, OptionalId
11
+ IndexNotSupported, OptionalId,
12
+ ModelCrudUtil, ModelExpiryUtil, ModelIndexedUtil, ModelStorageUtil
12
13
  } from '@travetto/model';
13
14
 
14
- import { ModelCrudUtil } from '@travetto/model/src/internal/service/crud';
15
- import { ModelExpiryUtil } from '@travetto/model/src/internal/service/expiry';
16
- import { ModelIndexedUtil } from '@travetto/model/src/internal/service/indexed';
17
- import { ModelStorageUtil } from '@travetto/model/src/internal/service/storage';
18
-
19
- import { DynamoDBModelConfig } from './config';
15
+ import { DynamoDBModelConfig } from './config.ts';
20
16
 
21
17
  const EXP_ATTR = 'expires_at__';
22
18
 
@@ -233,7 +229,7 @@ export class DynamoDBModelService implements ModelCrudSupport, ModelExpirySuppor
233
229
  */
234
230
  async deleteModel(cls: Class<ModelType>): Promise<void> {
235
231
  const table = this.#resolveTable(cls);
236
- const { Table: verify } = (await this.client.describeTable({ TableName: table }).catch(err => ({ Table: undefined })));
232
+ const { Table: verify } = (await this.client.describeTable({ TableName: table }).catch(() => ({ Table: undefined })));
237
233
  if (verify) {
238
234
  await this.client.deleteTable({ TableName: table });
239
235
  }
@@ -266,19 +262,19 @@ export class DynamoDBModelService implements ModelCrudSupport, ModelExpirySuppor
266
262
  for (const model of ModelRegistry.getClasses()) {
267
263
  await this.client.deleteTable({
268
264
  TableName: this.#resolveTable(model)
269
- }).catch(err => { });
265
+ }).catch(() => { });
270
266
  }
271
267
  }
272
268
 
273
269
  // Crud
274
270
  async get<T extends ModelType>(cls: Class<T>, id: string): Promise<T> {
275
- const res = await this.client.getItem({
271
+ const result = await this.client.getItem({
276
272
  TableName: this.#resolveTable(cls),
277
273
  Key: { id: toValue(id) }
278
274
  });
279
275
 
280
- if (res && res.Item && res.Item.body) {
281
- return loadAndCheckExpiry(cls, res.Item.body.S!);
276
+ if (result && result.Item && result.Item.body) {
277
+ return loadAndCheckExpiry(cls, result.Item.body.S!);
282
278
  }
283
279
  throw new NotFoundError(cls, id);
284
280
  }
@@ -316,12 +312,12 @@ export class DynamoDBModelService implements ModelCrudSupport, ModelExpirySuppor
316
312
 
317
313
  async delete<T extends ModelType>(cls: Class<T>, id: string): Promise<void> {
318
314
  ModelCrudUtil.ensureNotSubType(cls);
319
- const res = await this.client.deleteItem({
315
+ const result = await this.client.deleteItem({
320
316
  TableName: this.#resolveTable(cls),
321
317
  ReturnValues: 'ALL_OLD',
322
318
  Key: { id: { S: id } }
323
319
  });
324
- if (!res.Attributes) {
320
+ if (!result.Attributes) {
325
321
  throw new NotFoundError(cls, id);
326
322
  }
327
323
  }
@@ -356,7 +352,7 @@ export class DynamoDBModelService implements ModelCrudSupport, ModelExpirySuppor
356
352
  }
357
353
 
358
354
  // Expiry
359
- async deleteExpired<T extends ModelType>(cls: Class<T>): Promise<number> {
355
+ async deleteExpired<T extends ModelType>(_cls: Class<T>): Promise<number> {
360
356
  return -1;
361
357
  }
362
358