@8ms/helpers 1.3.19 → 1.3.21

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,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const isResponse200_1 = __importDefault(require("../isResponse200"));
7
+ const ApiResponse_1 = __importDefault(require("../../api/ApiResponse"));
7
8
  /**
8
9
  * Invoke a AWS Lambda function by passing in the Function name and optional Payload data.
9
10
  * Runs asynchronously, doesn't wait for function to fully end.
@@ -37,6 +38,17 @@ const invoke = async ({ awaitResponse, functionName, isJson, payload }) => {
37
38
  if ('string' === typeof response) {
38
39
  response = JSON.parse(response);
39
40
  }
41
+ // If the response is a ApiResponse compatible
42
+ if (undefined !== response &&
43
+ // @ts-ignore
44
+ undefined !== response?.error &&
45
+ // @ts-ignore
46
+ undefined !== response?.state) {
47
+ response = (new ApiResponse_1.default()).fromJson({
48
+ // @ts-ignore
49
+ input: response
50
+ });
51
+ }
40
52
  }
41
53
  }
42
54
  // Success but not waiting for response
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "1.3.19",
4
+ "version": "1.3.21",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"