Skip to content

Commit c3c7fce

Browse files
committed
feat(codegen): generate well-formatted TypeScript
1 parent 716bf8e commit c3c7fce

File tree

82 files changed

+2993
-2377
lines changed

Some content is hidden

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

82 files changed

+2993
-2377
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
yarn turbo run build -F="./private/*" --only
2723

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,14 @@ export interface XYZService {
2424
* @see {@link GetNumbersCommand}
2525
*/
2626
getNumbers(): Promise<GetNumbersCommandOutput>;
27-
getNumbers(args: GetNumbersCommandInput, options?: __HttpHandlerOptions): Promise<GetNumbersCommandOutput>;
28-
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;
2935
getNumbers(
3036
args: GetNumbersCommandInput,
3137
options: __HttpHandlerOptions,

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

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,16 @@ export { __Client };
7272
/**
7373
* @public
7474
*/
75-
export type ServiceInputTypes = GetNumbersCommandInput | TradeEventStreamCommandInput;
75+
export type ServiceInputTypes =
76+
| GetNumbersCommandInput
77+
| TradeEventStreamCommandInput;
7678

7779
/**
7880
* @public
7981
*/
80-
export type ServiceOutputTypes = GetNumbersCommandOutput | TradeEventStreamCommandOutput;
82+
export type ServiceOutputTypes =
83+
| GetNumbersCommandOutput
84+
| TradeEventStreamCommandOutput;
8185

8286
/**
8387
* @public
@@ -245,27 +249,26 @@ export class XYZServiceClient extends __Client<
245249
readonly config: XYZServiceClientResolvedConfig;
246250

247251
constructor(...[configuration]: __CheckOptionalClientConfig<XYZServiceClientConfig>) {
248-
let _config_0 = __getRuntimeConfig(configuration || {});
252+
const _config_0 = __getRuntimeConfig(configuration || {});
249253
super(_config_0 as any);
250254
this.initConfig = _config_0;
251-
let _config_1 = resolveClientEndpointParameters(_config_0);
252-
let _config_2 = resolveRetryConfig(_config_1);
253-
let _config_3 = resolveEndpointConfig(_config_2);
254-
let _config_4 = resolveEndpointRequiredConfig(_config_3);
255-
let _config_5 = resolveEventStreamSerdeConfig(_config_4);
256-
let _config_6 = resolveHttpAuthSchemeConfig(_config_5);
257-
let _config_7 = resolveRuntimeExtensions(_config_6, configuration?.extensions || []);
255+
const _config_1 = resolveClientEndpointParameters(_config_0);
256+
const _config_2 = resolveRetryConfig(_config_1);
257+
const _config_3 = resolveEndpointConfig(_config_2);
258+
const _config_4 = resolveEndpointRequiredConfig(_config_3);
259+
const _config_5 = resolveEventStreamSerdeConfig(_config_4);
260+
const _config_6 = resolveHttpAuthSchemeConfig(_config_5);
261+
const _config_7 = resolveRuntimeExtensions(_config_6, configuration?.extensions || []);
258262
this.config = _config_7;
259263
this.middlewareStack.use(getSchemaSerdePlugin(this.config));
260264
this.middlewareStack.use(getRetryPlugin(this.config));
261265
this.middlewareStack.use(getContentLengthPlugin(this.config));
262-
this.middlewareStack.use(
263-
getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
266+
this.middlewareStack.use(getHttpAuthSchemeEndpointRuleSetPlugin(this.config,
267+
{
264268
httpAuthSchemeParametersProvider: defaultXYZServiceHttpAuthSchemeParametersProvider,
265-
identityProviderConfigProvider: async (config: XYZServiceClientResolvedConfig) =>
266-
new DefaultIdentityProviderConfig({}),
267-
})
268-
);
269+
identityProviderConfigProvider: async (config: XYZServiceClientResolvedConfig) => new DefaultIdentityProviderConfig({}),
270+
}
271+
));
269272
this.middlewareStack.use(getHttpSigningPlugin(this.config));
270273
}
271274

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export type HttpAuthRuntimeConfig = Partial<{
2727
export const getHttpAuthExtensionConfiguration = (
2828
runtimeConfig: HttpAuthRuntimeConfig
2929
): HttpAuthExtensionConfiguration => {
30-
let _httpAuthSchemes = runtimeConfig.httpAuthSchemes!;
30+
const _httpAuthSchemes = runtimeConfig.httpAuthSchemes!;
3131
let _httpAuthSchemeProvider = runtimeConfig.httpAuthSchemeProvider!;
3232
return {
3333
setHttpAuthScheme(httpAuthScheme: HttpAuthScheme): void {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ function createSmithyApiNoAuthHttpAuthOption(authParameters: XYZServiceHttpAuthS
5050
/**
5151
* @internal
5252
*/
53-
export interface XYZServiceHttpAuthSchemeProvider extends HttpAuthSchemeProvider<XYZServiceHttpAuthSchemeParameters> {}
53+
export interface XYZServiceHttpAuthSchemeProvider
54+
extends HttpAuthSchemeProvider<XYZServiceHttpAuthSchemeParameters> {}
5455

5556
/**
5657
* @internal

private/my-local-model-schema/src/endpoint/EndpointParameters.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@ export interface ClientInputEndpointParameters {
88
endpoint?: string | Provider<string> | Endpoint | Provider<Endpoint> | EndpointV2 | Provider<EndpointV2>;
99
}
1010

11+
/**
12+
* @internal
13+
*/
1114
export type ClientResolvedEndpointParameters = Omit<ClientInputEndpointParameters, "endpoint"> & {
1215
defaultSigningName: string;
1316
};
1417

18+
/**
19+
* @internal
20+
*/
1521
export const resolveClientEndpointParameters = <T>(
1622
options: T & ClientInputEndpointParameters
1723
): T & ClientResolvedEndpointParameters => {
@@ -20,6 +26,9 @@ export const resolveClientEndpointParameters = <T>(
2026
});
2127
};
2228

29+
/**
30+
* @internal
31+
*/
2332
export const commonParams = {
2433
endpoint: { type: "builtInParams", name: "endpoint" },
2534
} as const;

private/my-local-model-schema/src/models/models_0.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ export interface GetNumbersResponse {
4343
/**
4444
* @public
4545
*/
46-
export interface Unit {}
46+
export interface Unit {
47+
}
4748

4849
/**
4950
* @public

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,10 @@ export const getRuntimeConfig = (config: XYZServiceClientConfig) => {
2929
eventStreamSerdeProvider: config?.eventStreamSerdeProvider ?? eventStreamSerdeProvider,
3030
maxAttempts: config?.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS, config),
3131
requestHandler: RequestHandler.create(config?.requestHandler ?? defaultConfigProvider),
32-
retryMode:
33-
config?.retryMode ??
34-
loadNodeConfig(
35-
{
36-
...NODE_RETRY_MODE_CONFIG_OPTIONS,
37-
default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE,
38-
},
39-
config
40-
),
32+
retryMode: config?.retryMode ?? loadNodeConfig({
33+
...NODE_RETRY_MODE_CONFIG_OPTIONS,
34+
default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE
35+
}, config),
4136
sha256: config?.sha256 ?? Hash.bind(null, "sha256"),
4237
streamCollector: config?.streamCollector ?? streamCollector,
4338
};

private/my-local-model-schema/src/schemas/schemas_0.ts

Lines changed: 52 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -39,104 +39,77 @@ import {
3939
RetryableError as __RetryableError,
4040
XYZServiceServiceException as __XYZServiceServiceException,
4141
} from "../models/errors";
42-
import { XYZServiceSyntheticServiceException as __XYZServiceSyntheticServiceException } from "../models/XYZServiceSyntheticServiceException";
42+
import {
43+
XYZServiceSyntheticServiceException as __XYZServiceSyntheticServiceException,
44+
} from "../models/XYZServiceSyntheticServiceException";
4345

4446
/* eslint no-var: 0 */
45-
46-
export var Alpha: StaticStructureSchema = [3, n0, _A, 0, [_i, _t], [0, 4]];
47-
export var CodedThrottlingError: StaticErrorSchema = [
48-
-3,
49-
n0,
50-
_CTE,
51-
{
52-
[_e]: _c,
53-
[_hE]: 429,
54-
},
55-
[],
47+
export var Alpha: StaticStructureSchema = [3, n0, _A,
48+
0,
49+
[_i, _t],
50+
[0, 4]
51+
];
52+
export var CodedThrottlingError: StaticErrorSchema = [-3, n0, _CTE,
53+
{ [_e]: _c, [_hE]: 429 },
5654
[],
55+
[]
5756
];
5857
TypeRegistry.for(n0).registerError(CodedThrottlingError, __CodedThrottlingError);
59-
60-
export var GetNumbersRequest: StaticStructureSchema = [3, n0, _GNR, 0, [_bD, _bI, _fWM, _fWMi], [17, 19, 0, 0]];
61-
export var GetNumbersResponse: StaticStructureSchema = [3, n0, _GNRe, 0, [_bD, _bI], [17, 19]];
62-
export var HaltError: StaticErrorSchema = [
63-
-3,
64-
n0,
65-
_HE,
66-
{
67-
[_e]: _c,
68-
},
69-
[],
58+
export var GetNumbersRequest: StaticStructureSchema = [3, n0, _GNR,
59+
0,
60+
[_bD, _bI, _fWM, _fWMi],
61+
[17, 19, 0, 0]
62+
];
63+
export var GetNumbersResponse: StaticStructureSchema = [3, n0, _GNRe,
64+
0,
65+
[_bD, _bI],
66+
[17, 19]
67+
];
68+
export var HaltError: StaticErrorSchema = [-3, n0, _HE,
69+
{ [_e]: _c },
7070
[],
71+
[]
7172
];
7273
TypeRegistry.for(n0).registerError(HaltError, __HaltError);
73-
74-
export var MysteryThrottlingError: StaticErrorSchema = [
75-
-3,
76-
n0,
77-
_MTE,
78-
{
79-
[_e]: _c,
80-
},
81-
[],
74+
export var MysteryThrottlingError: StaticErrorSchema = [-3, n0, _MTE,
75+
{ [_e]: _c },
8276
[],
77+
[]
8378
];
8479
TypeRegistry.for(n0).registerError(MysteryThrottlingError, __MysteryThrottlingError);
85-
86-
export var RetryableError: StaticErrorSchema = [
87-
-3,
88-
n0,
89-
_RE,
90-
{
91-
[_e]: _c,
92-
},
93-
[],
80+
export var RetryableError: StaticErrorSchema = [-3, n0, _RE,
81+
{ [_e]: _c },
9482
[],
83+
[]
9584
];
9685
TypeRegistry.for(n0).registerError(RetryableError, __RetryableError);
97-
98-
export var TradeEventStreamRequest: StaticStructureSchema = [3, n0, _TESR, 0, [_eS], [[() => TradeEvents, 0]]];
99-
export var TradeEventStreamResponse: StaticStructureSchema = [3, n0, _TESRr, 0, [_eS], [[() => TradeEvents, 0]]];
100-
export var XYZServiceServiceException: StaticErrorSchema = [
101-
-3,
102-
n0,
103-
_XYZSSE,
104-
{
105-
[_e]: _c,
106-
},
107-
[],
108-
[],
86+
export var TradeEventStreamRequest: StaticStructureSchema = [3, n0, _TESR,
87+
0,
88+
[_eS],
89+
[[() => TradeEvents, 0]]
10990
];
110-
TypeRegistry.for(n0).registerError(XYZServiceServiceException, __XYZServiceServiceException);
111-
112-
export var __Unit = "unit" as const;
113-
114-
export var XYZServiceSyntheticServiceException: StaticErrorSchema = [
115-
-3,
116-
_s,
117-
"XYZServiceSyntheticServiceException",
91+
export var TradeEventStreamResponse: StaticStructureSchema = [3, n0, _TESRr,
11892
0,
93+
[_eS],
94+
[[() => TradeEvents, 0]]
95+
];
96+
export var XYZServiceServiceException: StaticErrorSchema = [-3, n0, _XYZSSE,
97+
{ [_e]: _c },
11998
[],
120-
[],
99+
[]
121100
];
101+
TypeRegistry.for(n0).registerError(XYZServiceServiceException, __XYZServiceServiceException);
102+
export var __Unit = "unit" as const;
103+
export var XYZServiceSyntheticServiceException: StaticErrorSchema = [-3, _s, "XYZServiceSyntheticServiceException", 0, [], []];
122104
TypeRegistry.for(_s).registerError(XYZServiceSyntheticServiceException, __XYZServiceSyntheticServiceException);
123-
124-
export var TradeEvents: StaticStructureSchema = [
125-
3,
126-
n0,
127-
_TE,
128-
{
129-
[_st]: 1,
130-
},
105+
export var TradeEvents: StaticStructureSchema = [3, n0, _TE,
106+
{ [_st]: 1 },
131107
[_a, _b, _g],
132-
[() => Alpha, () => __Unit, () => __Unit],
108+
[() => Alpha, () => __Unit, () => __Unit]
133109
];
134-
export var GetNumbers: StaticOperationSchema = [9, n0, _GN, 0, () => GetNumbersRequest, () => GetNumbersResponse];
135-
export var TradeEventStream: StaticOperationSchema = [
136-
9,
137-
n0,
138-
_TES,
139-
0,
140-
() => TradeEventStreamRequest,
141-
() => TradeEventStreamResponse,
110+
export var GetNumbers: StaticOperationSchema = [9, n0, _GN,
111+
0, () => GetNumbersRequest, () => GetNumbersResponse
112+
];
113+
export var TradeEventStream: StaticOperationSchema = [9, n0, _TES,
114+
0, () => TradeEventStreamRequest, () => TradeEventStreamResponse
142115
];

0 commit comments

Comments
 (0)