@middy/util 7.1.3 → 7.1.5

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.
Files changed (3) hide show
  1. package/README.md +1 -5
  2. package/index.js +5 -4
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -49,8 +49,4 @@ Everyone is very welcome to contribute to this repository. Feel free to [raise i
49
49
 
50
50
  ## License
51
51
 
52
- Licensed under [MIT License](LICENSE). Copyright (c) 2017-2026 [will Farrell](https://github.com/willfarrell), [Luciano Mammino](https://github.com/lmammino), and [Middy contributors](https://github.com/middyjs/middy/graphs/contributors).
53
-
54
- <a href="https://app.fossa.io/projects/git%2Bgithub.com%2Fmiddyjs%2Fmiddy?ref=badge_large">
55
- <img src="https://app.fossa.io/api/projects/git%2Bgithub.com%2Fmiddyjs%2Fmiddy.svg?type=large" alt="FOSSA Status" style="max-width:100%;">
56
- </a>
52
+ Licensed under [MIT License](LICENSE). Copyright (c) 2017-2026 [will Farrell](https://github.com/willfarrell), [Luciano Mammino](https://github.com/lmammino), and [Middy contributors](https://github.com/middyjs/middy/graphs/contributors).
package/index.js CHANGED
@@ -46,6 +46,9 @@ export const canPrefetch = (options = {}) => {
46
46
  return !options.awsClientAssumeRole && !options.disablePrefetch;
47
47
  };
48
48
 
49
+ const safeGet = (obj, key) =>
50
+ obj != null && Object.hasOwn(obj, key) ? obj[key] : undefined;
51
+
49
52
  // Internal Context
50
53
  export const getInternal = async (variables, request) => {
51
54
  if (!variables || !request) return {};
@@ -77,7 +80,7 @@ export const getInternal = async (variables, request) => {
77
80
  }
78
81
  if (dotIndex !== -1) {
79
82
  for (const part of internalKey.substring(dotIndex + 1).split(".")) {
80
- value = value?.[part];
83
+ value = safeGet(value, part);
81
84
  }
82
85
  }
83
86
  syncResults[i] = value;
@@ -101,9 +104,7 @@ export const getInternal = async (variables, request) => {
101
104
  valuePromise = Promise.resolve(valuePromise);
102
105
  }
103
106
  promises.push(
104
- valuePromise.then((value) =>
105
- pathOptionKey.reduce((p, c) => p?.[c], value),
106
- ),
107
+ valuePromise.then((value) => pathOptionKey.reduce(safeGet, value)),
107
108
  );
108
109
  }
109
110
  // ensure promise has resolved by the time it's needed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middy/util",
3
- "version": "7.1.3",
3
+ "version": "7.1.5",
4
4
  "description": "🛵 The stylish Node.js middleware engine for AWS Lambda (util package)",
5
5
  "type": "module",
6
6
  "engines": {
@@ -60,7 +60,7 @@
60
60
  },
61
61
  "devDependencies": {
62
62
  "@aws-sdk/client-ssm": "^3.0.0",
63
- "@middy/core": "7.1.3",
63
+ "@middy/core": "7.1.5",
64
64
  "@types/aws-lambda": "^8.0.0",
65
65
  "@types/node": "^22.0.0",
66
66
  "aws-xray-sdk": "^3.3.3"