Skip to content

chore: generate default endpoint ruleset #1589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/ten-islands-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@smithy/middleware-endpoint": patch
"@smithy/middleware-serde": patch
---

reduce usage of endpoints2.0 type adapter in public interfaces
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export interface EndpointInputConfig<T extends EndpointParameters = EndpointPara
*/
interface PreviouslyResolved<T extends EndpointParameters = EndpointParameters> {
urlParser: UrlParser;
region: Provider<string>;
endpointProvider: (params: T, context?: { logger?: Logger }) => EndpointV2;
logger?: Logger;
serviceId?: string;
Expand Down
10 changes: 7 additions & 3 deletions packages/middleware-serde/src/serdePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ export const serializerMiddlewareOption: SerializeHandlerOptions = {
override: true,
};

// Type the modifies the EndpointBearer to make it compatible with Endpoints 2.0 change.
// Must be removed after all clients has been onboard the Endpoints 2.0
/**
* Modifies the EndpointBearer to make it compatible with Endpoints 2.0 change.
*
* @internal
* @deprecated
*/
export type V1OrV2Endpoint = {
// for v2
urlParser?: UrlParser;
Expand All @@ -49,7 +53,7 @@ export function getSerdePlugin<
CommandSerdeContext extends SerdeContext = any,
OutputType extends MetadataBearer = any,
>(
config: V1OrV2Endpoint & SerdeFunctions,
config: SerdeFunctions,
serializer: RequestSerializer<any, CommandSerdeContext>,
deserializer: ResponseDeserializer<OutputType, any, CommandSerdeContext>
): Pluggable<InputType, OutputType> {
Expand Down
10 changes: 6 additions & 4 deletions packages/middleware-serde/src/serializerMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ import type { V1OrV2Endpoint } from "./serdePlugin";
*/
export const serializerMiddleware =
<Input extends object = any, Output extends object = any, CommandSerdeContext extends SerdeContext = any>(
options: V1OrV2Endpoint & SerdeFunctions,
options: SerdeFunctions,
serializer: RequestSerializer<any, CommandSerdeContext>
): SerializeMiddleware<Input, Output> =>
(next: SerializeHandler<Input, Output>, context: HandlerExecutionContext): SerializeHandler<Input, Output> =>
async (args: SerializeHandlerArguments<Input>): Promise<SerializeHandlerOutput<Output>> => {
const endpointConfig = options as V1OrV2Endpoint;

const endpoint: Provider<Endpoint> =
context.endpointV2?.url && options.urlParser
? async () => options.urlParser!(context.endpointV2!.url as URL)
: options.endpoint!;
context.endpointV2?.url && endpointConfig.urlParser
? async () => endpointConfig.urlParser!(context.endpointV2!.url as URL)
: endpointConfig.endpoint!;

if (!endpoint) {
throw new Error("No valid endpoint provider available.");
Expand Down
2 changes: 2 additions & 0 deletions private/smithy-rpcv2-cbor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@smithy/hash-node": "workspace:^",
"@smithy/invalid-dependency": "workspace:^",
"@smithy/middleware-content-length": "workspace:^",
"@smithy/middleware-endpoint": "workspace:^",
"@smithy/middleware-retry": "workspace:^",
"@smithy/middleware-serde": "workspace:^",
"@smithy/middleware-stack": "workspace:^",
Expand All @@ -41,6 +42,7 @@
"@smithy/util-body-length-node": "workspace:^",
"@smithy/util-defaults-mode-browser": "workspace:^",
"@smithy/util-defaults-mode-node": "workspace:^",
"@smithy/util-endpoints": "workspace:^",
"@smithy/util-middleware": "workspace:^",
"@smithy/util-retry": "workspace:^",
"@smithy/util-utf8": "workspace:^",
Expand Down
37 changes: 23 additions & 14 deletions private/smithy-rpcv2-cbor/src/RpcV2ProtocolClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,21 @@ import {
SparseNullsOperationCommandInput,
SparseNullsOperationCommandOutput,
} from "./commands/SparseNullsOperationCommand";
import {
ClientInputEndpointParameters,
ClientResolvedEndpointParameters,
EndpointParameters,
resolveClientEndpointParameters,
} from "./endpoint/EndpointParameters";
import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig";
import { RuntimeExtension, RuntimeExtensionsConfig, resolveRuntimeExtensions } from "./runtimeExtensions";
import {
CustomEndpointsInputConfig,
CustomEndpointsResolvedConfig,
resolveCustomEndpointsConfig,
} from "@smithy/config-resolver";
import { DefaultIdentityProviderConfig, getHttpAuthSchemePlugin, getHttpSigningPlugin } from "@smithy/core";
DefaultIdentityProviderConfig,
getHttpAuthSchemeEndpointRuleSetPlugin,
getHttpSigningPlugin,
} from "@smithy/core";
import { getContentLengthPlugin } from "@smithy/middleware-content-length";
import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint";
import { RetryInputConfig, RetryResolvedConfig, getRetryPlugin, resolveRetryConfig } from "@smithy/middleware-retry";
import { HttpHandlerUserInput as __HttpHandlerUserInput } from "@smithy/protocol-http";
import {
Expand Down Expand Up @@ -205,9 +211,10 @@ export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHand
*/
export type RpcV2ProtocolClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> &
ClientDefaults &
CustomEndpointsInputConfig &
RetryInputConfig &
HttpAuthSchemeInputConfig;
EndpointInputConfig<EndpointParameters> &
HttpAuthSchemeInputConfig &
ClientInputEndpointParameters;
/**
* @public
*
Expand All @@ -221,9 +228,10 @@ export interface RpcV2ProtocolClientConfig extends RpcV2ProtocolClientConfigType
export type RpcV2ProtocolClientResolvedConfigType = __SmithyResolvedConfiguration<__HttpHandlerOptions> &
Required<ClientDefaults> &
RuntimeExtensionsConfig &
CustomEndpointsResolvedConfig &
RetryResolvedConfig &
HttpAuthSchemeResolvedConfig;
EndpointResolvedConfig<EndpointParameters> &
HttpAuthSchemeResolvedConfig &
ClientResolvedEndpointParameters;
/**
* @public
*
Expand All @@ -249,15 +257,16 @@ export class RpcV2ProtocolClient extends __Client<
let _config_0 = __getRuntimeConfig(configuration || {});
super(_config_0 as any);
this.initConfig = _config_0;
let _config_1 = resolveCustomEndpointsConfig(_config_0);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main point of the change is here. The deprecated resolveCustomEndpointsConfig input interface requires a user-supplied endpoint. Equivalent functionality will be provided by the default endpointRuleSet.

let _config_1 = resolveClientEndpointParameters(_config_0);
let _config_2 = resolveRetryConfig(_config_1);
let _config_3 = resolveHttpAuthSchemeConfig(_config_2);
let _config_4 = resolveRuntimeExtensions(_config_3, configuration?.extensions || []);
this.config = _config_4;
let _config_3 = resolveEndpointConfig(_config_2);
let _config_4 = resolveHttpAuthSchemeConfig(_config_3);
let _config_5 = resolveRuntimeExtensions(_config_4, configuration?.extensions || []);
this.config = _config_5;
this.middlewareStack.use(getRetryPlugin(this.config));
this.middlewareStack.use(getContentLengthPlugin(this.config));
this.middlewareStack.use(
getHttpAuthSchemePlugin(this.config, {
getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
httpAuthSchemeParametersProvider: defaultRpcV2ProtocolHttpAuthSchemeParametersProvider,
identityProviderConfigProvider: async (config: RpcV2ProtocolClientResolvedConfig) =>
new DefaultIdentityProviderConfig({}),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// smithy-typescript generated code
import { RpcV2ProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RpcV2ProtocolClient";
import { commonParams } from "../endpoint/EndpointParameters";
import { EmptyStructure } from "../models/models_0";
import { de_EmptyInputOutputCommand, se_EmptyInputOutputCommand } from "../protocols/Rpcv2cbor";
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
Expand Down Expand Up @@ -59,8 +61,12 @@ export class EmptyInputOutputCommand extends $Command
ServiceInputTypes,
ServiceOutputTypes
>()
.ep(commonParams)
.m(function (this: any, Command: any, cs: any, config: RpcV2ProtocolClientResolvedConfig, o: any) {
return [getSerdePlugin(config, this.serialize, this.deserialize)];
return [
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
];
})
.s("RpcV2Protocol", "EmptyInputOutput", {})
.n("RpcV2ProtocolClient", "EmptyInputOutputCommand")
Expand Down
8 changes: 7 additions & 1 deletion private/smithy-rpcv2-cbor/src/commands/Float16Command.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// smithy-typescript generated code
import { RpcV2ProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RpcV2ProtocolClient";
import { commonParams } from "../endpoint/EndpointParameters";
import { Float16Output } from "../models/models_0";
import { de_Float16Command, se_Float16Command } from "../protocols/Rpcv2cbor";
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
Expand Down Expand Up @@ -61,8 +63,12 @@ export class Float16Command extends $Command
ServiceInputTypes,
ServiceOutputTypes
>()
.ep(commonParams)
.m(function (this: any, Command: any, cs: any, config: RpcV2ProtocolClientResolvedConfig, o: any) {
return [getSerdePlugin(config, this.serialize, this.deserialize)];
return [
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
];
})
.s("RpcV2Protocol", "Float16", {})
.n("RpcV2ProtocolClient", "Float16Command")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// smithy-typescript generated code
import { RpcV2ProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RpcV2ProtocolClient";
import { commonParams } from "../endpoint/EndpointParameters";
import { FractionalSecondsOutput } from "../models/models_0";
import { de_FractionalSecondsCommand, se_FractionalSecondsCommand } from "../protocols/Rpcv2cbor";
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
Expand Down Expand Up @@ -61,8 +63,12 @@ export class FractionalSecondsCommand extends $Command
ServiceInputTypes,
ServiceOutputTypes
>()
.ep(commonParams)
.m(function (this: any, Command: any, cs: any, config: RpcV2ProtocolClientResolvedConfig, o: any) {
return [getSerdePlugin(config, this.serialize, this.deserialize)];
return [
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
];
})
.s("RpcV2Protocol", "FractionalSeconds", {})
.n("RpcV2ProtocolClient", "FractionalSecondsCommand")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// smithy-typescript generated code
import { RpcV2ProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RpcV2ProtocolClient";
import { commonParams } from "../endpoint/EndpointParameters";
import { GreetingWithErrorsOutput } from "../models/models_0";
import { de_GreetingWithErrorsCommand, se_GreetingWithErrorsCommand } from "../protocols/Rpcv2cbor";
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
Expand Down Expand Up @@ -74,8 +76,12 @@ export class GreetingWithErrorsCommand extends $Command
ServiceInputTypes,
ServiceOutputTypes
>()
.ep(commonParams)
.m(function (this: any, Command: any, cs: any, config: RpcV2ProtocolClientResolvedConfig, o: any) {
return [getSerdePlugin(config, this.serialize, this.deserialize)];
return [
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
];
})
.s("RpcV2Protocol", "GreetingWithErrors", {})
.n("RpcV2ProtocolClient", "GreetingWithErrorsCommand")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// smithy-typescript generated code
import { RpcV2ProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RpcV2ProtocolClient";
import { commonParams } from "../endpoint/EndpointParameters";
import { de_NoInputOutputCommand, se_NoInputOutputCommand } from "../protocols/Rpcv2cbor";
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
Expand Down Expand Up @@ -58,8 +60,12 @@ export class NoInputOutputCommand extends $Command
ServiceInputTypes,
ServiceOutputTypes
>()
.ep(commonParams)
.m(function (this: any, Command: any, cs: any, config: RpcV2ProtocolClientResolvedConfig, o: any) {
return [getSerdePlugin(config, this.serialize, this.deserialize)];
return [
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
];
})
.s("RpcV2Protocol", "NoInputOutput", {})
.n("RpcV2ProtocolClient", "NoInputOutputCommand")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// smithy-typescript generated code
import { RpcV2ProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RpcV2ProtocolClient";
import { commonParams } from "../endpoint/EndpointParameters";
import { OperationWithDefaultsInput, OperationWithDefaultsOutput } from "../models/models_0";
import { de_OperationWithDefaultsCommand, se_OperationWithDefaultsCommand } from "../protocols/Rpcv2cbor";
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
Expand Down Expand Up @@ -127,8 +129,12 @@ export class OperationWithDefaultsCommand extends $Command
ServiceInputTypes,
ServiceOutputTypes
>()
.ep(commonParams)
.m(function (this: any, Command: any, cs: any, config: RpcV2ProtocolClientResolvedConfig, o: any) {
return [getSerdePlugin(config, this.serialize, this.deserialize)];
return [
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
];
})
.s("RpcV2Protocol", "OperationWithDefaults", {})
.n("RpcV2ProtocolClient", "OperationWithDefaultsCommand")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// smithy-typescript generated code
import { RpcV2ProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RpcV2ProtocolClient";
import { commonParams } from "../endpoint/EndpointParameters";
import { SimpleStructure } from "../models/models_0";
import { de_OptionalInputOutputCommand, se_OptionalInputOutputCommand } from "../protocols/Rpcv2cbor";
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
Expand Down Expand Up @@ -63,8 +65,12 @@ export class OptionalInputOutputCommand extends $Command
ServiceInputTypes,
ServiceOutputTypes
>()
.ep(commonParams)
.m(function (this: any, Command: any, cs: any, config: RpcV2ProtocolClientResolvedConfig, o: any) {
return [getSerdePlugin(config, this.serialize, this.deserialize)];
return [
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
];
})
.s("RpcV2Protocol", "OptionalInputOutput", {})
.n("RpcV2ProtocolClient", "OptionalInputOutputCommand")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// smithy-typescript generated code
import { RpcV2ProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RpcV2ProtocolClient";
import { commonParams } from "../endpoint/EndpointParameters";
import { RecursiveShapesInputOutput } from "../models/models_0";
import { de_RecursiveShapesCommand, se_RecursiveShapesCommand } from "../protocols/Rpcv2cbor";
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
Expand Down Expand Up @@ -87,8 +89,12 @@ export class RecursiveShapesCommand extends $Command
ServiceInputTypes,
ServiceOutputTypes
>()
.ep(commonParams)
.m(function (this: any, Command: any, cs: any, config: RpcV2ProtocolClientResolvedConfig, o: any) {
return [getSerdePlugin(config, this.serialize, this.deserialize)];
return [
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
];
})
.s("RpcV2Protocol", "RecursiveShapes", {})
.n("RpcV2ProtocolClient", "RecursiveShapesCommand")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// smithy-typescript generated code
import { RpcV2ProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RpcV2ProtocolClient";
import { commonParams } from "../endpoint/EndpointParameters";
import { RpcV2CborDenseMapsInputOutput } from "../models/models_0";
import { de_RpcV2CborDenseMapsCommand, se_RpcV2CborDenseMapsCommand } from "../protocols/Rpcv2cbor";
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
Expand Down Expand Up @@ -104,8 +106,12 @@ export class RpcV2CborDenseMapsCommand extends $Command
ServiceInputTypes,
ServiceOutputTypes
>()
.ep(commonParams)
.m(function (this: any, Command: any, cs: any, config: RpcV2ProtocolClientResolvedConfig, o: any) {
return [getSerdePlugin(config, this.serialize, this.deserialize)];
return [
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
];
})
.s("RpcV2Protocol", "RpcV2CborDenseMaps", {})
.n("RpcV2ProtocolClient", "RpcV2CborDenseMapsCommand")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// smithy-typescript generated code
import { RpcV2ProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RpcV2ProtocolClient";
import { commonParams } from "../endpoint/EndpointParameters";
import { RpcV2CborListInputOutput } from "../models/models_0";
import { de_RpcV2CborListsCommand, se_RpcV2CborListsCommand } from "../protocols/Rpcv2cbor";
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
Expand Down Expand Up @@ -142,8 +144,12 @@ export class RpcV2CborListsCommand extends $Command
ServiceInputTypes,
ServiceOutputTypes
>()
.ep(commonParams)
.m(function (this: any, Command: any, cs: any, config: RpcV2ProtocolClientResolvedConfig, o: any) {
return [getSerdePlugin(config, this.serialize, this.deserialize)];
return [
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
];
})
.s("RpcV2Protocol", "RpcV2CborLists", {})
.n("RpcV2ProtocolClient", "RpcV2CborListsCommand")
Expand Down
Loading
Loading