idea-aws 4.4.20 → 4.5.0

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.
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.Cognito = void 0;
27
37
  const CognitoIP = __importStar(require("@aws-sdk/client-cognito-identity-provider"));
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.Comprehend = void 0;
27
37
  const AmazonComprehend = __importStar(require("@aws-sdk/client-comprehend"));
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.DynamoDB = void 0;
27
37
  const DDB = __importStar(require("@aws-sdk/lib-dynamodb"));
@@ -75,7 +85,7 @@ class DynamoDB {
75
85
  });
76
86
  return result;
77
87
  }
78
- catch (err) {
88
+ catch (_) {
79
89
  // ID exists, try again
80
90
  await this.IUNIDHelper(project, attempt + 1, maxAttempts);
81
91
  }
@@ -5,22 +5,20 @@ import { LambdaLogger } from './lambdaLogger';
5
5
  */
6
6
  export declare abstract class GenericController {
7
7
  protected event: any;
8
- protected callback: any;
9
8
  protected logger: LambdaLogger;
10
9
  /**
11
10
  * Initialize a new GenericController helper object.
12
11
  * @param event the event that invoked the AWS lambda function
13
- * @param callback the callback to resolve or reject the execution
14
12
  */
15
- constructor(event: any, callback: any);
13
+ constructor(event: any);
16
14
  /**
17
15
  * The main function (to override), that handles the request and must terminate invoking the method `done`.
18
16
  */
19
- handleRequest(): Promise<void>;
17
+ handleRequest(): Promise<any>;
20
18
  /**
21
- * Default callback for the Lambda.
19
+ * Default ending function for the Lambda.
22
20
  */
23
- protected done(error?: Error | any, res?: any): void;
21
+ protected done(error?: Error | any, res?: any): any;
24
22
  /**
25
23
  * Remap an error to manage the logging and make sure no unhandled error is returned to the requester.
26
24
  */
@@ -10,22 +10,20 @@ class GenericController {
10
10
  /**
11
11
  * Initialize a new GenericController helper object.
12
12
  * @param event the event that invoked the AWS lambda function
13
- * @param callback the callback to resolve or reject the execution
14
13
  */
15
- constructor(event, callback) {
14
+ constructor(event) {
16
15
  this.logger = new lambdaLogger_1.LambdaLogger();
17
16
  this.event = event;
18
- this.callback = callback;
19
17
  }
20
18
  /**
21
19
  * The main function (to override), that handles the request and must terminate invoking the method `done`.
22
20
  */
23
21
  async handleRequest() {
24
22
  this.logger.info('START');
25
- this.done();
23
+ return this.done();
26
24
  }
27
25
  /**
28
- * Default callback for the Lambda.
26
+ * Default ending function for the Lambda.
29
27
  */
30
28
  done(error = null, res) {
31
29
  if (error) {
@@ -33,10 +31,12 @@ class GenericController {
33
31
  this.logger.error('END-FAILED', error);
34
32
  else
35
33
  this.logger.warn('END-FAILED', error);
34
+ throw error;
36
35
  }
37
- else
36
+ else {
38
37
  this.logger.info('END-SUCCESS');
39
- this.callback(error, res);
38
+ return res;
39
+ }
40
40
  }
41
41
  /**
42
42
  * Remap an error to manage the logging and make sure no unhandled error is returned to the requester.
@@ -1,4 +1,4 @@
1
- import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
1
+ import { Metrics } from '@aws-lambda-powertools/metrics';
2
2
  /**
3
3
  * A wrapper for simple uses of CloudWatch Metrics.
4
4
  */
@@ -14,7 +14,7 @@ export declare class CloudWatchMetrics {
14
14
  /**
15
15
  * Add an entry for the metrics.
16
16
  */
17
- addMetric(metricName: string, value?: number, unit?: MetricUnits): void;
17
+ addMetric(metricName: string, value?: number, unit?: "Count"): void;
18
18
  /**
19
19
  * Add a metadata useful when you want to search highly contextual information along with your metrics in your logs.
20
20
  */
@@ -19,7 +19,7 @@ class CloudWatchMetrics {
19
19
  /**
20
20
  * Add an entry for the metrics.
21
21
  */
22
- addMetric(metricName, value = 1, unit = metrics_1.MetricUnits.Count) {
22
+ addMetric(metricName, value = 1, unit = metrics_1.MetricUnit.Count) {
23
23
  this.metrics.addMetric(metricName, unit, value);
24
24
  }
25
25
  /**
@@ -1,5 +1,5 @@
1
1
  import { Tracer } from '@aws-lambda-powertools/tracer';
2
- import { APIGatewayProxyEventV2, APIGatewayProxyEvent, Callback } from 'aws-lambda';
2
+ import { APIGatewayProxyEventV2, APIGatewayProxyEvent } from 'aws-lambda';
3
3
  import { CognitoUser, Auth0User } from 'idea-toolbox';
4
4
  import { CloudWatchMetrics } from './metrics';
5
5
  import { GenericController } from './genericController';
@@ -8,8 +8,7 @@ import { GenericController } from './genericController';
8
8
  */
9
9
  export declare abstract class ResourceController extends GenericController {
10
10
  protected event: APIGatewayProxyEventV2 | APIGatewayProxyEvent;
11
- protected callback: Callback;
12
- protected initError: boolean;
11
+ protected initError?: Error;
13
12
  protected authorization: string;
14
13
  protected claims: any;
15
14
  protected principalId: string;
@@ -28,6 +27,7 @@ export declare abstract class ResourceController extends GenericController {
28
27
  protected clientVersion: string;
29
28
  protected clientPlatform: string;
30
29
  protected clientBundle: string;
30
+ protected returnHeaders: Record<string, string>;
31
31
  protected returnStatusCode?: number;
32
32
  protected logRequestsWithKey: string;
33
33
  protected metrics: CloudWatchMetrics;
@@ -38,7 +38,7 @@ export declare abstract class ResourceController extends GenericController {
38
38
  protected defaultLang: string;
39
39
  protected translations: any;
40
40
  protected templateMatcher: RegExp;
41
- constructor(event: APIGatewayProxyEventV2 | APIGatewayProxyEvent, callback: Callback, options?: ResourceControllerOptions);
41
+ constructor(event: APIGatewayProxyEventV2 | APIGatewayProxyEvent, options?: ResourceControllerOptions);
42
42
  private initFromEventV2;
43
43
  private initFromEventV1;
44
44
  protected getEventSummary(limitBodyArrayDisplay?: boolean): Record<string, any>;
@@ -50,8 +50,8 @@ export declare abstract class ResourceController extends GenericController {
50
50
  * Force the parsing of a query parameter as a boolean.
51
51
  */
52
52
  protected getQueryParamAsBoolean(paramName: string): boolean;
53
- handleRequest: () => Promise<void>;
54
- protected done(error?: Error | any, rawResult?: any, statusCode?: number): void;
53
+ handleRequest: () => Promise<ResourceControllerResult>;
54
+ protected done(error?: Error | any, rawResult?: any, statusCode?: number, headers?: Record<string, string>): ResourceControllerResult;
55
55
  /**
56
56
  * To @override
57
57
  */
@@ -185,6 +185,14 @@ export interface ResourceControllerOptions {
185
185
  */
186
186
  tracer?: Tracer;
187
187
  }
188
+ /**
189
+ * The result of a Resource Controller's execution.
190
+ */
191
+ export interface ResourceControllerResult {
192
+ statusCode: number;
193
+ body: string;
194
+ headers: Record<string, string>;
195
+ }
188
196
  /**
189
197
  * The parameters needed to invoke an internal API request.
190
198
  * @deprecated don't run a Lambda from another Lambda (bad practice).
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.ResourceController = void 0;
27
37
  const fs_1 = require("fs");
@@ -38,22 +48,25 @@ ENV.POWERTOOLS_SERVICE_NAME = [PROJECT, STAGE, RESOURCE].filter(x => x).join('_'
38
48
  * An abstract class to inherit to manage API requests (AWS API Gateway) in an AWS Lambda function.
39
49
  */
40
50
  class ResourceController extends genericController_1.GenericController {
41
- constructor(event, callback, options = {}) {
42
- super(event, callback);
43
- this.initError = false;
51
+ constructor(event, options = {}) {
52
+ super(event);
44
53
  this.project = PROJECT;
45
54
  this.stage = STAGE;
46
55
  this.resource = RESOURCE;
47
56
  this.clientVersion = '?';
48
57
  this.clientPlatform = '?';
49
58
  this.clientBundle = null;
59
+ this.returnHeaders = {
60
+ 'Content-Type': 'application/json',
61
+ 'Access-Control-Allow-Origin': '*'
62
+ };
50
63
  this.templateMatcher = /{{\s?([^{}\s]*)\s?}}/g;
51
64
  ///
52
65
  /// REQUEST HANDLERS
53
66
  ///
54
67
  this.handleRequest = async () => {
55
68
  if (this.initError)
56
- return;
69
+ return this.done(this.handleControllerError(this.initError, 'INIT-ERROR', 'Malformed request'));
57
70
  this.logger.info('START', { event: this.getEventSummary() });
58
71
  if (this.tracer) {
59
72
  this.tracerLambdaSegment = this.tracer.getSegment();
@@ -91,7 +104,7 @@ class ResourceController extends genericController_1.GenericController {
91
104
  response = await this.headResource();
92
105
  break;
93
106
  default:
94
- this.done(new genericController_1.HandledError('Unsupported method'));
107
+ return this.done(new genericController_1.HandledError('Unsupported method'));
95
108
  }
96
109
  }
97
110
  else {
@@ -116,21 +129,20 @@ class ResourceController extends genericController_1.GenericController {
116
129
  response = await this.headResources();
117
130
  break;
118
131
  default:
119
- this.done(new genericController_1.HandledError('Unsupported method'));
132
+ return this.done(new genericController_1.HandledError('Unsupported method'));
120
133
  }
121
134
  }
122
- this.done(null, response);
135
+ return this.done(null, response);
123
136
  }
124
137
  catch (err) {
125
- this.done(this.handleControllerError(err, 'HANDLER-ERROR', 'Operation failed'));
138
+ return this.done(this.handleControllerError(err, 'HANDLER-ERROR', 'Operation failed'));
126
139
  }
127
140
  }
128
141
  catch (err) {
129
- this.done(this.handleControllerError(err, 'AUTH-CHECK-ERROR', 'Forbidden'));
142
+ return this.done(this.handleControllerError(err, 'AUTH-CHECK-ERROR', 'Forbidden'));
130
143
  }
131
144
  };
132
145
  this.event = event;
133
- this.callback = callback;
134
146
  try {
135
147
  if (event.version === '2.0')
136
148
  this.initFromEventV2(event, options);
@@ -154,9 +166,8 @@ class ResourceController extends genericController_1.GenericController {
154
166
  if (options.useMetrics)
155
167
  this.prepareMetrics();
156
168
  }
157
- catch (err) {
158
- this.initError = true;
159
- this.done(this.handleControllerError(err, 'INIT-ERROR', 'Malformed request'));
169
+ catch (error) {
170
+ this.initError = error;
160
171
  }
161
172
  }
162
173
  initFromEventV2(event, options) {
@@ -178,7 +189,7 @@ class ResourceController extends genericController_1.GenericController {
178
189
  try {
179
190
  this.body = (event.body ? JSON.parse(event.body) : {}) || {};
180
191
  }
181
- catch (error) {
192
+ catch (_) {
182
193
  throw new genericController_1.HandledError('Malformed body');
183
194
  }
184
195
  }
@@ -200,7 +211,7 @@ class ResourceController extends genericController_1.GenericController {
200
211
  try {
201
212
  this.body = (event.body ? JSON.parse(event.body) : {}) || {};
202
213
  }
203
- catch (error) {
214
+ catch (_) {
204
215
  throw new genericController_1.HandledError('Malformed body');
205
216
  }
206
217
  }
@@ -233,7 +244,7 @@ class ResourceController extends genericController_1.GenericController {
233
244
  getQueryParamAsBoolean(paramName) {
234
245
  return this.queryParams[paramName] && this.queryParams[paramName].toLowerCase() !== 'false';
235
246
  }
236
- done(error, rawResult, statusCode = this.returnStatusCode ?? (error ? 400 : 200)) {
247
+ done(error, rawResult, statusCode = this.returnStatusCode ?? (error ? 400 : 200), headers = this.returnHeaders) {
237
248
  const result = error ? { message: error.message } : rawResult ?? {};
238
249
  const responseTrace = { result: Array.isArray(result) ? { array: result.length } : result };
239
250
  this.logger.debug('END-DETAIL', responseTrace);
@@ -260,11 +271,7 @@ class ResourceController extends genericController_1.GenericController {
260
271
  this.storeLog(!error);
261
272
  if (this.metrics)
262
273
  this.publishMetrics(statusCode, error);
263
- this.callback(null, {
264
- statusCode: String(statusCode),
265
- body: JSON.stringify(result),
266
- headers: { 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*' }
267
- });
274
+ return { statusCode, body: JSON.stringify(result), headers };
268
275
  }
269
276
  /**
270
277
  * To @override
@@ -366,7 +373,7 @@ class ResourceController extends genericController_1.GenericController {
366
373
  try {
367
374
  await new dynamoDB_1.DynamoDB().put({ TableName: 'idea_logs', Item: log });
368
375
  }
369
- catch (error) {
376
+ catch (_) {
370
377
  // ignore
371
378
  }
372
379
  }
package/dist/src/s3.js CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.cleanFilename = exports.S3 = void 0;
27
37
  const AWSS3 = __importStar(require("@aws-sdk/client-s3"));
@@ -167,7 +177,7 @@ class S3 {
167
177
  else
168
178
  return true;
169
179
  }
170
- catch (err) {
180
+ catch (_) {
171
181
  return false;
172
182
  }
173
183
  }
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.SecretsManager = void 0;
27
37
  const AWSSecretsManager = __importStar(require("@aws-sdk/client-secrets-manager"));
package/dist/src/ses.js CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.SES = void 0;
27
37
  const client_ses_1 = require("@aws-sdk/client-ses");
@@ -51,7 +61,7 @@ class SES {
51
61
  const command = new AWSSES.GetEmailTemplateCommand({ TemplateName: templateName });
52
62
  await this.client.send(command);
53
63
  }
54
- catch (notFound) {
64
+ catch (_) {
55
65
  isNew = true;
56
66
  }
57
67
  const template = {
@@ -129,7 +139,7 @@ class SES {
129
139
  try {
130
140
  return (await new dynamoDB_1.DynamoDB().get({ TableName: 'idea_teamsSES', Key: { teamId } }));
131
141
  }
132
- catch (err) {
142
+ catch (_) {
133
143
  return null;
134
144
  }
135
145
  }
package/dist/src/sns.js CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.SNS = void 0;
27
37
  const AWSSNS = __importStar(require("@aws-sdk/client-sns"));
package/dist/src/ssm.js CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.SystemsManager = void 0;
27
37
  const AWSSystemsManager = __importStar(require("@aws-sdk/client-ssm"));
@@ -5,7 +5,7 @@ import { GenericController } from './genericController';
5
5
  */
6
6
  export declare abstract class StreamController extends GenericController {
7
7
  records: any[];
8
- constructor(event: any, callback: any);
8
+ constructor(event: any);
9
9
  protected abstract handleRecord(record: DynamoDBRecord): Promise<void>;
10
10
  handleRequest(): Promise<void>;
11
11
  }
@@ -6,15 +6,19 @@ const genericController_1 = require("./genericController");
6
6
  * An abstract class to inherit to manage AWS DDB streams in an AWS Lambda function.
7
7
  */
8
8
  class StreamController extends genericController_1.GenericController {
9
- constructor(event, callback) {
10
- super(event, callback);
9
+ constructor(event) {
10
+ super(event);
11
11
  this.records = event.Records ?? [];
12
12
  }
13
13
  async handleRequest() {
14
14
  this.logger.info('START', { streamOfRecords: this.records.length ?? 0 });
15
- await Promise.all(this.records.map(record => this.handleRecord(record)))
16
- .then(() => this.done())
17
- .catch((err) => this.done(this.handleControllerError(err, 'STREAM-ERROR', 'Operation failed')));
15
+ try {
16
+ await Promise.all(this.records.map(record => this.handleRecord(record)));
17
+ return this.done();
18
+ }
19
+ catch (err) {
20
+ return this.done(this.handleControllerError(err, 'STREAM-ERROR', 'Operation failed'));
21
+ }
18
22
  }
19
23
  }
20
24
  exports.StreamController = StreamController;
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.Translate = void 0;
27
37
  const AWSTranslate = __importStar(require("@aws-sdk/client-translate"));
@@ -0,0 +1 @@
1
+ {"root":["../index.ts","../src/attachments.ts","../src/cognito.ts","../src/comprehend.ts","../src/dynamodb.ts","../src/genericcontroller.ts","../src/lambdalogger.ts","../src/metrics.ts","../src/resourcecontroller.ts","../src/s3.ts","../src/secretsmanager.ts","../src/ses.ts","../src/sns.ts","../src/ssm.ts","../src/streamcontroller.ts","../src/translate.ts"],"version":"5.8.3"}
@@ -0,0 +1,40 @@
1
+ const { defineConfig } = require('eslint/config');
2
+
3
+ const globals = require('globals');
4
+ const tsParser = require('@typescript-eslint/parser');
5
+ const typescriptEslint = require('@typescript-eslint/eslint-plugin');
6
+ const js = require('@eslint/js');
7
+
8
+ const { FlatCompat } = require('@eslint/eslintrc');
9
+
10
+ const compat = new FlatCompat({
11
+ baseDirectory: __dirname,
12
+ recommendedConfig: js.configs.recommended,
13
+ allConfig: js.configs.all
14
+ });
15
+
16
+ module.exports = defineConfig([
17
+ {
18
+ languageOptions: {
19
+ globals: {
20
+ ...globals.browser,
21
+ ...globals.node,
22
+ ...globals.commonjs
23
+ },
24
+
25
+ parser: tsParser
26
+ },
27
+
28
+ plugins: {
29
+ '@typescript-eslint': typescriptEslint
30
+ },
31
+
32
+ extends: compat.extends('eslint:recommended', 'plugin:@typescript-eslint/recommended'),
33
+
34
+ rules: {
35
+ '@typescript-eslint/explicit-module-boundary-types': 0,
36
+ '@typescript-eslint/no-explicit-any': 0,
37
+ '@typescript-eslint/no-unused-vars': ['error', { caughtErrorsIgnorePattern: '^_' }]
38
+ }
39
+ }
40
+ ]);
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "idea-aws",
3
- "version": "4.4.20",
3
+ "version": "4.5.0",
4
4
  "description": "AWS wrappers to use in IDEA's back-ends",
5
5
  "license": "MPL-2.0",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "scripts": {
9
- "lint": "eslint --ext .ts",
9
+ "lint": "eslint '**/*.{ts,tsx}'",
10
10
  "compile": "tsc --build",
11
11
  "docs": "typedoc index.ts --customCss ./docs.style.css",
12
12
  "build": "./build.sh",
@@ -37,40 +37,40 @@
37
37
  },
38
38
  "homepage": "https://iter-idea.github.io/IDEA-AWS",
39
39
  "dependencies": {
40
- "@aws-lambda-powertools/metrics": "^1.18.1",
41
- "@aws-lambda-powertools/tracer": "^1.18.1",
42
- "idea-toolbox": "^7.1.1",
40
+ "@aws-lambda-powertools/metrics": "^2.24.0",
41
+ "@aws-lambda-powertools/tracer": "^2.24.0",
42
+ "idea-toolbox": "^7.1.10",
43
43
  "nanoid": "^3.3.7",
44
- "nodemailer": "^6.9.14",
44
+ "nodemailer": "^7.0.5",
45
45
  "source-map-support": "^0.5.21"
46
46
  },
47
47
  "peerDependencies": {
48
- "@aws-sdk/client-cognito-identity-provider": "^3.616.0",
49
- "@aws-sdk/client-comprehend": "^3.616.0",
50
- "@aws-sdk/client-dynamodb": "^3.616.0",
51
- "@aws-sdk/client-eventbridge": "^3.616.0",
52
- "@aws-sdk/client-lambda": "^3.616.0",
53
- "@aws-sdk/client-s3": "^3.614.0",
54
- "@aws-sdk/client-secrets-manager": "^3.616.0",
55
- "@aws-sdk/client-ses": "^3.616.0",
56
- "@aws-sdk/client-sesv2": "^3.616.0",
57
- "@aws-sdk/client-sns": "^3.616.0",
58
- "@aws-sdk/client-ssm": "^3.616.0",
59
- "@aws-sdk/client-translate": "^3.616.0",
60
- "@aws-sdk/lib-dynamodb": "^3.616.0",
61
- "@aws-sdk/lib-storage": "^3.616.0",
62
- "@aws-sdk/s3-request-presigner": "^3.616.0",
63
- "@aws-sdk/util-dynamodb": "^3.616.0"
48
+ "@aws-sdk/client-cognito-identity-provider": "^3.848.0",
49
+ "@aws-sdk/client-comprehend": "^3.848.0",
50
+ "@aws-sdk/client-dynamodb": "^3.848.0",
51
+ "@aws-sdk/client-eventbridge": "^3.848.0",
52
+ "@aws-sdk/client-lambda": "^3.851.0",
53
+ "@aws-sdk/client-s3": "^3.850.0",
54
+ "@aws-sdk/client-secrets-manager": "^3.848.0",
55
+ "@aws-sdk/client-ses": "^3.848.0",
56
+ "@aws-sdk/client-sesv2": "^3.849.0",
57
+ "@aws-sdk/client-sns": "^3.848.0",
58
+ "@aws-sdk/client-ssm": "^3.849.0",
59
+ "@aws-sdk/client-translate": "^3.848.0",
60
+ "@aws-sdk/lib-dynamodb": "^3.850.0",
61
+ "@aws-sdk/lib-storage": "^3.850.0",
62
+ "@aws-sdk/s3-request-presigner": "^3.850.0",
63
+ "@aws-sdk/util-dynamodb": "^3.848.0"
64
64
  },
65
65
  "devDependencies": {
66
- "@tsconfig/node20": "^20.1.4",
67
- "@types/aws-lambda": "^8.10.141",
68
- "@types/node": "^20.14.11",
69
- "@types/nodemailer": "^6.4.15",
70
- "@typescript-eslint/eslint-plugin": "^7.16.1",
71
- "@typescript-eslint/parser": "^7.16.1",
72
- "eslint": "^8.57.0",
73
- "typedoc": "^0.26.5",
74
- "typescript": "^5.5.2"
66
+ "@tsconfig/node20": "^20.1.6",
67
+ "@types/aws-lambda": "^8.10.152",
68
+ "@types/node": "^22.16.5",
69
+ "@types/nodemailer": "^6.4.17",
70
+ "@typescript-eslint/eslint-plugin": "^8.38.0",
71
+ "@typescript-eslint/parser": "^8.38.0",
72
+ "eslint": "^9.32.0",
73
+ "typedoc": "^0.28.8",
74
+ "typescript": "^5.8.3"
75
75
  }
76
76
  }