@contrail/util 2.2.0-alpha.3b8e11b → 2.2.0-alpha.72fba22
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
|
@@ -18,11 +18,10 @@ Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
18
18
|
|
|
19
19
|
### Added
|
|
20
20
|
|
|
21
|
-
- `response-size-util` — measures whether a payload fits within
|
|
21
|
+
- `response-size-util` — measures whether a payload fits within AWS Lambda's 6MB response limit, so services can decide to offload to S3 based on actual serialized bytes rather than a row count.
|
|
22
22
|
- `exceedsResponseBudget(value, options?)` — the decision helper. For arrays it serializes one element at a time and stops as soon as the budget is crossed, so the cost is bounded by the budget rather than by the size of the payload.
|
|
23
23
|
- `getJsonByteLength(value)` / `getUtf8ByteLength(str)` — exact UTF-8 byte measurement.
|
|
24
|
-
- `getResponseBudgetBytes(options?)` — the budget
|
|
25
|
-
- `LAMBDA_MAX_RESPONSE_BYTES`, `RESPONSE_GUARD_LIMIT_BYTES`, `DEFAULT_RESPONSE_BUFFER_BYTES`, `DEFAULT_RESPONSE_BUDGET_BYTES` — the ladder of thresholds a response crosses, each sitting below the one above it so a payload offloads before `core`'s response guard returns a 413, and the guard fires before Lambda rejects the invocation.
|
|
24
|
+
- `getResponseBudgetBytes(options?)`, `LAMBDA_MAX_RESPONSE_BYTES`, `DEFAULT_RESPONSE_BUFFER_BYTES` — the budget and its defaults (6MB ceiling, 512KB buffer).
|
|
26
25
|
|
|
27
26
|
## [1.2.1] - 2026-03-25
|
|
28
27
|
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
export declare const LAMBDA_MAX_RESPONSE_BYTES
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const DEFAULT_RESPONSE_BUFFER_BYTES = 500000;
|
|
4
|
-
export declare const DEFAULT_RESPONSE_BUDGET_BYTES: number;
|
|
1
|
+
export declare const LAMBDA_MAX_RESPONSE_BYTES: number;
|
|
2
|
+
export declare const DEFAULT_RESPONSE_BUFFER_BYTES: number;
|
|
5
3
|
export interface ResponseBudgetOptions {
|
|
6
|
-
|
|
4
|
+
maxBytes?: number;
|
|
7
5
|
bufferBytes?: number;
|
|
8
6
|
}
|
|
9
7
|
export declare function getResponseBudgetBytes(options?: ResponseBudgetOptions): number;
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.DEFAULT_RESPONSE_BUFFER_BYTES = exports.LAMBDA_MAX_RESPONSE_BYTES = void 0;
|
|
4
4
|
exports.getResponseBudgetBytes = getResponseBudgetBytes;
|
|
5
5
|
exports.getUtf8ByteLength = getUtf8ByteLength;
|
|
6
6
|
exports.getJsonByteLength = getJsonByteLength;
|
|
7
7
|
exports.exceedsResponseBudget = exceedsResponseBudget;
|
|
8
|
-
exports.LAMBDA_MAX_RESPONSE_BYTES =
|
|
9
|
-
exports.
|
|
10
|
-
exports.DEFAULT_RESPONSE_BUFFER_BYTES = 500000;
|
|
11
|
-
exports.DEFAULT_RESPONSE_BUDGET_BYTES = exports.RESPONSE_GUARD_LIMIT_BYTES - exports.DEFAULT_RESPONSE_BUFFER_BYTES;
|
|
8
|
+
exports.LAMBDA_MAX_RESPONSE_BYTES = 6 * 1024 * 1024;
|
|
9
|
+
exports.DEFAULT_RESPONSE_BUFFER_BYTES = 0.5 * 1024 * 1024;
|
|
12
10
|
const JSON_NULL_BYTES = 'null'.length;
|
|
13
11
|
function getResponseBudgetBytes(options = {}) {
|
|
14
12
|
var _a, _b;
|
|
15
|
-
const
|
|
13
|
+
const maxBytes = (_a = options.maxBytes) !== null && _a !== void 0 ? _a : exports.LAMBDA_MAX_RESPONSE_BYTES;
|
|
16
14
|
const bufferBytes = (_b = options.bufferBytes) !== null && _b !== void 0 ? _b : exports.DEFAULT_RESPONSE_BUFFER_BYTES;
|
|
17
|
-
return Math.max(0,
|
|
15
|
+
return Math.max(0, maxBytes - bufferBytes);
|
|
18
16
|
}
|
|
19
17
|
function getUtf8ByteLength(str) {
|
|
20
18
|
if (typeof Buffer !== 'undefined') {
|