Skip to content

Commit 99121e8

Browse files
authored
chore(core/protocols): inline schema number values (#7412)
* chore(core/protocols): inline schema number values * test: update types in unit tests
1 parent 7642359 commit 99121e8

29 files changed

+203
-116
lines changed

packages/core/src/submodules/account-id-endpoint/AccountIdEndpointModeConfigResolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Provider } from "@smithy/types";
1+
import type { Provider } from "@smithy/types";
22
import { normalizeProvider } from "@smithy/util-middleware";
33

44
import {

packages/core/src/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4ASigner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { HttpRequest } from "@smithy/protocol-http";
2-
import { AwsCredentialIdentity, HttpRequest as IHttpRequest } from "@smithy/types";
2+
import type { AwsCredentialIdentity, HttpRequest as IHttpRequest } from "@smithy/types";
33

44
import { getSkewCorrectedDate } from "../utils";
55
import { AwsSdkSigV4Signer, validateSigningProperties } from "./AwsSdkSigV4Signer";

packages/core/src/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { HttpRequest } from "@smithy/protocol-http";
22
import { ServiceException } from "@smithy/smithy-client";
3-
import {
3+
import type {
44
AuthScheme,
55
AwsCredentialIdentity,
66
HandlerExecutionContext,

packages/core/src/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4AConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { normalizeProvider } from "@smithy/core";
22
import { LoadedConfigSelectors } from "@smithy/node-config-provider";
33
import { ProviderError } from "@smithy/property-provider";
4-
import { Profile, Provider } from "@smithy/types";
4+
import type { Profile, Provider } from "@smithy/types";
55

66
/**
77
* @public

packages/core/src/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AwsCredentialIdentityProvider, IdentityProvider } from "@smithy/types";
1+
import type { AwsCredentialIdentityProvider } from "@smithy/types";
22
import { describe, expect, test as it, vi } from "vitest";
33

44
import { resolveAwsSdkSigV4Config } from "./resolveAwsSdkSigV4Config";

packages/core/src/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
normalizeProvider,
88
} from "@smithy/core";
99
import { SignatureV4, SignatureV4CryptoInit, SignatureV4Init } from "@smithy/signature-v4";
10-
import {
10+
import type {
1111
AuthScheme,
1212
AwsCredentialIdentity,
1313
AwsCredentialIdentityProvider,

packages/core/src/submodules/protocols/ConfigurableSerdeContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ConfigurableSerdeContext, SerdeFunctions } from "@smithy/types";
1+
import type { ConfigurableSerdeContext, SerdeFunctions } from "@smithy/types";
22

33
/**
44
* @internal

packages/core/src/submodules/protocols/cbor/AwsSmithyRpcV2CborProtocol.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { cbor } from "@smithy/core/cbor";
2-
import { op, SCHEMA } from "@smithy/core/schema";
2+
import { op } from "@smithy/core/schema";
33
import { error as registerError } from "@smithy/core/schema";
44
import { HttpResponse } from "@smithy/protocol-http";
5+
import type { NumericSchema, StringSchema } from "@smithy/types";
56
import { describe, expect, test as it } from "vitest";
67

78
import { AwsSmithyRpcV2CborProtocol } from "./AwsSmithyRpcV2CborProtocol";
@@ -20,7 +21,7 @@ describe(AwsSmithyRpcV2CborProtocol.name, () => {
2021
"MyQueryError",
2122
{ error: "client" },
2223
["Message", "Prop2"],
23-
[SCHEMA.STRING, SCHEMA.NUMERIC],
24+
[0 satisfies StringSchema, 1 satisfies NumericSchema],
2425
MyQueryError
2526
);
2627

packages/core/src/submodules/protocols/json/AwsJson1_0Protocol.spec.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { map, op, SCHEMA, sim, struct } from "@smithy/core/schema";
1+
import { map, op, sim, struct } from "@smithy/core/schema";
2+
import type {
3+
BlobSchema,
4+
BooleanSchema,
5+
DocumentSchema,
6+
NumericSchema,
7+
StringSchema,
8+
TimestampDefaultSchema,
9+
} from "@smithy/types";
210
import { toBase64 } from "@smithy/util-base64";
311
import { toUtf8 } from "@smithy/util-utf8";
412
import { describe, expect, test as it } from "vitest";
@@ -19,7 +27,13 @@ describe(AwsJson1_0Protocol.name, () => {
1927
"MyStruct",
2028
0,
2129
[...Object.keys(json)],
22-
[SCHEMA.STRING, SCHEMA.NUMERIC, SCHEMA.BOOLEAN, SCHEMA.BLOB, SCHEMA.TIMESTAMP_DEFAULT]
30+
[
31+
0 satisfies StringSchema,
32+
1 satisfies NumericSchema,
33+
2 satisfies BooleanSchema,
34+
21 satisfies BlobSchema,
35+
4 satisfies TimestampDefaultSchema,
36+
]
2337
);
2438
const serdeContext = {
2539
base64Encoder: toBase64,
@@ -85,18 +99,18 @@ describe(AwsJson1_0Protocol.name, () => {
8599
{},
86100
["header", "query", "headerMap", "payload"],
87101
[
88-
sim("ns", "MyHeader", SCHEMA.STRING, { httpHeader: "header", jsonName: "MyHeader" }),
89-
sim("ns", "MyQuery", SCHEMA.STRING, { httpQuery: "query" }),
102+
sim("ns", "MyHeader", 0 satisfies StringSchema, { httpHeader: "header", jsonName: "MyHeader" }),
103+
sim("ns", "MyQuery", 0 satisfies StringSchema, { httpQuery: "query" }),
90104
map(
91105
"ns",
92106
"HeaderMap",
93107
{
94108
httpPrefixHeaders: "",
95109
},
96-
SCHEMA.STRING,
97-
SCHEMA.NUMERIC
110+
0 satisfies StringSchema,
111+
1 satisfies NumericSchema
98112
),
99-
sim("ns", "MyPayload", SCHEMA.DOCUMENT, { httpPayload: 1 }),
113+
sim("ns", "MyPayload", 15 satisfies DocumentSchema, { httpPayload: 1 }),
100114
]
101115
);
102116
const operationSchema = op("ns", "MyOperation", {}, schema, "unit");

packages/core/src/submodules/protocols/json/AwsJsonRpcProtocol.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { error as registerError, op, SCHEMA } from "@smithy/core/schema";
1+
import { error as registerError, op } from "@smithy/core/schema";
22
import { HttpResponse } from "@smithy/protocol-http";
3+
import type { NumericSchema, StringSchema, TimestampEpochSecondsSchema } from "@smithy/types";
34
import { fromUtf8 } from "@smithy/util-utf8";
45
import { describe, expect, test as it } from "vitest";
56

@@ -25,7 +26,7 @@ describe(AwsJsonRpcProtocol.name, () => {
2526
expect(codec.settings).toEqual({
2627
jsonName: false,
2728
timestampFormat: {
28-
default: SCHEMA.TIMESTAMP_EPOCH_SECONDS,
29+
default: 7 satisfies TimestampEpochSecondsSchema,
2930
useTrait: true,
3031
},
3132
});
@@ -39,7 +40,7 @@ describe(AwsJsonRpcProtocol.name, () => {
3940
"MyQueryError",
4041
{ error: "client" },
4142
["Message", "Prop2"],
42-
[SCHEMA.STRING, SCHEMA.NUMERIC],
43+
[0 satisfies StringSchema, 1 satisfies NumericSchema],
4344
MyQueryError
4445
);
4546

0 commit comments

Comments
 (0)