aws-v3-sdk 1.0.15 → 1.0.16

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.
@@ -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)
@@ -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.16",
4
4
  "description": "AWS v3 SDK Utils",
5
5
  "main": "index.js",
6
6
  "scripts": {