@twin.org/entity-storage-connector-dynamodb 0.0.1-next.9 → 0.0.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.
@@ -50,9 +50,6 @@ class DynamoDbEntityStorageConnector {
50
50
  /**
51
51
  * Create a new instance of DynamoDbEntityStorageConnector.
52
52
  * @param options The options for the connector.
53
- * @param options.entitySchema The schema for the entity.
54
- * @param options.loggingConnectorType The type of logging connector to use, defaults to no logging.
55
- * @param options.config The configuration for the connector.
56
53
  */
57
54
  constructor(options) {
58
55
  core.Guards.object(this.CLASS_NAME, "options", options);
@@ -283,9 +280,10 @@ class DynamoDbEntityStorageConnector {
283
280
  * @param conditions The optional conditions to match for the entities.
284
281
  * @returns The id of the entity.
285
282
  */
286
- async set(entity, conditions) {
287
- core.Guards.object(this.CLASS_NAME, "entity", entity);
288
- const id = entity[this._primaryKey.property];
283
+ async set(entity$1, conditions) {
284
+ core.Guards.object(this.CLASS_NAME, "entity", entity$1);
285
+ entity.EntitySchemaHelper.validateEntity(entity$1, this.getSchema());
286
+ const id = entity$1[this._primaryKey.property];
289
287
  try {
290
288
  const docClient = this.createDocClient();
291
289
  const { conditionExpression, attributeNames, attributeValues } = this.buildConditionExpression(conditions);
@@ -293,15 +291,22 @@ class DynamoDbEntityStorageConnector {
293
291
  TableName: this._config.tableName,
294
292
  Item: {
295
293
  [DynamoDbEntityStorageConnector._PARTITION_ID_NAME]: DynamoDbEntityStorageConnector._PARTITION_ID_VALUE,
296
- ...entity
294
+ ...entity$1
297
295
  },
298
- ConditionExpression: conditionExpression,
296
+ // Only set the condition expression if we have conditions to match
297
+ // and the primary key exists, otherwise we are creating a new object
298
+ ConditionExpression: core.Is.stringValue(conditionExpression)
299
+ ? `(attribute_exists(${this._primaryKey.property}) AND ${conditionExpression}) OR attribute_not_exists(${this._primaryKey.property})`
300
+ : undefined,
299
301
  ExpressionAttributeNames: attributeNames,
300
302
  ExpressionAttributeValues: attributeValues
301
303
  });
302
304
  await docClient.send(putCommand);
303
305
  }
304
306
  catch (err) {
307
+ if (core.BaseError.isErrorName(err, "ConditionalCheckFailedException")) {
308
+ return;
309
+ }
305
310
  if (core.BaseError.isErrorCode(err, "ResourceNotFoundException")) {
306
311
  throw new core.GeneralError(this.CLASS_NAME, "tableDoesNotExist", {
307
312
  tableName: this._config.tableName
@@ -440,6 +445,14 @@ class DynamoDbEntityStorageConnector {
440
445
  }
441
446
  prop += comparator.property;
442
447
  let attributeName = this.populateAttributeNames(prop, attributeNames);
448
+ if (core.Is.empty(comparator.value)) {
449
+ if (comparator.comparison === entity.ComparisonOperator.Equals) {
450
+ return `attribute_not_exists(${attributeName})`;
451
+ }
452
+ else if (comparator.comparison === entity.ComparisonOperator.NotEquals) {
453
+ return `attribute_exists(${attributeName})`;
454
+ }
455
+ }
443
456
  let propName = `:${attributeName.replace(/\./g, "").replace(/#/g, "")}`;
444
457
  if (core.Is.array(comparator.value)) {
445
458
  const dbValues = comparator.value.map(v => this.propertyToDbValue(v, type));
@@ -563,7 +576,7 @@ class DynamoDbEntityStorageConnector {
563
576
  }
564
577
  /**
565
578
  * Create a new DB connection.
566
- * @returns The dynamo db connection.
579
+ * @returns The Dynamo DB connection.
567
580
  * @internal
568
581
  */
569
582
  createConnection() {
@@ -571,7 +584,7 @@ class DynamoDbEntityStorageConnector {
571
584
  }
572
585
  /**
573
586
  * Create a new DB connection configuration.
574
- * @returns The dynamo db connection configuration.
587
+ * @returns The Dynamo DB connection configuration.
575
588
  * @internal
576
589
  */
577
590
  createConnectionConfig() {
@@ -620,6 +633,7 @@ class DynamoDbEntityStorageConnector {
620
633
  : undefined;
621
634
  // If we have a sortable property defined in the descriptor then we must use
622
635
  // the secondary index for the query
636
+ let scanAscending = true;
623
637
  if (core.Is.arrayValue(sortProperties)) {
624
638
  if (sortProperties.length > 1) {
625
639
  throw new core.GeneralError(this.CLASS_NAME, "sortSingle");
@@ -637,6 +651,7 @@ class DynamoDbEntityStorageConnector {
637
651
  indexName = propertySchema.isPrimary
638
652
  ? undefined
639
653
  : `${sortProperty.property}Index`;
654
+ scanAscending = sortProperty.sortDirection === entity.SortDirection.Ascending;
640
655
  }
641
656
  }
642
657
  const attributeNames = { "#partitionId": "partitionId" };
@@ -661,6 +676,7 @@ class DynamoDbEntityStorageConnector {
661
676
  ExpressionAttributeValues: attributeValues,
662
677
  ProjectionExpression: properties?.map(p => p).join(", "),
663
678
  Limit: returnSize,
679
+ ScanIndexForward: scanAscending,
664
680
  ExclusiveStartKey: core.Is.empty(cursor)
665
681
  ? undefined
666
682
  : core.ObjectHelper.fromBytes(core.Converter.base64ToBytes(cursor))
@@ -669,7 +685,11 @@ class DynamoDbEntityStorageConnector {
669
685
  const results = await connection.send(query);
670
686
  let entities = [];
671
687
  if (core.Is.arrayValue(results.Items)) {
672
- entities = results.Items.map(item => utilDynamodb.unmarshall(item));
688
+ entities = results.Items.map(item => {
689
+ const unmarshalled = utilDynamodb.unmarshall(item);
690
+ delete unmarshalled[DynamoDbEntityStorageConnector._PARTITION_ID_NAME];
691
+ return unmarshalled;
692
+ });
673
693
  }
674
694
  return {
675
695
  entities,
@@ -2,7 +2,7 @@ import { waitUntilTableExists, DynamoDB, QueryCommand } from '@aws-sdk/client-dy
2
2
  import { GetCommand, PutCommand, DeleteCommand, DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
3
3
  import { unmarshall } from '@aws-sdk/util-dynamodb';
4
4
  import { Guards, Is, BaseError, GeneralError, Coerce, ObjectHelper, Converter } from '@twin.org/core';
5
- import { EntitySchemaFactory, EntitySchemaHelper, ComparisonOperator, LogicalOperator } from '@twin.org/entity';
5
+ import { EntitySchemaFactory, EntitySchemaHelper, ComparisonOperator, LogicalOperator, SortDirection } from '@twin.org/entity';
6
6
  import { LoggingConnectorFactory } from '@twin.org/logging-models';
7
7
 
8
8
  // Copyright 2024 IOTA Stiftung.
@@ -48,9 +48,6 @@ class DynamoDbEntityStorageConnector {
48
48
  /**
49
49
  * Create a new instance of DynamoDbEntityStorageConnector.
50
50
  * @param options The options for the connector.
51
- * @param options.entitySchema The schema for the entity.
52
- * @param options.loggingConnectorType The type of logging connector to use, defaults to no logging.
53
- * @param options.config The configuration for the connector.
54
51
  */
55
52
  constructor(options) {
56
53
  Guards.object(this.CLASS_NAME, "options", options);
@@ -283,6 +280,7 @@ class DynamoDbEntityStorageConnector {
283
280
  */
284
281
  async set(entity, conditions) {
285
282
  Guards.object(this.CLASS_NAME, "entity", entity);
283
+ EntitySchemaHelper.validateEntity(entity, this.getSchema());
286
284
  const id = entity[this._primaryKey.property];
287
285
  try {
288
286
  const docClient = this.createDocClient();
@@ -293,13 +291,20 @@ class DynamoDbEntityStorageConnector {
293
291
  [DynamoDbEntityStorageConnector._PARTITION_ID_NAME]: DynamoDbEntityStorageConnector._PARTITION_ID_VALUE,
294
292
  ...entity
295
293
  },
296
- ConditionExpression: conditionExpression,
294
+ // Only set the condition expression if we have conditions to match
295
+ // and the primary key exists, otherwise we are creating a new object
296
+ ConditionExpression: Is.stringValue(conditionExpression)
297
+ ? `(attribute_exists(${this._primaryKey.property}) AND ${conditionExpression}) OR attribute_not_exists(${this._primaryKey.property})`
298
+ : undefined,
297
299
  ExpressionAttributeNames: attributeNames,
298
300
  ExpressionAttributeValues: attributeValues
299
301
  });
300
302
  await docClient.send(putCommand);
301
303
  }
302
304
  catch (err) {
305
+ if (BaseError.isErrorName(err, "ConditionalCheckFailedException")) {
306
+ return;
307
+ }
303
308
  if (BaseError.isErrorCode(err, "ResourceNotFoundException")) {
304
309
  throw new GeneralError(this.CLASS_NAME, "tableDoesNotExist", {
305
310
  tableName: this._config.tableName
@@ -438,6 +443,14 @@ class DynamoDbEntityStorageConnector {
438
443
  }
439
444
  prop += comparator.property;
440
445
  let attributeName = this.populateAttributeNames(prop, attributeNames);
446
+ if (Is.empty(comparator.value)) {
447
+ if (comparator.comparison === ComparisonOperator.Equals) {
448
+ return `attribute_not_exists(${attributeName})`;
449
+ }
450
+ else if (comparator.comparison === ComparisonOperator.NotEquals) {
451
+ return `attribute_exists(${attributeName})`;
452
+ }
453
+ }
441
454
  let propName = `:${attributeName.replace(/\./g, "").replace(/#/g, "")}`;
442
455
  if (Is.array(comparator.value)) {
443
456
  const dbValues = comparator.value.map(v => this.propertyToDbValue(v, type));
@@ -561,7 +574,7 @@ class DynamoDbEntityStorageConnector {
561
574
  }
562
575
  /**
563
576
  * Create a new DB connection.
564
- * @returns The dynamo db connection.
577
+ * @returns The Dynamo DB connection.
565
578
  * @internal
566
579
  */
567
580
  createConnection() {
@@ -569,7 +582,7 @@ class DynamoDbEntityStorageConnector {
569
582
  }
570
583
  /**
571
584
  * Create a new DB connection configuration.
572
- * @returns The dynamo db connection configuration.
585
+ * @returns The Dynamo DB connection configuration.
573
586
  * @internal
574
587
  */
575
588
  createConnectionConfig() {
@@ -618,6 +631,7 @@ class DynamoDbEntityStorageConnector {
618
631
  : undefined;
619
632
  // If we have a sortable property defined in the descriptor then we must use
620
633
  // the secondary index for the query
634
+ let scanAscending = true;
621
635
  if (Is.arrayValue(sortProperties)) {
622
636
  if (sortProperties.length > 1) {
623
637
  throw new GeneralError(this.CLASS_NAME, "sortSingle");
@@ -635,6 +649,7 @@ class DynamoDbEntityStorageConnector {
635
649
  indexName = propertySchema.isPrimary
636
650
  ? undefined
637
651
  : `${sortProperty.property}Index`;
652
+ scanAscending = sortProperty.sortDirection === SortDirection.Ascending;
638
653
  }
639
654
  }
640
655
  const attributeNames = { "#partitionId": "partitionId" };
@@ -659,6 +674,7 @@ class DynamoDbEntityStorageConnector {
659
674
  ExpressionAttributeValues: attributeValues,
660
675
  ProjectionExpression: properties?.map(p => p).join(", "),
661
676
  Limit: returnSize,
677
+ ScanIndexForward: scanAscending,
662
678
  ExclusiveStartKey: Is.empty(cursor)
663
679
  ? undefined
664
680
  : ObjectHelper.fromBytes(Converter.base64ToBytes(cursor))
@@ -667,7 +683,11 @@ class DynamoDbEntityStorageConnector {
667
683
  const results = await connection.send(query);
668
684
  let entities = [];
669
685
  if (Is.arrayValue(results.Items)) {
670
- entities = results.Items.map(item => unmarshall(item));
686
+ entities = results.Items.map(item => {
687
+ const unmarshalled = unmarshall(item);
688
+ delete unmarshalled[DynamoDbEntityStorageConnector._PARTITION_ID_NAME];
689
+ return unmarshalled;
690
+ });
671
691
  }
672
692
  return {
673
693
  entities,
@@ -1,6 +1,6 @@
1
- import { type EntityCondition, type IEntitySchema, type SortDirection } from "@twin.org/entity";
1
+ import { type EntityCondition, type IEntitySchema, SortDirection } from "@twin.org/entity";
2
2
  import type { IEntityStorageConnector } from "@twin.org/entity-storage-models";
3
- import type { IDynamoDbEntityStorageConnectorConfig } from "./models/IDynamoDbEntityStorageConnectorConfig";
3
+ import type { IDynamoDbEntityStorageConnectorConstructorOptions } from "./models/IDynamoDbEntityStorageConnectorConstructorOptions";
4
4
  /**
5
5
  * Class for performing entity storage operations using Dynamo DB.
6
6
  */
@@ -12,15 +12,8 @@ export declare class DynamoDbEntityStorageConnector<T = unknown> implements IEnt
12
12
  /**
13
13
  * Create a new instance of DynamoDbEntityStorageConnector.
14
14
  * @param options The options for the connector.
15
- * @param options.entitySchema The schema for the entity.
16
- * @param options.loggingConnectorType The type of logging connector to use, defaults to no logging.
17
- * @param options.config The configuration for the connector.
18
15
  */
19
- constructor(options: {
20
- entitySchema: string;
21
- loggingConnectorType?: string;
22
- config: IDynamoDbEntityStorageConnectorConfig;
23
- });
16
+ constructor(options: IDynamoDbEntityStorageConnectorConstructorOptions);
24
17
  /**
25
18
  * Bootstrap the component by creating and initializing any resources it needs.
26
19
  * @param nodeLoggingConnectorType The node logging connector type, defaults to "node-logging".
@@ -1,2 +1,3 @@
1
1
  export * from "./dynamoDbEntityStorageConnector";
2
2
  export * from "./models/IDynamoDbEntityStorageConnectorConfig";
3
+ export * from "./models/IDynamoDbEntityStorageConnectorConstructorOptions";
@@ -0,0 +1,18 @@
1
+ import type { IDynamoDbEntityStorageConnectorConfig } from "./IDynamoDbEntityStorageConnectorConfig";
2
+ /**
3
+ * Options for the Dynamo DB Entity Storage Connector constructor.
4
+ */
5
+ export interface IDynamoDbEntityStorageConnectorConstructorOptions {
6
+ /**
7
+ * The schema for the entity
8
+ */
9
+ entitySchema: string;
10
+ /**
11
+ * The type of logging connector to use, defaults to no logging.
12
+ */
13
+ loggingConnectorType?: string;
14
+ /**
15
+ * The configuration for the connector.
16
+ */
17
+ config: IDynamoDbEntityStorageConnectorConfig;
18
+ }
package/docs/changelog.md CHANGED
@@ -1,5 +1,110 @@
1
1
  # @twin.org/entity-storage-connector-dynamodb - Changelog
2
2
 
3
- ## v0.0.1-next.9
3
+ ## 0.0.1 (2025-07-04)
4
+
5
+
6
+ ### Features
7
+
8
+ * add production release automation ([1eb4c8e](https://github.com/twinfoundation/entity-storage/commit/1eb4c8ee3eb099defdfc2d063ae44935276dcae8))
9
+ * release to production ([a309051](https://github.com/twinfoundation/entity-storage/commit/a3090519adebf7943232b4df12e4c6bd5afe7eed))
10
+ * update dependencies ([7ccc0c4](https://github.com/twinfoundation/entity-storage/commit/7ccc0c429125d073dc60b3de6cf101abc8cc6cba))
11
+ * update docs ([5203e62](https://github.com/twinfoundation/entity-storage/commit/5203e621c3ae368f6fefb29ea5146f024f4a1b0d))
12
+ * use shared store mechanism ([#34](https://github.com/twinfoundation/entity-storage/issues/34)) ([68b6b71](https://github.com/twinfoundation/entity-storage/commit/68b6b71e7a96d7d016cd57bfff36775b56bf3f93))
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * query params force coercion ([dd6aa87](https://github.com/twinfoundation/entity-storage/commit/dd6aa87efdfb60bab7d6756a86888863c45c51a7))
18
+
19
+
20
+ ### Dependencies
21
+
22
+ * The following workspace dependencies were updated
23
+ * dependencies
24
+ * @twin.org/entity-storage-models bumped from ^0.0.0 to ^0.0.1
25
+ * devDependencies
26
+ * @twin.org/entity-storage-connector-memory bumped from ^0.0.0 to ^0.0.1
27
+
28
+ ## [0.0.1-next.31](https://github.com/twinfoundation/entity-storage/compare/entity-storage-connector-dynamodb-v0.0.1-next.30...entity-storage-connector-dynamodb-v0.0.1-next.31) (2025-06-20)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * query params force coercion ([dd6aa87](https://github.com/twinfoundation/entity-storage/commit/dd6aa87efdfb60bab7d6756a86888863c45c51a7))
34
+
35
+
36
+ ### Dependencies
37
+
38
+ * The following workspace dependencies were updated
39
+ * dependencies
40
+ * @twin.org/entity-storage-models bumped from 0.0.1-next.30 to 0.0.1-next.31
41
+ * devDependencies
42
+ * @twin.org/entity-storage-connector-memory bumped from 0.0.1-next.30 to 0.0.1-next.31
43
+
44
+ ## [0.0.1-next.30](https://github.com/twinfoundation/entity-storage/compare/entity-storage-connector-dynamodb-v0.0.1-next.29...entity-storage-connector-dynamodb-v0.0.1-next.30) (2025-06-12)
45
+
46
+
47
+ ### Features
48
+
49
+ * update dependencies ([7ccc0c4](https://github.com/twinfoundation/entity-storage/commit/7ccc0c429125d073dc60b3de6cf101abc8cc6cba))
50
+
51
+
52
+ ### Dependencies
53
+
54
+ * The following workspace dependencies were updated
55
+ * dependencies
56
+ * @twin.org/entity-storage-models bumped from 0.0.1-next.29 to 0.0.1-next.30
57
+ * devDependencies
58
+ * @twin.org/entity-storage-connector-memory bumped from 0.0.1-next.29 to 0.0.1-next.30
59
+
60
+ ## [0.0.1-next.29](https://github.com/twinfoundation/entity-storage/compare/entity-storage-connector-dynamodb-v0.0.1-next.28...entity-storage-connector-dynamodb-v0.0.1-next.29) (2025-04-17)
61
+
62
+
63
+ ### Features
64
+
65
+ * use shared store mechanism ([#34](https://github.com/twinfoundation/entity-storage/issues/34)) ([68b6b71](https://github.com/twinfoundation/entity-storage/commit/68b6b71e7a96d7d016cd57bfff36775b56bf3f93))
66
+
67
+
68
+ ### Dependencies
69
+
70
+ * The following workspace dependencies were updated
71
+ * dependencies
72
+ * @twin.org/entity-storage-models bumped from 0.0.1-next.28 to 0.0.1-next.29
73
+ * devDependencies
74
+ * @twin.org/entity-storage-connector-memory bumped from 0.0.1-next.28 to 0.0.1-next.29
75
+
76
+ ## [0.0.1-next.28](https://github.com/twinfoundation/entity-storage/compare/entity-storage-connector-dynamodb-v0.0.1-next.27...entity-storage-connector-dynamodb-v0.0.1-next.28) (2025-04-09)
77
+
78
+
79
+ ### Features
80
+
81
+ * update docs ([5203e62](https://github.com/twinfoundation/entity-storage/commit/5203e621c3ae368f6fefb29ea5146f024f4a1b0d))
82
+
83
+
84
+ ### Dependencies
85
+
86
+ * The following workspace dependencies were updated
87
+ * dependencies
88
+ * @twin.org/entity-storage-models bumped from 0.0.1-next.27 to 0.0.1-next.28
89
+ * devDependencies
90
+ * @twin.org/entity-storage-connector-memory bumped from 0.0.1-next.27 to 0.0.1-next.28
91
+
92
+ ## [0.0.1-next.27](https://github.com/twinfoundation/entity-storage/compare/entity-storage-connector-dynamodb-v0.0.1-next.26...entity-storage-connector-dynamodb-v0.0.1-next.27) (2025-03-28)
93
+
94
+
95
+ ### Miscellaneous Chores
96
+
97
+ * **entity-storage-connector-dynamodb:** Synchronize repo versions
98
+
99
+
100
+ ### Dependencies
101
+
102
+ * The following workspace dependencies were updated
103
+ * dependencies
104
+ * @twin.org/entity-storage-models bumped from 0.0.1-next.26 to 0.0.1-next.27
105
+ * devDependencies
106
+ * @twin.org/entity-storage-connector-memory bumped from 0.0.1-next.26 to 0.0.1-next.27
107
+
108
+ ## v0.0.1-next.26
4
109
 
5
110
  - Initial Release
@@ -4,7 +4,9 @@ Class for performing entity storage operations using Dynamo DB.
4
4
 
5
5
  ## Type Parameters
6
6
 
7
- **T** = `unknown`
7
+ ### T
8
+
9
+ `T` = `unknown`
8
10
 
9
11
  ## Implements
10
12
 
@@ -12,33 +14,23 @@ Class for performing entity storage operations using Dynamo DB.
12
14
 
13
15
  ## Constructors
14
16
 
15
- ### new DynamoDbEntityStorageConnector()
17
+ ### Constructor
16
18
 
17
- > **new DynamoDbEntityStorageConnector**\<`T`\>(`options`): [`DynamoDbEntityStorageConnector`](DynamoDbEntityStorageConnector.md)\<`T`\>
19
+ > **new DynamoDbEntityStorageConnector**\<`T`\>(`options`): `DynamoDbEntityStorageConnector`\<`T`\>
18
20
 
19
21
  Create a new instance of DynamoDbEntityStorageConnector.
20
22
 
21
23
  #### Parameters
22
24
 
23
- **options**
24
-
25
- The options for the connector.
26
-
27
- • **options.entitySchema**: `string`
25
+ ##### options
28
26
 
29
- The schema for the entity.
27
+ [`IDynamoDbEntityStorageConnectorConstructorOptions`](../interfaces/IDynamoDbEntityStorageConnectorConstructorOptions.md)
30
28
 
31
- **options.loggingConnectorType?**: `string`
32
-
33
- The type of logging connector to use, defaults to no logging.
34
-
35
- • **options.config**: [`IDynamoDbEntityStorageConnectorConfig`](../interfaces/IDynamoDbEntityStorageConnectorConfig.md)
36
-
37
- The configuration for the connector.
29
+ The options for the connector.
38
30
 
39
31
  #### Returns
40
32
 
41
- [`DynamoDbEntityStorageConnector`](DynamoDbEntityStorageConnector.md)\<`T`\>
33
+ `DynamoDbEntityStorageConnector`\<`T`\>
42
34
 
43
35
  ## Properties
44
36
 
@@ -56,13 +48,15 @@ Runtime name for the class.
56
48
 
57
49
  ### bootstrap()
58
50
 
59
- > **bootstrap**(`nodeLoggingConnectorType`?): `Promise`\<`boolean`\>
51
+ > **bootstrap**(`nodeLoggingConnectorType?`): `Promise`\<`boolean`\>
60
52
 
61
53
  Bootstrap the component by creating and initializing any resources it needs.
62
54
 
63
55
  #### Parameters
64
56
 
65
- **nodeLoggingConnectorType?**: `string`
57
+ ##### nodeLoggingConnectorType?
58
+
59
+ `string`
66
60
 
67
61
  The node logging connector type, defaults to "node-logging".
68
62
 
@@ -80,13 +74,13 @@ True if the bootstrapping process was successful.
80
74
 
81
75
  ### getSchema()
82
76
 
83
- > **getSchema**(): `IEntitySchema`\<`unknown`\>
77
+ > **getSchema**(): `IEntitySchema`
84
78
 
85
79
  Get the schema for the entities.
86
80
 
87
81
  #### Returns
88
82
 
89
- `IEntitySchema`\<`unknown`\>
83
+ `IEntitySchema`
90
84
 
91
85
  The schema for the entities.
92
86
 
@@ -98,21 +92,27 @@ The schema for the entities.
98
92
 
99
93
  ### get()
100
94
 
101
- > **get**(`id`, `secondaryIndex`?, `conditions`?): `Promise`\<`undefined` \| `T`\>
95
+ > **get**(`id`, `secondaryIndex?`, `conditions?`): `Promise`\<`undefined` \| `T`\>
102
96
 
103
97
  Get an entity.
104
98
 
105
99
  #### Parameters
106
100
 
107
- **id**: `string`
101
+ ##### id
102
+
103
+ `string`
108
104
 
109
105
  The id of the entity to get, or the index value if secondaryIndex is set.
110
106
 
111
- **secondaryIndex?**: keyof `T`
107
+ ##### secondaryIndex?
108
+
109
+ keyof `T`
112
110
 
113
111
  Get the item using a secondary index.
114
112
 
115
- **conditions?**: `object`[]
113
+ ##### conditions?
114
+
115
+ `object`[]
116
116
 
117
117
  The optional conditions to match for the entities.
118
118
 
@@ -130,17 +130,21 @@ The object if it can be found or undefined.
130
130
 
131
131
  ### set()
132
132
 
133
- > **set**(`entity`, `conditions`?): `Promise`\<`void`\>
133
+ > **set**(`entity`, `conditions?`): `Promise`\<`void`\>
134
134
 
135
135
  Set an entity.
136
136
 
137
137
  #### Parameters
138
138
 
139
- **entity**: `T`
139
+ ##### entity
140
+
141
+ `T`
140
142
 
141
143
  The entity to set.
142
144
 
143
- **conditions?**: `object`[]
145
+ ##### conditions?
146
+
147
+ `object`[]
144
148
 
145
149
  The optional conditions to match for the entities.
146
150
 
@@ -158,17 +162,21 @@ The id of the entity.
158
162
 
159
163
  ### remove()
160
164
 
161
- > **remove**(`id`, `conditions`?): `Promise`\<`void`\>
165
+ > **remove**(`id`, `conditions?`): `Promise`\<`void`\>
162
166
 
163
167
  Remove the entity.
164
168
 
165
169
  #### Parameters
166
170
 
167
- **id**: `string`
171
+ ##### id
172
+
173
+ `string`
168
174
 
169
175
  The id of the entity to remove.
170
176
 
171
- **conditions?**: `object`[]
177
+ ##### conditions?
178
+
179
+ `object`[]
172
180
 
173
181
  The optional conditions to match for the entities.
174
182
 
@@ -186,51 +194,49 @@ Nothing.
186
194
 
187
195
  ### query()
188
196
 
189
- > **query**(`conditions`?, `sortProperties`?, `properties`?, `cursor`?, `pageSize`?): `Promise`\<`object`\>
197
+ > **query**(`conditions?`, `sortProperties?`, `properties?`, `cursor?`, `pageSize?`): `Promise`\<\{ `entities`: `Partial`\<`T`\>[]; `cursor?`: `string`; \}\>
190
198
 
191
199
  Find all the entities which match the conditions.
192
200
 
193
201
  #### Parameters
194
202
 
195
- **conditions?**: `EntityCondition`\<`T`\>
203
+ ##### conditions?
204
+
205
+ `EntityCondition`\<`T`\>
196
206
 
197
207
  The conditions to match for the entities.
198
208
 
199
- **sortProperties?**: `object`[]
209
+ ##### sortProperties?
210
+
211
+ `object`[]
200
212
 
201
213
  The optional sort order.
202
214
 
203
- **properties?**: keyof `T`[]
215
+ ##### properties?
216
+
217
+ keyof `T`[]
204
218
 
205
219
  The optional properties to return, defaults to all.
206
220
 
207
- **cursor?**: `string`
221
+ ##### cursor?
222
+
223
+ `string`
208
224
 
209
225
  The cursor to request the next page of entities.
210
226
 
211
- **pageSize?**: `number`
227
+ ##### pageSize?
228
+
229
+ `number`
212
230
 
213
231
  The suggested number of entities to return in each chunk, in some scenarios can return a different amount.
214
232
 
215
233
  #### Returns
216
234
 
217
- `Promise`\<`object`\>
235
+ `Promise`\<\{ `entities`: `Partial`\<`T`\>[]; `cursor?`: `string`; \}\>
218
236
 
219
237
  All the entities for the storage matching the conditions,
220
238
  and a cursor which can be used to request more entities.
221
239
 
222
- ##### entities
223
-
224
- > **entities**: `Partial`\<`T`\>[]
225
-
226
- The entities, which can be partial if a limited keys list was provided.
227
-
228
- ##### cursor?
229
-
230
- > `optional` **cursor**: `string`
231
-
232
- An optional cursor, when defined can be used to call find to get more entities.
233
-
234
240
  #### Implementation of
235
241
 
236
242
  `IEntityStorageConnector.query`
@@ -7,3 +7,4 @@
7
7
  ## Interfaces
8
8
 
9
9
  - [IDynamoDbEntityStorageConnectorConfig](interfaces/IDynamoDbEntityStorageConnectorConfig.md)
10
+ - [IDynamoDbEntityStorageConnectorConstructorOptions](interfaces/IDynamoDbEntityStorageConnectorConstructorOptions.md)
@@ -0,0 +1,27 @@
1
+ # Interface: IDynamoDbEntityStorageConnectorConstructorOptions
2
+
3
+ Options for the Dynamo DB Entity Storage Connector constructor.
4
+
5
+ ## Properties
6
+
7
+ ### entitySchema
8
+
9
+ > **entitySchema**: `string`
10
+
11
+ The schema for the entity
12
+
13
+ ***
14
+
15
+ ### loggingConnectorType?
16
+
17
+ > `optional` **loggingConnectorType**: `string`
18
+
19
+ The type of logging connector to use, defaults to no logging.
20
+
21
+ ***
22
+
23
+ ### config
24
+
25
+ > **config**: [`IDynamoDbEntityStorageConnectorConfig`](IDynamoDbEntityStorageConnectorConfig.md)
26
+
27
+ The configuration for the connector.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/entity-storage-connector-dynamodb",
3
- "version": "0.0.1-next.9",
3
+ "version": "0.0.1",
4
4
  "description": "Entity Storage connector implementation using DynamoDb storage",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,25 +14,25 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@aws-sdk/client-dynamodb": "3.656",
18
- "@aws-sdk/lib-dynamodb": "3.656",
19
- "@aws-sdk/util-dynamodb": "3.656",
20
- "@twin.org/core": "next",
21
- "@twin.org/entity": "next",
22
- "@twin.org/entity-storage-models": "0.0.1-next.9",
23
- "@twin.org/logging-models": "next",
24
- "@twin.org/nameof": "next"
17
+ "@aws-sdk/client-dynamodb": "3.828",
18
+ "@aws-sdk/lib-dynamodb": "3.828",
19
+ "@aws-sdk/util-dynamodb": "3.828",
20
+ "@twin.org/core": "^0.0.1",
21
+ "@twin.org/entity": "^0.0.1",
22
+ "@twin.org/entity-storage-models": "^0.0.1",
23
+ "@twin.org/logging-models": "^0.0.1",
24
+ "@twin.org/nameof": "^0.0.1"
25
25
  },
26
26
  "main": "./dist/cjs/index.cjs",
27
27
  "module": "./dist/esm/index.mjs",
28
28
  "types": "./dist/types/index.d.ts",
29
29
  "exports": {
30
30
  ".": {
31
+ "types": "./dist/types/index.d.ts",
31
32
  "require": "./dist/cjs/index.cjs",
32
- "import": "./dist/esm/index.mjs",
33
- "types": "./dist/types/index.d.ts"
33
+ "import": "./dist/esm/index.mjs"
34
34
  },
35
- "./locales": "./locales"
35
+ "./locales/*.json": "./locales/*.json"
36
36
  },
37
37
  "files": [
38
38
  "dist/cjs",