Skip to content

Commit b3abba4

Browse files
committed
chore: static schema compat
1 parent 6bf6fab commit b3abba4

File tree

16 files changed

+88
-80
lines changed

16 files changed

+88
-80
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ErrorSchema, NormalizedSchema, TypeRegistry } from "@smithy/core/schema";
2-
import type { HttpResponse as IHttpResponse, MetadataBearer, ResponseMetadata } from "@smithy/types";
2+
import type { HttpResponse as IHttpResponse, MetadataBearer, ResponseMetadata, StaticErrorSchema } from "@smithy/types";
33

44
/**
55
* @internal
@@ -64,8 +64,8 @@ export class ProtocolLib {
6464
response: IHttpResponse,
6565
dataObject: any,
6666
metadata: ResponseMetadata,
67-
getErrorSchema?: (registry: TypeRegistry, errorName: string) => ErrorSchema
68-
): Promise<{ errorSchema: ErrorSchema; errorMetadata: ErrorMetadataBearer }> {
67+
getErrorSchema?: (registry: TypeRegistry, errorName: string) => StaticErrorSchema
68+
): Promise<{ errorSchema: StaticErrorSchema; errorMetadata: ErrorMetadataBearer }> {
6969
let namespace = defaultNamespace;
7070
let errorName = errorIdentifier;
7171
if (errorIdentifier.includes("#")) {
@@ -81,7 +81,8 @@ export class ProtocolLib {
8181
const registry = TypeRegistry.for(namespace);
8282

8383
try {
84-
const errorSchema = getErrorSchema?.(registry, errorName) ?? (registry.getSchema(errorIdentifier) as ErrorSchema);
84+
const errorSchema =
85+
getErrorSchema?.(registry, errorName) ?? (registry.getSchema(errorIdentifier) as StaticErrorSchema);
8586
return { errorSchema, errorMetadata };
8687
} catch (e) {
8788
dataObject.message = dataObject.message ?? dataObject.Message ?? "UnknownError";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class AwsSmithyRpcV2CborProtocol extends SmithyRpcV2CborProtocol {
7272

7373
const ns = NormalizedSchema.of(errorSchema);
7474
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
75-
const ErrorCtor = TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
75+
const ErrorCtor = TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
7676
const exception = new ErrorCtor(message);
7777

7878
const output = {} as any;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export abstract class AwsJsonRpcProtocol extends RpcProtocol {
107107

108108
const ns = NormalizedSchema.of(errorSchema);
109109
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
110-
const ErrorCtor = TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
110+
const ErrorCtor = TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
111111
const exception = new ErrorCtor(message);
112112

113113
const output = {} as any;

packages/core/src/submodules/protocols/json/AwsRestJsonProtocol.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class AwsRestJsonProtocol extends HttpBindingProtocol {
103103

104104
const ns = NormalizedSchema.of(errorSchema);
105105
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
106-
const ErrorCtor = TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
106+
const ErrorCtor = TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
107107
const exception = new ErrorCtor(message);
108108

109109
await this.deserializeHttpMessage(errorSchema, context, response, dataObject);

packages/core/src/submodules/protocols/query/AwsQueryProtocol.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type {
1111
OperationSchema,
1212
ResponseMetadata,
1313
SerdeFunctions,
14+
StaticErrorSchema,
1415
TimestampDateTimeSchema,
1516
} from "@smithy/types";
1617

@@ -160,11 +161,11 @@ export class AwsQueryProtocol extends RpcProtocol {
160161
(registry: TypeRegistry, errorName: string) =>
161162
registry.find(
162163
(schema) => (NormalizedSchema.of(schema).getMergedTraits().awsQueryError as any)?.[0] === errorName
163-
) as ErrorSchema
164+
) as StaticErrorSchema
164165
);
165166

166167
const ns = NormalizedSchema.of(errorSchema);
167-
const ErrorCtor = TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
168+
const ErrorCtor = TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
168169
const exception = new ErrorCtor(message);
169170

170171
const output = {

packages/core/src/submodules/protocols/xml/AwsRestXmlProtocol.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export class AwsRestXmlProtocol extends HttpBindingProtocol {
108108
const ns = NormalizedSchema.of(errorSchema);
109109
const message =
110110
dataObject.Error?.message ?? dataObject.Error?.Message ?? dataObject.message ?? dataObject.Message ?? "Unknown";
111-
const ErrorCtor = TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
111+
const ErrorCtor = TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
112112
const exception = new ErrorCtor(message);
113113

114114
await this.deserializeHttpMessage(errorSchema, context, response, dataObject);

private/aws-protocoltests-ec2-schema/src/schemas/schemas_0.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export const n0 = "aws.protocoltests.ec2";
178178
export const n1 = "aws.protocoltests.shared";
179179

180180
// smithy-typescript generated code
181-
import { error, TypeRegistry } from "@smithy/core/schema";
181+
import { TypeRegistry } from "@smithy/core/schema";
182182
import {
183183
StaticErrorSchema,
184184
StaticListSchema,
@@ -429,7 +429,7 @@ export var XmlListsOutput: StaticStructureSchema = [
429429
64 | 4,
430430
64 | 0,
431431
64 | 1,
432-
[1, n1, _NSL, 0, 64 | 0] as StaticListSchema,
432+
[1, n1, _NSL, 0, 64 | 0],
433433
[
434434
() => RenamedListMembers,
435435
{
@@ -513,7 +513,7 @@ export var XmlTimestampsOutput: StaticStructureSchema = [
513513
export var GreetingStruct: StaticStructureSchema = [3, n1, _GS, 0, [_hi], [0]];
514514
export var Unit = "unit" as const;
515515

516-
export var EC2ProtocolServiceException = error(_s, "EC2ProtocolServiceException", 0, [], [], null);
516+
export var EC2ProtocolServiceException: StaticErrorSchema = [-3, _s, "EC2ProtocolServiceException", 0, [], []];
517517
TypeRegistry.for(_s).registerError(EC2ProtocolServiceException, __EC2ProtocolServiceException);
518518

519519
export var ListWithMemberNamespace: StaticListSchema = [

private/aws-protocoltests-json-10-schema/src/schemas/schemas_0.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export const n0 = "aws.protocoltests.json10";
136136
export const n1 = "aws.protocoltests.shared";
137137

138138
// smithy-typescript generated code
139-
import { error, TypeRegistry } from "@smithy/core/schema";
139+
import { TypeRegistry } from "@smithy/core/schema";
140140
import {
141141
StaticErrorSchema,
142142
StaticListSchema,
@@ -368,7 +368,7 @@ export var TopLevel: StaticStructureSchema = [
368368
export var GreetingStruct: StaticStructureSchema = [3, n1, _GS, 0, [_h], [0]];
369369
export var Unit = "unit" as const;
370370

371-
export var JSONRPC10ServiceException = error(_sm, "JSONRPC10ServiceException", 0, [], [], null);
371+
export var JSONRPC10ServiceException: StaticErrorSchema = [-3, _sm, "JSONRPC10ServiceException", 0, [], []];
372372
TypeRegistry.for(_sm).registerError(JSONRPC10ServiceException, __JSONRPC10ServiceException);
373373

374374
export var DialogList: StaticListSchema = [1, n0, _DL, 0, () => Dialog];

private/aws-protocoltests-json-schema-machinelearning/src/schemas/schemas_0.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const _sm = "smithy.ts.sdk.synthetic.com.amazonaws.machinelearning";
2424
export const n0 = "com.amazonaws.machinelearning";
2525

2626
// smithy-typescript generated code
27-
import { error, TypeRegistry } from "@smithy/core/schema";
27+
import { TypeRegistry } from "@smithy/core/schema";
2828
import { StaticErrorSchema, StaticMapSchema, StaticOperationSchema, StaticStructureSchema } from "@smithy/types";
2929

3030
import {
@@ -108,7 +108,7 @@ TypeRegistry.for(n0).registerError(ResourceNotFoundException, __ResourceNotFound
108108

109109
export var Unit = "unit" as const;
110110

111-
export var MachineLearningServiceException = error(_sm, "MachineLearningServiceException", 0, [], [], null);
111+
export var MachineLearningServiceException: StaticErrorSchema = [-3, _sm, "MachineLearningServiceException", 0, [], []];
112112
TypeRegistry.for(_sm).registerError(MachineLearningServiceException, __MachineLearningServiceException);
113113

114114
export var DetailsMap = 128 | 0;

private/aws-protocoltests-json-schema/src/schemas/schemas_0.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export const n0 = "aws.protocoltests.json";
137137
export const n1 = "aws.protocoltests.shared";
138138

139139
// smithy-typescript generated code
140-
import { error, TypeRegistry } from "@smithy/core/schema";
140+
import { TypeRegistry } from "@smithy/core/schema";
141141
import {
142142
StaticErrorSchema,
143143
StaticListSchema,
@@ -162,10 +162,11 @@ export var JsonValue: StaticSimpleSchema = [
162162
0,
163163
n0,
164164
_JV,
165-
0,
166165
{
167166
[_mT]: _a,
168167
},
168+
169+
0,
169170
];
170171
export var ComplexError: StaticErrorSchema = [
171172
-3,
@@ -322,13 +323,13 @@ export var KitchenSink: StaticStructureSchema = [
322323
1,
323324
5,
324325
[() => JsonValue, 0],
325-
[1, n0, _LOLOS, 0, 64 | 0] as StaticListSchema,
326-
[1, n0, _LOMOS, 0, 128 | 0] as StaticListSchema,
326+
[1, n0, _LOLOS, 0, 64 | 0],
327+
[1, n0, _LOMOS, 0, 128 | 0],
327328
64 | 0,
328329
() => ListOfStructs,
329330
1,
330-
[2, n0, _MOLOS, 0, 64 | 0, 64 | 0] as StaticMapSchema,
331-
[2, n0, _MOMOS, 0, 0, 128 | 0, 128 | 0] as StaticMapSchema,
331+
[2, n0, _MOLOS, 0, 0, 64 | 0],
332+
[2, n0, _MOMOS, 0, 0, 128 | 0],
332333
128 | 0,
333334
() => MapOfStructs,
334335
[() => ListOfKitchenSinks, 0],
@@ -393,7 +394,7 @@ export var UnionInputOutput: StaticStructureSchema = [3, n0, _UIO, 0, [_co], [()
393394
export var GreetingStruct: StaticStructureSchema = [3, n1, _GS, 0, [_h], [0]];
394395
export var Unit = "unit" as const;
395396

396-
export var JsonProtocolServiceException = error(_sm, "JsonProtocolServiceException", 0, [], [], null);
397+
export var JsonProtocolServiceException: StaticErrorSchema = [-3, _sm, "JsonProtocolServiceException", 0, [], []];
397398
TypeRegistry.for(_sm).registerError(JsonProtocolServiceException, __JsonProtocolServiceException);
398399

399400
export var ListOfKitchenSinks: StaticListSchema = [1, n0, _LOKS, 0, [() => KitchenSink, 0]];

0 commit comments

Comments
 (0)