shiftcode / dynamo-easy

DynamoDB client for NodeJS and browser with a fluent api to build requests. We take care of the type mapping between JS and DynamoDB, customizable trough typescript decorators.
https://shiftcode.github.io/dynamo-easy/
MIT License
207 stars 27 forks source link

feat(aws-sdk-v3): remove v2 types #422

Closed nduthoit closed 7 months ago

nduthoit commented 7 months ago

Addresses this TODO by using the built-in aws-sdk v3 types and removing the need for src/aws-sdk-v2.types.ts.

Type previous value replacement
BatchGetRequestMap { [key: string]: KeysAndAttributes } Record<string, KeysAndAttributes>
BatchWriteItemRequestMap { [key: string]: WriteRequest[] } Record<string, WriteRequest[]>
ExpressionAttributeNameMap { [key: string]: string } Record<string, string>
ExpressionAttributeValueMap { [key: string]: AttributeValue } Record<string, AttributeValue>
AttributeMap { [key: string]: AttributeValue } Record<string, AttributeValue>
Key { [key: string]: AttributeValue } Record<string, AttributeValue>

Also switches to using KeyType from @aws-sdk/client-dynamodb. Tested and it worked at runtime.

michaelwittwer commented 7 months ago

@nduthoit Wow, Thanks a lot for that contribution. This looks great and happy to hear that it worked by using the KeyType from @aws-sdk/client-dynamodb. I am still a little hesitant if we can take your verification as "it works everywhere", the last issue was reported here in a react context, this might behave differently depending on the build pipeline. I can't remember where I hit the issue. Added some minor comments, other than that this is ready to be merged.

nduthoit commented 7 months ago

@michaelwittwer yes, I hear you, "works on my machine" is not necessarily the best proof 😅

I tried replicating the reported issue with KeyType using @aws-sdk/client-dynamodb@v3.188.0 but was not able to.

michaelwittwer commented 7 months ago

@nduthoit Thanks for the update. Do you use any bundler or plain tsc and then run with node?

github-actions[bot] commented 7 months ago

:tada: This PR is included in version 8.0.0-next.4 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

michaelwittwer commented 7 months ago

@nduthoit I just tried to compile our Angular application using v3.188.0 and it fails with:

../../node_modules/@shiftcoders/dynamo-easy/dist/_esm2022/decorator/impl/key/partition-key.decorator.js:27:16-37 - Error: export 'KeyType' (imported as 'DynamoDB') was not found in '@aws-sdk/client-dynamodb' (possible exports: ArchivalSummaryFilterSensitiveLog, AttributeDefinitionFilterSensitiveLog, AttributeValue, AttributeValueFilterSensitiveLog, AttributeValueUpdateFilterSensitiveLog, AutoScalingPolicyDescriptionFilterSensitiveLog, AutoScalingPolicyUpdateFilterSensitiveLog, AutoScalingSettingsDescriptionFilterSensitiveLog, AutoScalingSettingsUpdateFilterSensitiveLog, AutoScalingTargetTrackingScalingPolicyConfigurationDescriptionFilterSensitiveLog, AutoScalingTargetTrackingScalingPolicyConfigurationUpdateFilterSensitiveLog, BackupDescriptionFilterSensitiveLog, BackupDetailsFilterSensitiveLog, BackupInUseException, BackupNotFoundException, BackupSummaryFilterSensitiveLog, BackupType, BackupTypeFilter, BatchExecuteStatementCommand, BatchExecuteStatementInputFilterSensitiveLog, BatchExecuteStatementOutputFilterSensitiveLog, BatchGetItemCommand, BatchGetItemInputFilterSensitiveLog, BatchGetItemOutputFilterSensitiveLog, BatchStatementErrorCodeEnum, BatchStatementErrorFilterSensitiveLog, BatchStatementRequestFilterSensitiveLog, BatchStatementResponseFilterSensitiveLog, BatchWriteItemCommand, BatchWriteItemInputFilterSensitiveLog, BatchWriteItemOutputFilterSensitiveLog, BillingModeSummaryFilterSensitiveLog, CancellationReasonFilterSensitiveLog, CapacityFilterSensitiveLog, ConditionCheckFilterSensitiveLog, ConditionFilterSensitiveLog, ConditionalCheckFailedException, ConsumedCapacityFilterSensitiveLog, ContinuousBackupsDescriptionFilterSensitiveLog, ContinuousBackupsUnavailableException, ContributorInsightsSummaryFilterSensitiveLog, CreateBackupCommand, CreateBackupInputFilterSensitiveLog, CreateBackupOutputFilterSensitiveLog, CreateGlobalSecondaryIndexActionFilterSensitiveLog, CreateGlobalTableCommand, CreateGlobalTableInputFilterSensitiveLog, CreateGlobalTableOutputFilterSensitiveLog, CreateReplicaActionFilterSensitiveLog, CreateReplicationGroupMemberActionFilterSensitiveLog, CreateTableCommand, CreateTableInputFilterSensitiveLog, CreateTableOutputFilterSensitiveLog, CsvOptionsFilterSensitiveLog, DeleteBackupCommand, DeleteBackupInputFilterSensitiveLog, DeleteBackupOutputFilterSensitiveLog, DeleteFilterSensitiveLog, DeleteGlobalSecondaryIndexActionFilterSensitiveLog, DeleteItemCommand, DeleteItemInputFilterSensitiveLog, DeleteItemOutputFilterSensitiveLog, DeleteReplicaActionFilterSensitiveLog, DeleteReplicationGroupMemberActionFilterSensitiveLog, DeleteRequestFilterSensitiveLog, DeleteTableCommand, DeleteTableInputFilterSensitiveLog, DeleteTableOutputFilterSensitiveLog, DescribeBackupCommand, DescribeBackupInputFilterSensitiveLog, DescribeBackupOutputFilterSensitiveLog, DescribeContinuousBackupsCommand, DescribeContinuousBackupsInputFilterSensitiveLog, DescribeContinuousBackupsOutputFilterSensitiveLog, DescribeContributorInsightsCommand, DescribeContributorInsightsInputFilterSensitiveLog, DescribeContributorInsightsOutputFilterSensitiveLog, DescribeEndpointsCommand, DescribeEndpointsRequestFilterSensitiveLog, DescribeEndpointsResponseFilterSensitiveLog, DescribeExportCommand, DescribeExportInputFilterSensitiveLog, DescribeExportOutputFilterSensitiveLog, DescribeGlobalTableCommand, DescribeGlobalTableInputFilterSensitiveLog, DescribeGlobalTableOutputFilterSensitiveLog, DescribeGlobalTableSettingsCommand, DescribeGlobalTableSettingsInputFilterSensitiveLog, DescribeGlobalTableSettingsOutputFilterSensitiveLog, DescribeImportCommand, DescribeImportInputFilterSensitiveLog, DescribeImportOutputFilterSensitiveLog, DescribeKinesisStreamingDestinationCommand, DescribeKinesisStreamingDestinationInputFilterSensitiveLog, DescribeKinesisStreamingDestinationOutputFilterSensitiveLog, DescribeLimitsCommand, DescribeLimitsInputFilterSensitiveLog, DescribeLimitsOutputFilterSensitiveLog, DescribeTableCommand, DescribeTableInputFilterSensitiveLog, DescribeTableOutputFilterSensitiveLog, DescribeTableReplicaAutoScalingCommand, DescribeTableReplicaAutoScalingInputFilterSensitiveLog, DescribeTableReplicaAutoScalingOutputFilterSensitiveLog, DescribeTimeToLiveCommand, DescribeTimeToLiveInputFilterSensitiveLog, DescribeTimeToLiveOutputFilterSensitiveLog, DisableKinesisStreamingDestinationCommand, DuplicateItemException, DynamoDB, DynamoDBClient, DynamoDBServiceException, EnableKinesisStreamingDestinationCommand, EndpointFilterSensitiveLog, ExecuteStatementCommand, ExecuteStatementInputFilterSensitiveLog, ExecuteStatementOutputFilterSensitiveLog, ExecuteTransactionCommand, ExecuteTransactionInputFilterSensitiveLog, ExecuteTransactionOutputFilterSensitiveLog, ExpectedAttributeValueFilterSensitiveLog, ExportConflictException, ExportDescriptionFilterSensitiveLog, ExportFormat, ExportNotFoundException, ExportStatus, ExportSummaryFilterSensitiveLog, ExportTableToPointInTimeCommand, ExportTableToPointInTimeInputFilterSensitiveLog, ExportTableToPointInTimeOutputFilterSensitiveLog, FailureExceptionFilterSensitiveLog, GetFilterSensitiveLog, GetItemCommand, GetItemInputFilterSensitiveLog, GetItemOutputFilterSensitiveLog, GlobalSecondaryIndexAutoScalingUpdateFilterSensitiveLog, GlobalSecondaryIndexDescriptionFilterSensitiveLog, GlobalSecondaryIndexFilterSensitiveLog, GlobalSecondaryIndexInfoFilterSensitiveLog, GlobalSecondaryIndexUpdateFilterSensitiveLog, GlobalTableAlreadyExistsException, GlobalTableDescriptionFilterSensitiveLog, GlobalTableFilterSensitiveLog, GlobalTableGlobalSecondaryIndexSettingsUpdateFilterSensitiveLog, GlobalTableNotFoundException, IdempotentParameterMismatchException, ImportConflictException, ImportNotFoundException, ImportStatus, ImportSummaryFilterSensitiveLog, ImportTableCommand, ImportTableDescriptionFilterSensitiveLog, ImportTableInputFilterSensitiveLog, ImportTableOutputFilterSensitiveLog, IndexNotFoundException, InputCompressionType, InputFormat, InputFormatOptionsFilterSensitiveLog, InternalServerError, InvalidEndpointException, InvalidExportTimeException, InvalidRestoreTimeException, ItemCollectionMetricsFilterSensitiveLog, ItemCollectionSizeLimitExceededException, ItemResponseFilterSensitiveLog, KeySchemaElementFilterSensitiveLog, KeysAndAttributesFilterSensitiveLog, KinesisDataStreamDestinationFilterSensitiveLog, KinesisStreamingDestinationInputFilterSensitiveLog, KinesisStreamingDestinationOutputFilterSensitiveLog, LimitExceededException, ListBackupsCommand, ListBackupsInputFilterSensitiveLog, ListBackupsOutputFilterSensitiveLog, ListContributorInsightsCommand, ListContributorInsightsInputFilterSensitiveLog, ListContributorInsightsOutputFilterSensitiveLog, ListExportsCommand, ListExportsInputFilterSensitiveLog, ListExportsOutputFilterSensitiveLog, ListGlobalTablesCommand, ListGlobalTablesInputFilterSensitiveLog, ListGlobalTablesOutputFilterSensitiveLog, ListImportsCommand, ListImportsInputFilterSensitiveLog, ListImportsOutputFilterSensitiveLog, ListTablesCommand, ListTablesInputFilterSensitiveLog, ListTablesOutputFilterSensitiveLog, ListTagsOfResourceCommand, ListTagsOfResourceInputFilterSensitiveLog, ListTagsOfResourceOutputFilterSensitiveLog, LocalSecondaryIndexDescriptionFilterSensitiveLog, LocalSecondaryIndexFilterSensitiveLog, LocalSecondaryIndexInfoFilterSensitiveLog, ParameterizedStatementFilterSensitiveLog, PointInTimeRecoveryDescriptionFilterSensitiveLog, PointInTimeRecoverySpecificationFilterSensitiveLog, PointInTimeRecoveryUnavailableException, ProjectionFilterSensitiveLog, ProvisionedThroughputDescriptionFilterSensitiveLog, ProvisionedThroughputExceededException, ProvisionedThroughputFilterSensitiveLog, ProvisionedThroughputOverrideFilterSensitiveLog, PutFilterSensitiveLog, PutItemCommand, PutItemInputFilterSensitiveLog, PutItemOutputFilterSensitiveLog, PutRequestFilterSensitiveLog, QueryCommand, QueryInputFilterSensitiveLog, QueryOutputFilterSensitiveLog, ReplicaAlreadyExistsException, ReplicaAutoScalingDescriptionFilterSensitiveLog, ReplicaAutoScalingUpdateFilterSensitiveLog, ReplicaDescriptionFilterSensitiveLog, ReplicaFilterSensitiveLog, ReplicaGlobalSecondaryIndexAutoScalingDescriptionFilterSensitiveLog, ReplicaGlobalSecondaryIndexAutoScalingUpdateFilterSensitiveLog, ReplicaGlobalSecondaryIndexDescriptionFilterSensitiveLog, ReplicaGlobalSecondaryIndexFilterSensitiveLog, ReplicaGlobalSecondaryIndexSettingsDescriptionFilterSensitiveLog, ReplicaGlobalSecondaryIndexSettingsUpdateFilterSensitiveLog, ReplicaNotFoundException, ReplicaSettingsDescriptionFilterSensitiveLog, ReplicaSettingsUpdateFilterSensitiveLog, ReplicaUpdateFilterSensitiveLog, ReplicationGroupUpdateFilterSensitiveLog, RequestLimitExceeded, ResourceInUseException, ResourceNotFoundException, RestoreSummaryFilterSensitiveLog, RestoreTableFromBackupCommand, RestoreTableFromBackupInputFilterSensitiveLog, RestoreTableFromBackupOutputFilterSensitiveLog, RestoreTableToPointInTimeCommand, RestoreTableToPointInTimeInputFilterSensitiveLog, RestoreTableToPointInTimeOutputFilterSensitiveLog, S3BucketSourceFilterSensitiveLog, SSEDescriptionFilterSensitiveLog, SSESpecificationFilterSensitiveLog, ScanCommand, ScanInputFilterSensitiveLog, ScanOutputFilterSensitiveLog, SourceTableDetailsFilterSensitiveLog, SourceTableFeatureDetailsFilterSensitiveLog, StreamSpecificationFilterSensitiveLog, TableAlreadyExistsException, TableAutoScalingDescriptionFilterSensitiveLog, TableClass, TableClassSummaryFilterSensitiveLog, TableCreationParametersFilterSensitiveLog, TableDescriptionFilterSensitiveLog, TableInUseException, TableNotFoundException, TagFilterSensitiveLog, TagResourceCommand, TagResourceInputFilterSensitiveLog, TimeToLiveDescriptionFilterSensitiveLog, TimeToLiveSpecificationFilterSensitiveLog, TransactGetItemFilterSensitiveLog, TransactGetItemsCommand, TransactGetItemsInputFilterSensitiveLog, TransactGetItemsOutputFilterSensitiveLog, TransactWriteItemFilterSensitiveLog, TransactWriteItemsCommand, TransactWriteItemsInputFilterSensitiveLog, TransactWriteItemsOutputFilterSensitiveLog, TransactionCanceledException, TransactionConflictException, TransactionInProgressException, UntagResourceCommand, UntagResourceInputFilterSensitiveLog, UpdateContinuousBackupsCommand, UpdateContinuousBackupsInputFilterSensitiveLog, UpdateContinuousBackupsOutputFilterSensitiveLog, UpdateContributorInsightsCommand, UpdateContributorInsightsInputFilterSensitiveLog, UpdateContributorInsightsOutputFilterSensitiveLog, UpdateFilterSensitiveLog, UpdateGlobalSecondaryIndexActionFilterSensitiveLog, UpdateGlobalTableCommand, UpdateGlobalTableInputFilterSensitiveLog, UpdateGlobalTableOutputFilterSensitiveLog, UpdateGlobalTableSettingsCommand, UpdateGlobalTableSettingsInputFilterSensitiveLog, UpdateGlobalTableSettingsOutputFilterSensitiveLog, UpdateItemCommand, UpdateItemInputFilterSensitiveLog, UpdateItemOutputFilterSensitiveLog, UpdateReplicationGroupMemberActionFilterSensitiveLog, UpdateTableCommand, UpdateTableInputFilterSensitiveLog, UpdateTableOutputFilterSensitiveLog, UpdateTableReplicaAutoScalingCommand, UpdateTableReplicaAutoScalingInputFilterSensitiveLog, UpdateTableReplicaAutoScalingOutputFilterSensitiveLog, UpdateTimeToLiveCommand, UpdateTimeToLiveInputFilterSensitiveLog, UpdateTimeToLiveOutputFilterSensitiveLog, WriteRequestFilterSensitiveLog, paginateListContributorInsights, paginateListExports, paginateListImports, paginateListTables, paginateQuery, paginateScan, waitForTableExists, waitForTableNotExists, waitUntilTableExists, waitUntilTableNotExists)

I see the issue going away starting with version 3.214.0 (was fun to try and error 🙈 ), will push an updated version range.

nduthoit commented 7 months ago

@nduthoit Thanks for the update. Do you use any bundler or plain tsc and then run with node?

We use webpack

Nice find on the version that includes the KeyType export!