@smithy/middleware-content-length 4.2.13 → 4.3.0

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/dist-cjs/index.js CHANGED
@@ -1,46 +1,7 @@
1
- 'use strict';
2
-
3
- var protocolHttp = require('@smithy/protocol-http');
4
-
5
- const CONTENT_LENGTH_HEADER = "content-length";
6
- function contentLengthMiddleware(bodyLengthChecker) {
7
- return (next) => async (args) => {
8
- const request = args.request;
9
- if (protocolHttp.HttpRequest.isInstance(request)) {
10
- const { body, headers } = request;
11
- if (body &&
12
- Object.keys(headers)
13
- .map((str) => str.toLowerCase())
14
- .indexOf(CONTENT_LENGTH_HEADER) === -1) {
15
- try {
16
- const length = bodyLengthChecker(body);
17
- request.headers = {
18
- ...request.headers,
19
- [CONTENT_LENGTH_HEADER]: String(length),
20
- };
21
- }
22
- catch (error) {
23
- }
24
- }
25
- }
26
- return next({
27
- ...args,
28
- request,
29
- });
30
- };
31
- }
32
- const contentLengthMiddlewareOptions = {
33
- step: "build",
34
- tags: ["SET_CONTENT_LENGTH", "CONTENT_LENGTH"],
35
- name: "contentLengthMiddleware",
36
- override: true,
37
- };
38
- const getContentLengthPlugin = (options) => ({
39
- applyToStack: (clientStack) => {
40
- clientStack.add(contentLengthMiddleware(options.bodyLengthChecker), contentLengthMiddlewareOptions);
41
- },
42
- });
43
-
44
- exports.contentLengthMiddleware = contentLengthMiddleware;
45
- exports.contentLengthMiddlewareOptions = contentLengthMiddlewareOptions;
46
- exports.getContentLengthPlugin = getContentLengthPlugin;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getContentLengthPlugin = exports.contentLengthMiddlewareOptions = exports.contentLengthMiddleware = void 0;
4
+ var protocols_1 = require("@smithy/core/protocols");
5
+ Object.defineProperty(exports, "contentLengthMiddleware", { enumerable: true, get: function () { return protocols_1.contentLengthMiddleware; } });
6
+ Object.defineProperty(exports, "contentLengthMiddlewareOptions", { enumerable: true, get: function () { return protocols_1.contentLengthMiddlewareOptions; } });
7
+ Object.defineProperty(exports, "getContentLengthPlugin", { enumerable: true, get: function () { return protocols_1.getContentLengthPlugin; } });
package/dist-es/index.js CHANGED
@@ -1,39 +1 @@
1
- import { HttpRequest } from "@smithy/protocol-http";
2
- const CONTENT_LENGTH_HEADER = "content-length";
3
- export function contentLengthMiddleware(bodyLengthChecker) {
4
- return (next) => async (args) => {
5
- const request = args.request;
6
- if (HttpRequest.isInstance(request)) {
7
- const { body, headers } = request;
8
- if (body &&
9
- Object.keys(headers)
10
- .map((str) => str.toLowerCase())
11
- .indexOf(CONTENT_LENGTH_HEADER) === -1) {
12
- try {
13
- const length = bodyLengthChecker(body);
14
- request.headers = {
15
- ...request.headers,
16
- [CONTENT_LENGTH_HEADER]: String(length),
17
- };
18
- }
19
- catch (error) {
20
- }
21
- }
22
- }
23
- return next({
24
- ...args,
25
- request,
26
- });
27
- };
28
- }
29
- export const contentLengthMiddlewareOptions = {
30
- step: "build",
31
- tags: ["SET_CONTENT_LENGTH", "CONTENT_LENGTH"],
32
- name: "contentLengthMiddleware",
33
- override: true,
34
- };
35
- export const getContentLengthPlugin = (options) => ({
36
- applyToStack: (clientStack) => {
37
- clientStack.add(contentLengthMiddleware(options.bodyLengthChecker), contentLengthMiddlewareOptions);
38
- },
39
- });
1
+ export { contentLengthMiddleware, contentLengthMiddlewareOptions, getContentLengthPlugin, } from "@smithy/core/protocols";
@@ -1,6 +1,2 @@
1
- import type { BodyLengthCalculator, BuildHandlerOptions, BuildMiddleware, Pluggable } from "@smithy/types";
2
- export declare function contentLengthMiddleware(bodyLengthChecker: BodyLengthCalculator): BuildMiddleware<any, any>;
3
- export declare const contentLengthMiddlewareOptions: BuildHandlerOptions;
4
- export declare const getContentLengthPlugin: (options: {
5
- bodyLengthChecker: BodyLengthCalculator;
6
- }) => Pluggable<any, any>;
1
+ /** @deprecated Use @smithy/core/protocols instead. */
2
+ export { contentLengthMiddleware, contentLengthMiddlewareOptions, getContentLengthPlugin, } from "@smithy/core/protocols";
package/package.json CHANGED
@@ -1,18 +1,10 @@
1
1
  {
2
2
  "name": "@smithy/middleware-content-length",
3
- "version": "4.2.13",
3
+ "version": "4.3.0",
4
4
  "scripts": {
5
- "build": "concurrently 'yarn:build:types' 'yarn:build:es:cjs'",
6
- "build:es:cjs": "yarn g:tsc -p tsconfig.es.json && node ../../scripts/inline middleware-content-length",
7
- "build:types": "yarn g:tsc -p tsconfig.types.json",
8
- "build:types:downlevel": "premove dist-types/ts3.4 && downlevel-dts dist-types dist-types/ts3.4",
9
- "clean": "premove dist-cjs dist-es dist-types tsconfig.cjs.tsbuildinfo tsconfig.es.tsbuildinfo tsconfig.types.tsbuildinfo",
10
- "format": "prettier --config ../../prettier.config.js --ignore-path ../../.prettierignore --write \"**/*.{ts,md,json}\"",
11
- "lint": "eslint -c ../../.eslintrc.js \"src/**/*.ts\"",
12
- "stage-release": "premove .release && yarn pack && mkdir ./.release && tar zxvf ./package.tgz --directory ./.release && rm ./package.tgz",
13
- "test": "exit 0",
14
- "test:integration": "yarn g:vitest run -c vitest.config.integ.mts",
15
- "test:integration:watch": "yarn g:vitest watch -c vitest.config.integ.mts"
5
+ "build": "yarn g:tsc -p tsconfig.cjs.json && yarn g:tsc -p tsconfig.es.json && yarn g:tsc -p tsconfig.types.json",
6
+ "clean": "rm -rf dist-cjs dist-es dist-types",
7
+ "stage-release": "rm -rf .release && yarn pack && mkdir ./.release && tar zxvf ./package.tgz --directory ./.release && rm ./package.tgz"
16
8
  },
17
9
  "main": "./dist-cjs/index.js",
18
10
  "module": "./dist-es/index.js",
@@ -24,20 +16,12 @@
24
16
  "license": "Apache-2.0",
25
17
  "sideEffects": false,
26
18
  "dependencies": {
27
- "@smithy/protocol-http": "^5.3.13",
28
- "@smithy/types": "^4.14.0",
19
+ "@smithy/core": "^3.24.0",
29
20
  "tslib": "^2.6.2"
30
21
  },
31
22
  "engines": {
32
23
  "node": ">=18.0.0"
33
24
  },
34
- "typesVersions": {
35
- "<4.5": {
36
- "dist-types/*": [
37
- "dist-types/ts3.4/*"
38
- ]
39
- }
40
- },
41
25
  "files": [
42
26
  "dist-*/**"
43
27
  ],
@@ -47,13 +31,6 @@
47
31
  "url": "https://github.com/smithy-lang/smithy-typescript.git",
48
32
  "directory": "packages/middleware-content-length"
49
33
  },
50
- "devDependencies": {
51
- "@smithy/util-test": "^0.2.8",
52
- "concurrently": "7.0.0",
53
- "downlevel-dts": "0.10.1",
54
- "premove": "4.0.0",
55
- "typedoc": "0.23.23"
56
- },
57
34
  "typedoc": {
58
35
  "entryPoint": "src/index.ts"
59
36
  },
package/README.md DELETED
@@ -1,17 +0,0 @@
1
- # @smithy/middleware-content-length
2
-
3
- [![NPM version](https://img.shields.io/npm/v/@smithy/middleware-content-length/latest.svg)](https://www.npmjs.com/package/@smithy/middleware-content-length)
4
- [![NPM downloads](https://img.shields.io/npm/dm/@smithy/middleware-content-length.svg)](https://www.npmjs.com/package/@smithy/middleware-content-length)
5
-
6
- ### :warning: Internal API :warning:
7
-
8
- > This is an internal package.
9
- > That means this is used as a dependency for other, public packages, but
10
- > should not be taken directly as a dependency in your application's `package.json`.
11
-
12
- > If you are updating the version of this package, for example to bring in a
13
- > bug-fix, you should do so by updating your application lockfile with
14
- > e.g. `npm up @scope/package` or equivalent command in another
15
- > package manager, rather than taking a direct dependency.
16
-
17
- ---