Skip to content

Commit 8dd0237

Browse files
committed
test fixes
1 parent 998c9d5 commit 8dd0237

File tree

4 files changed

+39
-27
lines changed

4 files changed

+39
-27
lines changed

.changeset/good-students-play.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
"@smithy/smithy-client": minor
23
"@smithy/types": minor
34
"@smithy/core": minor
45
---

packages/core/src/submodules/schema/schemas/NormalizedSchema.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ export class NormalizedSchema implements INormalizedSchema {
6464
* @param ref - a polymorphic SchemaRef to be dereferenced/normalized.
6565
* @param memberName - optional memberName if this NormalizedSchema should be considered a member schema.
6666
*/
67-
private constructor(readonly ref: $SchemaRef, private readonly memberName?: string) {
67+
private constructor(
68+
readonly ref: $SchemaRef,
69+
private readonly memberName?: string
70+
) {
6871
const traitStack = [] as SchemaTraits[];
6972
let _ref = ref;
7073
let schema = ref;
@@ -320,10 +323,10 @@ export class NormalizedSchema implements INormalizedSchema {
320323
typeof sc === "number"
321324
? 0b0011_1111 & sc
322325
: sc && typeof sc === "object" && (isMap || isList)
323-
? ((sc as StaticMapSchema | StaticListSchema)[3 + (sc as StaticSchema)[0]] as typeof sc)
324-
: isDoc
325-
? (15 satisfies DocumentSchema)
326-
: void 0;
326+
? ((sc as StaticMapSchema | StaticListSchema)[3 + (sc as StaticSchema)[0]] as typeof sc)
327+
: isDoc
328+
? (15 satisfies DocumentSchema)
329+
: void 0;
327330
if (memberSchema != null) {
328331
return member([memberSchema, 0], isMap ? "value" : "member");
329332
}

packages/smithy-client/src/schemaLogFilter.spec.ts

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,47 @@
1-
import { list, map, SCHEMA, sim, struct } from "@smithy/core/schema";
1+
import type {
2+
BooleanSchema,
3+
NumericSchema,
4+
StaticSimpleSchema,
5+
StaticStructureSchema,
6+
StringSchema,
7+
} from "@smithy/types";
28
import { describe, expect, test as it } from "vitest";
39

410
import { schemaLogFilter } from "./schemaLogFilter";
511

612
describe(schemaLogFilter.name, () => {
713
it("should filter sensitive trait-marked fields", () => {
8-
const sensitiveString = sim("ns", "SensitiveString", 0, { sensitive: 1 });
14+
const sensitiveString: StaticSimpleSchema = [0, "ns", "SensitiveString", { sensitive: 1 }, 0];
915

10-
const schema = struct(
16+
const schema: StaticStructureSchema = [
17+
3,
1118
"ns",
1219
"Struct",
1320
0,
1421
["a", "b", "sensitive", "nestedSensitive", "various"],
1522
[
16-
SCHEMA.STRING,
17-
SCHEMA.STRING,
23+
0 satisfies StringSchema,
24+
0 satisfies StringSchema,
1825
sensitiveString,
19-
struct("ns", "NestedSensitiveStruct", 0, ["sensitive"], [sensitiveString]),
20-
struct(
26+
[3, "ns", "NestedSensitiveStruct", 0, ["sensitive"], [sensitiveString]],
27+
[
28+
3,
2129
"ns",
2230
"Various",
2331
0,
2432
["boolean", "number", "struct", "list-s", "list", "map-s", "map"],
2533
[
26-
sim("ns", "Boolean", SCHEMA.BOOLEAN, { sensitive: 1 }),
27-
sim("ns", "Numeric", SCHEMA.NUMERIC, { sensitive: 1 }),
28-
struct("ns", "SensitiveStruct", { sensitive: 1 }, [], []),
29-
list("ns", "List", 0, sensitiveString),
30-
list("ns", "List", 0, SCHEMA.STRING),
31-
map("ns", "Map", 0, sensitiveString, SCHEMA.STRING),
32-
map("ns", "Map", 0, SCHEMA.STRING, SCHEMA.STRING),
33-
]
34-
),
35-
]
36-
);
34+
[0, "ns", "Boolean", { sensitive: 1 }, 2 satisfies BooleanSchema],
35+
[0, "ns", "Numeric", { sensitive: 1 }, 1 satisfies NumericSchema],
36+
[3, "ns", "SensitiveStruct", { sensitive: 1 }, [], []],
37+
[1, "ns", "List", 0, sensitiveString],
38+
[1, "ns", "List", 0, 0 satisfies StringSchema],
39+
[2, "ns", "Map", 0, sensitiveString, 0 satisfies StringSchema],
40+
[2, "ns", "Map", 0, 0 satisfies StringSchema, 0 satisfies StringSchema],
41+
],
42+
],
43+
],
44+
];
3745

3846
expect(
3947
schemaLogFilter(schema, {

packages/types/src/schema/schema-deprecated.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import type { SchemaTraits, UnitSchema, SimpleSchema, NormalizedSchema, ConfigurableSerdeContext } from "./schema";
2-
import type { StaticSchema } from "./static-schemas";
1+
import type { EndpointV2 } from "../endpoint";
2+
import type { HandlerExecutionContext } from "../middleware";
33
import type { MetadataBearer } from "../response";
44
import type { EndpointBearer, SerdeFunctions } from "../serde";
5-
import type { HandlerExecutionContext } from "../middleware";
6-
import type { EndpointV2 } from "../endpoint";
5+
import type { ConfigurableSerdeContext, NormalizedSchema, SchemaTraits, SimpleSchema, UnitSchema } from "./schema";
6+
import type { StaticSchema } from "./static-schemas";
77

88
/**
99
* A schema is an object or value that describes how to serialize/deserialize data.

0 commit comments

Comments
 (0)