idea-aws 4.4.5 → 4.4.6

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.
@@ -4,7 +4,7 @@ import { CognitoUser } from 'idea-toolbox';
4
4
  * A wrapper for AWS Cognito.
5
5
  */
6
6
  export declare class Cognito {
7
- protected cognito: CognitoIP.CognitoIdentityProviderClient;
7
+ client: CognitoIP.CognitoIdentityProviderClient;
8
8
  constructor(options?: {
9
9
  region?: string;
10
10
  });
@@ -31,7 +31,7 @@ const idea_toolbox_1 = require("idea-toolbox");
31
31
  */
32
32
  class Cognito {
33
33
  constructor(options = {}) {
34
- this.cognito = new CognitoIP.CognitoIdentityProviderClient({ region: options.region });
34
+ this.client = new CognitoIP.CognitoIdentityProviderClient({ region: options.region });
35
35
  }
36
36
  /**
37
37
  * Change the region in which to find the user pool.
@@ -39,7 +39,7 @@ class Cognito {
39
39
  */
40
40
  setRegion(region) {
41
41
  // there is no quick way to change the region without re-creating the object
42
- this.cognito = new CognitoIP.CognitoIdentityProviderClient({ region });
42
+ this.client = new CognitoIP.CognitoIdentityProviderClient({ region });
43
43
  }
44
44
  /**
45
45
  * Get the attributes of the user, from the authorizer claims.
@@ -79,7 +79,7 @@ class Cognito {
79
79
  async getUserByEmail(email, userPoolId) {
80
80
  const command = new CognitoIP.AdminGetUserCommand({ UserPoolId: userPoolId, Username: email });
81
81
  try {
82
- const user = await this.cognito.send(command);
82
+ const user = await this.client.send(command);
83
83
  return this.mapCognitoUserAttributesAsPlainObject(user);
84
84
  }
85
85
  catch (error) {
@@ -94,7 +94,7 @@ class Cognito {
94
94
  async getUserBySub(sub, userPoolId) {
95
95
  // as of today, there is no a direct way to find a user by its sub: we need to run a query against the users base
96
96
  const command = new CognitoIP.ListUsersCommand({ UserPoolId: userPoolId, Filter: `sub = "${sub}"`, Limit: 1 });
97
- const { Users } = await this.cognito.send(command);
97
+ const { Users } = await this.client.send(command);
98
98
  if (Users.length < 1)
99
99
  throw new Error('User not found');
100
100
  return this.mapCognitoUserAttributesAsPlainObject(Users[0]);
@@ -106,7 +106,7 @@ class Cognito {
106
106
  const params = { UserPoolId: userPoolId };
107
107
  if (options.pagination)
108
108
  params.PaginationToken = options.pagination;
109
- const { Users, PaginationToken: pagination } = await this.cognito.send(new CognitoIP.ListUsersCommand(params));
109
+ const { Users, PaginationToken: pagination } = await this.client.send(new CognitoIP.ListUsersCommand(params));
110
110
  const users = options.users.concat(Users.map(u => new idea_toolbox_1.CognitoUser(this.mapCognitoUserAttributesAsPlainObject(u))));
111
111
  if (pagination)
112
112
  return await this.listUsers(userPoolId, { pagination, users });
@@ -159,7 +159,7 @@ class Cognito {
159
159
  params.MessageAction = 'SUPPRESS';
160
160
  if (options.temporaryPassword)
161
161
  params.TemporaryPassword = options.temporaryPassword;
162
- const { User } = await this.cognito.send(new CognitoIP.AdminCreateUserCommand(params));
162
+ const { User } = await this.client.send(new CognitoIP.AdminCreateUserCommand(params));
163
163
  const userId = this.mapCognitoUserAttributesAsPlainObject(User).sub;
164
164
  if (!userId)
165
165
  throw new Error('Creation failed');
@@ -178,7 +178,7 @@ class Cognito {
178
178
  };
179
179
  if (options.temporaryPassword)
180
180
  params.TemporaryPassword = options.temporaryPassword;
181
- await this.cognito.send(new CognitoIP.AdminCreateUserCommand(params));
181
+ await this.client.send(new CognitoIP.AdminCreateUserCommand(params));
182
182
  }
183
183
  /**
184
184
  * Set a new password for a specific user identified by its email (admin-only).
@@ -198,7 +198,7 @@ class Cognito {
198
198
  Password: password,
199
199
  Permanent: options.permanent
200
200
  };
201
- await this.cognito.send(new CognitoIP.AdminSetUserPasswordCommand(params));
201
+ await this.client.send(new CognitoIP.AdminSetUserPasswordCommand(params));
202
202
  }
203
203
  /**
204
204
  * Delete a user by its email (username), in the pool specified.
@@ -207,7 +207,7 @@ class Cognito {
207
207
  if ((0, idea_toolbox_1.isEmpty)(email, 'email'))
208
208
  throw new Error('Invalid email');
209
209
  const command = new CognitoIP.AdminDeleteUserCommand({ UserPoolId: userPoolId, Username: email });
210
- await this.cognito.send(command);
210
+ await this.client.send(command);
211
211
  }
212
212
  //
213
213
  // USER
@@ -222,7 +222,7 @@ class Cognito {
222
222
  AuthFlow: 'ADMIN_NO_SRP_AUTH',
223
223
  AuthParameters: { USERNAME: email, PASSWORD: password }
224
224
  });
225
- const { AuthenticationResult } = await this.cognito.send(command);
225
+ const { AuthenticationResult } = await this.client.send(command);
226
226
  if (!AuthenticationResult)
227
227
  throw new Error('Sign-in failed');
228
228
  return AuthenticationResult;
@@ -237,7 +237,7 @@ class Cognito {
237
237
  AuthFlow: 'REFRESH_TOKEN_AUTH',
238
238
  AuthParameters: { USERNAME: email, REFRESH_TOKEN: refreshToken }
239
239
  });
240
- const { AuthenticationResult } = await this.cognito.send(command);
240
+ const { AuthenticationResult } = await this.client.send(command);
241
241
  if (!AuthenticationResult)
242
242
  throw new Error('Refresh failed');
243
243
  return AuthenticationResult;
@@ -256,7 +256,7 @@ class Cognito {
256
256
  { Name: 'email_verified', Value: 'true' }
257
257
  ]
258
258
  });
259
- await this.cognito.send(command);
259
+ await this.client.send(command);
260
260
  // sign out the user from all its devices and resolve
261
261
  await this.globalSignOut(newEmail, userPoolId);
262
262
  }
@@ -272,14 +272,14 @@ class Cognito {
272
272
  PreviousPassword: oldPassword,
273
273
  ProposedPassword: newPassword
274
274
  });
275
- await this.cognito.send(command);
275
+ await this.client.send(command);
276
276
  }
277
277
  /**
278
278
  * Send to a user the instructions to change the password.
279
279
  */
280
280
  async forgotPassword(email, userPoolClientId) {
281
281
  const command = new CognitoIP.ForgotPasswordCommand({ Username: email, ClientId: userPoolClientId });
282
- const { CodeDeliveryDetails } = await this.cognito.send(command);
282
+ const { CodeDeliveryDetails } = await this.client.send(command);
283
283
  return CodeDeliveryDetails;
284
284
  }
285
285
  /**
@@ -292,7 +292,7 @@ class Cognito {
292
292
  ConfirmationCode: confirmationCode,
293
293
  Password: newPassword
294
294
  });
295
- await this.cognito.send(command);
295
+ await this.client.send(command);
296
296
  }
297
297
  /**
298
298
  * Update a (Cognito)User's attributes, excluding the attributes that require specific methods.
@@ -311,14 +311,14 @@ class Cognito {
311
311
  Username: user.email,
312
312
  UserAttributes
313
313
  });
314
- await this.cognito.send(command);
314
+ await this.client.send(command);
315
315
  }
316
316
  /**
317
317
  * Sign out the user from all devices.
318
318
  */
319
319
  async globalSignOut(email, userPoolId) {
320
320
  const command = new CognitoIP.AdminUserGlobalSignOutCommand({ Username: email, UserPoolId: userPoolId });
321
- await this.cognito.send(command);
321
+ await this.client.send(command);
322
322
  }
323
323
  /**
324
324
  * Confirm and conclude a registration, usign a confirmation code.
@@ -335,7 +335,7 @@ class Cognito {
335
335
  ConfirmationCode: confirmationCode,
336
336
  ClientId: userPoolClientId
337
337
  });
338
- await this.cognito.send(command);
338
+ await this.client.send(command);
339
339
  }
340
340
  /**
341
341
  * List the groups of the user pool.
@@ -344,7 +344,7 @@ class Cognito {
344
344
  const params = { UserPoolId: userPoolId };
345
345
  if (options.pagination)
346
346
  params.NextToken = options.pagination;
347
- const res = await this.cognito.send(new CognitoIP.ListGroupsCommand(params));
347
+ const res = await this.client.send(new CognitoIP.ListGroupsCommand(params));
348
348
  const pagination = res.NextToken;
349
349
  const groups = options.groups.concat(res.Groups.map(g => ({ name: g.GroupName, description: g.Description })));
350
350
  if (pagination)
@@ -357,14 +357,14 @@ class Cognito {
357
357
  */
358
358
  async createGroup(groupName, userPoolId) {
359
359
  const command = new CognitoIP.CreateGroupCommand({ GroupName: groupName, UserPoolId: userPoolId });
360
- await this.cognito.send(command);
360
+ await this.client.send(command);
361
361
  }
362
362
  /**
363
363
  * Delete a group from the user pool.
364
364
  */
365
365
  async deleteGroup(groupName, userPoolId) {
366
366
  const command = new CognitoIP.DeleteGroupCommand({ GroupName: groupName, UserPoolId: userPoolId });
367
- await this.cognito.send(command);
367
+ await this.client.send(command);
368
368
  }
369
369
  /**
370
370
  * List the users part of a group in the user pool.
@@ -376,7 +376,7 @@ class Cognito {
376
376
  };
377
377
  if (options.pagination)
378
378
  params.NextToken = options.pagination;
379
- const res = await this.cognito.send(new CognitoIP.ListUsersInGroupCommand(params));
379
+ const res = await this.client.send(new CognitoIP.ListUsersInGroupCommand(params));
380
380
  const pagination = res.NextToken;
381
381
  const users = options.users.concat(res.Users.map(u => new idea_toolbox_1.CognitoUser(this.mapCognitoUserAttributesAsPlainObject(u))));
382
382
  if (pagination)
@@ -394,7 +394,7 @@ class Cognito {
394
394
  GroupName: group,
395
395
  Username: user.userId
396
396
  });
397
- await this.cognito.send(command);
397
+ await this.client.send(command);
398
398
  }
399
399
  /**
400
400
  * Remove a user (by email) from a group in the user pool.
@@ -406,7 +406,7 @@ class Cognito {
406
406
  GroupName: group,
407
407
  Username: user.userId
408
408
  });
409
- await this.cognito.send(command);
409
+ await this.client.send(command);
410
410
  }
411
411
  }
412
412
  exports.Cognito = Cognito;
@@ -4,7 +4,7 @@ import { Sentiment } from 'idea-toolbox';
4
4
  * A wrapper for Amazon Comprehend.
5
5
  */
6
6
  export declare class Comprehend {
7
- protected comprehend: AmazonComprehend.ComprehendClient;
7
+ client: AmazonComprehend.ComprehendClient;
8
8
  constructor(options?: {
9
9
  region?: string;
10
10
  });
@@ -30,7 +30,7 @@ const AmazonComprehend = __importStar(require("@aws-sdk/client-comprehend"));
30
30
  */
31
31
  class Comprehend {
32
32
  constructor(options = {}) {
33
- this.comprehend = new AmazonComprehend.ComprehendClient({ region: options.region });
33
+ this.client = new AmazonComprehend.ComprehendClient({ region: options.region });
34
34
  }
35
35
  /**
36
36
  * Inspects text and returns an inference of the prevailing sentiment (POSITIVE, NEUTRAL, MIXED, or NEGATIVE).
@@ -39,7 +39,7 @@ class Comprehend {
39
39
  if (!params.language || !params.text)
40
40
  throw new Error('Missing some parameters');
41
41
  const command = new AmazonComprehend.DetectSentimentCommand({ LanguageCode: params.language, Text: params.text });
42
- const { Sentiment } = await this.comprehend.send(command);
42
+ const { Sentiment } = await this.client.send(command);
43
43
  return Sentiment;
44
44
  }
45
45
  /**
@@ -49,7 +49,7 @@ class Comprehend {
49
49
  if (!params.text)
50
50
  throw new Error('Missing text');
51
51
  const command = new AmazonComprehend.DetectDominantLanguageCommand({ Text: params.text });
52
- const { Languages } = await this.comprehend.send(command);
52
+ const { Languages } = await this.client.send(command);
53
53
  if (!Languages.length)
54
54
  throw new Error('Not found');
55
55
  return Languages[0].LanguageCode;
@@ -5,7 +5,7 @@ import { LambdaLogger } from './lambdaLogger';
5
5
  * A wrapper for AWS DynamoDB.
6
6
  */
7
7
  export declare class DynamoDB {
8
- protected dynamo: DDB.DynamoDBDocument;
8
+ client: DDB.DynamoDBDocument;
9
9
  protected logger: LambdaLogger;
10
10
  constructor();
11
11
  /**
@@ -36,7 +36,7 @@ const lambdaLogger_1 = require("./lambdaLogger");
36
36
  class DynamoDB {
37
37
  constructor() {
38
38
  this.logger = new lambdaLogger_1.LambdaLogger();
39
- this.dynamo = DDB.DynamoDBDocument.from(new client_dynamodb_1.DynamoDB(), {
39
+ this.client = DDB.DynamoDBDocument.from(new client_dynamodb_1.DynamoDB(), {
40
40
  marshallOptions: { convertEmptyValues: true, removeUndefinedValues: true, convertClassInstanceToMap: true }
41
41
  });
42
42
  }
@@ -104,7 +104,7 @@ class DynamoDB {
104
104
  */
105
105
  async get(params) {
106
106
  this.logger.trace(`Get ${params.TableName}`);
107
- const { Item } = await this.dynamo.get(params);
107
+ const { Item } = await this.client.get(params);
108
108
  if (!Item)
109
109
  throw new Error('Not found');
110
110
  return Item;
@@ -115,7 +115,7 @@ class DynamoDB {
115
115
  */
116
116
  async put(params) {
117
117
  this.logger.trace(`Put ${params.TableName}`);
118
- return await this.dynamo.put(params);
118
+ return await this.client.put(params);
119
119
  }
120
120
  /**
121
121
  * Update an item of a DynamoDB table.
@@ -123,7 +123,7 @@ class DynamoDB {
123
123
  */
124
124
  async update(params) {
125
125
  this.logger.trace(`Update ${params.TableName}`);
126
- return await this.dynamo.update(params);
126
+ return await this.client.update(params);
127
127
  }
128
128
  /**
129
129
  * Delete an item of a DynamoDB table.
@@ -131,7 +131,7 @@ class DynamoDB {
131
131
  */
132
132
  async delete(params) {
133
133
  this.logger.trace(`Delete ${params.TableName}`);
134
- return await this.dynamo.delete(params);
134
+ return await this.client.delete(params);
135
135
  }
136
136
  /**
137
137
  * Get group of items based on their keys from DynamoDB table, avoiding the limits of DynamoDB's BatchGetItem.
@@ -155,7 +155,7 @@ class DynamoDB {
155
155
  this.logger.trace(`Batch get ${table}: ${currentChunk} of ${keys.length}`);
156
156
  let result;
157
157
  try {
158
- result = await this.dynamo.batchGet(batch);
158
+ result = await this.client.batchGet(batch);
159
159
  }
160
160
  catch (err) {
161
161
  if (!ignoreErr)
@@ -213,7 +213,7 @@ class DynamoDB {
213
213
  const wait = (seconds) => new Promise(x => setTimeout(() => x(), seconds * 1000));
214
214
  let attempts = 0;
215
215
  do {
216
- const response = await this.dynamo.batchWrite(params);
216
+ const response = await this.client.batchWrite(params);
217
217
  if (response.UnprocessedItems &&
218
218
  response.UnprocessedItems[table] &&
219
219
  response.UnprocessedItems[table].length > 0) {
@@ -251,9 +251,9 @@ class DynamoDB {
251
251
  async queryScanHelper(params, items, isQuery) {
252
252
  let result;
253
253
  if (isQuery)
254
- result = await this.dynamo.query(params);
254
+ result = await this.client.query(params);
255
255
  else
256
- result = await this.dynamo.scan(params);
256
+ result = await this.client.scan(params);
257
257
  items = items.concat(result.Items);
258
258
  if (result.LastEvaluatedKey) {
259
259
  params.ExclusiveStartKey = result.LastEvaluatedKey;
@@ -268,7 +268,7 @@ class DynamoDB {
268
268
  */
269
269
  async queryClassic(params) {
270
270
  this.logger.trace(`Query classic ${params.TableName}`);
271
- const result = await this.dynamo.query(params);
271
+ const result = await this.client.query(params);
272
272
  this.logger.trace(`Results query classic ${params.TableName}: ${result.Items.length ?? 0}`);
273
273
  return result;
274
274
  }
@@ -278,7 +278,7 @@ class DynamoDB {
278
278
  */
279
279
  async scanClassic(params) {
280
280
  this.logger.trace(`Scan classic ${params.TableName}`);
281
- const result = await this.dynamo.scan(params);
281
+ const result = await this.client.scan(params);
282
282
  this.logger.trace(`Results scan classic ${params.TableName}: ${result.Items.length ?? 0}`);
283
283
  return result;
284
284
  }
@@ -290,7 +290,7 @@ class DynamoDB {
290
290
  if (!ops.length)
291
291
  return this.logger.trace('Transaction writes: no elements to write');
292
292
  this.logger.trace('Transaction writes');
293
- await this.dynamo.transactWrite({ TransactItems: ops });
293
+ await this.client.transactWrite({ TransactItems: ops });
294
294
  }
295
295
  }
296
296
  exports.DynamoDB = DynamoDB;
package/dist/src/s3.d.ts CHANGED
@@ -6,7 +6,7 @@ import { LambdaLogger } from './lambdaLogger';
6
6
  * A wrapper for AWS Simple Storage Service.
7
7
  */
8
8
  export declare class S3 {
9
- protected s3: AWSS3.S3Client;
9
+ client: AWSS3.S3Client;
10
10
  protected logger: LambdaLogger;
11
11
  protected DEFAULT_DOWNLOAD_BUCKET_PREFIX: string;
12
12
  protected DEFAULT_DOWNLOAD_BUCKET: string;
package/dist/src/s3.js CHANGED
@@ -39,7 +39,7 @@ class S3 {
39
39
  this.DEFAULT_DOWNLOAD_BUCKET = 'idea-downloads';
40
40
  this.DEFAULT_DOWNLOAD_BUCKET_SEC_TO_EXP = 180;
41
41
  this.DEFAULT_UPLOAD_BUCKET_SEC_TO_EXP = 300;
42
- this.s3 = new AWSS3.S3Client();
42
+ this.client = new AWSS3.S3Client();
43
43
  }
44
44
  /**
45
45
  * Create a download link of a piece of data (through S3).
@@ -53,7 +53,7 @@ class S3 {
53
53
  options.bucket = options.bucket ?? this.DEFAULT_DOWNLOAD_BUCKET;
54
54
  options.secToExp = options.secToExp ?? this.DEFAULT_DOWNLOAD_BUCKET_SEC_TO_EXP;
55
55
  const params = { Bucket: options.bucket, Key: options.key, Body: data, ContentType: options.contentType };
56
- const upload = new lib_storage_1.Upload({ client: this.s3, params });
56
+ const upload = new lib_storage_1.Upload({ client: this.client, params });
57
57
  await upload.done();
58
58
  return this.signedURLGet(options.bucket, options.key, { secToExp: options.secToExp, filename: options.filename });
59
59
  }
@@ -65,7 +65,7 @@ class S3 {
65
65
  if (options.filename)
66
66
  putParams.ContentDisposition = `attachment; filename ="${(0, exports.cleanFilename)(options.filename)}"`;
67
67
  const expiresIn = options.secToExp ?? this.DEFAULT_UPLOAD_BUCKET_SEC_TO_EXP;
68
- const url = await (0, s3_request_presigner_1.getSignedUrl)(this.s3, new AWSS3.PutObjectCommand(putParams), { expiresIn });
68
+ const url = await (0, s3_request_presigner_1.getSignedUrl)(this.client, new AWSS3.PutObjectCommand(putParams), { expiresIn });
69
69
  return new idea_toolbox_1.SignedURL({ url });
70
70
  }
71
71
  /**
@@ -76,7 +76,7 @@ class S3 {
76
76
  if (options.filename)
77
77
  getParams.ResponseContentDisposition = `attachment; filename ="${(0, exports.cleanFilename)(options.filename)}"`;
78
78
  const expiresIn = options.secToExp ?? this.DEFAULT_DOWNLOAD_BUCKET_SEC_TO_EXP;
79
- const url = await (0, s3_request_presigner_1.getSignedUrl)(this.s3, new AWSS3.GetObjectCommand(getParams), { expiresIn });
79
+ const url = await (0, s3_request_presigner_1.getSignedUrl)(this.client, new AWSS3.GetObjectCommand(getParams), { expiresIn });
80
80
  return new idea_toolbox_1.SignedURL({ url });
81
81
  }
82
82
  /**
@@ -89,7 +89,7 @@ class S3 {
89
89
  Bucket: options.bucket,
90
90
  Key: options.key
91
91
  });
92
- await this.s3.send(command);
92
+ await this.client.send(command);
93
93
  }
94
94
  /**
95
95
  * Get an object from a S3 bucket.
@@ -100,7 +100,7 @@ class S3 {
100
100
  if (options.filename)
101
101
  params.ResponseContentDisposition = `attachment; filename ="${(0, exports.cleanFilename)(options.filename)}"`;
102
102
  const command = new AWSS3.GetObjectCommand(params);
103
- return await this.s3.send(command);
103
+ return await this.client.send(command);
104
104
  }
105
105
  /**
106
106
  * Get an object from a S3 bucket and parse the content as a JSON object.
@@ -130,7 +130,7 @@ class S3 {
130
130
  if (options.filename)
131
131
  params.ContentDisposition = `attachment; filename ="${(0, exports.cleanFilename)(options.filename)}"`;
132
132
  this.logger.trace(`S3 put object: ${options.key}`);
133
- return await this.s3.send(new AWSS3.PutObjectCommand(params));
133
+ return await this.client.send(new AWSS3.PutObjectCommand(params));
134
134
  }
135
135
  /**
136
136
  * Delete an object from an S3 bucket.
@@ -138,7 +138,7 @@ class S3 {
138
138
  async deleteObject(options) {
139
139
  this.logger.trace(`S3 delete object: ${options.key}`);
140
140
  const deleteCommand = new AWSS3.DeleteObjectCommand({ Bucket: options.bucket, Key: options.key });
141
- return await this.s3.send(deleteCommand);
141
+ return await this.client.send(deleteCommand);
142
142
  }
143
143
  /**
144
144
  * List the objects of an S3 bucket.
@@ -146,7 +146,7 @@ class S3 {
146
146
  async listObjects(options) {
147
147
  this.logger.trace(`S3 list object: ${options.prefix}`);
148
148
  const command = new AWSS3.ListObjectsCommand({ Bucket: options.bucket, Prefix: options.prefix });
149
- return await this.s3.send(command);
149
+ return await this.client.send(command);
150
150
  }
151
151
  /**
152
152
  * List the objects keys of an S3 bucket.
@@ -161,7 +161,7 @@ class S3 {
161
161
  async doesObjectExist(options) {
162
162
  try {
163
163
  const command = new AWSS3.HeadObjectCommand({ Bucket: options.bucket, Key: options.key });
164
- const { ContentLength } = await this.s3.send(command);
164
+ const { ContentLength } = await this.client.send(command);
165
165
  if (options.emptyMeansNotFound)
166
166
  return ContentLength > 0;
167
167
  else
@@ -3,7 +3,7 @@ import * as AWSSecretsManager from '@aws-sdk/client-secrets-manager';
3
3
  * A wrapper for AWS Secrets manager.
4
4
  */
5
5
  export declare class SecretsManager {
6
- protected sm: AWSSecretsManager.SecretsManagerClient;
6
+ client: AWSSecretsManager.SecretsManagerClient;
7
7
  protected cache: Map<string, string>;
8
8
  constructor();
9
9
  /**
@@ -31,7 +31,7 @@ const AWSSecretsManager = __importStar(require("@aws-sdk/client-secrets-manager"
31
31
  class SecretsManager {
32
32
  constructor() {
33
33
  this.cache = new Map();
34
- this.sm = new AWSSecretsManager.SecretsManagerClient();
34
+ this.client = new AWSSecretsManager.SecretsManagerClient();
35
35
  }
36
36
  /**
37
37
  * Get a secret string from the Secret Manager by its id.
@@ -40,7 +40,7 @@ class SecretsManager {
40
40
  if (!options.noCache && this.cache.has(secretId))
41
41
  return this.cache.get(secretId);
42
42
  const command = new AWSSecretsManager.GetSecretValueCommand({ SecretId: secretId });
43
- const { SecretString } = await this.sm.send(command);
43
+ const { SecretString } = await this.client.send(command);
44
44
  this.cache.set(secretId, SecretString);
45
45
  return SecretString;
46
46
  }
package/dist/src/ses.d.ts CHANGED
@@ -7,7 +7,7 @@ import { LambdaLogger } from './lambdaLogger';
7
7
  * A wrapper for AWS Simple Email Service.
8
8
  */
9
9
  export declare class SES {
10
- protected ses: AWSSES.SESv2Client;
10
+ client: AWSSES.SESv2Client;
11
11
  protected logger: LambdaLogger;
12
12
  constructor(options?: {
13
13
  region?: string;
package/dist/src/ses.js CHANGED
@@ -35,21 +35,21 @@ const lambdaLogger_1 = require("./lambdaLogger");
35
35
  class SES {
36
36
  constructor(options = {}) {
37
37
  this.logger = new lambdaLogger_1.LambdaLogger();
38
- this.ses = new AWSSES.SESv2Client({ region: options.region });
38
+ this.client = new AWSSES.SESv2Client({ region: options.region });
39
39
  }
40
40
  //
41
41
  // CONFIG
42
42
  //
43
43
  async getTemplate(templateName) {
44
44
  const command = new AWSSES.GetEmailTemplateCommand({ TemplateName: templateName });
45
- const { TemplateContent } = await this.ses.send(command);
45
+ const { TemplateContent } = await this.client.send(command);
46
46
  return TemplateContent;
47
47
  }
48
48
  async setTemplate(templateName, subject, content, isHTML) {
49
49
  let isNew = false;
50
50
  try {
51
51
  const command = new AWSSES.GetEmailTemplateCommand({ TemplateName: templateName });
52
- await this.ses.send(command);
52
+ await this.client.send(command);
53
53
  }
54
54
  catch (notFound) {
55
55
  isNew = true;
@@ -67,18 +67,18 @@ class SES {
67
67
  command = new AWSSES.CreateEmailTemplateCommand(template);
68
68
  else
69
69
  command = new AWSSES.UpdateEmailTemplateCommand(template);
70
- await this.ses.send(command);
70
+ await this.client.send(command);
71
71
  }
72
72
  async deleteTemplate(templateName) {
73
73
  const command = new AWSSES.DeleteEmailTemplateCommand({ TemplateName: templateName });
74
- await this.ses.send(command);
74
+ await this.client.send(command);
75
75
  }
76
76
  async testTemplate(templateName, data) {
77
77
  const command = new AWSSES.TestRenderEmailTemplateCommand({
78
78
  TemplateName: templateName,
79
79
  TemplateData: JSON.stringify(data)
80
80
  });
81
- const { RenderedTemplate } = await this.ses.send(command);
81
+ const { RenderedTemplate } = await this.client.send(command);
82
82
  return RenderedTemplate;
83
83
  }
84
84
  //
@@ -102,8 +102,8 @@ class SES {
102
102
  FromEmailAddressIdentityArn: sesParams.sourceArn
103
103
  });
104
104
  let ses;
105
- if (this.ses.config.region === sesParams.region)
106
- ses = this.ses;
105
+ if (this.client.config.region === sesParams.region)
106
+ ses = this.client;
107
107
  else
108
108
  ses = new AWSSES.SESv2Client({ region: sesParams.region });
109
109
  this.logger.trace('SES send templated email');
@@ -142,8 +142,8 @@ class SES {
142
142
  FromEmailAddressIdentityArn: sesParams.sourceArn
143
143
  });
144
144
  let ses;
145
- if (this.ses.config.region === sesParams.region)
146
- ses = this.ses;
145
+ if (this.client.config.region === sesParams.region)
146
+ ses = this.client;
147
147
  else
148
148
  ses = new AWSSES.SESv2Client({ region: sesParams.region });
149
149
  this.logger.trace('SES send email');
package/dist/src/sns.d.ts CHANGED
@@ -5,7 +5,7 @@ import { LambdaLogger } from './lambdaLogger';
5
5
  * A wrapper for AWS Simple Notification Service.
6
6
  */
7
7
  export declare class SNS {
8
- protected client: AWSSNS.SNSClient;
8
+ client: AWSSNS.SNSClient;
9
9
  protected logger: LambdaLogger;
10
10
  constructor(options?: {
11
11
  region?: string;
package/dist/src/ssm.d.ts CHANGED
@@ -3,7 +3,7 @@ import * as AWSSystemsManager from '@aws-sdk/client-ssm';
3
3
  * A wrapper for AWS Systems Manager (SSM).
4
4
  */
5
5
  export declare class SystemsManager {
6
- protected ssm: AWSSystemsManager.SSMClient;
6
+ client: AWSSystemsManager.SSMClient;
7
7
  protected cache: Map<string, string>;
8
8
  constructor();
9
9
  /**
package/dist/src/ssm.js CHANGED
@@ -31,7 +31,7 @@ const AWSSystemsManager = __importStar(require("@aws-sdk/client-ssm"));
31
31
  class SystemsManager {
32
32
  constructor() {
33
33
  this.cache = new Map();
34
- this.ssm = new AWSSystemsManager.SSMClient();
34
+ this.client = new AWSSystemsManager.SSMClient();
35
35
  }
36
36
  /**
37
37
  * Get a parameter by its name (path).
@@ -40,7 +40,7 @@ class SystemsManager {
40
40
  if (!options.noCache && this.cache.has(name))
41
41
  return this.cache.get(name);
42
42
  const command = new AWSSystemsManager.GetParameterCommand({ Name: name, WithDecryption: options.withDecryption });
43
- const { Parameter } = await this.ssm.send(command);
43
+ const { Parameter } = await this.client.send(command);
44
44
  this.cache.set(name, Parameter.Value);
45
45
  return Parameter.Value;
46
46
  }
@@ -4,7 +4,7 @@ import { Languages, PDFEntity, PDFTemplateSection } from 'idea-toolbox';
4
4
  * A wrapper for Amazon Translate.
5
5
  */
6
6
  export declare class Translate {
7
- protected translate: AWSTranslate.TranslateClient;
7
+ client: AWSTranslate.TranslateClient;
8
8
  /**
9
9
  * Default input language code.
10
10
  */
@@ -46,7 +46,7 @@ class Translate {
46
46
  * Default terminology list.
47
47
  */
48
48
  this.terminologyNames = [];
49
- this.translate = new AWSTranslate.TranslateClient({ region: options.region });
49
+ this.client = new AWSTranslate.TranslateClient({ region: options.region });
50
50
  }
51
51
  /**
52
52
  * Translates input text from the source language to the target language.
@@ -67,7 +67,7 @@ class Translate {
67
67
  TargetLanguageCode: this.targetLanguageCode,
68
68
  TerminologyNames: this.terminologyNames
69
69
  });
70
- const { TranslatedText } = await this.translate.send(command);
70
+ const { TranslatedText } = await this.client.send(command);
71
71
  return TranslatedText;
72
72
  }
73
73
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "idea-aws",
3
- "version": "4.4.5",
3
+ "version": "4.4.6",
4
4
  "description": "AWS wrappers to use in IDEA's back-ends",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",