Skip to content

Commit c848d0a

Browse files
committed
chore: fix formatting and type imports
1 parent 4858763 commit c848d0a

File tree

12 files changed

+59
-49
lines changed

12 files changed

+59
-49
lines changed

packages/eventstream-serde-universal/src/clientContextParams-precedence.integ.spec.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,23 @@ import { XYZService } from "xyz";
33

44
describe("client context parameters precedence integration test", () => {
55
it("should handle conflicting vs non-conflicting parameter precedence correctly", async () => {
6-
// For non-conflicting parameter root level takes precedence over nested defaults
6+
// For non-conflicting params
77
const clientWithNonConflicting = new XYZService({
88
endpoint: "https://localhost",
99
apiKey: async () => ({ apiKey: "test-key" }),
1010
customParam: "user-custom-value",
1111
clientContextParams: {
1212
apiKey: "test-key",
13-
customParam: "default-custom-value",
13+
customParam: "nested-custom-value",
1414
},
1515
});
1616

17-
// Verify the resolved config has the user's root-level value
18-
const resolvedConfig = (clientWithNonConflicting as any).config;
19-
expect(resolvedConfig.customParam).toBe("user-custom-value");
17+
// Verify that endpoint resolution uses the nested value over root value
18+
const resolvedConfig = (clientWithNonConflicting).config;
19+
const effectiveCustomParam = resolvedConfig.clientContextParams?.customParam ?? resolvedConfig.customParam;
20+
expect(effectiveCustomParam).toBe("nested-custom-value");
2021

21-
// For conflicting parameters nested values are used for endpoint resolution
22+
// For conflicting parameters
2223
const clientWithConflicting = new XYZService({
2324
endpoint: "https://localhost",
2425
apiKey: async () => ({ apiKey: "auth-key" }),
@@ -28,13 +29,13 @@ describe("client context parameters precedence integration test", () => {
2829
});
2930

3031
// Verify that both auth and endpoint contexts can coexist
31-
const resolvedConfigConflicting = (clientWithConflicting as any).config;
32+
const resolvedConfigConflicting = (clientWithConflicting).config;
3233

3334
// Verify endpoint context has the nested value
34-
expect(resolvedConfigConflicting.clientContextParams.apiKey).toBe("endpoint-key");
35+
expect(resolvedConfigConflicting.clientContextParams?.apiKey).toBe("endpoint-key");
3536

3637
// Verify auth context has the auth provider
37-
const authIdentity = await resolvedConfigConflicting.apiKey();
38-
expect(authIdentity.apiKey).toBe("auth-key");
38+
const authIdentity = await resolvedConfigConflicting.apiKey?.();
39+
expect(authIdentity?.apiKey).toBe("auth-key");
3940
});
4041
});

private/my-local-model-schema/src/auth/httpAuthExtensionConfiguration.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 HttpAuthScheme, ApiKeyIdentity, ApiKeyIdentityProvider } from "@smithy/types";
2+
import type { ApiKeyIdentity, ApiKeyIdentityProvider, HttpAuthScheme } from "@smithy/types";
33

44
import type { XYZServiceHttpAuthSchemeProvider } from "./httpAuthSchemeProvider";
55

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// smithy-typescript generated code
22
import { doesIdentityRequireRefresh, isIdentityExpired, memoizeIdentityProvider } from "@smithy/core";
33
import {
4+
type ApiKeyIdentity,
5+
type ApiKeyIdentityProvider,
46
type HandlerExecutionContext,
57
type HttpAuthOption,
68
type HttpAuthScheme,
79
type HttpAuthSchemeParameters,
810
type HttpAuthSchemeParametersProvider,
911
type HttpAuthSchemeProvider,
1012
type Provider,
11-
ApiKeyIdentity,
12-
ApiKeyIdentityProvider,
1313
HttpApiKeyAuthLocation,
1414
} from "@smithy/types";
1515
import { getSmithyContext, normalizeProvider } from "@smithy/util-middleware";

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,44 @@ export const ruleSet: RuleSetObject = {
88
builtIn: "SDK::Endpoint",
99
required: true,
1010
documentation: "The endpoint used to send the request.",
11-
type: "String",
11+
type: "string",
1212
},
1313
ApiKey: {
1414
required: false,
1515
documentation: "ApiKey",
16-
type: "String",
16+
type: "string",
1717
},
1818
region: {
19-
type: "String",
19+
type: "string",
2020
required: false,
2121
documentation: "AWS region",
2222
},
2323
customParam: {
24-
type: "String",
24+
type: "string",
2525
required: true,
2626
default: "default-custom-value",
2727
documentation: "Custom parameter for testing",
2828
},
2929
enableFeature: {
30-
type: "Boolean",
30+
type: "boolean",
3131
required: true,
3232
default: true,
3333
documentation: "Feature toggle with default",
3434
},
3535
debugMode: {
36-
type: "Boolean",
36+
type: "boolean",
3737
required: true,
3838
default: false,
3939
documentation: "Debug mode with default",
4040
},
4141
nonConflictingParam: {
42-
type: "String",
42+
type: "string",
4343
required: true,
4444
default: "non-conflict-default",
4545
documentation: "Non-conflicting with default",
4646
},
4747
logger: {
48-
type: "String",
48+
type: "string",
4949
required: true,
5050
default: "default-logger",
5151
documentation: "Conflicting logger with default",

private/my-local-model/src/auth/httpAuthExtensionConfiguration.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 HttpAuthScheme, ApiKeyIdentity, ApiKeyIdentityProvider } from "@smithy/types";
2+
import type { ApiKeyIdentity, ApiKeyIdentityProvider, HttpAuthScheme } from "@smithy/types";
33

44
import type { XYZServiceHttpAuthSchemeProvider } from "./httpAuthSchemeProvider";
55

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// smithy-typescript generated code
22
import { doesIdentityRequireRefresh, isIdentityExpired, memoizeIdentityProvider } from "@smithy/core";
33
import {
4+
type ApiKeyIdentity,
5+
type ApiKeyIdentityProvider,
46
type HandlerExecutionContext,
57
type HttpAuthOption,
68
type HttpAuthScheme,
79
type HttpAuthSchemeParameters,
810
type HttpAuthSchemeParametersProvider,
911
type HttpAuthSchemeProvider,
1012
type Provider,
11-
ApiKeyIdentity,
12-
ApiKeyIdentityProvider,
1313
HttpApiKeyAuthLocation,
1414
} from "@smithy/types";
1515
import { getSmithyContext, normalizeProvider } from "@smithy/util-middleware";

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,44 @@ export const ruleSet: RuleSetObject = {
88
builtIn: "SDK::Endpoint",
99
required: true,
1010
documentation: "The endpoint used to send the request.",
11-
type: "String",
11+
type: "string",
1212
},
1313
ApiKey: {
1414
required: false,
1515
documentation: "ApiKey",
16-
type: "String",
16+
type: "string",
1717
},
1818
region: {
19-
type: "String",
19+
type: "string",
2020
required: false,
2121
documentation: "AWS region",
2222
},
2323
customParam: {
24-
type: "String",
24+
type: "string",
2525
required: true,
2626
default: "default-custom-value",
2727
documentation: "Custom parameter for testing",
2828
},
2929
enableFeature: {
30-
type: "Boolean",
30+
type: "boolean",
3131
required: true,
3232
default: true,
3333
documentation: "Feature toggle with default",
3434
},
3535
debugMode: {
36-
type: "Boolean",
36+
type: "boolean",
3737
required: true,
3838
default: false,
3939
documentation: "Debug mode with default",
4040
},
4141
nonConflictingParam: {
42-
type: "String",
42+
type: "string",
4343
required: true,
4444
default: "non-conflict-default",
4545
documentation: "Non-conflicting with default",
4646
},
4747
logger: {
48-
type: "String",
48+
type: "string",
4949
required: true,
5050
default: "default-logger",
5151
documentation: "Conflicting logger with default",

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/auth/http/integration/SupportHttpApiKeyAuth.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ public class SupportHttpApiKeyAuth implements HttpAuthTypeScriptIntegration {
3636
.name("ApiKeyIdentity")
3737
.namespace(TypeScriptDependency.SMITHY_TYPES.getPackageName(), "/")
3838
.addDependency(TypeScriptDependency.SMITHY_TYPES)
39+
.putProperty("typeOnly", true)
3940
.build();
4041
private static final Symbol API_KEY_IDENTITY_PROVIDER = Symbol.builder()
4142
.name("ApiKeyIdentityProvider")
4243
.namespace(TypeScriptDependency.SMITHY_TYPES.getPackageName(), "/")
4344
.addDependency(TypeScriptDependency.SMITHY_TYPES)
45+
.putProperty("typeOnly", true)
4446
.build();
4547
private static final Symbol HTTP_API_KEY_LOCATION = Symbol.builder()
4648
.name("HttpApiKeyAuthLocation")

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/endpointsV2/ClientConfigKeys.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ public static boolean isKnownConfigKey(String key) {
104104
*/
105105
public static Map<String, String> getCustomContextParams(
106106
Map<String, String> clientContextParams,
107-
Map<String, String> builtInParams) {
107+
Map<String, String> builtInParams
108+
) {
108109
Map<String, String> customContextParams = new java.util.HashMap<>();
109110
for (Map.Entry<String, String> entry : clientContextParams.entrySet()) {
110111
if (!builtInParams.containsKey(entry.getKey())

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/endpointsV2/EndpointsV2Generator.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,20 +117,24 @@ private void generateEndpointParameters() {
117117
Map<String, String> builtInParams = ruleSetParameterFinder.getBuiltInParams();
118118
builtInParams.keySet().removeIf(OmitEndpointParams::isOmitted);
119119
Map<String, String> customContextParams = ClientConfigKeys.getCustomContextParams(
120-
clientContextParams, builtInParams);
120+
clientContextParams, builtInParams
121+
);
121122

122123
writer.writeDocs("@public");
123124
writer.openBlock(
124125
"export interface ClientInputEndpointParameters {",
125126
"}",
126127
() -> {
127-
Map<String, String> allClientContextParams = ruleSetParameterFinder.getClientContextParams();
128-
if (!allClientContextParams.isEmpty()) {
128+
// Only include client context params that are NOT built-ins
129+
Map<String, String> clientContextParamsExcludingBuiltIns = new HashMap<>(clientContextParams);
130+
clientContextParamsExcludingBuiltIns.keySet().removeAll(builtInParams.keySet());
131+
if (!clientContextParamsExcludingBuiltIns.isEmpty()) {
129132
writer.write("clientContextParams?: {");
130133
writer.indent();
131134
ObjectNode ruleSet = endpointRuleSetTrait.getRuleSet().expectObjectNode();
132135
ruleSet.getObjectMember("parameters").ifPresent(parameters -> {
133-
parameters.accept(new RuleSetParametersVisitor(writer, allClientContextParams, true));
136+
parameters.accept(new RuleSetParametersVisitor(writer,
137+
clientContextParamsExcludingBuiltIns, true));
134138
});
135139
writer.dedent();
136140
writer.write("};");

0 commit comments

Comments
 (0)