aws-v3-sdk 1.0.15 → 1.0.17

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/clients/all.js CHANGED
@@ -4,5 +4,7 @@ module.exports = {
4
4
  EnvironmentCredentials: require('./credential'),
5
5
  S3: require('./s3'),
6
6
  STS: require('./sts'),
7
+ SQS: require('./sqs'),
8
+ SNS: require('./sns'),
7
9
  CognitoIdentityServiceProvider: require('./cognito')
8
10
  }
@@ -1,4 +1,4 @@
1
- const { CognitoIdentityProviderClient, ListUsersCommand } = require('@aws-sdk/client-cognito-identity-provider')
1
+ const { CognitoIdentityProviderClient, ListUsersCommand, AdminCreateUserCommand, AdminEnableUserCommand, AdminDisableUserCommand, AdminSetUserMFAPreferenceCommand, AdminUserGlobalSignOutCommand, AdminDeleteUserCommand } = require('@aws-sdk/client-cognito-identity-provider')
2
2
 
3
3
  class CognitoIdentityServiceProvider {
4
4
  constructor (region) {
@@ -13,6 +13,62 @@ class CognitoIdentityServiceProvider {
13
13
  callback(err)
14
14
  })
15
15
  }
16
+
17
+ async adminCreateUser (params, callback) {
18
+ const command = new AdminCreateUserCommand(params);
19
+ this.client.send(command).then(data => {
20
+ callback(null, data)
21
+ }).catch(err => {
22
+ callback(err)
23
+ })
24
+ }
25
+
26
+ async adminSetUserMFAPreference (params, callback) {
27
+ const command = new AdminSetUserMFAPreferenceCommand(params);
28
+ this.client.send(command).then(data => {
29
+ callback(null, data)
30
+ }).catch(err => {
31
+ callback(err)
32
+ })
33
+ }
34
+
35
+ async adminDeleteUser (params, callback) {
36
+ const command = new AdminDeleteUserCommand(params);
37
+ this.client.send(command).then(data => {
38
+ callback(null, data)
39
+ }).catch(err => {
40
+ callback(err)
41
+ })
42
+ }
43
+
44
+ async adminEnableUser (params, callback) {
45
+ const command = new AdminEnableUserCommand(params);
46
+ this.client.send(command).then(data => {
47
+ callback(null, data)
48
+ }).catch(err => {
49
+ callback(err)
50
+ })
51
+ }
52
+
53
+
54
+ async adminDisableUser (params, callback) {
55
+ const command = new AdminDisableUserCommand(params);
56
+ this.client.send(command).then(data => {
57
+ callback(null, data)
58
+ }).catch(err => {
59
+ callback(err)
60
+ })
61
+ }
62
+
63
+ async adminUserGlobalSignOut (params, callback) {
64
+ const command = new AdminUserGlobalSignOutCommand(params);
65
+ this.client.send(command).then(data => {
66
+ callback(null, data)
67
+ }).catch(err => {
68
+ callback(err)
69
+ })
70
+ }
71
+
16
72
  }
17
73
 
18
74
  module.exports = CognitoIdentityServiceProvider
@@ -81,7 +81,12 @@ class DocumentClient {
81
81
  }
82
82
 
83
83
  update (params, callback) {
84
- const docClient = DynamoDBDocument.from(new DynamoDB())
84
+ const options = {
85
+ marshallOptions: {
86
+ removeUndefinedValues: true
87
+ }
88
+ }
89
+ const docClient = DynamoDBDocument.from(ddb, options)
85
90
  docClient.update(params, (err, response) => {
86
91
  if (err) {
87
92
  return callback(err)
package/clients/sns.js ADDED
@@ -0,0 +1,27 @@
1
+ const { SNSClient, PublishCommand } = require("@aws-sdk/client-sns");
2
+ const snsClient = new SNSClient({});
3
+
4
+ class SNS {
5
+ publish (params, callback) {
6
+ return new Promise((resolve, reject) => {
7
+ let publishCommand = new PublishCommand(params)
8
+ const response = snsClient.send(publishCommand).then(response=>{
9
+ resolve(response)
10
+ }).catch(err=>{
11
+ reject(err)
12
+ })
13
+ }).then(result => {
14
+ if (callback && typeof callback === 'function') {
15
+ callback(null, result)
16
+ }
17
+ return result
18
+ }).catch(error => {
19
+ if (callback && typeof callback === 'function') {
20
+ callback(error, null)
21
+ }
22
+ return Promise.reject(error)
23
+ })
24
+ }
25
+ }
26
+
27
+ module.exports = SNS
package/clients/sqs.js ADDED
@@ -0,0 +1,69 @@
1
+ const { SQSClient, ReceiveMessageCommand, DeleteMessageCommand, SendMessageCommand } = require("@aws-sdk/client-sqs");
2
+ const snsClient = new SQSClient();
3
+
4
+ class SQS {
5
+ sendMessage (params, callback) {
6
+ return new Promise((resolve, reject) => {
7
+ const command = new SendMessageCommand(params)
8
+ const response = snsClient.send(command).then(response=>{
9
+ resolve(response)
10
+ }).catch(err=>{
11
+ reject(err)
12
+ })
13
+ }).then(result => {
14
+ if (callback && typeof callback === 'function') {
15
+ callback(null, result)
16
+ }
17
+ return result
18
+ }).catch(error => {
19
+ if (callback && typeof callback === 'function') {
20
+ callback(error, null)
21
+ }
22
+ return Promise.reject(error)
23
+ })
24
+ }
25
+
26
+ receiveMessage (params, callback) {
27
+ return new Promise((resolve, reject) => {
28
+ const command = new ReceiveMessageCommand(params)
29
+ const response = snsClient.send(command).then(response=>{
30
+ resolve(response)
31
+ }).catch(err=>{
32
+ reject(err)
33
+ })
34
+ }).then(result => {
35
+ if (callback && typeof callback === 'function') {
36
+ callback(null, result)
37
+ }
38
+ return result
39
+ }).catch(error => {
40
+ if (callback && typeof callback === 'function') {
41
+ callback(error, null)
42
+ }
43
+ return Promise.reject(error)
44
+ })
45
+ }
46
+
47
+ deleteMessage (params, callback) {
48
+ return new Promise((resolve, reject) => {
49
+ const command = new DeleteMessageCommand(params)
50
+ const response = snsClient.send(command).then(response=>{
51
+ resolve(response)
52
+ }).catch(err=>{
53
+ reject(err)
54
+ })
55
+ }).then(result => {
56
+ if (callback && typeof callback === 'function') {
57
+ callback(null, result)
58
+ }
59
+ return result
60
+ }).catch(error => {
61
+ if (callback && typeof callback === 'function') {
62
+ callback(error, null)
63
+ }
64
+ return Promise.reject(error)
65
+ })
66
+ }
67
+ }
68
+
69
+ module.exports = SQS
@@ -1,9 +1,12 @@
1
- const { sendGetRequest } = require('./sendGetRequest')
1
+ const { sendGetRequest, sendGetRequestCallback, getCount, multiSearch } = require('./sendGetRequest')
2
2
  const { sendAuditsReqToES } = require('./es-audits-wrapper')
3
3
  const { sendReqToES } = require('./es-wrapper')
4
4
 
5
5
  module.exports = {
6
6
  sendGetRequest,
7
+ sendGetRequestCallback,
8
+ getCount,
9
+ multiSearch,
7
10
  sendReqToES,
8
11
  sendAuditsReqToES
9
12
  }
@@ -55,3 +55,62 @@ exports.sendGetRequest = async (index, query, from, size, sort, _source) => {
55
55
  })
56
56
  })
57
57
  }
58
+
59
+ exports.sendGetRequestCallback = async (index, query, from, size, sort, callback) => {
60
+ const client = await getClient()
61
+ return new Promise((resolve, reject) => {
62
+ let body = { query }
63
+ if (sort) {
64
+ body = { query, sort }
65
+ }
66
+ client.search({
67
+ index,
68
+ from,
69
+ size,
70
+ body
71
+ }).then(response => {
72
+ const data = response.body.hits.hits
73
+ const totalCount = response.body.hits.total
74
+ const mappedData = data.map(item => {
75
+ return item._source
76
+ })
77
+ callback(null, { items: mappedData, data: mappedData, totalCount })
78
+ }).catch(e => {
79
+ callback(null, { items: [], data: [], totalCount: 0 })
80
+ })
81
+ })
82
+ }
83
+
84
+ exports.getCount = async (index, query) => {
85
+ const client = await getClient()
86
+ return new Promise((resolve, reject) => {
87
+ client.count({
88
+ index,
89
+ body: { query }
90
+ }).then(response => {
91
+ const data = response.body
92
+ resolve({ data })
93
+ }).catch(e => {
94
+ console.log(e);
95
+ resolve({ })
96
+ })
97
+ })
98
+ }
99
+
100
+ exports.multiSearch = async (query) => {
101
+ const client = await getClient()
102
+ return new Promise((resolve, reject) => {
103
+ let body = query
104
+ client.msearch({
105
+ body
106
+ }).then(response => {
107
+ resolve(response);
108
+ }).catch(e => {
109
+ console.log(e);
110
+ resolve({ items: [], data: [], totalCount: 0 })
111
+ })
112
+ })
113
+ }
114
+
115
+
116
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aws-v3-sdk",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "AWS v3 SDK Utils",
5
5
  "main": "index.js",
6
6
  "scripts": {