aws-v3-sdk 2.0.1 → 2.0.2

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.
@@ -116,6 +116,18 @@ class DocumentClient {
116
116
  })
117
117
  }
118
118
 
119
+ transactWrite (params, callback) {
120
+ const docClient = DynamoDBDocument.from(new DynamoDB())
121
+ docClient.transactWrite(params, function (err, data) {
122
+ if (err) {
123
+ callback(err)
124
+ }
125
+ else {
126
+ callback(null, data)
127
+ }
128
+ })
129
+ }
130
+
119
131
  batchGet (params, callback) {
120
132
  const docClient = DynamoDBDocument.from(ddb)
121
133
 
@@ -321,6 +333,31 @@ class DocumentClient {
321
333
  return Promise.reject(error)
322
334
  })
323
335
  }
336
+
337
+ transactWriteAsync (params, callback) {
338
+ const docClient = DynamoDBDocument.from(new DynamoDB())
339
+ return new Promise((resolve, reject) => {
340
+ docClient.transactWrite(params, (err, response) => {
341
+ if (err || !response) {
342
+ return reject(err)
343
+ }
344
+ if (response) {
345
+ return resolve(response)
346
+ }
347
+ })
348
+ }).then(result => {
349
+ if (callback && typeof callback === 'function') {
350
+ callback(null, result)
351
+ }
352
+ return result
353
+ }).catch(error => {
354
+ if (callback && typeof callback === 'function') {
355
+ callback(error, null)
356
+ }
357
+ return Promise.reject(error)
358
+ })
359
+ }
324
360
  }
325
361
 
362
+
326
363
  module.exports = DocumentClient
package/clients/s3.js CHANGED
@@ -1,4 +1,4 @@
1
- const { S3Client, GetObjectCommand, PutObjectCommand, ListObjectsCommand, DeleteObjectsCommand, CreateMultipartUploadCommand, CompleteMultipartUploadCommand, UploadPartCommand } = require('@aws-sdk/client-s3')
1
+ const { S3Client, GetObjectCommand, PutObjectCommand, HeadObjectCommand, ListObjectsCommand, DeleteObjectsCommand, CreateMultipartUploadCommand, CompleteMultipartUploadCommand, UploadPartCommand } = require('@aws-sdk/client-s3')
2
2
  const { getSignedUrl } = require('@aws-sdk/s3-request-presigner')
3
3
 
4
4
  const { Agent } = require('https')
@@ -147,6 +147,30 @@ class S3 {
147
147
  return Promise.reject(error)
148
148
  })
149
149
  }
150
+
151
+ headObject (params, callback) {
152
+ return new Promise((resolve, reject) => {
153
+ const headObject = new HeadObjectCommand(params)
154
+ client.send(headObject, (err, data) => {
155
+ if (err || !data) {
156
+ resolve(err)
157
+ }
158
+ if (data) {
159
+ resolve(data)
160
+ }
161
+ })
162
+ }).then(result => {
163
+ if (callback && typeof callback === 'function') {
164
+ callback(null, result)
165
+ }
166
+ return result
167
+ }).catch(error => {
168
+ if (callback && typeof callback === 'function') {
169
+ callback(error, null)
170
+ }
171
+ return Promise.reject(error)
172
+ })
173
+ }
150
174
  }
151
175
 
152
176
  module.exports = S3
@@ -48,7 +48,7 @@ exports.sendAuditsReqToES = async (method, index, type, id, data) => {
48
48
  index,
49
49
  type,
50
50
  body: data,
51
- refresh: false
51
+ refresh: true
52
52
 
53
53
  })
54
54
  return response.body
@@ -28,8 +28,7 @@ const getClient = async () => {
28
28
  const cred = createAwsConnector(credentials, REGION)
29
29
  return new Client({
30
30
  ...cred,
31
- node: host,
32
- maxRetries: 0
31
+ node: host
33
32
  })
34
33
  }
35
34
 
@@ -40,8 +39,7 @@ exports.sendReqToES = async (method, index, type, id, data) => {
40
39
  const response = await client.delete({
41
40
  index,
42
41
  type,
43
- id,
44
- refresh: false
42
+ id
45
43
  })
46
44
  return response.body
47
45
  } else if (method === 'UPDATE') {
@@ -50,17 +48,7 @@ exports.sendReqToES = async (method, index, type, id, data) => {
50
48
  index,
51
49
  type,
52
50
  body: data,
53
- refresh: false,
54
- retry_on_conflict: 10
55
- })
56
- return response.body
57
- } else if (method === 'UPDATE_BY_QUERY') {
58
- const response = await client.updateByQuery({
59
- index,
60
- type,
61
- body: data,
62
- refresh: false,
63
- retry_on_conflict: 10
51
+ refresh: true
64
52
  })
65
53
  return response.body
66
54
  } else {
@@ -69,7 +57,7 @@ exports.sendReqToES = async (method, index, type, id, data) => {
69
57
  index,
70
58
  type,
71
59
  body: data,
72
- refresh: false
60
+ refresh: true
73
61
  })
74
62
  return response.body
75
63
  }
@@ -52,7 +52,7 @@ exports.sendGetRequest = async (index, query, from, size, sort, _source) => {
52
52
  options.size = size
53
53
  }
54
54
  if (_source) {
55
- options._source = _source
55
+ options._source = size
56
56
  }
57
57
  client.search(options).then(response => {
58
58
  logger.debug(response, { response })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aws-v3-sdk",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "AWS v3 SDK Utils",
5
5
  "main": "index.js",
6
6
  "scripts": {