Skip to content

Commit

Permalink
feat(endpoint): fixes to types
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Sep 20, 2022
1 parent a6a8fd2 commit 3dee79e
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import { EndpointParameterInstructions } from "../types";
*
* @private
*/
export const getEndpointFromInstructions = async (
export const getEndpointFromInstructions = async <T extends EndpointParameters>(
commandInput: any,
instructionsSupplier: Partial<{
getEndpointParameterInstructions(): EndpointParameterInstructions;
}>,
clientConfig: Partial<EndpointResolvedConfig>,
clientConfig: Partial<EndpointResolvedConfig<T>>,
context?: HandlerExecutionContext
): Promise<EndpointV2> => {
const endpointParams: EndpointParameters = {};
Expand Down Expand Up @@ -43,7 +43,7 @@ export const getEndpointFromInstructions = async (
}
}

const endpoint: EndpointV2 = clientConfig.endpointProvider!(endpointParams, context);
const endpoint: EndpointV2 = clientConfig.endpointProvider!(endpointParams as T, context);
return endpoint;
};

Expand Down
5 changes: 3 additions & 2 deletions packages/middleware-endpoint/src/endpointMiddleware.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { HttpRequest } from "@aws-sdk/protocol-http";
import { parseQueryString } from "@aws-sdk/querystring-parser";
import {
EndpointParameters,
EndpointV2,
HandlerExecutionContext,
MetadataBearer,
Expand All @@ -17,11 +18,11 @@ import { EndpointParameterInstructions } from "./types";
/**
* @private
*/
export const endpointMiddleware = ({
export const endpointMiddleware = <T extends EndpointParameters>({
config,
instructions,
}: {
config: EndpointResolvedConfig;
config: EndpointResolvedConfig<T>;
instructions: EndpointParameterInstructions;
}): SerializeMiddleware<any, any> => {
return <Output extends MetadataBearer>(
Expand Down
8 changes: 4 additions & 4 deletions packages/middleware-endpoint/src/getEndpointPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Pluggable, SerializeHandlerOptions } from "@aws-sdk/types";
import { EndpointParameters, Pluggable, SerializeHandlerOptions } from "@aws-sdk/types";

import { endpointMiddleware } from "./endpointMiddleware";
import { EndpointResolvedConfig } from "./resolveEndpointConfig";
Expand All @@ -11,13 +11,13 @@ export const endpointMiddlewareOptions: SerializeHandlerOptions = {
override: true,
};

export const getEndpointPlugin = (
config: EndpointResolvedConfig,
export const getEndpointPlugin = <T extends EndpointParameters>(
config: EndpointResolvedConfig<T>,
instructions: EndpointParameterInstructions
): Pluggable<any, any> => ({
applyToStack: (clientStack) => {
clientStack.add(
endpointMiddleware({
endpointMiddleware<T>({
config,
instructions,
}),
Expand Down
4 changes: 2 additions & 2 deletions packages/middleware-endpoint/src/resolveEndpointConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface EndpointInputConfig<T extends EndpointParameters = EndpointPara
* The fully qualified endpoint of the webservice. This is only required when using
* a custom endpoint (for example, when using a local version of S3).
*/
endpoint?: string | Endpoint | Provider<Endpoint> | EndpointV2 | Provider<EndpointV2>;
endpoint: string | Endpoint | Provider<Endpoint> | EndpointV2 | Provider<EndpointV2>;

endpointProvider?: (params: T, context?: { logger?: Logger }) => EndpointV2;

Expand Down Expand Up @@ -50,7 +50,7 @@ export interface EndpointResolvedConfig<T extends EndpointParameters = EndpointP
* Resolved value for input {@link EndpointsInputConfig.endpoint}
* @deprecated Use {@link EndpointResolvedConfig.endpointProvider} instead
*/
endpoint?: Provider<Endpoint>;
endpoint: Provider<Endpoint>;

endpointProvider: (params: T, context?: { logger?: Logger }) => EndpointV2;

Expand Down
1 change: 0 additions & 1 deletion packages/middleware-serde/src/serdePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
MetadataBearer,
MiddlewareStack,
Pluggable,
Provider,
RequestSerializer,
ResponseDeserializer,
SerializeHandlerOptions,
Expand Down
2 changes: 1 addition & 1 deletion packages/middleware-signing/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const awsAuthMiddleware =
if (!HttpRequest.isInstance(args.request)) return next(args);

// TODO(identityandauth): call authScheme resolver
const authScheme: AuthScheme = (context.endpointV2 as EndpointV2)?.properties?.authSchemes?.[0];
const authScheme: AuthScheme | undefined = (context.endpointV2 as EndpointV2)?.properties?.authSchemes?.[0];

const signer = await options.signer(authScheme);

Expand Down
3 changes: 2 additions & 1 deletion packages/util-endpoints/src/types/RuleSetObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ export type DeprecatedObject = {
};

export type ParameterObject = {
type: "string" | "boolean";
type: "String" | "Boolean";
default?: string | boolean;
required?: boolean;
documentation?: string;
builtIn?: string;
deprecated?: DeprecatedObject;
};

Expand Down

0 comments on commit 3dee79e

Please sign in to comment.