@contrail/util 1.3.3-alpha.7783621 → 1.4.0-alpha.36276cd

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.
package/CHANGELOG.md CHANGED
@@ -7,11 +7,12 @@ Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
- ## [1.3.3] - 2026-09-03
11
-
12
- ### Fixed
10
+ ### Added
13
11
 
14
- - `ObjectUtil.mergeDeep` no longer discards a value when the target cannot be merged into. An incoming object landing on an existing array, string, or number replaces it, instead of being silently skipped. Merging two objects is unchanged: keys the source omits still survive.
12
+ - `lambda-util` AWS Lambda response-size helpers shared across services.
13
+ - `MAX_LAMBDA_RESPONSE_MB` / `RESPONSE_SIZE_BUFFER_MB` — the 6MB Lambda response cap and the safety buffer held below it.
14
+ - `RESPONSE_BYTE_LIMIT` — the cap minus the buffer, in bytes, for size checks that work in bytes.
15
+ - `getSerializedByteSize` — serialized byte size of any value. Treats `undefined` as `null`, since `JSON.stringify(undefined)` returns `undefined` rather than a string and `Buffer.byteLength` throws on it.
15
16
 
16
17
  ## [1.2.1] - 2026-03-25
17
18
 
package/lib/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './app-util/app-util';
2
2
  export * from './compression-util';
3
3
  export * from './date-util/date-util';
4
+ export * from './lambda-util/lambda-util';
4
5
  export * from './map-util/map-util';
5
6
  export * from './object-util/object-util';
6
7
  export * from './order-util/order-util';
package/lib/index.js CHANGED
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./app-util/app-util"), exports);
18
18
  __exportStar(require("./compression-util"), exports);
19
19
  __exportStar(require("./date-util/date-util"), exports);
20
+ __exportStar(require("./lambda-util/lambda-util"), exports);
20
21
  __exportStar(require("./map-util/map-util"), exports);
21
22
  __exportStar(require("./object-util/object-util"), exports);
22
23
  __exportStar(require("./order-util/order-util"), exports);
@@ -0,0 +1,4 @@
1
+ export declare const MAX_LAMBDA_RESPONSE_MB = 6;
2
+ export declare const RESPONSE_SIZE_BUFFER_MB = 0.5;
3
+ export declare const RESPONSE_BYTE_LIMIT: number;
4
+ export declare function getSerializedByteSize(value: unknown): number;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RESPONSE_BYTE_LIMIT = exports.RESPONSE_SIZE_BUFFER_MB = exports.MAX_LAMBDA_RESPONSE_MB = void 0;
4
+ exports.getSerializedByteSize = getSerializedByteSize;
5
+ exports.MAX_LAMBDA_RESPONSE_MB = 6;
6
+ exports.RESPONSE_SIZE_BUFFER_MB = 0.5;
7
+ exports.RESPONSE_BYTE_LIMIT = (exports.MAX_LAMBDA_RESPONSE_MB - exports.RESPONSE_SIZE_BUFFER_MB) * 1024 * 1024;
8
+ function getSerializedByteSize(value) {
9
+ return Buffer.byteLength(JSON.stringify(value !== null && value !== void 0 ? value : null));
10
+ }
@@ -9,7 +9,7 @@ function mergeDeep(target, ...sources) {
9
9
  if ((0, isObject_1.isObject)(target) && (0, isObject_1.isObject)(source)) {
10
10
  for (const key in source) {
11
11
  if ((0, isObject_1.isObject)(source[key]) && !isDate(source[key])) {
12
- if (!(0, isObject_1.isObject)(target[key]))
12
+ if (!target[key])
13
13
  Object.assign(target, { [key]: {} });
14
14
  mergeDeep(target[key], source[key]);
15
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/util",
3
- "version": "1.3.3-alpha.7783621",
3
+ "version": "1.4.0-alpha.36276cd",
4
4
  "description": "General JavaScript utilities",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",