@aws-sdk/core 3.894.0 → 3.899.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/submodules/protocols/index.js +28 -45
- package/dist-es/submodules/protocols/ProtocolLib.js +4 -10
- package/dist-es/submodules/protocols/cbor/AwsSmithyRpcV2CborProtocol.js +3 -2
- package/dist-es/submodules/protocols/json/AwsJsonRpcProtocol.js +3 -6
- package/dist-es/submodules/protocols/json/AwsRestJsonProtocol.js +3 -8
- package/dist-es/submodules/protocols/json/JsonShapeSerializer.js +1 -1
- package/dist-es/submodules/protocols/query/AwsQueryProtocol.js +13 -8
- package/dist-es/submodules/protocols/xml/AwsRestXmlProtocol.js +3 -8
- package/dist-es/submodules/protocols/xml/XmlShapeDeserializer.js +3 -0
- package/dist-types/submodules/protocols/ProtocolLib.d.ts +1 -9
- package/dist-types/ts3.4/submodules/protocols/ProtocolLib.d.ts +0 -2
- package/package.json +3 -4
|
@@ -54,22 +54,10 @@ var import_schema2 = require("@smithy/core/schema");
|
|
|
54
54
|
|
|
55
55
|
// src/submodules/protocols/ProtocolLib.ts
|
|
56
56
|
var import_schema = require("@smithy/core/schema");
|
|
57
|
-
var import_util_body_length_browser = require("@smithy/util-body-length-browser");
|
|
58
57
|
var ProtocolLib = class {
|
|
59
58
|
static {
|
|
60
59
|
__name(this, "ProtocolLib");
|
|
61
60
|
}
|
|
62
|
-
/**
|
|
63
|
-
* @param body - to be inspected.
|
|
64
|
-
* @param serdeContext - this is a subset type but in practice is the client.config having a property called bodyLengthChecker.
|
|
65
|
-
*
|
|
66
|
-
* @returns content-length value for the body if possible.
|
|
67
|
-
* @throws Error and should be caught and handled if not possible to determine length.
|
|
68
|
-
*/
|
|
69
|
-
calculateContentLength(body, serdeContext) {
|
|
70
|
-
const bodyLengthCalculator = serdeContext?.bodyLengthChecker ?? import_util_body_length_browser.calculateBodyLength;
|
|
71
|
-
return String(bodyLengthCalculator(body));
|
|
72
|
-
}
|
|
73
61
|
/**
|
|
74
62
|
* This is only for REST protocols.
|
|
75
63
|
*
|
|
@@ -127,12 +115,11 @@ var ProtocolLib = class {
|
|
|
127
115
|
const errorSchema = getErrorSchema?.(registry, errorName) ?? registry.getSchema(errorIdentifier);
|
|
128
116
|
return { errorSchema, errorMetadata };
|
|
129
117
|
} catch (e) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const baseExceptionSchema = import_schema.TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace).getBaseException();
|
|
118
|
+
dataObject.message = dataObject.message ?? dataObject.Message ?? "UnknownError";
|
|
119
|
+
const synthetic = import_schema.TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace);
|
|
120
|
+
const baseExceptionSchema = synthetic.getBaseException();
|
|
134
121
|
if (baseExceptionSchema) {
|
|
135
|
-
const ErrorCtor = baseExceptionSchema
|
|
122
|
+
const ErrorCtor = synthetic.getErrorCtor(baseExceptionSchema) ?? Error;
|
|
136
123
|
throw Object.assign(new ErrorCtor({ name: errorName }), errorMetadata, dataObject);
|
|
137
124
|
}
|
|
138
125
|
throw Object.assign(new Error(errorName), errorMetadata, dataObject);
|
|
@@ -220,7 +207,8 @@ var AwsSmithyRpcV2CborProtocol = class extends import_cbor.SmithyRpcV2CborProtoc
|
|
|
220
207
|
);
|
|
221
208
|
const ns = import_schema2.NormalizedSchema.of(errorSchema);
|
|
222
209
|
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
223
|
-
const
|
|
210
|
+
const ErrorCtor = import_schema2.TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
|
|
211
|
+
const exception = new ErrorCtor(message);
|
|
224
212
|
const output = {};
|
|
225
213
|
for (const [name, member] of ns.structIterator()) {
|
|
226
214
|
output[name] = this.deserializer.readValue(member, dataObject[name]);
|
|
@@ -683,7 +671,7 @@ var JsonShapeSerializer = class extends SerdeContextConfig {
|
|
|
683
671
|
return (0, import_serde4.generateIdempotencyToken)();
|
|
684
672
|
}
|
|
685
673
|
const mediaType = ns.getMergedTraits().mediaType;
|
|
686
|
-
if (
|
|
674
|
+
if (value != null && mediaType) {
|
|
687
675
|
const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
|
|
688
676
|
if (isJson) {
|
|
689
677
|
return import_serde4.LazyJsonString.from(value);
|
|
@@ -776,10 +764,6 @@ var AwsJsonRpcProtocol = class extends import_protocols3.RpcProtocol {
|
|
|
776
764
|
if ((0, import_schema5.deref)(operationSchema.input) === "unit" || !request.body) {
|
|
777
765
|
request.body = "{}";
|
|
778
766
|
}
|
|
779
|
-
try {
|
|
780
|
-
request.headers["content-length"] = this.mixin.calculateContentLength(request.body, this.serdeContext);
|
|
781
|
-
} catch (e) {
|
|
782
|
-
}
|
|
783
767
|
return request;
|
|
784
768
|
}
|
|
785
769
|
getPayloadCodec() {
|
|
@@ -799,7 +783,8 @@ var AwsJsonRpcProtocol = class extends import_protocols3.RpcProtocol {
|
|
|
799
783
|
);
|
|
800
784
|
const ns = import_schema5.NormalizedSchema.of(errorSchema);
|
|
801
785
|
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
802
|
-
const
|
|
786
|
+
const ErrorCtor = import_schema5.TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
|
|
787
|
+
const exception = new ErrorCtor(message);
|
|
803
788
|
const output = {};
|
|
804
789
|
for (const [name, member] of ns.structIterator()) {
|
|
805
790
|
const target = member.getMergedTraits().jsonName ?? name;
|
|
@@ -929,12 +914,6 @@ var AwsRestJsonProtocol = class extends import_protocols4.HttpBindingProtocol {
|
|
|
929
914
|
if (request.headers["content-type"] && !request.body) {
|
|
930
915
|
request.body = "{}";
|
|
931
916
|
}
|
|
932
|
-
if (request.body) {
|
|
933
|
-
try {
|
|
934
|
-
request.headers["content-length"] = this.mixin.calculateContentLength(request.body, this.serdeContext);
|
|
935
|
-
} catch (e) {
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
917
|
return request;
|
|
939
918
|
}
|
|
940
919
|
async handleError(operationSchema, context, response, dataObject, metadata) {
|
|
@@ -948,7 +927,8 @@ var AwsRestJsonProtocol = class extends import_protocols4.HttpBindingProtocol {
|
|
|
948
927
|
);
|
|
949
928
|
const ns = import_schema6.NormalizedSchema.of(errorSchema);
|
|
950
929
|
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
951
|
-
const
|
|
930
|
+
const ErrorCtor = import_schema6.TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
|
|
931
|
+
const exception = new ErrorCtor(message);
|
|
952
932
|
await this.deserializeHttpMessage(errorSchema, context, response, dataObject);
|
|
953
933
|
const output = {};
|
|
954
934
|
for (const [name, member] of ns.structIterator()) {
|
|
@@ -1037,6 +1017,9 @@ var XmlShapeDeserializer = class extends SerdeContextConfig {
|
|
|
1037
1017
|
}
|
|
1038
1018
|
readSchema(_schema, value) {
|
|
1039
1019
|
const ns = import_schema7.NormalizedSchema.of(_schema);
|
|
1020
|
+
if (ns.isUnitSchema()) {
|
|
1021
|
+
return;
|
|
1022
|
+
}
|
|
1040
1023
|
const traits = ns.getMergedTraits();
|
|
1041
1024
|
if (ns.isListSchema() && !Array.isArray(value)) {
|
|
1042
1025
|
return this.readSchema(ns, [value]);
|
|
@@ -1329,10 +1312,6 @@ var AwsQueryProtocol = class extends import_protocols7.RpcProtocol {
|
|
|
1329
1312
|
if (request.body.endsWith("&")) {
|
|
1330
1313
|
request.body = request.body.slice(-1);
|
|
1331
1314
|
}
|
|
1332
|
-
try {
|
|
1333
|
-
request.headers["content-length"] = this.mixin.calculateContentLength(request.body, this.serdeContext);
|
|
1334
|
-
} catch (e) {
|
|
1335
|
-
}
|
|
1336
1315
|
return request;
|
|
1337
1316
|
}
|
|
1338
1317
|
async deserializeResponse(operationSchema, context, response) {
|
|
@@ -1372,6 +1351,13 @@ var AwsQueryProtocol = class extends import_protocols7.RpcProtocol {
|
|
|
1372
1351
|
async handleError(operationSchema, context, response, dataObject, metadata) {
|
|
1373
1352
|
const errorIdentifier = this.loadQueryErrorCode(response, dataObject) ?? "Unknown";
|
|
1374
1353
|
const errorData = this.loadQueryError(dataObject);
|
|
1354
|
+
const message = this.loadQueryErrorMessage(dataObject);
|
|
1355
|
+
errorData.message = message;
|
|
1356
|
+
errorData.Error = {
|
|
1357
|
+
Type: errorData.Type,
|
|
1358
|
+
Code: errorData.Code,
|
|
1359
|
+
Message: message
|
|
1360
|
+
};
|
|
1375
1361
|
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(
|
|
1376
1362
|
errorIdentifier,
|
|
1377
1363
|
this.options.defaultNamespace,
|
|
@@ -1383,9 +1369,11 @@ var AwsQueryProtocol = class extends import_protocols7.RpcProtocol {
|
|
|
1383
1369
|
)
|
|
1384
1370
|
);
|
|
1385
1371
|
const ns = import_schema9.NormalizedSchema.of(errorSchema);
|
|
1386
|
-
const
|
|
1387
|
-
const exception = new
|
|
1388
|
-
const output = {
|
|
1372
|
+
const ErrorCtor = import_schema9.TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
|
|
1373
|
+
const exception = new ErrorCtor(message);
|
|
1374
|
+
const output = {
|
|
1375
|
+
Error: errorData.Error
|
|
1376
|
+
};
|
|
1389
1377
|
for (const [name, member] of ns.structIterator()) {
|
|
1390
1378
|
const target = member.getMergedTraits().xmlName ?? name;
|
|
1391
1379
|
const value = errorData[target] ?? dataObject[target];
|
|
@@ -1847,12 +1835,6 @@ var AwsRestXmlProtocol = class extends import_protocols9.HttpBindingProtocol {
|
|
|
1847
1835
|
request.body = '<?xml version="1.0" encoding="UTF-8"?>' + request.body;
|
|
1848
1836
|
}
|
|
1849
1837
|
}
|
|
1850
|
-
if (request.body) {
|
|
1851
|
-
try {
|
|
1852
|
-
request.headers["content-length"] = this.mixin.calculateContentLength(request.body, this.serdeContext);
|
|
1853
|
-
} catch (e) {
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
1838
|
return request;
|
|
1857
1839
|
}
|
|
1858
1840
|
async deserializeResponse(operationSchema, context, response) {
|
|
@@ -1869,7 +1851,8 @@ var AwsRestXmlProtocol = class extends import_protocols9.HttpBindingProtocol {
|
|
|
1869
1851
|
);
|
|
1870
1852
|
const ns = import_schema11.NormalizedSchema.of(errorSchema);
|
|
1871
1853
|
const message = dataObject.Error?.message ?? dataObject.Error?.Message ?? dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
1872
|
-
const
|
|
1854
|
+
const ErrorCtor = import_schema11.TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
|
|
1855
|
+
const exception = new ErrorCtor(message);
|
|
1873
1856
|
await this.deserializeHttpMessage(errorSchema, context, response, dataObject);
|
|
1874
1857
|
const output = {};
|
|
1875
1858
|
for (const [name, member] of ns.structIterator()) {
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { TypeRegistry } from "@smithy/core/schema";
|
|
2
|
-
import { calculateBodyLength } from "@smithy/util-body-length-browser";
|
|
3
2
|
export class ProtocolLib {
|
|
4
|
-
calculateContentLength(body, serdeContext) {
|
|
5
|
-
const bodyLengthCalculator = serdeContext?.bodyLengthChecker ?? calculateBodyLength;
|
|
6
|
-
return String(bodyLengthCalculator(body));
|
|
7
|
-
}
|
|
8
3
|
resolveRestContentType(defaultContentType, inputSchema) {
|
|
9
4
|
const members = inputSchema.getMemberSchemas();
|
|
10
5
|
const httpPayloadMember = Object.values(members).find((m) => {
|
|
@@ -53,12 +48,11 @@ export class ProtocolLib {
|
|
|
53
48
|
return { errorSchema, errorMetadata };
|
|
54
49
|
}
|
|
55
50
|
catch (e) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const baseExceptionSchema = TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace).getBaseException();
|
|
51
|
+
dataObject.message = dataObject.message ?? dataObject.Message ?? "UnknownError";
|
|
52
|
+
const synthetic = TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace);
|
|
53
|
+
const baseExceptionSchema = synthetic.getBaseException();
|
|
60
54
|
if (baseExceptionSchema) {
|
|
61
|
-
const ErrorCtor = baseExceptionSchema
|
|
55
|
+
const ErrorCtor = synthetic.getErrorCtor(baseExceptionSchema) ?? Error;
|
|
62
56
|
throw Object.assign(new ErrorCtor({ name: errorName }), errorMetadata, dataObject);
|
|
63
57
|
}
|
|
64
58
|
throw Object.assign(new Error(errorName), errorMetadata, dataObject);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { loadSmithyRpcV2CborErrorCode, SmithyRpcV2CborProtocol } from "@smithy/core/cbor";
|
|
2
|
-
import { NormalizedSchema } from "@smithy/core/schema";
|
|
2
|
+
import { NormalizedSchema, TypeRegistry } from "@smithy/core/schema";
|
|
3
3
|
import { ProtocolLib } from "../ProtocolLib";
|
|
4
4
|
export class AwsSmithyRpcV2CborProtocol extends SmithyRpcV2CborProtocol {
|
|
5
5
|
awsQueryCompatible;
|
|
@@ -23,7 +23,8 @@ export class AwsSmithyRpcV2CborProtocol extends SmithyRpcV2CborProtocol {
|
|
|
23
23
|
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorName, this.options.defaultNamespace, response, dataObject, metadata);
|
|
24
24
|
const ns = NormalizedSchema.of(errorSchema);
|
|
25
25
|
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
26
|
-
const
|
|
26
|
+
const ErrorCtor = TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
|
|
27
|
+
const exception = new ErrorCtor(message);
|
|
27
28
|
const output = {};
|
|
28
29
|
for (const [name, member] of ns.structIterator()) {
|
|
29
30
|
output[name] = this.deserializer.readValue(member, dataObject[name]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RpcProtocol } from "@smithy/core/protocols";
|
|
2
|
-
import { deref, NormalizedSchema, SCHEMA } from "@smithy/core/schema";
|
|
2
|
+
import { deref, NormalizedSchema, SCHEMA, TypeRegistry } from "@smithy/core/schema";
|
|
3
3
|
import { ProtocolLib } from "../ProtocolLib";
|
|
4
4
|
import { JsonCodec } from "./JsonCodec";
|
|
5
5
|
import { loadRestJsonErrorCode } from "./parseJsonBody";
|
|
@@ -41,10 +41,6 @@ export class AwsJsonRpcProtocol extends RpcProtocol {
|
|
|
41
41
|
if (deref(operationSchema.input) === "unit" || !request.body) {
|
|
42
42
|
request.body = "{}";
|
|
43
43
|
}
|
|
44
|
-
try {
|
|
45
|
-
request.headers["content-length"] = this.mixin.calculateContentLength(request.body, this.serdeContext);
|
|
46
|
-
}
|
|
47
|
-
catch (e) { }
|
|
48
44
|
return request;
|
|
49
45
|
}
|
|
50
46
|
getPayloadCodec() {
|
|
@@ -58,7 +54,8 @@ export class AwsJsonRpcProtocol extends RpcProtocol {
|
|
|
58
54
|
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata);
|
|
59
55
|
const ns = NormalizedSchema.of(errorSchema);
|
|
60
56
|
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
61
|
-
const
|
|
57
|
+
const ErrorCtor = TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
|
|
58
|
+
const exception = new ErrorCtor(message);
|
|
62
59
|
const output = {};
|
|
63
60
|
for (const [name, member] of ns.structIterator()) {
|
|
64
61
|
const target = member.getMergedTraits().jsonName ?? name;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpBindingProtocol, HttpInterceptingShapeDeserializer, HttpInterceptingShapeSerializer, } from "@smithy/core/protocols";
|
|
2
|
-
import { NormalizedSchema, SCHEMA } from "@smithy/core/schema";
|
|
2
|
+
import { NormalizedSchema, SCHEMA, TypeRegistry } from "@smithy/core/schema";
|
|
3
3
|
import { ProtocolLib } from "../ProtocolLib";
|
|
4
4
|
import { JsonCodec } from "./JsonCodec";
|
|
5
5
|
import { loadRestJsonErrorCode } from "./parseJsonBody";
|
|
@@ -46,12 +46,6 @@ export class AwsRestJsonProtocol extends HttpBindingProtocol {
|
|
|
46
46
|
if (request.headers["content-type"] && !request.body) {
|
|
47
47
|
request.body = "{}";
|
|
48
48
|
}
|
|
49
|
-
if (request.body) {
|
|
50
|
-
try {
|
|
51
|
-
request.headers["content-length"] = this.mixin.calculateContentLength(request.body, this.serdeContext);
|
|
52
|
-
}
|
|
53
|
-
catch (e) { }
|
|
54
|
-
}
|
|
55
49
|
return request;
|
|
56
50
|
}
|
|
57
51
|
async handleError(operationSchema, context, response, dataObject, metadata) {
|
|
@@ -59,7 +53,8 @@ export class AwsRestJsonProtocol extends HttpBindingProtocol {
|
|
|
59
53
|
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata);
|
|
60
54
|
const ns = NormalizedSchema.of(errorSchema);
|
|
61
55
|
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
62
|
-
const
|
|
56
|
+
const ErrorCtor = TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
|
|
57
|
+
const exception = new ErrorCtor(message);
|
|
63
58
|
await this.deserializeHttpMessage(errorSchema, context, response, dataObject);
|
|
64
59
|
const output = {};
|
|
65
60
|
for (const [name, member] of ns.structIterator()) {
|
|
@@ -104,7 +104,7 @@ export class JsonShapeSerializer extends SerdeContextConfig {
|
|
|
104
104
|
return generateIdempotencyToken();
|
|
105
105
|
}
|
|
106
106
|
const mediaType = ns.getMergedTraits().mediaType;
|
|
107
|
-
if (
|
|
107
|
+
if (value != null && mediaType) {
|
|
108
108
|
const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
|
|
109
109
|
if (isJson) {
|
|
110
110
|
return LazyJsonString.from(value);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { collectBody, RpcProtocol } from "@smithy/core/protocols";
|
|
2
|
-
import { deref, NormalizedSchema, SCHEMA } from "@smithy/core/schema";
|
|
2
|
+
import { deref, NormalizedSchema, SCHEMA, TypeRegistry } from "@smithy/core/schema";
|
|
3
3
|
import { ProtocolLib } from "../ProtocolLib";
|
|
4
4
|
import { XmlShapeDeserializer } from "../xml/XmlShapeDeserializer";
|
|
5
5
|
import { QueryShapeSerializer } from "./QueryShapeSerializer";
|
|
@@ -52,10 +52,6 @@ export class AwsQueryProtocol extends RpcProtocol {
|
|
|
52
52
|
if (request.body.endsWith("&")) {
|
|
53
53
|
request.body = request.body.slice(-1);
|
|
54
54
|
}
|
|
55
|
-
try {
|
|
56
|
-
request.headers["content-length"] = this.mixin.calculateContentLength(request.body, this.serdeContext);
|
|
57
|
-
}
|
|
58
|
-
catch (e) { }
|
|
59
55
|
return request;
|
|
60
56
|
}
|
|
61
57
|
async deserializeResponse(operationSchema, context, response) {
|
|
@@ -92,11 +88,20 @@ export class AwsQueryProtocol extends RpcProtocol {
|
|
|
92
88
|
async handleError(operationSchema, context, response, dataObject, metadata) {
|
|
93
89
|
const errorIdentifier = this.loadQueryErrorCode(response, dataObject) ?? "Unknown";
|
|
94
90
|
const errorData = this.loadQueryError(dataObject);
|
|
91
|
+
const message = this.loadQueryErrorMessage(dataObject);
|
|
92
|
+
errorData.message = message;
|
|
93
|
+
errorData.Error = {
|
|
94
|
+
Type: errorData.Type,
|
|
95
|
+
Code: errorData.Code,
|
|
96
|
+
Message: message,
|
|
97
|
+
};
|
|
95
98
|
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, errorData, metadata, (registry, errorName) => registry.find((schema) => NormalizedSchema.of(schema).getMergedTraits().awsQueryError?.[0] === errorName));
|
|
96
99
|
const ns = NormalizedSchema.of(errorSchema);
|
|
97
|
-
const
|
|
98
|
-
const exception = new
|
|
99
|
-
const output = {
|
|
100
|
+
const ErrorCtor = TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
|
|
101
|
+
const exception = new ErrorCtor(message);
|
|
102
|
+
const output = {
|
|
103
|
+
Error: errorData.Error,
|
|
104
|
+
};
|
|
100
105
|
for (const [name, member] of ns.structIterator()) {
|
|
101
106
|
const target = member.getMergedTraits().xmlName ?? name;
|
|
102
107
|
const value = errorData[target] ?? dataObject[target];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpBindingProtocol, HttpInterceptingShapeDeserializer, HttpInterceptingShapeSerializer, } from "@smithy/core/protocols";
|
|
2
|
-
import { NormalizedSchema, SCHEMA } from "@smithy/core/schema";
|
|
2
|
+
import { NormalizedSchema, SCHEMA, TypeRegistry } from "@smithy/core/schema";
|
|
3
3
|
import { ProtocolLib } from "../ProtocolLib";
|
|
4
4
|
import { loadRestXmlErrorCode } from "./parseXmlBody";
|
|
5
5
|
import { XmlCodec } from "./XmlCodec";
|
|
@@ -43,12 +43,6 @@ export class AwsRestXmlProtocol extends HttpBindingProtocol {
|
|
|
43
43
|
request.body = '<?xml version="1.0" encoding="UTF-8"?>' + request.body;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
if (request.body) {
|
|
47
|
-
try {
|
|
48
|
-
request.headers["content-length"] = this.mixin.calculateContentLength(request.body, this.serdeContext);
|
|
49
|
-
}
|
|
50
|
-
catch (e) { }
|
|
51
|
-
}
|
|
52
46
|
return request;
|
|
53
47
|
}
|
|
54
48
|
async deserializeResponse(operationSchema, context, response) {
|
|
@@ -59,7 +53,8 @@ export class AwsRestXmlProtocol extends HttpBindingProtocol {
|
|
|
59
53
|
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata);
|
|
60
54
|
const ns = NormalizedSchema.of(errorSchema);
|
|
61
55
|
const message = dataObject.Error?.message ?? dataObject.Error?.Message ?? dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
62
|
-
const
|
|
56
|
+
const ErrorCtor = TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
|
|
57
|
+
const exception = new ErrorCtor(message);
|
|
63
58
|
await this.deserializeHttpMessage(errorSchema, context, response, dataObject);
|
|
64
59
|
const output = {};
|
|
65
60
|
for (const [name, member] of ns.structIterator()) {
|
|
@@ -42,6 +42,9 @@ export class XmlShapeDeserializer extends SerdeContextConfig {
|
|
|
42
42
|
}
|
|
43
43
|
readSchema(_schema, value) {
|
|
44
44
|
const ns = NormalizedSchema.of(_schema);
|
|
45
|
+
if (ns.isUnitSchema()) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
45
48
|
const traits = ns.getMergedTraits();
|
|
46
49
|
if (ns.isListSchema() && !Array.isArray(value)) {
|
|
47
50
|
return this.readSchema(ns, [value]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ErrorSchema, NormalizedSchema, TypeRegistry } from "@smithy/core/schema";
|
|
2
|
-
import type { HttpResponse as IHttpResponse, MetadataBearer, ResponseMetadata
|
|
2
|
+
import type { HttpResponse as IHttpResponse, MetadataBearer, ResponseMetadata } from "@smithy/types";
|
|
3
3
|
/**
|
|
4
4
|
* @internal
|
|
5
5
|
*/
|
|
@@ -13,14 +13,6 @@ type ErrorMetadataBearer = MetadataBearer & {
|
|
|
13
13
|
* @internal
|
|
14
14
|
*/
|
|
15
15
|
export declare class ProtocolLib {
|
|
16
|
-
/**
|
|
17
|
-
* @param body - to be inspected.
|
|
18
|
-
* @param serdeContext - this is a subset type but in practice is the client.config having a property called bodyLengthChecker.
|
|
19
|
-
*
|
|
20
|
-
* @returns content-length value for the body if possible.
|
|
21
|
-
* @throws Error and should be caught and handled if not possible to determine length.
|
|
22
|
-
*/
|
|
23
|
-
calculateContentLength(body: any, serdeContext?: SerdeFunctions): string;
|
|
24
16
|
/**
|
|
25
17
|
* This is only for REST protocols.
|
|
26
18
|
*
|
|
@@ -7,14 +7,12 @@ import {
|
|
|
7
7
|
HttpResponse as IHttpResponse,
|
|
8
8
|
MetadataBearer,
|
|
9
9
|
ResponseMetadata,
|
|
10
|
-
SerdeFunctions,
|
|
11
10
|
} from "@smithy/types";
|
|
12
11
|
type ErrorMetadataBearer = MetadataBearer & {
|
|
13
12
|
$response: IHttpResponse;
|
|
14
13
|
$fault: "client" | "server";
|
|
15
14
|
};
|
|
16
15
|
export declare class ProtocolLib {
|
|
17
|
-
calculateContentLength(body: any, serdeContext?: SerdeFunctions): string;
|
|
18
16
|
resolveRestContentType(
|
|
19
17
|
defaultContentType: string,
|
|
20
18
|
inputSchema: NormalizedSchema
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.899.0",
|
|
4
4
|
"description": "Core functions & classes shared by multiple AWS SDK clients.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "yarn lint && concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
@@ -83,15 +83,14 @@
|
|
|
83
83
|
"dependencies": {
|
|
84
84
|
"@aws-sdk/types": "3.893.0",
|
|
85
85
|
"@aws-sdk/xml-builder": "3.894.0",
|
|
86
|
-
"@smithy/core": "^3.
|
|
86
|
+
"@smithy/core": "^3.13.0",
|
|
87
87
|
"@smithy/node-config-provider": "^4.2.2",
|
|
88
88
|
"@smithy/property-provider": "^4.1.1",
|
|
89
89
|
"@smithy/protocol-http": "^5.2.1",
|
|
90
90
|
"@smithy/signature-v4": "^5.2.1",
|
|
91
|
-
"@smithy/smithy-client": "^4.6.
|
|
91
|
+
"@smithy/smithy-client": "^4.6.5",
|
|
92
92
|
"@smithy/types": "^4.5.0",
|
|
93
93
|
"@smithy/util-base64": "^4.1.0",
|
|
94
|
-
"@smithy/util-body-length-browser": "^4.1.0",
|
|
95
94
|
"@smithy/util-middleware": "^4.1.1",
|
|
96
95
|
"@smithy/util-utf8": "^4.1.0",
|
|
97
96
|
"tslib": "^2.6.2"
|