@lafken/dynamo 0.12.29 → 0.13.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.
|
@@ -12,6 +12,7 @@ export declare class InternalTable extends InternalTable_base {
|
|
|
12
12
|
constructor(scope: Construct, props: InternalTableProps);
|
|
13
13
|
private static getAttributes;
|
|
14
14
|
private static getBillingModeProps;
|
|
15
|
+
private static toKeys;
|
|
15
16
|
private static getIndexes;
|
|
16
17
|
private createFilterCriteria;
|
|
17
18
|
private getKeyFilterCriteria;
|
|
@@ -13,7 +13,7 @@ const mapFieldType = {
|
|
|
13
13
|
class InternalTable extends resolver_1.lafkenResource.make(dynamodb_table_1.DynamodbTable) {
|
|
14
14
|
constructor(scope, props) {
|
|
15
15
|
const { modelProps, partitionKey: partitionKeyName, sortKey: sortKeyName, fields, } = (0, service_1.getModelInformation)(props.classResource);
|
|
16
|
-
const { globalIndexes, localIndexes, indexAttributes } = InternalTable.getIndexes(
|
|
16
|
+
const { globalIndexes, localIndexes, indexAttributes } = InternalTable.getIndexes(modelProps.indexes, sortKeyName);
|
|
17
17
|
const availableAttributes = new Set([...(indexAttributes || new Set())]);
|
|
18
18
|
availableAttributes.add(partitionKeyName.toString());
|
|
19
19
|
if (sortKeyName) {
|
|
@@ -124,7 +124,10 @@ class InternalTable extends resolver_1.lafkenResource.make(dynamodb_table_1.Dyna
|
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
static
|
|
127
|
+
static toKeys(key) {
|
|
128
|
+
return Array.isArray(key) ? key.map((k) => k.toString()) : [key.toString()];
|
|
129
|
+
}
|
|
130
|
+
static getIndexes(indexes = [], sortKeyName) {
|
|
128
131
|
if (indexes.length === 0) {
|
|
129
132
|
return {};
|
|
130
133
|
}
|
|
@@ -150,14 +153,39 @@ class InternalTable extends resolver_1.lafkenResource.make(dynamodb_table_1.Dyna
|
|
|
150
153
|
});
|
|
151
154
|
continue;
|
|
152
155
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
+
const partitionKeys = InternalTable.toKeys(index.partitionKey);
|
|
157
|
+
const sortKeys = index.sortKey ? InternalTable.toKeys(index.sortKey) : [];
|
|
158
|
+
for (const attribute of [...partitionKeys, ...sortKeys]) {
|
|
159
|
+
indexAttributes.add(attribute);
|
|
160
|
+
}
|
|
161
|
+
const isMultiAttribute = partitionKeys.length > 1 || sortKeys.length > 1;
|
|
162
|
+
if (isMultiAttribute) {
|
|
163
|
+
if (partitionKeys.length > 4 || sortKeys.length > 4) {
|
|
164
|
+
throw new Error(`A multi-attribute index supports up to 4 partition and 4 sort attributes. Check the index "${index.name}".`);
|
|
165
|
+
}
|
|
166
|
+
globalIndexes.push({
|
|
167
|
+
name: index.name,
|
|
168
|
+
keySchema: [
|
|
169
|
+
...partitionKeys.map((attributeName) => ({
|
|
170
|
+
attributeName,
|
|
171
|
+
keyType: 'HASH',
|
|
172
|
+
})),
|
|
173
|
+
...sortKeys.map((attributeName) => ({
|
|
174
|
+
attributeName,
|
|
175
|
+
keyType: 'RANGE',
|
|
176
|
+
})),
|
|
177
|
+
],
|
|
178
|
+
projectionType,
|
|
179
|
+
nonKeyAttributes,
|
|
180
|
+
readCapacity: index.readCapacity,
|
|
181
|
+
writeCapacity: index.writeCapacity,
|
|
182
|
+
});
|
|
183
|
+
continue;
|
|
156
184
|
}
|
|
157
185
|
globalIndexes.push({
|
|
158
186
|
name: index.name,
|
|
159
|
-
hashKey:
|
|
160
|
-
rangeKey:
|
|
187
|
+
hashKey: partitionKeys[0],
|
|
188
|
+
rangeKey: sortKeys[0],
|
|
161
189
|
projectionType,
|
|
162
190
|
nonKeyAttributes,
|
|
163
191
|
readCapacity: index.readCapacity,
|
|
@@ -18,5 +18,5 @@ export declare const filterResolver: {
|
|
|
18
18
|
in: (key: string, valueName: any, values: any[]) => ExpressionResolverResult;
|
|
19
19
|
notContains(key: string, valueName: string, value: any): ExpressionResolverResult;
|
|
20
20
|
};
|
|
21
|
-
export declare const notValueKeys: Set<"
|
|
21
|
+
export declare const notValueKeys: Set<"beginsWith" | "between" | "contains" | "equal" | "exist" | "greaterOrEqualThan" | "greaterThan" | "in" | "lessOrEqualThan" | "lessThan" | "notContains" | "notEqual" | "notExist">;
|
|
22
22
|
export declare const filterKeys: Set<string>;
|
|
@@ -14,6 +14,7 @@ class BatchWriteBuilder extends base_1.QueryBuilderBase {
|
|
|
14
14
|
getCommand() {
|
|
15
15
|
return this.commands;
|
|
16
16
|
}
|
|
17
|
+
// biome-ignore lint/suspicious/noConfusingVoidType: exec() resolves to void[] from Promise.all of void-returning commands
|
|
17
18
|
then(resolve, reject) {
|
|
18
19
|
return this.exec().then(resolve, reject);
|
|
19
20
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lafken/dynamo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Define DynamoDB tables using TypeScript decorators - type-safe, declarative infrastructure with Lafken",
|
|
6
6
|
"keywords": [
|
|
@@ -56,30 +56,30 @@
|
|
|
56
56
|
"lib"
|
|
57
57
|
],
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@aws-sdk/client-dynamodb": "^3.
|
|
60
|
-
"@aws-sdk/util-dynamodb": "^3.996.
|
|
59
|
+
"@aws-sdk/client-dynamodb": "^3.1090.0",
|
|
60
|
+
"@aws-sdk/util-dynamodb": "^3.996.7",
|
|
61
61
|
"reflect-metadata": "^0.2.2",
|
|
62
|
-
"@lafken/resolver": "0.
|
|
62
|
+
"@lafken/resolver": "0.13.1"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@cdktn/provider-aws": "^24.
|
|
66
|
-
"@swc/core": "^1.15.
|
|
65
|
+
"@cdktn/provider-aws": "^24.11.0",
|
|
66
|
+
"@swc/core": "^1.15.43",
|
|
67
67
|
"@swc/helpers": "^0.5.23",
|
|
68
|
-
"@vitest/runner": "^4.1.
|
|
68
|
+
"@vitest/runner": "^4.1.10",
|
|
69
69
|
"aws-sdk-client-mock": "^4.1.0",
|
|
70
|
-
"cdktn": "^0.23.
|
|
70
|
+
"cdktn": "^0.23.4",
|
|
71
71
|
"cdktn-vitest": "^1.0.0",
|
|
72
|
-
"constructs": "^10.
|
|
73
|
-
"typescript": "
|
|
72
|
+
"constructs": "^10.7.0",
|
|
73
|
+
"typescript": "7.0.2",
|
|
74
74
|
"unplugin-swc": "^1.5.9",
|
|
75
|
-
"vitest": "^4.1.
|
|
76
|
-
"@lafken/common": "0.
|
|
75
|
+
"vitest": "^4.1.10",
|
|
76
|
+
"@lafken/common": "0.13.1"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"@cdktn/provider-aws": ">=23.0.0",
|
|
80
80
|
"cdktn": ">=0.22.0",
|
|
81
81
|
"constructs": "^10.4.5",
|
|
82
|
-
"@lafken/common": "0.
|
|
82
|
+
"@lafken/common": "0.13.1"
|
|
83
83
|
},
|
|
84
84
|
"engines": {
|
|
85
85
|
"node": ">=20.19"
|