@@ -16,13 +16,11 @@ import {
16
16
S3 ,
17
17
} from "../config" ;
18
18
import { getV3ClientTypes } from "../ts-type" ;
19
+ import { addNamedModule } from "./addNamedModule" ;
19
20
import { getClientTSTypeRefCount } from "./getClientTSTypeRefCount" ;
20
21
import { getNewExpressionCount } from "./getNewExpressionCount" ;
21
22
22
- import * as importEqualsModule from "./importEqualsModule" ;
23
- import * as importModule from "./importModule" ;
24
- import * as requireModule from "./requireModule" ;
25
- import { ClientModulesOptions , ImportType } from "./types" ;
23
+ import { ClientModulesOptions } from "./types" ;
26
24
27
25
export const addClientModules = (
28
26
j : JSCodeshift ,
@@ -38,13 +36,6 @@ export const addClientModules = (
38
36
importType,
39
37
} = options ;
40
38
41
- const { addNamedModule } =
42
- importType === ImportType . REQUIRE
43
- ? requireModule
44
- : importType === ImportType . IMPORT_EQUALS
45
- ? importEqualsModule
46
- : importModule ;
47
-
48
39
const v3ClientTypes = getV3ClientTypes ( j , source , options ) ;
49
40
const newExpressionCount = getNewExpressionCount ( j , source , options ) ;
50
41
const clientTSTypeRefCount = getClientTSTypeRefCount ( j , source , options ) ;
@@ -53,13 +44,15 @@ export const addClientModules = (
53
44
// Add named import for types, if needed.
54
45
for ( const v3ClientType of v3ClientTypes ) {
55
46
addNamedModule ( j , source , {
47
+ importType,
56
48
importedName : v3ClientType ,
57
49
packageName : v3ClientPackageName ,
58
50
} ) ;
59
51
}
60
52
61
53
if ( newExpressionCount > 0 || clientTSTypeRefCount > 0 ) {
62
54
addNamedModule ( j , source , {
55
+ importType,
63
56
importedName : v3ClientName ,
64
57
localName : v2ClientName === v2ClientLocalName ? v3ClientName : v2ClientLocalName ,
65
58
packageName : v3ClientPackageName ,
@@ -69,6 +62,7 @@ export const addClientModules = (
69
62
for ( const waiterState of waiterStates ) {
70
63
const v3WaiterApiName = getV3ClientWaiterApiName ( waiterState ) ;
71
64
addNamedModule ( j , source , {
65
+ importType,
72
66
importedName : v3WaiterApiName ,
73
67
packageName : v3ClientPackageName ,
74
68
} ) ;
@@ -77,18 +71,21 @@ export const addClientModules = (
77
71
if ( v2ClientName === S3 ) {
78
72
if ( isS3UploadApiUsed ( j , source , clientIdentifiers ) ) {
79
73
addNamedModule ( j , source , {
74
+ importType,
80
75
importedName : "Upload" ,
81
76
packageName : "@aws-sdk/lib-storage" ,
82
77
} ) ;
83
78
}
84
79
85
80
if ( isS3GetSignedUrlApiUsed ( j , source , clientIdentifiers ) ) {
86
81
addNamedModule ( j , source , {
82
+ importType,
87
83
importedName : "getSignedUrl" ,
88
84
packageName : "@aws-sdk/s3-request-presigner" ,
89
85
} ) ;
90
86
for ( const apiName of getS3SignedUrlApiNames ( j , source , clientIdentifiers ) ) {
91
87
addNamedModule ( j , source , {
88
+ importType,
92
89
importedName : getCommandName ( apiName ) ,
93
90
packageName : v3ClientPackageName ,
94
91
} ) ;
@@ -113,13 +110,15 @@ export const addClientModules = (
113
110
// Add named import for types, if needed.
114
111
for ( const docClientType of docClientTypes ) {
115
112
addNamedModule ( j , source , {
113
+ importType,
116
114
importedName : docClientType ,
117
115
packageName : "@aws-sdk/lib-dynamodb" ,
118
116
} ) ;
119
117
}
120
118
121
119
if ( docClientNewExpressionCount > 0 ) {
122
120
addNamedModule ( j , source , {
121
+ importType,
123
122
importedName : DYNAMODB_DOCUMENT ,
124
123
packageName : "@aws-sdk/lib-dynamodb" ,
125
124
} ) ;
0 commit comments