Skip to content

Commit c161362

Browse files
committed
feat(codegen): support type import statements
1 parent ca0ee3f commit c161362

File tree

158 files changed

+6476
-5340
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+6476
-5340
lines changed

.changeset/famous-planes-vanish.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ generate-protocol-tests:
1818
cp -r ./smithy-typescript-protocol-test-codegen/build/smithyprojections/smithy-typescript-protocol-test-codegen/my-local-model/typescript-client-codegen/ ./private/my-local-model
1919
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
2020
node ./scripts/post-protocol-test-codegen
21-
npx prettier --write ./private/smithy-rpcv2-cbor
22-
npx prettier --write ./private/smithy-rpcv2-cbor-schema
23-
npx prettier --write ./private/my-local-model
24-
npx prettier --write ./private/my-local-model-schema
2521
yarn
2622
(cd ./private/smithy-rpcv2-cbor && npm run build)
2723
(cd ./private/smithy-rpcv2-cbor-schema && npm run build)

private/my-local-model-schema/src/XYZService.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
// smithy-typescript generated code
2-
import { XYZServiceClient, XYZServiceClientConfig } from "./XYZServiceClient";
3-
import { GetNumbersCommand, GetNumbersCommandInput, GetNumbersCommandOutput } from "./commands/GetNumbersCommand";
2+
import { createAggregatedClient } from "@smithy/smithy-client";
3+
import type { HttpHandlerOptions as __HttpHandlerOptions } from "@smithy/types";
4+
5+
import {
6+
type GetNumbersCommandInput,
7+
type GetNumbersCommandOutput,
8+
GetNumbersCommand,
9+
} from "./commands/GetNumbersCommand";
410
import {
11+
type TradeEventStreamCommandInput,
12+
type TradeEventStreamCommandOutput,
513
TradeEventStreamCommand,
6-
TradeEventStreamCommandInput,
7-
TradeEventStreamCommandOutput,
814
} from "./commands/TradeEventStreamCommand";
9-
import { createAggregatedClient } from "@smithy/smithy-client";
10-
import { HttpHandlerOptions as __HttpHandlerOptions } from "@smithy/types";
15+
import { XYZServiceClient } from "./XYZServiceClient";
1116

1217
const commands = {
1318
GetNumbersCommand,
@@ -19,8 +24,14 @@ export interface XYZService {
1924
* @see {@link GetNumbersCommand}
2025
*/
2126
getNumbers(): Promise<GetNumbersCommandOutput>;
22-
getNumbers(args: GetNumbersCommandInput, options?: __HttpHandlerOptions): Promise<GetNumbersCommandOutput>;
23-
getNumbers(args: GetNumbersCommandInput, cb: (err: any, data?: GetNumbersCommandOutput) => void): void;
27+
getNumbers(
28+
args: GetNumbersCommandInput,
29+
options?: __HttpHandlerOptions,
30+
): Promise<GetNumbersCommandOutput>;
31+
getNumbers(
32+
args: GetNumbersCommandInput,
33+
cb: (err: any, data?: GetNumbersCommandOutput) => void
34+
): void;
2435
getNumbers(
2536
args: GetNumbersCommandInput,
2637
options: __HttpHandlerOptions,
@@ -33,7 +44,7 @@ export interface XYZService {
3344
tradeEventStream(): Promise<TradeEventStreamCommandOutput>;
3445
tradeEventStream(
3546
args: TradeEventStreamCommandInput,
36-
options?: __HttpHandlerOptions
47+
options?: __HttpHandlerOptions,
3748
): Promise<TradeEventStreamCommandOutput>;
3849
tradeEventStream(
3950
args: TradeEventStreamCommandInput,
@@ -44,6 +55,7 @@ export interface XYZService {
4455
options: __HttpHandlerOptions,
4556
cb: (err: any, data?: TradeEventStreamCommandOutput) => void
4657
): void;
58+
4759
}
4860

4961
/**

private/my-local-model-schema/src/XYZServiceClient.ts

Lines changed: 81 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,97 @@
11
// smithy-typescript generated code
2-
import {
3-
HttpAuthSchemeInputConfig,
4-
HttpAuthSchemeResolvedConfig,
5-
defaultXYZServiceHttpAuthSchemeParametersProvider,
6-
resolveHttpAuthSchemeConfig,
7-
} from "./auth/httpAuthSchemeProvider";
8-
import { GetNumbersCommandInput, GetNumbersCommandOutput } from "./commands/GetNumbersCommand";
9-
import { TradeEventStreamCommandInput, TradeEventStreamCommandOutput } from "./commands/TradeEventStreamCommand";
10-
import {
11-
ClientInputEndpointParameters,
12-
ClientResolvedEndpointParameters,
13-
EndpointParameters,
14-
resolveClientEndpointParameters,
15-
} from "./endpoint/EndpointParameters";
16-
import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig";
17-
import { RuntimeExtension, RuntimeExtensionsConfig, resolveRuntimeExtensions } from "./runtimeExtensions";
182
import {
193
DefaultIdentityProviderConfig,
204
getHttpAuthSchemeEndpointRuleSetPlugin,
215
getHttpSigningPlugin,
226
} from "@smithy/core";
237
import { getSchemaSerdePlugin } from "@smithy/core/schema";
248
import {
25-
EventStreamSerdeInputConfig,
26-
EventStreamSerdeResolvedConfig,
9+
type EventStreamSerdeInputConfig,
10+
type EventStreamSerdeResolvedConfig,
2711
resolveEventStreamSerdeConfig,
2812
} from "@smithy/eventstream-serde-config-resolver";
2913
import { getContentLengthPlugin } from "@smithy/middleware-content-length";
3014
import {
31-
EndpointInputConfig,
32-
EndpointRequiredInputConfig,
33-
EndpointRequiredResolvedConfig,
34-
EndpointResolvedConfig,
15+
type EndpointInputConfig,
16+
type EndpointRequiredInputConfig,
17+
type EndpointRequiredResolvedConfig,
18+
type EndpointResolvedConfig,
3519
resolveEndpointConfig,
3620
resolveEndpointRequiredConfig,
3721
} from "@smithy/middleware-endpoint";
38-
import { RetryInputConfig, RetryResolvedConfig, getRetryPlugin, resolveRetryConfig } from "@smithy/middleware-retry";
39-
import { HttpHandlerUserInput as __HttpHandlerUserInput } from "@smithy/protocol-http";
4022
import {
23+
type RetryInputConfig,
24+
type RetryResolvedConfig,
25+
getRetryPlugin,
26+
resolveRetryConfig,
27+
} from "@smithy/middleware-retry";
28+
import type { HttpHandlerUserInput as __HttpHandlerUserInput } from "@smithy/protocol-http";
29+
import {
30+
type DefaultsMode as __DefaultsMode,
31+
type SmithyConfiguration as __SmithyConfiguration,
32+
type SmithyResolvedConfiguration as __SmithyResolvedConfiguration,
4133
Client as __Client,
42-
DefaultsMode as __DefaultsMode,
43-
SmithyConfiguration as __SmithyConfiguration,
44-
SmithyResolvedConfiguration as __SmithyResolvedConfiguration,
4534
} from "@smithy/smithy-client";
46-
import {
47-
ClientProtocol,
48-
HttpRequest,
49-
HttpResponse,
35+
import type {
5036
BodyLengthCalculator as __BodyLengthCalculator,
5137
CheckOptionalClientConfig as __CheckOptionalClientConfig,
5238
ChecksumConstructor as __ChecksumConstructor,
39+
ClientProtocol,
5340
Decoder as __Decoder,
5441
Encoder as __Encoder,
5542
EventStreamSerdeProvider as __EventStreamSerdeProvider,
5643
HashConstructor as __HashConstructor,
5744
HttpHandlerOptions as __HttpHandlerOptions,
45+
HttpRequest,
46+
HttpResponse,
5847
Logger as __Logger,
5948
Provider as __Provider,
6049
StreamCollector as __StreamCollector,
6150
UrlParser as __UrlParser,
6251
} from "@smithy/types";
6352

64-
export { __Client };
53+
import {
54+
type HttpAuthSchemeInputConfig,
55+
type HttpAuthSchemeResolvedConfig,
56+
defaultXYZServiceHttpAuthSchemeParametersProvider,
57+
resolveHttpAuthSchemeConfig,
58+
} from "./auth/httpAuthSchemeProvider";
59+
import type { GetNumbersCommandInput, GetNumbersCommandOutput } from "./commands/GetNumbersCommand";
60+
import type { TradeEventStreamCommandInput, TradeEventStreamCommandOutput } from "./commands/TradeEventStreamCommand";
61+
import {
62+
type ClientInputEndpointParameters,
63+
type ClientResolvedEndpointParameters,
64+
type EndpointParameters,
65+
resolveClientEndpointParameters,
66+
} from "./endpoint/EndpointParameters";
67+
import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig";
68+
import {
69+
type RuntimeExtension,
70+
type RuntimeExtensionsConfig,
71+
resolveRuntimeExtensions,
72+
} from "./runtimeExtensions";
73+
74+
export { __Client }
6575

6676
/**
6777
* @public
6878
*/
69-
export type ServiceInputTypes = GetNumbersCommandInput | TradeEventStreamCommandInput;
79+
export type ServiceInputTypes =
80+
| GetNumbersCommandInput
81+
| TradeEventStreamCommandInput;
7082

7183
/**
7284
* @public
7385
*/
74-
export type ServiceOutputTypes = GetNumbersCommandOutput | TradeEventStreamCommandOutput;
86+
export type ServiceOutputTypes =
87+
| GetNumbersCommandOutput
88+
| TradeEventStreamCommandOutput;
7589

7690
/**
7791
* @public
7892
*/
79-
export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHandlerOptions>> {
93+
export interface ClientDefaults
94+
extends Partial<__SmithyConfiguration<__HttpHandlerOptions>> {
8095
/**
8196
* The HTTP handler to use or its constructor options. Fetch in browser and Https in Nodejs.
8297
*/
@@ -184,19 +199,20 @@ export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHand
184199
* The {@link @smithy/smithy-client#DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK.
185200
*/
186201
defaultsMode?: __DefaultsMode | __Provider<__DefaultsMode>;
202+
187203
}
188204

189205
/**
190206
* @public
191207
*/
192-
export type XYZServiceClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> &
193-
ClientDefaults &
194-
RetryInputConfig &
195-
EndpointInputConfig<EndpointParameters> &
196-
EndpointRequiredInputConfig &
197-
EventStreamSerdeInputConfig &
198-
HttpAuthSchemeInputConfig &
199-
ClientInputEndpointParameters;
208+
export type XYZServiceClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>>
209+
& ClientDefaults
210+
& RetryInputConfig
211+
& EndpointInputConfig<EndpointParameters>
212+
& EndpointRequiredInputConfig
213+
& EventStreamSerdeInputConfig
214+
& HttpAuthSchemeInputConfig
215+
& ClientInputEndpointParameters
200216
/**
201217
* @public
202218
*
@@ -207,15 +223,15 @@ export interface XYZServiceClientConfig extends XYZServiceClientConfigType {}
207223
/**
208224
* @public
209225
*/
210-
export type XYZServiceClientResolvedConfigType = __SmithyResolvedConfiguration<__HttpHandlerOptions> &
211-
Required<ClientDefaults> &
212-
RuntimeExtensionsConfig &
213-
RetryResolvedConfig &
214-
EndpointResolvedConfig<EndpointParameters> &
215-
EndpointRequiredResolvedConfig &
216-
EventStreamSerdeResolvedConfig &
217-
HttpAuthSchemeResolvedConfig &
218-
ClientResolvedEndpointParameters;
226+
export type XYZServiceClientResolvedConfigType = __SmithyResolvedConfiguration<__HttpHandlerOptions>
227+
& Required<ClientDefaults>
228+
& RuntimeExtensionsConfig
229+
& RetryResolvedConfig
230+
& EndpointResolvedConfig<EndpointParameters>
231+
& EndpointRequiredResolvedConfig
232+
& EventStreamSerdeResolvedConfig
233+
& HttpAuthSchemeResolvedConfig
234+
& ClientResolvedEndpointParameters
219235
/**
220236
* @public
221237
*
@@ -239,27 +255,26 @@ export class XYZServiceClient extends __Client<
239255
readonly config: XYZServiceClientResolvedConfig;
240256

241257
constructor(...[configuration]: __CheckOptionalClientConfig<XYZServiceClientConfig>) {
242-
let _config_0 = __getRuntimeConfig(configuration || {});
258+
const _config_0 = __getRuntimeConfig(configuration || {});
243259
super(_config_0 as any);
244260
this.initConfig = _config_0;
245-
let _config_1 = resolveClientEndpointParameters(_config_0);
246-
let _config_2 = resolveRetryConfig(_config_1);
247-
let _config_3 = resolveEndpointConfig(_config_2);
248-
let _config_4 = resolveEndpointRequiredConfig(_config_3);
249-
let _config_5 = resolveEventStreamSerdeConfig(_config_4);
250-
let _config_6 = resolveHttpAuthSchemeConfig(_config_5);
251-
let _config_7 = resolveRuntimeExtensions(_config_6, configuration?.extensions || []);
261+
const _config_1 = resolveClientEndpointParameters(_config_0);
262+
const _config_2 = resolveRetryConfig(_config_1);
263+
const _config_3 = resolveEndpointConfig(_config_2);
264+
const _config_4 = resolveEndpointRequiredConfig(_config_3);
265+
const _config_5 = resolveEventStreamSerdeConfig(_config_4);
266+
const _config_6 = resolveHttpAuthSchemeConfig(_config_5);
267+
const _config_7 = resolveRuntimeExtensions(_config_6, configuration?.extensions || []);
252268
this.config = _config_7;
253269
this.middlewareStack.use(getSchemaSerdePlugin(this.config));
254270
this.middlewareStack.use(getRetryPlugin(this.config));
255271
this.middlewareStack.use(getContentLengthPlugin(this.config));
256-
this.middlewareStack.use(
257-
getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
272+
this.middlewareStack.use(getHttpAuthSchemeEndpointRuleSetPlugin(this.config,
273+
{
258274
httpAuthSchemeParametersProvider: defaultXYZServiceHttpAuthSchemeParametersProvider,
259-
identityProviderConfigProvider: async (config: XYZServiceClientResolvedConfig) =>
260-
new DefaultIdentityProviderConfig({}),
261-
})
262-
);
275+
identityProviderConfigProvider: async (config: XYZServiceClientResolvedConfig) => new DefaultIdentityProviderConfig({}),
276+
}
277+
));
263278
this.middlewareStack.use(getHttpSigningPlugin(this.config));
264279
}
265280

private/my-local-model-schema/src/auth/httpAuthExtensionConfiguration.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// smithy-typescript generated code
2-
import { XYZServiceHttpAuthSchemeProvider } from "./httpAuthSchemeProvider";
3-
import { HttpAuthScheme } from "@smithy/types";
2+
import type { HttpAuthScheme } from "@smithy/types";
3+
4+
import type { XYZServiceHttpAuthSchemeProvider } from "./httpAuthSchemeProvider";
45

56
/**
67
* @internal
@@ -23,14 +24,12 @@ export type HttpAuthRuntimeConfig = Partial<{
2324
/**
2425
* @internal
2526
*/
26-
export const getHttpAuthExtensionConfiguration = (
27-
runtimeConfig: HttpAuthRuntimeConfig
28-
): HttpAuthExtensionConfiguration => {
29-
let _httpAuthSchemes = runtimeConfig.httpAuthSchemes!;
27+
export const getHttpAuthExtensionConfiguration = (runtimeConfig: HttpAuthRuntimeConfig): HttpAuthExtensionConfiguration => {
28+
const _httpAuthSchemes = runtimeConfig.httpAuthSchemes!;
3029
let _httpAuthSchemeProvider = runtimeConfig.httpAuthSchemeProvider!;
3130
return {
3231
setHttpAuthScheme(httpAuthScheme: HttpAuthScheme): void {
33-
const index = _httpAuthSchemes.findIndex((scheme) => scheme.schemeId === httpAuthScheme.schemeId);
32+
const index = _httpAuthSchemes.findIndex(scheme => scheme.schemeId === httpAuthScheme.schemeId);
3433
if (index === -1) {
3534
_httpAuthSchemes.push(httpAuthScheme);
3635
} else {
@@ -46,7 +45,7 @@ export const getHttpAuthExtensionConfiguration = (
4645
httpAuthSchemeProvider(): XYZServiceHttpAuthSchemeProvider {
4746
return _httpAuthSchemeProvider;
4847
},
49-
};
48+
}
5049
};
5150

5251
/**

0 commit comments

Comments
 (0)