quidproquo-actionprocessor-awslambda 0.0.156 → 0.0.157

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,13 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.createAwsClient = void 0;
4
13
  const cache = new WeakMap();
@@ -13,8 +22,25 @@ function createAwsClient(ClientClass, args) {
13
22
  const argsKey = JSON.stringify(args);
14
23
  // Check if the instance already exists in the cache
15
24
  if (!argsCache.has(argsKey)) {
25
+ const newClient = new ClientClass(args);
26
+ // If the send method exists, wrap it with error handling so we can see it in the logs
27
+ if (typeof newClient.send === 'function') {
28
+ const originalSend = newClient.send;
29
+ newClient.send = function (...sendArgs) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ const paramsText = JSON.stringify(sendArgs);
32
+ try {
33
+ return yield originalSend.apply(this, sendArgs);
34
+ }
35
+ catch (error) {
36
+ error.message = `aws client (${argsKey}) send with args: ${paramsText}\n\n${error.message}`;
37
+ throw error;
38
+ }
39
+ });
40
+ };
41
+ }
16
42
  // Create a new instance and store it in the cache
17
- argsCache.set(argsKey, new ClientClass(args));
43
+ argsCache.set(argsKey, newClient);
18
44
  }
19
45
  // Return the cached instance
20
46
  return argsCache.get(argsKey);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quidproquo-actionprocessor-awslambda",
3
- "version": "0.0.156",
3
+ "version": "0.0.157",
4
4
  "description": "",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "types": "./lib/commonjs/index.d.js",