Skip to content

Commit 90f9532

Browse files
committed
chore: refactor code and add custom ruleset
1 parent 622284b commit 90f9532

File tree

11 files changed

+270
-101
lines changed

11 files changed

+270
-101
lines changed

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ import {
1313
import { getContentLengthPlugin } from "@smithy/middleware-content-length";
1414
import {
1515
type EndpointInputConfig,
16-
type EndpointRequiredInputConfig,
17-
type EndpointRequiredResolvedConfig,
1816
type EndpointResolvedConfig,
1917
resolveEndpointConfig,
20-
resolveEndpointRequiredConfig,
2118
} from "@smithy/middleware-endpoint";
2219
import {
2320
type RetryInputConfig,
@@ -199,7 +196,6 @@ export type XYZServiceClientConfigType = Partial<__SmithyConfiguration<__HttpHan
199196
ClientDefaults &
200197
RetryInputConfig &
201198
EndpointInputConfig<EndpointParameters> &
202-
EndpointRequiredInputConfig &
203199
EventStreamSerdeInputConfig &
204200
HttpAuthSchemeInputConfig &
205201
ClientInputEndpointParameters;
@@ -218,7 +214,6 @@ export type XYZServiceClientResolvedConfigType = __SmithyResolvedConfiguration<_
218214
RuntimeExtensionsConfig &
219215
RetryResolvedConfig &
220216
EndpointResolvedConfig<EndpointParameters> &
221-
EndpointRequiredResolvedConfig &
222217
EventStreamSerdeResolvedConfig &
223218
HttpAuthSchemeResolvedConfig &
224219
ClientResolvedEndpointParameters;
@@ -248,14 +243,13 @@ export class XYZServiceClient extends __Client<
248243
const _config_0 = __getRuntimeConfig(configuration || {});
249244
super(_config_0 as any);
250245
this.initConfig = _config_0;
251-
const _config_1 = resolveClientEndpointParameters(_config_0);
252-
const _config_2 = resolveRetryConfig(_config_1);
253-
const _config_3 = resolveEndpointConfig(_config_2);
254-
const _config_4 = resolveEndpointRequiredConfig(_config_3);
255-
const _config_5 = resolveEventStreamSerdeConfig(_config_4);
256-
const _config_6 = resolveHttpAuthSchemeConfig(_config_5);
257-
const _config_7 = resolveRuntimeExtensions(_config_6, configuration?.extensions || []);
258-
this.config = _config_7;
246+
let _config_1 = resolveClientEndpointParameters(_config_0);
247+
let _config_2 = resolveRetryConfig(_config_1);
248+
let _config_3 = resolveEndpointConfig(_config_2);
249+
let _config_4 = resolveEventStreamSerdeConfig(_config_3);
250+
let _config_5 = resolveHttpAuthSchemeConfig(_config_4);
251+
let _config_6 = resolveRuntimeExtensions(_config_5, configuration?.extensions || []);
252+
this.config = _config_6;
259253
this.middlewareStack.use(getSchemaSerdePlugin(this.config));
260254
this.middlewareStack.use(getRetryPlugin(this.config));
261255
this.middlewareStack.use(getContentLengthPlugin(this.config));
Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,63 @@
11
// smithy-typescript generated code
2-
import { type Endpoint, type EndpointV2, EndpointParameters as __EndpointParameters, Provider } from "@smithy/types";
2+
import type { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provider } from "@smithy/types";
33

44
/**
55
* @public
66
*/
77
export interface ClientInputEndpointParameters {
8+
clientContextParams?: {
9+
apiKey?: string | undefined | Provider<string | undefined>;
10+
customParam?: string | undefined | Provider<string | undefined>;
11+
};
812
endpoint?: string | Provider<string> | Endpoint | Provider<Endpoint> | EndpointV2 | Provider<EndpointV2>;
13+
apiKey?: string | undefined | Provider<string | undefined>;
14+
customParam?: string | undefined | Provider<string | undefined>;
915
}
1016

11-
/**
12-
* @public
13-
*/
14-
export type ClientResolvedEndpointParameters = Omit<ClientInputEndpointParameters, "endpoint"> & {
17+
export type ClientResolvedEndpointParameters = Omit<
18+
ClientInputEndpointParameters,
19+
"endpoint" | "clientContextParams"
20+
> & {
1521
defaultSigningName: string;
22+
clientContextParams: {
23+
apiKey?: string | undefined | Provider<string | undefined>;
24+
customParam?: string | undefined | Provider<string | undefined>;
25+
};
1626
};
1727

1828
/**
1929
* @internal
2030
*/
31+
const clientContextParamDefaults = {
32+
apiKey: "default-api-key",
33+
customParam: "default-custom-value",
34+
} as const;
35+
2136
export const resolveClientEndpointParameters = <T>(
2237
options: T & ClientInputEndpointParameters
2338
): T & ClientResolvedEndpointParameters => {
2439
return Object.assign(options, {
40+
apiKey: options.apiKey ?? "default-api-key",
41+
customParam: options.customParam ?? "default-custom-value",
2542
defaultSigningName: "",
43+
clientContextParams: Object.assign(clientContextParamDefaults, options.clientContextParams),
2644
});
2745
};
2846

2947
/**
3048
* @internal
3149
*/
3250
export const commonParams = {
51+
apiKey: { type: "clientContextParams", name: "apiKey" },
52+
customParam: { type: "clientContextParams", name: "customParam" },
3353
endpoint: { type: "builtInParams", name: "endpoint" },
3454
} as const;
3555

3656
/**
3757
* @internal
3858
*/
3959
export interface EndpointParameters extends __EndpointParameters {
40-
endpoint?: string | undefined;
60+
endpoint: string;
61+
apiKey?: string | undefined;
62+
customParam?: string | undefined;
4163
}

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

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,33 @@ export const ruleSet: RuleSetObject = {
55
version: "1.0",
66
parameters: {
77
endpoint: {
8-
type: "string",
98
builtIn: "SDK::Endpoint",
10-
documentation: "Endpoint used for making requests. Should be formatted as a URI.",
9+
required: true,
10+
documentation: "The endpoint used to send the request.",
11+
type: "String",
12+
},
13+
apiKey: {
14+
type: "String",
15+
required: true,
16+
default: "default-api-key",
17+
documentation: "API key for service authentication",
18+
},
19+
customParam: {
20+
type: "String",
21+
required: true,
22+
default: "default-custom-value",
23+
documentation: "Custom parameter for testing",
1124
},
1225
},
1326
rules: [
1427
{
15-
conditions: [
16-
{
17-
fn: "isSet",
18-
argv: [
19-
{
20-
ref: "endpoint",
21-
},
22-
],
23-
},
24-
],
28+
conditions: [],
2529
endpoint: {
26-
url: {
27-
ref: "endpoint",
28-
},
30+
url: "{endpoint}",
31+
properties: {},
32+
headers: {},
2933
},
3034
type: "endpoint",
3135
},
32-
{
33-
conditions: [],
34-
error: "(default endpointRuleSet) endpoint is not set - you must configure an endpoint.",
35-
type: "error",
36-
},
3736
],
3837
};

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@ import {
1212
import { getContentLengthPlugin } from "@smithy/middleware-content-length";
1313
import {
1414
type EndpointInputConfig,
15-
type EndpointRequiredInputConfig,
16-
type EndpointRequiredResolvedConfig,
1715
type EndpointResolvedConfig,
1816
resolveEndpointConfig,
19-
resolveEndpointRequiredConfig,
2017
} from "@smithy/middleware-endpoint";
2118
import {
2219
type RetryInputConfig,
@@ -185,7 +182,6 @@ export type XYZServiceClientConfigType = Partial<__SmithyConfiguration<__HttpHan
185182
ClientDefaults &
186183
RetryInputConfig &
187184
EndpointInputConfig<EndpointParameters> &
188-
EndpointRequiredInputConfig &
189185
EventStreamSerdeInputConfig &
190186
HttpAuthSchemeInputConfig &
191187
ClientInputEndpointParameters;
@@ -204,7 +200,6 @@ export type XYZServiceClientResolvedConfigType = __SmithyResolvedConfiguration<_
204200
RuntimeExtensionsConfig &
205201
RetryResolvedConfig &
206202
EndpointResolvedConfig<EndpointParameters> &
207-
EndpointRequiredResolvedConfig &
208203
EventStreamSerdeResolvedConfig &
209204
HttpAuthSchemeResolvedConfig &
210205
ClientResolvedEndpointParameters;
@@ -234,6 +229,7 @@ export class XYZServiceClient extends __Client<
234229
const _config_0 = __getRuntimeConfig(configuration || {});
235230
super(_config_0 as any);
236231
this.initConfig = _config_0;
232+
<<<<<<< HEAD
237233
const _config_1 = resolveClientEndpointParameters(_config_0);
238234
const _config_2 = resolveRetryConfig(_config_1);
239235
const _config_3 = resolveEndpointConfig(_config_2);
@@ -242,6 +238,15 @@ export class XYZServiceClient extends __Client<
242238
const _config_6 = resolveHttpAuthSchemeConfig(_config_5);
243239
const _config_7 = resolveRuntimeExtensions(_config_6, configuration?.extensions || []);
244240
this.config = _config_7;
241+
=======
242+
let _config_1 = resolveClientEndpointParameters(_config_0);
243+
let _config_2 = resolveRetryConfig(_config_1);
244+
let _config_3 = resolveEndpointConfig(_config_2);
245+
let _config_4 = resolveEventStreamSerdeConfig(_config_3);
246+
let _config_5 = resolveHttpAuthSchemeConfig(_config_4);
247+
let _config_6 = resolveRuntimeExtensions(_config_5, configuration?.extensions || []);
248+
this.config = _config_6;
249+
>>>>>>> 815c7a737 (chore: refactor code and add custom ruleset)
245250
this.middlewareStack.use(getRetryPlugin(this.config));
246251
this.middlewareStack.use(getContentLengthPlugin(this.config));
247252
this.middlewareStack.use(
Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,63 @@
11
// smithy-typescript generated code
2-
import { type Endpoint, type EndpointV2, EndpointParameters as __EndpointParameters, Provider } from "@smithy/types";
2+
import type { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provider } from "@smithy/types";
33

44
/**
55
* @public
66
*/
77
export interface ClientInputEndpointParameters {
8+
clientContextParams?: {
9+
apiKey?: string | undefined | Provider<string | undefined>;
10+
customParam?: string | undefined | Provider<string | undefined>;
11+
};
812
endpoint?: string | Provider<string> | Endpoint | Provider<Endpoint> | EndpointV2 | Provider<EndpointV2>;
13+
apiKey?: string | undefined | Provider<string | undefined>;
14+
customParam?: string | undefined | Provider<string | undefined>;
915
}
1016

11-
/**
12-
* @public
13-
*/
14-
export type ClientResolvedEndpointParameters = Omit<ClientInputEndpointParameters, "endpoint"> & {
17+
export type ClientResolvedEndpointParameters = Omit<
18+
ClientInputEndpointParameters,
19+
"endpoint" | "clientContextParams"
20+
> & {
1521
defaultSigningName: string;
22+
clientContextParams: {
23+
apiKey?: string | undefined | Provider<string | undefined>;
24+
customParam?: string | undefined | Provider<string | undefined>;
25+
};
1626
};
1727

1828
/**
1929
* @internal
2030
*/
31+
const clientContextParamDefaults = {
32+
apiKey: "default-api-key",
33+
customParam: "default-custom-value",
34+
} as const;
35+
2136
export const resolveClientEndpointParameters = <T>(
2237
options: T & ClientInputEndpointParameters
2338
): T & ClientResolvedEndpointParameters => {
2439
return Object.assign(options, {
40+
apiKey: options.apiKey ?? "default-api-key",
41+
customParam: options.customParam ?? "default-custom-value",
2542
defaultSigningName: "",
43+
clientContextParams: Object.assign(clientContextParamDefaults, options.clientContextParams),
2644
});
2745
};
2846

2947
/**
3048
* @internal
3149
*/
3250
export const commonParams = {
51+
apiKey: { type: "clientContextParams", name: "apiKey" },
52+
customParam: { type: "clientContextParams", name: "customParam" },
3353
endpoint: { type: "builtInParams", name: "endpoint" },
3454
} as const;
3555

3656
/**
3757
* @internal
3858
*/
3959
export interface EndpointParameters extends __EndpointParameters {
40-
endpoint?: string | undefined;
60+
endpoint: string;
61+
apiKey?: string | undefined;
62+
customParam?: string | undefined;
4163
}

private/my-local-model/src/endpoint/ruleset.ts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,33 @@ export const ruleSet: RuleSetObject = {
55
version: "1.0",
66
parameters: {
77
endpoint: {
8-
type: "string",
98
builtIn: "SDK::Endpoint",
10-
documentation: "Endpoint used for making requests. Should be formatted as a URI.",
9+
required: true,
10+
documentation: "The endpoint used to send the request.",
11+
type: "String",
12+
},
13+
apiKey: {
14+
type: "String",
15+
required: true,
16+
default: "default-api-key",
17+
documentation: "API key for service authentication",
18+
},
19+
customParam: {
20+
type: "String",
21+
required: true,
22+
default: "default-custom-value",
23+
documentation: "Custom parameter for testing",
1124
},
1225
},
1326
rules: [
1427
{
15-
conditions: [
16-
{
17-
fn: "isSet",
18-
argv: [
19-
{
20-
ref: "endpoint",
21-
},
22-
],
23-
},
24-
],
28+
conditions: [],
2529
endpoint: {
26-
url: {
27-
ref: "endpoint",
28-
},
30+
url: "{endpoint}",
31+
properties: {},
32+
headers: {},
2933
},
3034
type: "endpoint",
3135
},
32-
{
33-
conditions: [],
34-
error: "(default endpointRuleSet) endpoint is not set - you must configure an endpoint.",
35-
type: "error",
36-
},
3736
],
3837
};

private/smithy-rpcv2-cbor-schema/src/endpoint/EndpointParameters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// smithy-typescript generated code
2-
import { type Endpoint, type EndpointV2, EndpointParameters as __EndpointParameters, Provider } from "@smithy/types";
2+
import type { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provider } from "@smithy/types";
33

44
/**
55
* @public

private/smithy-rpcv2-cbor/src/endpoint/EndpointParameters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// smithy-typescript generated code
2-
import { type Endpoint, type EndpointV2, EndpointParameters as __EndpointParameters, Provider } from "@smithy/types";
2+
import type { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provider } from "@smithy/types";
33

44
/**
55
* @public

0 commit comments

Comments
 (0)