Skip to content

Commit 1a0507a

Browse files
author
Michael Wittwer
committed
feat(aws-sdk-v3): [WIP] first compiling version
1 parent ca5f456 commit 1a0507a

34 files changed

+119
-169
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717
test:
1818
strategy:
1919
matrix:
20-
# Test with Node.js v16(maintenance), v18 (LTS) and v19 current
20+
# Test with Node.js v18 (LTS) and v19 current
2121
node:
22-
- 16
2322
- 18
23+
- 19
2424
name: Node.js v${{ matrix.node }}
2525
runs-on: ubuntu-latest
2626
steps:
@@ -49,7 +49,6 @@ jobs:
4949
- run: HUSKY=0 npm ci
5050
# Run tests
5151
- run: npm run test:ci
52-
5352
build:
5453
runs-on: ubuntu-latest
5554
steps:

src/aws-sdk-v2.types.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// tslint:disable:interface-over-type-literal
2+
/*
3+
* holds different types which are no longer available in aws-sdk v3, might be inlined at some point. Open to discuss.
4+
* TODO v3: discuss how to proceed
5+
*/
6+
import { AttributeValue, KeysAndAttributes, WriteRequest } from '@aws-sdk/client-dynamodb'
7+
export type BatchGetRequestMap = { [key: string]: KeysAndAttributes }
8+
export type BatchWriteItemRequestMap = { [key: string]: WriteRequest[] }
9+
10+
export type ExpressionAttributeNameMap = { [key: string]: string /* was: AttributeName */ }
11+
export type ExpressionAttributeValueMap = { [key: string]: AttributeValue /* was: AttributeValue */ }
12+
13+
export type Key = { [key: string]: AttributeValue }

src/config/config.type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface Config {
2424
tableNameResolver: TableNameResolver
2525
/**
2626
* function called before calling dynamoDB api
27+
* @deprecated v3: should be replaced by using the default middleware stack provided by aws-sdk v3
2728
*/
2829
sessionValidityEnsurer: SessionValidityEnsurer
2930
}

src/decorator/impl/index/gsi-partition-key.decorator.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* @module decorators
33
*/
4+
import { KeyType } from '@aws-sdk/client-dynamodb'
45
import { IndexType } from './index-type.enum'
56
import { initOrUpdateIndex } from './util'
67

@@ -10,7 +11,7 @@ import { initOrUpdateIndex } from './util'
1011
export function GSIPartitionKey(indexName: string): PropertyDecorator {
1112
return (target: any, propertyKey: string | symbol) => {
1213
if (typeof propertyKey === 'string') {
13-
initOrUpdateIndex(IndexType.GSI, { name: indexName, keyType: 'HASH' }, target, propertyKey)
14+
initOrUpdateIndex(IndexType.GSI, { name: indexName, keyType: KeyType.HASH }, target, propertyKey)
1415
}
1516
}
1617
}

src/decorator/impl/index/gsi-sort-key.decorator.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* @module decorators
33
*/
4+
import { KeyType } from '@aws-sdk/client-dynamodb'
45
import { IndexType } from './index-type.enum'
56
import { initOrUpdateIndex } from './util'
67

@@ -10,7 +11,7 @@ import { initOrUpdateIndex } from './util'
1011
export function GSISortKey(indexName: string): PropertyDecorator {
1112
return (target: any, propertyKey: string | symbol) => {
1213
if (typeof propertyKey === 'string') {
13-
initOrUpdateIndex(IndexType.GSI, { name: indexName, keyType: 'RANGE' }, target, propertyKey)
14+
initOrUpdateIndex(IndexType.GSI, { name: indexName, keyType: KeyType.RANGE }, target, propertyKey)
1415
}
1516
}
1617
}

src/decorator/impl/index/lsi-sort-key.decorator.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* @module decorators
33
*/
4+
import { KeyType } from '@aws-sdk/client-dynamodb'
45
import { IndexType } from './index-type.enum'
56
import { initOrUpdateIndex } from './util'
67

@@ -10,7 +11,7 @@ import { initOrUpdateIndex } from './util'
1011
export function LSISortKey(indexName: string): PropertyDecorator {
1112
return (target: any, propertyKey: string | symbol) => {
1213
if (typeof propertyKey === 'string') {
13-
initOrUpdateIndex(IndexType.LSI, { name: indexName, keyType: 'RANGE' }, target, propertyKey)
14+
initOrUpdateIndex(IndexType.LSI, { name: indexName, keyType: KeyType.RANGE }, target, propertyKey)
1415
}
1516
}
1617
}

src/decorator/impl/key/partition-key.decorator.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* @module decorators
33
*/
4+
import { KeyType } from '@aws-sdk/client-dynamodb'
45
import { createOptModelLogger } from '../../../logger/logger'
56
import { PropertyMetadata } from '../../metadata/property-metadata.model'
67
import { initOrUpdateProperty } from '../property/init-or-update-property.function'
@@ -31,7 +32,7 @@ export function PartitionKey(): PropertyDecorator {
3132
}
3233
}
3334

34-
initOrUpdateProperty({ key: { type: 'HASH' } }, target, propertyKey)
35+
initOrUpdateProperty({ key: { type: KeyType.HASH } }, target, propertyKey)
3536
}
3637
}
3738
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/**
22
* @module decorators
33
*/
4+
import { KeyType } from '@aws-sdk/client-dynamodb'
45
import { initOrUpdateProperty } from '../property/init-or-update-property.function'
56

67
export function SortKey(): PropertyDecorator {
78
return (target: any, propertyKey: string | symbol) => {
89
if (typeof propertyKey === 'string') {
9-
initOrUpdateProperty({ key: { type: 'RANGE' } }, target, propertyKey)
10+
initOrUpdateProperty({ key: { type: KeyType.RANGE } }, target, propertyKey)
1011
}
1112
}
1213
}

src/dynamo/batchget/batch-get-full.response.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
/**
22
* @module multi-model-requests/batch-get
33
*/
4-
5-
// tslint:disable-next-line:interface-over-type-literal
64
import * as DynamoDB from '@aws-sdk/client-dynamodb'
5+
import * as DynamoDBv2 from '../../aws-sdk-v2.types'
76
import { BatchGetResponse } from './batch-get.response'
87

98
/**
@@ -17,9 +16,9 @@ export interface BatchGetFullResponse {
1716
/**
1817
* A map of tables and their respective keys that were not processed with the current response. The UnprocessedKeys value is in the same form as RequestItems, so the value can be provided directly to a subsequent BatchGetItem operation. For more information, see RequestItems in the Request Parameters section. Each element consists of: Keys - An array of primary key attribute values that define specific items in the table. ProjectionExpression - One or more attributes to be retrieved from the table or index. By default, all attributes are returned. If a requested attribute is not found, it does not appear in the result. ConsistentRead - The consistency of a read operation. If set to true, then a strongly consistent read is used; otherwise, an eventually consistent read is used. If there are no unprocessed keys remaining, the response contains an empty UnprocessedKeys map.
1918
*/
20-
UnprocessedKeys?: DynamoDB.BatchGetRequestMap
19+
UnprocessedKeys?: DynamoDBv2.BatchGetRequestMap
2120
/**
2221
* The read capacity units consumed by the entire BatchGetItem operation. Each element consists of: TableName - The table that consumed the provisioned throughput. CapacityUnits - The total number of capacity units consumed.
2322
*/
24-
ConsumedCapacity?: DynamoDB.ConsumedCapacityMultiple
23+
ConsumedCapacity?: DynamoDB.ConsumedCapacity[]
2524
}

src/dynamo/batchget/batch-get-utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* @module multi-model-requests/batch-get
33
*/
44
import * as DynamoDB from '@aws-sdk/client-dynamodb'
5+
import * as DynamoDBv2 from '../../aws-sdk-v2.types'
56
import { promiseDelay } from '../../helper/promise-delay.function'
67
import { DynamoDbWrapper } from '../dynamo-db-wrapper'
78

@@ -44,7 +45,7 @@ export function batchGetItemsFetchAll(
4445
* @hidden
4546
*/
4647
export type BatchGetItemOutputWithUnprocessedKeys = DynamoDB.BatchGetItemOutput & {
47-
UnprocessedKeys: DynamoDB.BatchGetRequestMap
48+
UnprocessedKeys: DynamoDBv2.BatchGetRequestMap
4849
}
4950

5051
/**

0 commit comments

Comments
 (0)