aws-v3-sdk 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +138 -2
- package/clients/all.js +2 -1
- package/clients/cloudfront.js +28 -0
- package/clients/dynamo/DocumentClient.js +4 -1
- package/clients/lambda.js +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,2 +1,138 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# AWS SDK for JavaScript
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/aws-v3-sdk)
|
|
4
|
+
[](https://www.npmjs.com/package/aws-v3-sdk)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## Version 3.x
|
|
8
|
+
|
|
9
|
+
This package can be used to migrate to AWS SDK v3 from AWS SDK v2 without much change in exisint codebase.
|
|
10
|
+
This package takes the exisint AWS SDK v2 format and convert it to the AWS SDK v3 format.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
AWS SDK V2
|
|
14
|
+
```js
|
|
15
|
+
const AWS = require('aws-sdk')
|
|
16
|
+
const docClient = new AWS.DynamoDB.DocumentClient()
|
|
17
|
+
let params = {
|
|
18
|
+
TableName: TABLE_NAME,
|
|
19
|
+
Key: {
|
|
20
|
+
'id': ID
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
docClient.get(params, function (err, data) {
|
|
24
|
+
console.log(data.Item)
|
|
25
|
+
})
|
|
26
|
+
```
|
|
27
|
+
AWS SDK V3
|
|
28
|
+
```js
|
|
29
|
+
const AWS = require('aws-v3-sdk')
|
|
30
|
+
const docClient = new AWS.DynamoDB.DocumentClient()
|
|
31
|
+
let params = {
|
|
32
|
+
TableName: TABLE_NAME,
|
|
33
|
+
Key: {
|
|
34
|
+
'id': ID
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
docClient.get(params, function (err, data) {
|
|
38
|
+
console.log(data.Item)
|
|
39
|
+
})
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Table of Contents:
|
|
43
|
+
* [Supported Function](#supported-function)
|
|
44
|
+
* [Getting Started](#getting-Started)
|
|
45
|
+
* [Getting Help](#getting-help)
|
|
46
|
+
* [Contributing](#contributing)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## Supported Functions
|
|
50
|
+
|
|
51
|
+
1. Dynamo DB
|
|
52
|
+
2. Lambda
|
|
53
|
+
3. OpenSearch
|
|
54
|
+
4. Cognito
|
|
55
|
+
5. S3
|
|
56
|
+
6. SNS
|
|
57
|
+
7. SQS
|
|
58
|
+
8. STS
|
|
59
|
+
9. Cognito
|
|
60
|
+
|
|
61
|
+
## Getting Started
|
|
62
|
+
|
|
63
|
+
## How To Install
|
|
64
|
+
|
|
65
|
+
### In Node.js
|
|
66
|
+
|
|
67
|
+
The preferred way to install the AWS SDK for Node.js is to use the
|
|
68
|
+
[npm](http://npmjs.org) package manager for Node.js. Simply type the following
|
|
69
|
+
into a terminal window:
|
|
70
|
+
|
|
71
|
+
```sh
|
|
72
|
+
npm install aws-v3-sdk
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Then within your application, you can reference the react native compatible version of the SDK with the following:
|
|
76
|
+
We can use the old SDK format without migrating the code base. Just update the AWS import.
|
|
77
|
+
|
|
78
|
+
```javascript
|
|
79
|
+
const AWS = require('aws-v3-sdk')
|
|
80
|
+
|
|
81
|
+
const s3 = new AWS.S3()
|
|
82
|
+
|
|
83
|
+
const params = {
|
|
84
|
+
Bucket: <BUCKET NAME>,
|
|
85
|
+
Key: <FILE KEY>,
|
|
86
|
+
Body: <STRING DATA,
|
|
87
|
+
ContentType: 'text/json'
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
s3.putObject(params, (err, data) => {
|
|
92
|
+
if (err) {
|
|
93
|
+
< DO Stuff HERE >
|
|
94
|
+
} else {
|
|
95
|
+
< DO Stuff HERE >
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
### Supported Functions
|
|
103
|
+
|
|
104
|
+
**Dynamo DB**
|
|
105
|
+
get
|
|
106
|
+
query
|
|
107
|
+
scan
|
|
108
|
+
put
|
|
109
|
+
delete
|
|
110
|
+
update
|
|
111
|
+
batchWrite
|
|
112
|
+
transactWrite
|
|
113
|
+
batchGet
|
|
114
|
+
|
|
115
|
+
S3
|
|
116
|
+
getSignedUrl
|
|
117
|
+
getObject
|
|
118
|
+
putObject
|
|
119
|
+
headObject
|
|
120
|
+
createMultipartUpload
|
|
121
|
+
completeMultipartUpload
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
### Known Limitations
|
|
126
|
+
There are a few known limitations.
|
|
127
|
+
|
|
128
|
+
* This package has not been updated to handle all the AWS SDK APIs.
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
# Contributing
|
|
132
|
+
We welcome community contributions and pull requests. See [CONTRIBUTING.md](https://github.com/aws/aws-sdk-js/blob/master/CONTRIBUTING.md) for information on how to set up a development environment and submit code.
|
|
133
|
+
|
|
134
|
+
## License
|
|
135
|
+
|
|
136
|
+
This SDK is distributed under the
|
|
137
|
+
[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0),
|
|
138
|
+
see LICENSE.txt and NOTICE.txt for more information.
|
package/clients/all.js
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const { CloudFrontClient, CreateInvalidationCommand } = require('@aws-sdk/client-cloudfront') // CommonJS import
|
|
2
|
+
|
|
3
|
+
class Cloudfront {
|
|
4
|
+
constructor (region) {
|
|
5
|
+
this.client = new CloudFrontClient()
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
async invalidate (params, callback) {
|
|
9
|
+
const input = {
|
|
10
|
+
DistributionId: params.DistributionId, // required
|
|
11
|
+
InvalidationBatch: {
|
|
12
|
+
Paths: {
|
|
13
|
+
Quantity: params.Paths.length,
|
|
14
|
+
Items: params.Paths
|
|
15
|
+
},
|
|
16
|
+
CallerReference: new Date().getTime()
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const command = new CreateInvalidationCommand(input)
|
|
20
|
+
this.client.send(command).then(data => {
|
|
21
|
+
callback(null, data)
|
|
22
|
+
}).catch(err => {
|
|
23
|
+
callback(err)
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = Cloudfront
|
|
@@ -6,7 +6,10 @@ const { NodeHttpHandler } = require('@aws-sdk/node-http-handler')
|
|
|
6
6
|
|
|
7
7
|
const ddb = new DynamoDBClient({
|
|
8
8
|
requestHandler: new NodeHttpHandler({
|
|
9
|
-
httpsAgent: new Agent({
|
|
9
|
+
httpsAgent: new Agent({
|
|
10
|
+
keepAlive: false,
|
|
11
|
+
maxSockets: 50
|
|
12
|
+
})
|
|
10
13
|
})
|
|
11
14
|
})
|
|
12
15
|
|
package/clients/lambda.js
CHANGED
|
@@ -5,7 +5,10 @@ const { Agent } = require('https')
|
|
|
5
5
|
const { NodeHttpHandler } = require('@aws-sdk/node-http-handler')
|
|
6
6
|
|
|
7
7
|
const keepAliveOptions = new NodeHttpHandler({
|
|
8
|
-
httpsAgent: new Agent({
|
|
8
|
+
httpsAgent: new Agent({
|
|
9
|
+
keepAlive: false,
|
|
10
|
+
maxSockets: 50
|
|
11
|
+
})
|
|
9
12
|
})
|
|
10
13
|
|
|
11
14
|
class Lambda {
|