@resistdesign/voltra 3.0.0-alpha.53 → 3.0.0-alpha.54
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.
|
@@ -69,6 +69,10 @@ export type RetryStrategy = {
|
|
|
69
69
|
* DynamoDB client configuration subset for generated docs.
|
|
70
70
|
*/
|
|
71
71
|
export type DynamoDBSpecificConfig = {
|
|
72
|
+
/**
|
|
73
|
+
* When true, the first sort field is treated as the DynamoDB index name.
|
|
74
|
+
*/
|
|
75
|
+
useFirstSortFieldAsIndexName?: boolean;
|
|
72
76
|
/**
|
|
73
77
|
* Custom request handler override.
|
|
74
78
|
*/
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
* @packageDocumentation
|
|
3
3
|
*
|
|
4
4
|
* DynamoDB-backed data item driver for TypeInfo ORM. Supports CRUD and list
|
|
5
|
-
* operations using scans by default,
|
|
6
|
-
*
|
|
5
|
+
* operations using scans by default, with optional GSI-backed queries when the
|
|
6
|
+
* first sort field is configured to act as an index name.
|
|
7
7
|
*/
|
|
8
8
|
import { DataItemDBDriver, DataItemDBDriverConfig, SupportedDataItemDBDriverEntry } from "./common/Types";
|
|
9
9
|
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
|
|
10
10
|
import { TypeInfoDataItem } from "../../../common/TypeParsing/TypeInfo";
|
|
11
11
|
import { TypeInfoORMUpdateConfig } from "../../../common/TypeInfoORM";
|
|
12
12
|
import { ListItemsConfig, ListItemsResults } from "../../../common/SearchTypes";
|
|
13
|
+
import type { DynamoDBSpecificConfig } from "./DynamoDBDataItemDBDriver/ConfigTypes";
|
|
13
14
|
/**
|
|
14
15
|
* A {@link DataItemDBDriver} that uses DynamoDB as its database.
|
|
15
16
|
* */
|
|
@@ -19,6 +20,7 @@ export declare class DynamoDBDataItemDBDriver<ItemType extends TypeInfoDataItem,
|
|
|
19
20
|
*/
|
|
20
21
|
protected config: DataItemDBDriverConfig<ItemType, UniquelyIdentifyingFieldName>;
|
|
21
22
|
protected dynamoDBClient: DynamoDBClient;
|
|
23
|
+
protected specificConfig: DynamoDBSpecificConfig;
|
|
22
24
|
/**
|
|
23
25
|
* @param config Driver configuration including DynamoDB client settings.
|
|
24
26
|
*/
|
package/api/index.js
CHANGED
|
@@ -5429,6 +5429,13 @@ var ConfigTypeInfoMap_default2 = {
|
|
|
5429
5429
|
},
|
|
5430
5430
|
DynamoDBSpecificConfig: {
|
|
5431
5431
|
fields: {
|
|
5432
|
+
useFirstSortFieldAsIndexName: {
|
|
5433
|
+
type: "boolean",
|
|
5434
|
+
array: false,
|
|
5435
|
+
readonly: false,
|
|
5436
|
+
optional: true,
|
|
5437
|
+
tags: {}
|
|
5438
|
+
},
|
|
5432
5439
|
requestHandler: {
|
|
5433
5440
|
type: "string",
|
|
5434
5441
|
array: false,
|
|
@@ -5843,11 +5850,14 @@ var DynamoDBDataItemDBDriver = class {
|
|
|
5843
5850
|
constructor(config) {
|
|
5844
5851
|
this.config = config;
|
|
5845
5852
|
const { dbSpecificConfig } = config;
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5853
|
+
const { useFirstSortFieldAsIndexName, ...clientConfig } = dbSpecificConfig ?? {};
|
|
5854
|
+
this.specificConfig = {
|
|
5855
|
+
useFirstSortFieldAsIndexName
|
|
5856
|
+
};
|
|
5857
|
+
this.dynamoDBClient = new DynamoDBClient(clientConfig);
|
|
5849
5858
|
}
|
|
5850
5859
|
dynamoDBClient;
|
|
5860
|
+
specificConfig;
|
|
5851
5861
|
/**
|
|
5852
5862
|
* Create an item in the database.
|
|
5853
5863
|
* @returns Generated identifier for the created item.
|
|
@@ -5965,7 +5975,7 @@ var DynamoDBDataItemDBDriver = class {
|
|
|
5965
5975
|
ExpressionAttributeValues
|
|
5966
5976
|
} = createFilterExpression(fieldCriteria, logicalOperator);
|
|
5967
5977
|
const primarySortField = sortFields?.[0];
|
|
5968
|
-
const indexName = primarySortField?.field;
|
|
5978
|
+
const indexName = this.specificConfig.useFirstSortFieldAsIndexName ? primarySortField?.field : void 0;
|
|
5969
5979
|
const params = {
|
|
5970
5980
|
TableName: tableName,
|
|
5971
5981
|
Select: selectedFields && selectedFields.length > 0 ? "SPECIFIC_ATTRIBUTES" : "ALL_ATTRIBUTES",
|