1
1
const debug = require ( 'debug' ) ( 'cypress:binary' )
2
2
import la from 'lazy-ass'
3
3
import is from 'check-more-types'
4
- import { CopyObjectCommandInput , CopyObjectCommandOutput , ObjectCannedACL , S3 } from '@ aws-sdk/client- s3'
4
+ import S3 from 'aws-sdk/clients/ s3'
5
5
6
6
export const hasOnlyStringValues = ( o ) => {
7
7
return Object . values ( o ) . every ( ( v ) => is . unemptyString ( v ) )
@@ -22,11 +22,9 @@ export const s3helpers = {
22
22
}
23
23
24
24
return new S3 ( {
25
- credentials : {
26
- accessKeyId : aws . accessKeyId ,
27
- secretAccessKey : aws . secretAccessKey ,
28
- sessionToken : aws . sessionToken ,
29
- } ,
25
+ accessKeyId : aws . accessKeyId ,
26
+ secretAccessKey : aws . secretAccessKey ,
27
+ sessionToken : aws . sessionToken ,
30
28
} )
31
29
} ,
32
30
@@ -85,12 +83,12 @@ export const s3helpers = {
85
83
* and ACL 'public-read'
86
84
*/
87
85
copyS3 ( sourceKey : string , destinationKey : string , bucket : string ,
88
- contentType : string , acl : ObjectCannedACL ,
89
- s3 : S3 ) : Promise < CopyObjectCommandOutput > {
86
+ contentType : S3 . ContentType , acl : S3 . ObjectCannedACL ,
87
+ s3 : S3 ) : Promise < S3 . CopyObjectOutput > {
90
88
return new Promise ( ( resolve , reject ) => {
91
89
debug ( 'copying %s in bucket %s to %s' , sourceKey , bucket , destinationKey )
92
90
93
- const params : CopyObjectCommandInput = {
91
+ const params : S3 . CopyObjectRequest = {
94
92
Bucket : bucket ,
95
93
CopySource : `${ bucket } /${ sourceKey } ` ,
96
94
Key : destinationKey ,
@@ -118,7 +116,7 @@ export const s3helpers = {
118
116
* but the returned object has these prefixes stripped. Thus if we set
119
117
* a single "x-amz-meta-user: gleb", the resolved object will be simply {user: "gleb"}
120
118
*/
121
- getUserMetadata ( bucket : string , key : string , s3 : S3 ) : Promise < Record < string , string > > {
119
+ getUserMetadata ( bucket : string , key : string , s3 : S3 ) : Promise < S3 . Metadata > {
122
120
return new Promise ( ( resole , reject ) => {
123
121
debug ( 'getting user metadata from %s %s' , bucket , key )
124
122
@@ -141,15 +139,15 @@ export const s3helpers = {
141
139
* Setting user metadata can be accomplished with copying the object back onto itself
142
140
* with replaced metadata object.
143
141
*/
144
- setUserMetadata ( bucket : string , key : string , metadata : Record < string , string > ,
145
- contentType : string , acl : ObjectCannedACL , s3 : S3 ) : Promise < CopyObjectCommandOutput > {
142
+ setUserMetadata ( bucket : string , key : string , metadata : S3 . Metadata ,
143
+ contentType : S3 . ContentType , acl : S3 . ObjectCannedACL , s3 : S3 ) : Promise < S3 . CopyObjectOutput > {
146
144
la ( hasOnlyStringValues ( metadata ) ,
147
145
'metadata object can only have string values' , metadata )
148
146
149
147
return new Promise ( ( resolve , reject ) => {
150
148
debug ( 'setting metadata to %o for %s %s' , metadata , bucket , key )
151
149
152
- const params : CopyObjectCommandInput = {
150
+ const params : S3 . CopyObjectRequest = {
153
151
Bucket : bucket ,
154
152
CopySource : `${ bucket } /${ key } ` ,
155
153
Key : key ,
0 commit comments