aws / aws-sdk-js-codemod

Codemod scripts to update AWS SDK for JavaScript APIs.
MIT No Attribution
73 stars 10 forks source link

[Feature]: Transform deep import of DocumentClient #799

Open trivikr opened 8 months ago

trivikr commented 8 months ago

Self-service

Problem

Transformation is not done for the following code:

import { DocumentClient } from 'aws-sdk/lib/dynamodb/document_client';

const client = new DocumentClient();

Solution

Transformed code

import { DynamoDBDocument } from '@aws-sdk/lib-dynamodb';
import { DynamoDB } from '@aws-sdk/client-dynamodb';

const client = DynamoDBDocument.from(new DynamoDB());

Alternatives

Skip the transformation, as deep import from aws-sdk/lib/* is not documented in public. The official documented deep import is aws-sdk/clients/*

Additional context

No response

trivikr commented 7 months ago

https://github.com/Budibase/budibase/blob/cb11a1609136ff8a165143fa97c6bb39cbdc17e8/packages/server/src/integrations/dynamodb.ts#L12