From 3ebbd1b2ea6d069fad94d50b39a31c8f42146706 Mon Sep 17 00:00:00 2001 From: George Fu Date: Wed, 4 Jun 2025 11:25:28 -0400 Subject: [PATCH] chore: use smithy synthetic namespace for service base exceptions --- .changeset/funny-pigs-kiss.md | 5 +++++ .../src/submodules/schema/TypeRegistry.spec.ts | 17 ++++++++++------- .../core/src/submodules/schema/TypeRegistry.ts | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 .changeset/funny-pigs-kiss.md diff --git a/.changeset/funny-pigs-kiss.md b/.changeset/funny-pigs-kiss.md new file mode 100644 index 00000000000..4a7d58fd1ef --- /dev/null +++ b/.changeset/funny-pigs-kiss.md @@ -0,0 +1,5 @@ +--- +"@smithy/core": patch +--- + +use smithy synthetic namespace for base errors diff --git a/packages/core/src/submodules/schema/TypeRegistry.spec.ts b/packages/core/src/submodules/schema/TypeRegistry.spec.ts index 32cca2f100a..ad3562a3417 100644 --- a/packages/core/src/submodules/schema/TypeRegistry.spec.ts +++ b/packages/core/src/submodules/schema/TypeRegistry.spec.ts @@ -7,12 +7,15 @@ import { struct } from "./schemas/StructureSchema"; import { TypeRegistry } from "./TypeRegistry"; describe(TypeRegistry.name, () => { - const [List, Map, Struct] = [list("ack", "List", { sparse: 1 }, 0), map("ack", "Map", 0, 0, 1), () => schema]; - const schema = struct("ack", "Structure", {}, ["list", "map", "struct"], [List, Map, Struct]); - - const tr = TypeRegistry.for("ack"); + const [List, Map, Struct] = [ + list("NAMESPACE", "List", { sparse: 1 }, 0), + map("NAMESPACE", "Map", 0, 0, 1), + () => schema, + ]; + const schema = struct("NAMESPACE", "Structure", {}, ["list", "map", "struct"], [List, Map, Struct]); it("stores and retrieves schema objects", () => { + const tr = TypeRegistry.for("NAMESPACE"); expect(tr.getSchema("List")).toBe(List); expect(tr.getSchema("Map")).toBe(Map); expect(tr.getSchema("Structure")).toBe(schema); @@ -20,8 +23,8 @@ describe(TypeRegistry.name, () => { it("has a helper method to retrieve a synthetic base exception", () => { // the service namespace is appended to the synthetic prefix. - const err = error("smithyts.client.synthetic.ack", "UhOhServiceException", 0, [], [], Error); - const tr = TypeRegistry.for("smithyts.client.synthetic.ack"); - expect(tr.getBaseException()).toEqual(err); + const err = error("smithy.ts.sdk.synthetic.NAMESPACE", "UhOhServiceException", 0, [], [], Error); + const tr = TypeRegistry.for("smithy.ts.sdk.synthetic.NAMESPACE"); + expect(tr.getBaseException()).toBe(err); }); }); diff --git a/packages/core/src/submodules/schema/TypeRegistry.ts b/packages/core/src/submodules/schema/TypeRegistry.ts index 0712b2b79fd..55c151e9423 100644 --- a/packages/core/src/submodules/schema/TypeRegistry.ts +++ b/packages/core/src/submodules/schema/TypeRegistry.ts @@ -65,7 +65,7 @@ export class TypeRegistry { */ public getBaseException(): ErrorSchema | undefined { for (const [id, schema] of this.schemas.entries()) { - if (id.startsWith("smithyts.client.synthetic.") && id.endsWith("ServiceException")) { + if (id.startsWith("smithy.ts.sdk.synthetic.") && id.endsWith("ServiceException")) { return schema as ErrorSchema; } }