@smithy/core 3.23.9 → 3.23.10

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
@@ -2,7 +2,6 @@
2
2
 
3
3
  var types = require('@smithy/types');
4
4
  var utilMiddleware = require('@smithy/util-middleware');
5
- var middlewareSerde = require('@smithy/middleware-serde');
6
5
  var protocolHttp = require('@smithy/protocol-http');
7
6
  var protocols = require('@smithy/core/protocols');
8
7
 
@@ -93,7 +92,7 @@ const httpAuthSchemeMiddlewareOptions = {
93
92
  name: "httpAuthSchemeMiddleware",
94
93
  override: true,
95
94
  relation: "before",
96
- toMiddleware: middlewareSerde.serializerMiddlewareOption.name,
95
+ toMiddleware: "serializerMiddleware",
97
96
  };
98
97
  const getHttpAuthSchemePlugin = (config, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }) => ({
99
98
  applyToStack: (clientStack) => {
@@ -756,7 +756,8 @@ const checkCborResponse = (response) => {
756
756
  }
757
757
  };
758
758
  const buildHttpRpcRequest = async (context, headers, path, resolvedHostname, body) => {
759
- const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
759
+ const endpoint = await context.endpoint();
760
+ const { hostname, protocol = "https", port, path: basePath } = endpoint;
760
761
  const contents = {
761
762
  protocol,
762
763
  hostname,
@@ -770,6 +771,11 @@ const buildHttpRpcRequest = async (context, headers, path, resolvedHostname, bod
770
771
  if (resolvedHostname !== undefined) {
771
772
  contents.hostname = resolvedHostname;
772
773
  }
774
+ if (endpoint.headers) {
775
+ for (const [name, value] of Object.entries(endpoint.headers)) {
776
+ contents.headers[name] = value;
777
+ }
778
+ }
773
779
  if (body !== undefined) {
774
780
  contents.body = body;
775
781
  try {
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ var urlParser = require('@smithy/url-parser');
4
+
5
+ const toEndpointV1 = (endpoint) => {
6
+ if (typeof endpoint === "object") {
7
+ if ("url" in endpoint) {
8
+ const v1Endpoint = urlParser.parseUrl(endpoint.url);
9
+ if (endpoint.headers) {
10
+ v1Endpoint.headers = {};
11
+ for (const [name, values] of Object.entries(endpoint.headers)) {
12
+ v1Endpoint.headers[name.toLowerCase()] = values.join(", ");
13
+ }
14
+ }
15
+ return v1Endpoint;
16
+ }
17
+ return endpoint;
18
+ }
19
+ return urlParser.parseUrl(endpoint);
20
+ };
21
+
22
+ exports.toEndpointV1 = toEndpointV1;
@@ -71,6 +71,11 @@ class HttpProtocol extends SerdeContext {
71
71
  for (const [k, v] of endpoint.url.searchParams.entries()) {
72
72
  request.query[k] = v;
73
73
  }
74
+ if (endpoint.headers) {
75
+ for (const [name, values] of Object.entries(endpoint.headers)) {
76
+ request.headers[name] = values.join(", ");
77
+ }
78
+ }
74
79
  return request;
75
80
  }
76
81
  else {
@@ -81,6 +86,11 @@ class HttpProtocol extends SerdeContext {
81
86
  request.query = {
82
87
  ...endpoint.query,
83
88
  };
89
+ if (endpoint.headers) {
90
+ for (const [name, value] of Object.entries(endpoint.headers)) {
91
+ request.headers[name] = value;
92
+ }
93
+ }
84
94
  return request;
85
95
  }
86
96
  }
@@ -490,7 +500,7 @@ class RpcProtocol extends HttpProtocol {
490
500
  payload = serializer.flush();
491
501
  }
492
502
  }
493
- request.headers = headers;
503
+ request.headers = Object.assign(request.headers, headers);
494
504
  request.query = query;
495
505
  request.body = payload;
496
506
  request.method = "POST";
@@ -2,6 +2,7 @@
2
2
 
3
3
  var protocolHttp = require('@smithy/protocol-http');
4
4
  var utilMiddleware = require('@smithy/util-middleware');
5
+ var endpoints = require('@smithy/core/endpoints');
5
6
 
6
7
  const deref = (schemaRef) => {
7
8
  if (typeof schemaRef === "function") {
@@ -84,8 +85,8 @@ const findHeader = (pattern, headers) => {
84
85
  const schemaSerializationMiddleware = (config) => (next, context) => async (args) => {
85
86
  const { operationSchema } = utilMiddleware.getSmithyContext(context);
86
87
  const [, ns, n, t, i, o] = operationSchema ?? [];
87
- const endpoint = context.endpointV2?.url && config.urlParser
88
- ? async () => config.urlParser(context.endpointV2.url)
88
+ const endpoint = context.endpointV2
89
+ ? async () => endpoints.toEndpointV1(context.endpointV2)
89
90
  : config.endpoint;
90
91
  const request = await config.protocol.serializeRequest(operation(ns, n, t, i, o), args.input, {
91
92
  ...config,
@@ -1,4 +1,3 @@
1
- import { serializerMiddlewareOption } from "@smithy/middleware-serde";
2
1
  import { httpAuthSchemeMiddleware } from "./httpAuthSchemeMiddleware";
3
2
  export const httpAuthSchemeMiddlewareOptions = {
4
3
  step: "serialize",
@@ -6,7 +5,7 @@ export const httpAuthSchemeMiddlewareOptions = {
6
5
  name: "httpAuthSchemeMiddleware",
7
6
  override: true,
8
7
  relation: "before",
9
- toMiddleware: serializerMiddlewareOption.name,
8
+ toMiddleware: "serializerMiddleware",
10
9
  };
11
10
  export const getHttpAuthSchemePlugin = (config, { httpAuthSchemeParametersProvider, identityProviderConfigProvider, }) => ({
12
11
  applyToStack: (clientStack) => {
@@ -61,7 +61,8 @@ export const checkCborResponse = (response) => {
61
61
  }
62
62
  };
63
63
  export const buildHttpRpcRequest = async (context, headers, path, resolvedHostname, body) => {
64
- const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
64
+ const endpoint = await context.endpoint();
65
+ const { hostname, protocol = "https", port, path: basePath } = endpoint;
65
66
  const contents = {
66
67
  protocol,
67
68
  hostname,
@@ -75,6 +76,11 @@ export const buildHttpRpcRequest = async (context, headers, path, resolvedHostna
75
76
  if (resolvedHostname !== undefined) {
76
77
  contents.hostname = resolvedHostname;
77
78
  }
79
+ if (endpoint.headers) {
80
+ for (const [name, value] of Object.entries(endpoint.headers)) {
81
+ contents.headers[name] = value;
82
+ }
83
+ }
78
84
  if (body !== undefined) {
79
85
  contents.body = body;
80
86
  try {
@@ -0,0 +1 @@
1
+ export * from "./toEndpointV1";
@@ -0,0 +1,17 @@
1
+ import { parseUrl } from "@smithy/url-parser";
2
+ export const toEndpointV1 = (endpoint) => {
3
+ if (typeof endpoint === "object") {
4
+ if ("url" in endpoint) {
5
+ const v1Endpoint = parseUrl(endpoint.url);
6
+ if (endpoint.headers) {
7
+ v1Endpoint.headers = {};
8
+ for (const [name, values] of Object.entries(endpoint.headers)) {
9
+ v1Endpoint.headers[name.toLowerCase()] = values.join(", ");
10
+ }
11
+ }
12
+ return v1Endpoint;
13
+ }
14
+ return endpoint;
15
+ }
16
+ return parseUrl(endpoint);
17
+ };
@@ -41,6 +41,11 @@ export class HttpProtocol extends SerdeContext {
41
41
  for (const [k, v] of endpoint.url.searchParams.entries()) {
42
42
  request.query[k] = v;
43
43
  }
44
+ if (endpoint.headers) {
45
+ for (const [name, values] of Object.entries(endpoint.headers)) {
46
+ request.headers[name] = values.join(", ");
47
+ }
48
+ }
44
49
  return request;
45
50
  }
46
51
  else {
@@ -51,6 +56,11 @@ export class HttpProtocol extends SerdeContext {
51
56
  request.query = {
52
57
  ...endpoint.query,
53
58
  };
59
+ if (endpoint.headers) {
60
+ for (const [name, value] of Object.entries(endpoint.headers)) {
61
+ request.headers[name] = value;
62
+ }
63
+ }
54
64
  return request;
55
65
  }
56
66
  }
@@ -51,7 +51,7 @@ export class RpcProtocol extends HttpProtocol {
51
51
  payload = serializer.flush();
52
52
  }
53
53
  }
54
- request.headers = headers;
54
+ request.headers = Object.assign(request.headers, headers);
55
55
  request.query = query;
56
56
  request.body = payload;
57
57
  request.method = "POST";
@@ -1,10 +1,11 @@
1
+ import { toEndpointV1 } from "@smithy/core/endpoints";
1
2
  import { getSmithyContext } from "@smithy/util-middleware";
2
3
  import { operation } from "../schemas/operation";
3
4
  export const schemaSerializationMiddleware = (config) => (next, context) => async (args) => {
4
5
  const { operationSchema } = getSmithyContext(context);
5
6
  const [, ns, n, t, i, o] = operationSchema ?? [];
6
- const endpoint = context.endpointV2?.url && config.urlParser
7
- ? async () => config.urlParser(context.endpointV2.url)
7
+ const endpoint = context.endpointV2
8
+ ? async () => toEndpointV1(context.endpointV2)
8
9
  : config.endpoint;
9
10
  const request = await config.protocol.serializeRequest(operation(ns, n, t, i, o), args.input, {
10
11
  ...config,
@@ -0,0 +1 @@
1
+ export * from "./toEndpointV1";
@@ -0,0 +1,6 @@
1
+ import type { Endpoint, EndpointV2 } from "@smithy/types";
2
+ /**
3
+ * Converts an endpoint to EndpointV1 format.
4
+ * @internal
5
+ */
6
+ export declare const toEndpointV1: (endpoint: string | Endpoint | EndpointV2) => Endpoint;
@@ -0,0 +1 @@
1
+ export * from "./toEndpointV1";
@@ -0,0 +1,6 @@
1
+ import { Endpoint, EndpointV2 } from "@smithy/types";
2
+ /**
3
+ * Converts an endpoint to EndpointV1 format.
4
+ * @internal
5
+ */
6
+ export declare const toEndpointV1: (endpoint: string | Endpoint | EndpointV2) => Endpoint;
package/endpoints.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Do not edit:
3
+ * This is a compatibility redirect for contexts that do not understand package.json exports field.
4
+ */
5
+ declare module "@smithy/core/endpoints" {
6
+ export * from "@smithy/core/dist-types/submodules/endpoints/index.d";
7
+ }
package/endpoints.js ADDED
@@ -0,0 +1,6 @@
1
+
2
+ /**
3
+ * Do not edit:
4
+ * This is a compatibility redirect for contexts that do not understand package.json exports field.
5
+ */
6
+ module.exports = require("./dist-cjs/submodules/endpoints/index.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/core",
3
- "version": "3.23.9",
3
+ "version": "3.23.10",
4
4
  "scripts": {
5
5
  "build": "yarn lint && concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
6
6
  "build:cjs": "node ../../scripts/inline core",
@@ -69,6 +69,13 @@
69
69
  "node": "./dist-cjs/submodules/event-streams/index.js",
70
70
  "import": "./dist-es/submodules/event-streams/index.js",
71
71
  "require": "./dist-cjs/submodules/event-streams/index.js"
72
+ },
73
+ "./endpoints": {
74
+ "types": "./dist-types/submodules/endpoints/index.d.ts",
75
+ "module": "./dist-es/submodules/endpoints/index.js",
76
+ "node": "./dist-cjs/submodules/endpoints/index.js",
77
+ "import": "./dist-es/submodules/endpoints/index.js",
78
+ "require": "./dist-cjs/submodules/endpoints/index.js"
72
79
  }
73
80
  },
74
81
  "author": {
@@ -79,13 +86,13 @@
79
86
  "license": "Apache-2.0",
80
87
  "sideEffects": false,
81
88
  "dependencies": {
82
- "@smithy/middleware-serde": "^4.2.12",
83
- "@smithy/protocol-http": "^5.3.11",
84
- "@smithy/types": "^4.13.0",
89
+ "@smithy/protocol-http": "^5.3.12",
90
+ "@smithy/types": "^4.13.1",
91
+ "@smithy/url-parser": "^4.2.12",
85
92
  "@smithy/util-base64": "^4.3.2",
86
93
  "@smithy/util-body-length-browser": "^4.2.2",
87
- "@smithy/util-middleware": "^4.2.11",
88
- "@smithy/util-stream": "^4.5.17",
94
+ "@smithy/util-middleware": "^4.2.12",
95
+ "@smithy/util-stream": "^4.5.18",
89
96
  "@smithy/util-utf8": "^4.2.2",
90
97
  "@smithy/uuid": "^1.1.2",
91
98
  "tslib": "^2.6.2"
@@ -103,6 +110,8 @@
103
110
  "files": [
104
111
  "./cbor.d.ts",
105
112
  "./cbor.js",
113
+ "./endpoints.d.ts",
114
+ "./endpoints.js",
106
115
  "./event-streams.d.ts",
107
116
  "./event-streams.js",
108
117
  "./protocols.d.ts",
@@ -120,7 +129,7 @@
120
129
  "directory": "packages/core"
121
130
  },
122
131
  "devDependencies": {
123
- "@smithy/eventstream-serde-node": "^4.2.11",
132
+ "@smithy/eventstream-serde-node": "^4.2.12",
124
133
  "@types/node": "^18.11.9",
125
134
  "concurrently": "7.0.0",
126
135
  "downlevel-dts": "0.10.1",