Skip to content
Closed
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
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ generate-protocol-tests:
cp -r ./smithy-typescript-protocol-test-codegen/build/smithyprojections/smithy-typescript-protocol-test-codegen/my-local-model/typescript-client-codegen/ ./private/my-local-model
cp -r ./smithy-typescript-protocol-test-codegen/build/smithyprojections/smithy-typescript-protocol-test-codegen/my-local-model-schema/typescript-client-codegen/ ./private/my-local-model-schema
node ./scripts/post-protocol-test-codegen
npx prettier --write ./private/smithy-rpcv2-cbor
npx prettier --write ./private/smithy-rpcv2-cbor-schema
npx prettier --write ./private/my-local-model
npx prettier --write ./private/my-local-model-schema
# npx prettier --write ./private/smithy-rpcv2-cbor
# npx prettier --write ./private/smithy-rpcv2-cbor-schema
# npx prettier --write ./private/my-local-model
# npx prettier --write ./private/my-local-model-schema
yarn
yarn turbo run build -F="./private/*" --only

Expand Down
26 changes: 20 additions & 6 deletions private/my-local-model-schema/src/XYZService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
// smithy-typescript generated code
import { XYZServiceClient, XYZServiceClientConfig } from "./XYZServiceClient";
import { GetNumbersCommand, GetNumbersCommandInput, GetNumbersCommandOutput } from "./commands/GetNumbersCommand";
import {
XYZServiceClient,
XYZServiceClientConfig,
} from "./XYZServiceClient";
import {
GetNumbersCommand,
GetNumbersCommandInput,
GetNumbersCommandOutput,
} from "./commands/GetNumbersCommand";
import {
TradeEventStreamCommand,
TradeEventStreamCommandInput,
Expand All @@ -12,15 +19,21 @@ import { HttpHandlerOptions as __HttpHandlerOptions } from "@smithy/types";
const commands = {
GetNumbersCommand,
TradeEventStreamCommand,
};
}

export interface XYZService {
/**
* @see {@link GetNumbersCommand}
*/
getNumbers(): Promise<GetNumbersCommandOutput>;
getNumbers(args: GetNumbersCommandInput, options?: __HttpHandlerOptions): Promise<GetNumbersCommandOutput>;
getNumbers(args: GetNumbersCommandInput, cb: (err: any, data?: GetNumbersCommandOutput) => void): void;
getNumbers(
args: GetNumbersCommandInput,
options?: __HttpHandlerOptions,
): Promise<GetNumbersCommandOutput>;
getNumbers(
args: GetNumbersCommandInput,
cb: (err: any, data?: GetNumbersCommandOutput) => void
): void;
getNumbers(
args: GetNumbersCommandInput,
options: __HttpHandlerOptions,
Expand All @@ -33,7 +46,7 @@ export interface XYZService {
tradeEventStream(): Promise<TradeEventStreamCommandOutput>;
tradeEventStream(
args: TradeEventStreamCommandInput,
options?: __HttpHandlerOptions
options?: __HttpHandlerOptions,
): Promise<TradeEventStreamCommandOutput>;
tradeEventStream(
args: TradeEventStreamCommandInput,
Expand All @@ -44,6 +57,7 @@ export interface XYZService {
options: __HttpHandlerOptions,
cb: (err: any, data?: TradeEventStreamCommandOutput) => void
): void;

}

/**
Expand Down
92 changes: 57 additions & 35 deletions private/my-local-model-schema/src/XYZServiceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,26 @@ import {
defaultXYZServiceHttpAuthSchemeParametersProvider,
resolveHttpAuthSchemeConfig,
} from "./auth/httpAuthSchemeProvider";
import { GetNumbersCommandInput, GetNumbersCommandOutput } from "./commands/GetNumbersCommand";
import { TradeEventStreamCommandInput, TradeEventStreamCommandOutput } from "./commands/TradeEventStreamCommand";
import {
GetNumbersCommandInput,
GetNumbersCommandOutput,
} from "./commands/GetNumbersCommand";
import {
TradeEventStreamCommandInput,
TradeEventStreamCommandOutput,
} from "./commands/TradeEventStreamCommand";
import {
ClientInputEndpointParameters,
ClientResolvedEndpointParameters,
EndpointParameters,
resolveClientEndpointParameters,
} from "./endpoint/EndpointParameters";
import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig";
import { RuntimeExtension, RuntimeExtensionsConfig, resolveRuntimeExtensions } from "./runtimeExtensions";
import {
RuntimeExtension,
RuntimeExtensionsConfig,
resolveRuntimeExtensions,
} from "./runtimeExtensions";
import {
DefaultIdentityProviderConfig,
getHttpAuthSchemeEndpointRuleSetPlugin,
Expand All @@ -35,7 +45,12 @@ import {
resolveEndpointConfig,
resolveEndpointRequiredConfig,
} from "@smithy/middleware-endpoint";
import { RetryInputConfig, RetryResolvedConfig, getRetryPlugin, resolveRetryConfig } from "@smithy/middleware-retry";
import {
RetryInputConfig,
RetryResolvedConfig,
getRetryPlugin,
resolveRetryConfig,
} from "@smithy/middleware-retry";
import { HttpHandlerUserInput as __HttpHandlerUserInput } from "@smithy/protocol-http";
import {
Client as __Client,
Expand All @@ -61,22 +76,27 @@ import {
UrlParser as __UrlParser,
} from "@smithy/types";

export { __Client };
export { __Client }

/**
* @public
*/
export type ServiceInputTypes = GetNumbersCommandInput | TradeEventStreamCommandInput;
export type ServiceInputTypes =
| GetNumbersCommandInput
| TradeEventStreamCommandInput;

/**
* @public
*/
export type ServiceOutputTypes = GetNumbersCommandOutput | TradeEventStreamCommandOutput;
export type ServiceOutputTypes =
| GetNumbersCommandOutput
| TradeEventStreamCommandOutput;

/**
* @public
*/
export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHandlerOptions>> {
export interface ClientDefaults
extends Partial<__SmithyConfiguration<__HttpHandlerOptions>> {
/**
* The HTTP handler to use or its constructor options. Fetch in browser and Https in Nodejs.
*/
Expand Down Expand Up @@ -184,19 +204,20 @@ export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHand
* The {@link @smithy/smithy-client#DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK.
*/
defaultsMode?: __DefaultsMode | __Provider<__DefaultsMode>;

}

/**
* @public
*/
export type XYZServiceClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> &
ClientDefaults &
RetryInputConfig &
EndpointInputConfig<EndpointParameters> &
EndpointRequiredInputConfig &
EventStreamSerdeInputConfig &
HttpAuthSchemeInputConfig &
ClientInputEndpointParameters;
export type XYZServiceClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>>
& ClientDefaults
& RetryInputConfig
& EndpointInputConfig<EndpointParameters>
& EndpointRequiredInputConfig
& EventStreamSerdeInputConfig
& HttpAuthSchemeInputConfig
& ClientInputEndpointParameters
/**
* @public
*
Expand All @@ -207,15 +228,15 @@ export interface XYZServiceClientConfig extends XYZServiceClientConfigType {}
/**
* @public
*/
export type XYZServiceClientResolvedConfigType = __SmithyResolvedConfiguration<__HttpHandlerOptions> &
Required<ClientDefaults> &
RuntimeExtensionsConfig &
RetryResolvedConfig &
EndpointResolvedConfig<EndpointParameters> &
EndpointRequiredResolvedConfig &
EventStreamSerdeResolvedConfig &
HttpAuthSchemeResolvedConfig &
ClientResolvedEndpointParameters;
export type XYZServiceClientResolvedConfigType = __SmithyResolvedConfiguration<__HttpHandlerOptions>
& Required<ClientDefaults>
& RuntimeExtensionsConfig
& RetryResolvedConfig
& EndpointResolvedConfig<EndpointParameters>
& EndpointRequiredResolvedConfig
& EventStreamSerdeResolvedConfig
& HttpAuthSchemeResolvedConfig
& ClientResolvedEndpointParameters
/**
* @public
*
Expand Down Expand Up @@ -251,16 +272,17 @@ export class XYZServiceClient extends __Client<
let _config_7 = resolveRuntimeExtensions(_config_6, configuration?.extensions || []);
this.config = _config_7;
this.middlewareStack.use(getSchemaSerdePlugin(this.config));
this.middlewareStack.use(getRetryPlugin(this.config));
this.middlewareStack.use(getContentLengthPlugin(this.config));
this.middlewareStack.use(
getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
httpAuthSchemeParametersProvider: defaultXYZServiceHttpAuthSchemeParametersProvider,
identityProviderConfigProvider: async (config: XYZServiceClientResolvedConfig) =>
new DefaultIdentityProviderConfig({}),
})
);
this.middlewareStack.use(getHttpSigningPlugin(this.config));
this.middlewareStack.use(getRetryPlugin(this.config
));
this.middlewareStack.use(getContentLengthPlugin(this.config
));
this.middlewareStack.use(getHttpAuthSchemeEndpointRuleSetPlugin(this.config
, {
httpAuthSchemeParametersProvider: defaultXYZServiceHttpAuthSchemeParametersProvider,identityProviderConfigProvider: async (config: XYZServiceClientResolvedConfig) => new DefaultIdentityProviderConfig({
}), }
));
this.middlewareStack.use(getHttpSigningPlugin(this.config
));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ export type HttpAuthRuntimeConfig = Partial<{
/**
* @internal
*/
export const getHttpAuthExtensionConfiguration = (
runtimeConfig: HttpAuthRuntimeConfig
): HttpAuthExtensionConfiguration => {
export const getHttpAuthExtensionConfiguration = (runtimeConfig: HttpAuthRuntimeConfig): HttpAuthExtensionConfiguration => {
let _httpAuthSchemes = runtimeConfig.httpAuthSchemes!;
let _httpAuthSchemeProvider = runtimeConfig.httpAuthSchemeProvider!;
return {
setHttpAuthScheme(httpAuthScheme: HttpAuthScheme): void {
const index = _httpAuthSchemes.findIndex((scheme) => scheme.schemeId === httpAuthScheme.schemeId);
const index = _httpAuthSchemes.findIndex(scheme => scheme.schemeId === httpAuthScheme.schemeId);
if (index === -1) {
_httpAuthSchemes.push(httpAuthScheme);
} else {
Expand All @@ -46,7 +44,7 @@ export const getHttpAuthExtensionConfiguration = (
httpAuthSchemeProvider(): XYZServiceHttpAuthSchemeProvider {
return _httpAuthSchemeProvider;
},
};
}
};

/**
Expand Down
37 changes: 16 additions & 21 deletions private/my-local-model-schema/src/auth/httpAuthSchemeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,26 @@ import {
HttpAuthSchemeProvider,
Provider,
} from "@smithy/types";
import { getSmithyContext, normalizeProvider } from "@smithy/util-middleware";
import {
getSmithyContext,
normalizeProvider,
} from "@smithy/util-middleware";

/**
* @internal
*/
export interface XYZServiceHttpAuthSchemeParameters extends HttpAuthSchemeParameters {}
export interface XYZServiceHttpAuthSchemeParameters extends HttpAuthSchemeParameters {
}

/**
* @internal
*/
export interface XYZServiceHttpAuthSchemeParametersProvider
extends HttpAuthSchemeParametersProvider<
XYZServiceClientResolvedConfig,
HandlerExecutionContext,
XYZServiceHttpAuthSchemeParameters,
object
> {}
export interface XYZServiceHttpAuthSchemeParametersProvider extends HttpAuthSchemeParametersProvider<XYZServiceClientResolvedConfig, HandlerExecutionContext, XYZServiceHttpAuthSchemeParameters, object> {}

/**
* @internal
*/
export const defaultXYZServiceHttpAuthSchemeParametersProvider = async (
config: XYZServiceClientResolvedConfig,
context: HandlerExecutionContext,
input: object
): Promise<XYZServiceHttpAuthSchemeParameters> => {
export const defaultXYZServiceHttpAuthSchemeParametersProvider = async (config: XYZServiceClientResolvedConfig, context: HandlerExecutionContext, input: object): Promise<XYZServiceHttpAuthSchemeParameters> => {
return {
operation: getSmithyContext(context).operation as string,
};
Expand All @@ -44,7 +38,7 @@ function createSmithyApiNoAuthHttpAuthOption(authParameters: XYZServiceHttpAuthS
return {
schemeId: "smithy.api#noAuth",
};
}
};

/**
* @internal
Expand All @@ -59,8 +53,8 @@ export const defaultXYZServiceHttpAuthSchemeProvider: XYZServiceHttpAuthSchemePr
switch (authParameters.operation) {
default: {
options.push(createSmithyApiNoAuthHttpAuthOption(authParameters));
}
}
};
};
return options;
};

Expand All @@ -87,6 +81,7 @@ export interface HttpAuthSchemeInputConfig {
* @internal
*/
httpAuthSchemeProvider?: XYZServiceHttpAuthSchemeProvider;

}

/**
Expand All @@ -112,15 +107,15 @@ export interface HttpAuthSchemeResolvedConfig {
* @internal
*/
readonly httpAuthSchemeProvider: XYZServiceHttpAuthSchemeProvider;

}

/**
* @internal
*/
export const resolveHttpAuthSchemeConfig = <T>(
config: T & HttpAuthSchemeInputConfig
): T & HttpAuthSchemeResolvedConfig => {
return Object.assign(config, {
export const resolveHttpAuthSchemeConfig = <T>(config: T & HttpAuthSchemeInputConfig): T & HttpAuthSchemeResolvedConfig => {
return Object.assign(
config, {
authSchemePreference: normalizeProvider(config.authSchemePreference ?? []),
}) as T & HttpAuthSchemeResolvedConfig;
};
Loading