Skip to content

Commit b447256

Browse files
committed
reorganize core upstream of smithy-client
1 parent ba2b4d0 commit b447256

16 files changed

+96
-75
lines changed

.changeset/unlucky-books-think.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@smithy/middleware-compression": patch
3+
"@smithy/middleware-endpoint": patch
4+
"@smithy/smithy-client": patch
5+
"@smithy/core": patch
6+
---
7+
8+
reorganize smithy/core to be upstream of smithy/smithy-client

packages/core/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,12 @@
4646
},
4747
"license": "Apache-2.0",
4848
"dependencies": {
49-
"@smithy/middleware-endpoint": "workspace:^",
50-
"@smithy/middleware-retry": "workspace:^",
5149
"@smithy/middleware-serde": "workspace:^",
5250
"@smithy/protocol-http": "workspace:^",
53-
"@smithy/smithy-client": "workspace:^",
5451
"@smithy/types": "workspace:^",
5552
"@smithy/util-body-length-browser": "workspace:^",
5653
"@smithy/util-middleware": "workspace:^",
54+
"@smithy/util-stream": "workspace:^",
5755
"@smithy/util-utf8": "workspace:^",
5856
"tslib": "^2.6.2"
5957
},

packages/core/src/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
export * from "./getSmithyContext";
12
export * from "./middleware-http-auth-scheme";
23
export * from "./middleware-http-signing";
3-
export * from "./util-identity-and-auth";
4-
export * from "./getSmithyContext";
54
export * from "./normalizeProvider";
5+
export { createPaginator } from "./pagination/createPaginator";
6+
export * from "./protocols/collect-stream-body";
67
export * from "./protocols/requestBuilder";
8+
export * from "./protocols/resolve-path";
9+
export * from "./protocols/extended-encode-uri-component";
710
export * from "./setFeature";
8-
export { createPaginator } from "./pagination/createPaginator";
11+
export * from "./util-identity-and-auth";

packages/core/src/middleware-http-auth-scheme/getHttpAuthSchemeEndpointRuleSetPlugin.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { endpointMiddlewareOptions } from "@smithy/middleware-endpoint";
21
import {
32
HandlerExecutionContext,
43
HttpAuthSchemeParameters,
@@ -20,7 +19,7 @@ export const httpAuthSchemeEndpointRuleSetMiddlewareOptions: SerializeHandlerOpt
2019
name: "httpAuthSchemeMiddleware",
2120
override: true,
2221
relation: "before",
23-
toMiddleware: endpointMiddlewareOptions.name!,
22+
toMiddleware: "endpointV2Middleware",
2423
};
2524

2625
/**

packages/core/src/middleware-http-signing/getHttpSigningMiddleware.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { retryMiddlewareOptions } from "@smithy/middleware-retry";
21
import { FinalizeRequestHandlerOptions, Pluggable, RelativeMiddlewareOptions } from "@smithy/types";
32

43
import { httpSigningMiddleware } from "./httpSigningMiddleware";
@@ -13,7 +12,7 @@ export const httpSigningMiddlewareOptions: FinalizeRequestHandlerOptions & Relat
1312
aliases: ["apiKeyMiddleware", "tokenMiddleware", "awsAuthMiddleware"],
1413
override: true,
1514
relation: "after",
16-
toMiddleware: retryMiddlewareOptions.name!,
15+
toMiddleware: "retryMiddleware",
1716
};
1817

1918
/**
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { SerdeContext } from "@smithy/types";
2+
import { Uint8ArrayBlobAdapter } from "@smithy/util-stream";
3+
4+
/**
5+
* @internal
6+
*
7+
* Collect low-level response body stream to Uint8Array.
8+
*/
9+
export const collectBody = async (
10+
streamBody: any = new Uint8Array(),
11+
context: {
12+
streamCollector: SerdeContext["streamCollector"];
13+
}
14+
): Promise<Uint8ArrayBlobAdapter> => {
15+
if (streamBody instanceof Uint8Array) {
16+
return Uint8ArrayBlobAdapter.mutate(streamBody);
17+
}
18+
19+
if (!streamBody) {
20+
return Uint8ArrayBlobAdapter.mutate(new Uint8Array());
21+
}
22+
23+
const fromContext = context.streamCollector(streamBody);
24+
25+
return Uint8ArrayBlobAdapter.mutate(await fromContext);
26+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @internal
3+
*
4+
* Function that wraps encodeURIComponent to encode additional characters
5+
* to fully adhere to RFC 3986.
6+
*/
7+
export function extendedEncodeURIComponent(str: string): string {
8+
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
9+
return "%" + c.charCodeAt(0).toString(16).toUpperCase();
10+
});
11+
}

packages/core/src/protocols/requestBuilder.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { HttpRequest } from "@smithy/protocol-http";
2-
import { resolvedPath } from "@smithy/smithy-client";
32
import type { SerdeContext } from "@smithy/types";
43

4+
import { resolvedPath } from "./resolve-path";
5+
56
/**
67
* @internal
78
* used in code-generated serde.

0 commit comments

Comments
 (0)