@aws-sdk/core 3.873.0 → 3.879.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 +361 -224
- package/dist-es/submodules/protocols/ProtocolLib.js +94 -0
- package/dist-es/submodules/protocols/cbor/AwsSmithyRpcV2CborProtocol.js +39 -0
- package/dist-es/submodules/protocols/common.js +2 -1
- package/dist-es/submodules/protocols/index.js +1 -0
- package/dist-es/submodules/protocols/json/AwsJson1_0Protocol.js +2 -1
- package/dist-es/submodules/protocols/json/AwsJson1_1Protocol.js +2 -1
- package/dist-es/submodules/protocols/json/AwsJsonRpcProtocol.js +19 -29
- package/dist-es/submodules/protocols/json/AwsRestJsonProtocol.js +10 -54
- package/dist-es/submodules/protocols/query/AwsQueryProtocol.js +9 -32
- package/dist-es/submodules/protocols/xml/AwsRestXmlProtocol.js +11 -62
- package/dist-es/submodules/protocols/xml/XmlShapeSerializer.js +3 -3
- package/dist-types/submodules/protocols/ProtocolLib.d.ts +57 -0
- package/dist-types/submodules/protocols/cbor/AwsSmithyRpcV2CborProtocol.d.ts +23 -0
- package/dist-types/submodules/protocols/index.d.ts +1 -0
- package/dist-types/submodules/protocols/json/AwsJson1_0Protocol.d.ts +2 -1
- package/dist-types/submodules/protocols/json/AwsJson1_1Protocol.d.ts +2 -1
- package/dist-types/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +6 -3
- package/dist-types/submodules/protocols/json/AwsRestJsonProtocol.d.ts +2 -1
- package/dist-types/submodules/protocols/query/AwsQueryProtocol.d.ts +2 -2
- package/dist-types/submodules/protocols/xml/AwsRestXmlProtocol.d.ts +1 -0
- package/dist-types/ts3.4/submodules/protocols/ProtocolLib.d.ts +39 -0
- package/dist-types/ts3.4/submodules/protocols/cbor/AwsSmithyRpcV2CborProtocol.d.ts +33 -0
- package/dist-types/ts3.4/submodules/protocols/index.d.ts +1 -0
- package/dist-types/ts3.4/submodules/protocols/json/AwsJson1_0Protocol.d.ts +2 -0
- package/dist-types/ts3.4/submodules/protocols/json/AwsJson1_1Protocol.d.ts +2 -0
- package/dist-types/ts3.4/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +5 -1
- package/dist-types/ts3.4/submodules/protocols/json/AwsRestJsonProtocol.d.ts +1 -0
- package/dist-types/ts3.4/submodules/protocols/query/AwsQueryProtocol.d.ts +2 -1
- package/dist-types/ts3.4/submodules/protocols/xml/AwsRestXmlProtocol.d.ts +1 -0
- package/package.json +3 -3
|
@@ -28,6 +28,7 @@ __export(index_exports, {
|
|
|
28
28
|
AwsQueryProtocol: () => AwsQueryProtocol,
|
|
29
29
|
AwsRestJsonProtocol: () => AwsRestJsonProtocol,
|
|
30
30
|
AwsRestXmlProtocol: () => AwsRestXmlProtocol,
|
|
31
|
+
AwsSmithyRpcV2CborProtocol: () => AwsSmithyRpcV2CborProtocol,
|
|
31
32
|
JsonCodec: () => JsonCodec,
|
|
32
33
|
JsonShapeDeserializer: () => JsonShapeDeserializer,
|
|
33
34
|
JsonShapeSerializer: () => JsonShapeSerializer,
|
|
@@ -47,6 +48,197 @@ __export(index_exports, {
|
|
|
47
48
|
});
|
|
48
49
|
module.exports = __toCommonJS(index_exports);
|
|
49
50
|
|
|
51
|
+
// src/submodules/protocols/cbor/AwsSmithyRpcV2CborProtocol.ts
|
|
52
|
+
var import_cbor = require("@smithy/core/cbor");
|
|
53
|
+
var import_schema2 = require("@smithy/core/schema");
|
|
54
|
+
|
|
55
|
+
// src/submodules/protocols/ProtocolLib.ts
|
|
56
|
+
var import_schema = require("@smithy/core/schema");
|
|
57
|
+
var import_util_body_length_browser = require("@smithy/util-body-length-browser");
|
|
58
|
+
var ProtocolLib = class {
|
|
59
|
+
static {
|
|
60
|
+
__name(this, "ProtocolLib");
|
|
61
|
+
}
|
|
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
|
+
/**
|
|
74
|
+
* This is only for REST protocols.
|
|
75
|
+
*
|
|
76
|
+
* @param defaultContentType - of the protocol.
|
|
77
|
+
* @param inputSchema - schema for which to determine content type.
|
|
78
|
+
*
|
|
79
|
+
* @returns content-type header value or undefined when not applicable.
|
|
80
|
+
*/
|
|
81
|
+
resolveRestContentType(defaultContentType, inputSchema) {
|
|
82
|
+
const members = inputSchema.getMemberSchemas();
|
|
83
|
+
const httpPayloadMember = Object.values(members).find((m) => {
|
|
84
|
+
return !!m.getMergedTraits().httpPayload;
|
|
85
|
+
});
|
|
86
|
+
if (httpPayloadMember) {
|
|
87
|
+
const mediaType = httpPayloadMember.getMergedTraits().mediaType;
|
|
88
|
+
if (mediaType) {
|
|
89
|
+
return mediaType;
|
|
90
|
+
} else if (httpPayloadMember.isStringSchema()) {
|
|
91
|
+
return "text/plain";
|
|
92
|
+
} else if (httpPayloadMember.isBlobSchema()) {
|
|
93
|
+
return "application/octet-stream";
|
|
94
|
+
} else {
|
|
95
|
+
return defaultContentType;
|
|
96
|
+
}
|
|
97
|
+
} else if (!inputSchema.isUnitSchema()) {
|
|
98
|
+
const hasBody = Object.values(members).find((m) => {
|
|
99
|
+
const { httpQuery, httpQueryParams, httpHeader, httpLabel, httpPrefixHeaders } = m.getMergedTraits();
|
|
100
|
+
return !httpQuery && !httpQueryParams && !httpHeader && !httpLabel && httpPrefixHeaders === void 0;
|
|
101
|
+
});
|
|
102
|
+
if (hasBody) {
|
|
103
|
+
return defaultContentType;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Shared code for finding error schema or throwing an unmodeled base error.
|
|
109
|
+
* @returns error schema and error metadata.
|
|
110
|
+
*
|
|
111
|
+
* @throws ServiceBaseException or generic Error if no error schema could be found.
|
|
112
|
+
*/
|
|
113
|
+
async getErrorSchemaOrThrowBaseException(errorIdentifier, defaultNamespace, response, dataObject, metadata, getErrorSchema) {
|
|
114
|
+
let namespace = defaultNamespace;
|
|
115
|
+
let errorName = errorIdentifier;
|
|
116
|
+
if (errorIdentifier.includes("#")) {
|
|
117
|
+
[namespace, errorName] = errorIdentifier.split("#");
|
|
118
|
+
}
|
|
119
|
+
const errorMetadata = {
|
|
120
|
+
$metadata: metadata,
|
|
121
|
+
$response: response,
|
|
122
|
+
$fault: response.statusCode < 500 ? "client" : "server"
|
|
123
|
+
};
|
|
124
|
+
const registry = import_schema.TypeRegistry.for(namespace);
|
|
125
|
+
try {
|
|
126
|
+
const errorSchema = getErrorSchema?.(registry, errorName) ?? registry.getSchema(errorIdentifier);
|
|
127
|
+
return { errorSchema, errorMetadata };
|
|
128
|
+
} catch (e) {
|
|
129
|
+
if (dataObject.Message) {
|
|
130
|
+
dataObject.message = dataObject.Message;
|
|
131
|
+
}
|
|
132
|
+
const baseExceptionSchema = import_schema.TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace).getBaseException();
|
|
133
|
+
if (baseExceptionSchema) {
|
|
134
|
+
const ErrorCtor = baseExceptionSchema.ctor;
|
|
135
|
+
throw Object.assign(new ErrorCtor({ name: errorName }), errorMetadata, dataObject);
|
|
136
|
+
}
|
|
137
|
+
throw Object.assign(new Error(errorName), errorMetadata, dataObject);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Reads the x-amzn-query-error header for awsQuery compatibility.
|
|
142
|
+
*
|
|
143
|
+
* @param output - values that will be assigned to an error object.
|
|
144
|
+
* @param response - from which to read awsQueryError headers.
|
|
145
|
+
*/
|
|
146
|
+
setQueryCompatError(output, response) {
|
|
147
|
+
const queryErrorHeader = response.headers?.["x-amzn-query-error"];
|
|
148
|
+
if (output !== void 0 && queryErrorHeader != null) {
|
|
149
|
+
const [Code, Type] = queryErrorHeader.split(";");
|
|
150
|
+
const entries = Object.entries(output);
|
|
151
|
+
const Error2 = {
|
|
152
|
+
Code,
|
|
153
|
+
Type
|
|
154
|
+
};
|
|
155
|
+
Object.assign(output, Error2);
|
|
156
|
+
for (const [k, v] of entries) {
|
|
157
|
+
Error2[k] = v;
|
|
158
|
+
}
|
|
159
|
+
delete Error2.__type;
|
|
160
|
+
output.Error = Error2;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Assigns Error, Type, Code from the awsQuery error object to the output error object.
|
|
165
|
+
* @param queryCompatErrorData - query compat error object.
|
|
166
|
+
* @param errorData - canonical error object returned to the caller.
|
|
167
|
+
*/
|
|
168
|
+
queryCompatOutput(queryCompatErrorData, errorData) {
|
|
169
|
+
if (queryCompatErrorData.Error) {
|
|
170
|
+
errorData.Error = queryCompatErrorData.Error;
|
|
171
|
+
}
|
|
172
|
+
if (queryCompatErrorData.Type) {
|
|
173
|
+
errorData.Type = queryCompatErrorData.Type;
|
|
174
|
+
}
|
|
175
|
+
if (queryCompatErrorData.Code) {
|
|
176
|
+
errorData.Code = queryCompatErrorData.Code;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
// src/submodules/protocols/cbor/AwsSmithyRpcV2CborProtocol.ts
|
|
182
|
+
var AwsSmithyRpcV2CborProtocol = class extends import_cbor.SmithyRpcV2CborProtocol {
|
|
183
|
+
static {
|
|
184
|
+
__name(this, "AwsSmithyRpcV2CborProtocol");
|
|
185
|
+
}
|
|
186
|
+
awsQueryCompatible;
|
|
187
|
+
mixin = new ProtocolLib();
|
|
188
|
+
constructor({
|
|
189
|
+
defaultNamespace,
|
|
190
|
+
awsQueryCompatible
|
|
191
|
+
}) {
|
|
192
|
+
super({ defaultNamespace });
|
|
193
|
+
this.awsQueryCompatible = !!awsQueryCompatible;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* @override
|
|
197
|
+
*/
|
|
198
|
+
async serializeRequest(operationSchema, input, context) {
|
|
199
|
+
const request = await super.serializeRequest(operationSchema, input, context);
|
|
200
|
+
if (this.awsQueryCompatible) {
|
|
201
|
+
request.headers["x-amzn-query-mode"] = "true";
|
|
202
|
+
}
|
|
203
|
+
return request;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* @override
|
|
207
|
+
*/
|
|
208
|
+
async handleError(operationSchema, context, response, dataObject, metadata) {
|
|
209
|
+
if (this.awsQueryCompatible) {
|
|
210
|
+
this.mixin.setQueryCompatError(dataObject, response);
|
|
211
|
+
}
|
|
212
|
+
const errorName = (0, import_cbor.loadSmithyRpcV2CborErrorCode)(response, dataObject) ?? "Unknown";
|
|
213
|
+
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(
|
|
214
|
+
errorName,
|
|
215
|
+
this.options.defaultNamespace,
|
|
216
|
+
response,
|
|
217
|
+
dataObject,
|
|
218
|
+
metadata
|
|
219
|
+
);
|
|
220
|
+
const ns = import_schema2.NormalizedSchema.of(errorSchema);
|
|
221
|
+
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
222
|
+
const exception = new errorSchema.ctor(message);
|
|
223
|
+
const output = {};
|
|
224
|
+
for (const [name, member] of ns.structIterator()) {
|
|
225
|
+
output[name] = this.deserializer.readValue(member, dataObject[name]);
|
|
226
|
+
}
|
|
227
|
+
if (this.awsQueryCompatible) {
|
|
228
|
+
this.mixin.queryCompatOutput(dataObject, output);
|
|
229
|
+
}
|
|
230
|
+
throw Object.assign(
|
|
231
|
+
exception,
|
|
232
|
+
errorMetadata,
|
|
233
|
+
{
|
|
234
|
+
$fault: ns.getMergedTraits().error,
|
|
235
|
+
message
|
|
236
|
+
},
|
|
237
|
+
output
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
|
|
50
242
|
// src/submodules/protocols/coercing-serializers.ts
|
|
51
243
|
var _toStr = /* @__PURE__ */ __name((val) => {
|
|
52
244
|
if (val == null) {
|
|
@@ -104,8 +296,7 @@ var _toNum = /* @__PURE__ */ __name((val) => {
|
|
|
104
296
|
|
|
105
297
|
// src/submodules/protocols/json/AwsJsonRpcProtocol.ts
|
|
106
298
|
var import_protocols = require("@smithy/core/protocols");
|
|
107
|
-
var
|
|
108
|
-
var import_util_body_length_browser = require("@smithy/util-body-length-browser");
|
|
299
|
+
var import_schema5 = require("@smithy/core/schema");
|
|
109
300
|
|
|
110
301
|
// src/submodules/protocols/ConfigurableSerdeContext.ts
|
|
111
302
|
var SerdeContextConfig = class {
|
|
@@ -119,7 +310,7 @@ var SerdeContextConfig = class {
|
|
|
119
310
|
};
|
|
120
311
|
|
|
121
312
|
// src/submodules/protocols/json/JsonShapeDeserializer.ts
|
|
122
|
-
var
|
|
313
|
+
var import_schema3 = require("@smithy/core/schema");
|
|
123
314
|
var import_serde2 = require("@smithy/core/serde");
|
|
124
315
|
var import_util_base64 = require("@smithy/util-base64");
|
|
125
316
|
|
|
@@ -145,7 +336,8 @@ __name(jsonReviver, "jsonReviver");
|
|
|
145
336
|
|
|
146
337
|
// src/submodules/protocols/common.ts
|
|
147
338
|
var import_smithy_client = require("@smithy/smithy-client");
|
|
148
|
-
var
|
|
339
|
+
var import_util_utf8 = require("@smithy/util-utf8");
|
|
340
|
+
var collectBodyString = /* @__PURE__ */ __name((streamBody, context) => (0, import_smithy_client.collectBody)(streamBody, context).then((body) => (context?.utf8Encoder ?? import_util_utf8.toUtf8)(body)), "collectBodyString");
|
|
149
341
|
|
|
150
342
|
// src/submodules/protocols/json/parseJsonBody.ts
|
|
151
343
|
var parseJsonBody = /* @__PURE__ */ __name((streamBody, context) => collectBodyString(streamBody, context).then((encoded) => {
|
|
@@ -221,7 +413,7 @@ var JsonShapeDeserializer = class extends SerdeContextConfig {
|
|
|
221
413
|
}
|
|
222
414
|
_read(schema, value) {
|
|
223
415
|
const isObject = value !== null && typeof value === "object";
|
|
224
|
-
const ns =
|
|
416
|
+
const ns = import_schema3.NormalizedSchema.of(schema);
|
|
225
417
|
if (ns.isListSchema() && Array.isArray(value)) {
|
|
226
418
|
const listMember = ns.getValueSchema();
|
|
227
419
|
const out = [];
|
|
@@ -265,13 +457,13 @@ var JsonShapeDeserializer = class extends SerdeContextConfig {
|
|
|
265
457
|
}
|
|
266
458
|
if (ns.isTimestampSchema()) {
|
|
267
459
|
const options = this.settings.timestampFormat;
|
|
268
|
-
const format = options.useTrait ? ns.getSchema() ===
|
|
460
|
+
const format = options.useTrait ? ns.getSchema() === import_schema3.SCHEMA.TIMESTAMP_DEFAULT ? options.default : ns.getSchema() ?? options.default : options.default;
|
|
269
461
|
switch (format) {
|
|
270
|
-
case
|
|
462
|
+
case import_schema3.SCHEMA.TIMESTAMP_DATE_TIME:
|
|
271
463
|
return (0, import_serde2.parseRfc3339DateTimeWithOffset)(value);
|
|
272
|
-
case
|
|
464
|
+
case import_schema3.SCHEMA.TIMESTAMP_HTTP_DATE:
|
|
273
465
|
return (0, import_serde2.parseRfc7231DateTime)(value);
|
|
274
|
-
case
|
|
466
|
+
case import_schema3.SCHEMA.TIMESTAMP_EPOCH_SECONDS:
|
|
275
467
|
return (0, import_serde2.parseEpochTimestamp)(value);
|
|
276
468
|
default:
|
|
277
469
|
console.warn("Missing timestamp format, parsing value with Date constructor:", value);
|
|
@@ -302,7 +494,7 @@ var JsonShapeDeserializer = class extends SerdeContextConfig {
|
|
|
302
494
|
};
|
|
303
495
|
|
|
304
496
|
// src/submodules/protocols/json/JsonShapeSerializer.ts
|
|
305
|
-
var
|
|
497
|
+
var import_schema4 = require("@smithy/core/schema");
|
|
306
498
|
var import_serde4 = require("@smithy/core/serde");
|
|
307
499
|
|
|
308
500
|
// src/submodules/protocols/json/jsonReplacer.ts
|
|
@@ -378,7 +570,7 @@ var JsonShapeSerializer = class extends SerdeContextConfig {
|
|
|
378
570
|
buffer;
|
|
379
571
|
rootSchema;
|
|
380
572
|
write(schema, value) {
|
|
381
|
-
this.rootSchema =
|
|
573
|
+
this.rootSchema = import_schema4.NormalizedSchema.of(schema);
|
|
382
574
|
this.buffer = this._write(this.rootSchema, value);
|
|
383
575
|
}
|
|
384
576
|
flush() {
|
|
@@ -390,7 +582,7 @@ var JsonShapeSerializer = class extends SerdeContextConfig {
|
|
|
390
582
|
}
|
|
391
583
|
_write(schema, value, container) {
|
|
392
584
|
const isObject = value !== null && typeof value === "object";
|
|
393
|
-
const ns =
|
|
585
|
+
const ns = import_schema4.NormalizedSchema.of(schema);
|
|
394
586
|
if (ns.isListSchema() && Array.isArray(value)) {
|
|
395
587
|
const listMember = ns.getValueSchema();
|
|
396
588
|
const out = [];
|
|
@@ -436,13 +628,13 @@ var JsonShapeSerializer = class extends SerdeContextConfig {
|
|
|
436
628
|
}
|
|
437
629
|
if (ns.isTimestampSchema() && value instanceof Date) {
|
|
438
630
|
const options = this.settings.timestampFormat;
|
|
439
|
-
const format = options.useTrait ? ns.getSchema() ===
|
|
631
|
+
const format = options.useTrait ? ns.getSchema() === import_schema4.SCHEMA.TIMESTAMP_DEFAULT ? options.default : ns.getSchema() ?? options.default : options.default;
|
|
440
632
|
switch (format) {
|
|
441
|
-
case
|
|
633
|
+
case import_schema4.SCHEMA.TIMESTAMP_DATE_TIME:
|
|
442
634
|
return value.toISOString().replace(".000Z", "Z");
|
|
443
|
-
case
|
|
635
|
+
case import_schema4.SCHEMA.TIMESTAMP_HTTP_DATE:
|
|
444
636
|
return (0, import_serde4.dateToUtcString)(value);
|
|
445
|
-
case
|
|
637
|
+
case import_schema4.SCHEMA.TIMESTAMP_EPOCH_SECONDS:
|
|
446
638
|
return value.getTime() / 1e3;
|
|
447
639
|
default:
|
|
448
640
|
console.warn("Missing timestamp format, using epoch seconds", value);
|
|
@@ -500,7 +692,13 @@ var AwsJsonRpcProtocol = class extends import_protocols.RpcProtocol {
|
|
|
500
692
|
deserializer;
|
|
501
693
|
serviceTarget;
|
|
502
694
|
codec;
|
|
503
|
-
|
|
695
|
+
mixin = new ProtocolLib();
|
|
696
|
+
awsQueryCompatible;
|
|
697
|
+
constructor({
|
|
698
|
+
defaultNamespace,
|
|
699
|
+
serviceTarget,
|
|
700
|
+
awsQueryCompatible
|
|
701
|
+
}) {
|
|
504
702
|
super({
|
|
505
703
|
defaultNamespace
|
|
506
704
|
});
|
|
@@ -508,12 +706,13 @@ var AwsJsonRpcProtocol = class extends import_protocols.RpcProtocol {
|
|
|
508
706
|
this.codec = new JsonCodec({
|
|
509
707
|
timestampFormat: {
|
|
510
708
|
useTrait: true,
|
|
511
|
-
default:
|
|
709
|
+
default: import_schema5.SCHEMA.TIMESTAMP_EPOCH_SECONDS
|
|
512
710
|
},
|
|
513
711
|
jsonName: false
|
|
514
712
|
});
|
|
515
713
|
this.serializer = this.codec.createSerializer();
|
|
516
714
|
this.deserializer = this.codec.createDeserializer();
|
|
715
|
+
this.awsQueryCompatible = !!awsQueryCompatible;
|
|
517
716
|
}
|
|
518
717
|
async serializeRequest(operationSchema, input, context) {
|
|
519
718
|
const request = await super.serializeRequest(operationSchema, input, context);
|
|
@@ -522,13 +721,16 @@ var AwsJsonRpcProtocol = class extends import_protocols.RpcProtocol {
|
|
|
522
721
|
}
|
|
523
722
|
Object.assign(request.headers, {
|
|
524
723
|
"content-type": `application/x-amz-json-${this.getJsonRpcVersion()}`,
|
|
525
|
-
"x-amz-target": `${this.serviceTarget}.${
|
|
724
|
+
"x-amz-target": `${this.serviceTarget}.${import_schema5.NormalizedSchema.of(operationSchema).getName()}`
|
|
526
725
|
});
|
|
527
|
-
if (
|
|
726
|
+
if (this.awsQueryCompatible) {
|
|
727
|
+
request.headers["x-amzn-query-mode"] = "true";
|
|
728
|
+
}
|
|
729
|
+
if ((0, import_schema5.deref)(operationSchema.input) === "unit" || !request.body) {
|
|
528
730
|
request.body = "{}";
|
|
529
731
|
}
|
|
530
732
|
try {
|
|
531
|
-
request.headers["content-length"] =
|
|
733
|
+
request.headers["content-length"] = this.mixin.calculateContentLength(request.body, this.serdeContext);
|
|
532
734
|
} catch (e) {
|
|
533
735
|
}
|
|
534
736
|
return request;
|
|
@@ -537,41 +739,37 @@ var AwsJsonRpcProtocol = class extends import_protocols.RpcProtocol {
|
|
|
537
739
|
return this.codec;
|
|
538
740
|
}
|
|
539
741
|
async handleError(operationSchema, context, response, dataObject, metadata) {
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
let errorName = errorIdentifier;
|
|
543
|
-
if (errorIdentifier.includes("#")) {
|
|
544
|
-
[namespace, errorName] = errorIdentifier.split("#");
|
|
545
|
-
}
|
|
546
|
-
const registry = import_schema3.TypeRegistry.for(namespace);
|
|
547
|
-
let errorSchema;
|
|
548
|
-
try {
|
|
549
|
-
errorSchema = registry.getSchema(errorIdentifier);
|
|
550
|
-
} catch (e) {
|
|
551
|
-
const baseExceptionSchema = import_schema3.TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace).getBaseException();
|
|
552
|
-
if (baseExceptionSchema) {
|
|
553
|
-
const ErrorCtor = baseExceptionSchema.ctor;
|
|
554
|
-
throw Object.assign(new ErrorCtor(errorName), dataObject);
|
|
555
|
-
}
|
|
556
|
-
throw new Error(errorName);
|
|
742
|
+
if (this.awsQueryCompatible) {
|
|
743
|
+
this.mixin.setQueryCompatError(dataObject, response);
|
|
557
744
|
}
|
|
558
|
-
const
|
|
745
|
+
const errorIdentifier = loadRestJsonErrorCode(response, dataObject) ?? "Unknown";
|
|
746
|
+
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(
|
|
747
|
+
errorIdentifier,
|
|
748
|
+
this.options.defaultNamespace,
|
|
749
|
+
response,
|
|
750
|
+
dataObject,
|
|
751
|
+
metadata
|
|
752
|
+
);
|
|
753
|
+
const ns = import_schema5.NormalizedSchema.of(errorSchema);
|
|
559
754
|
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
560
755
|
const exception = new errorSchema.ctor(message);
|
|
561
|
-
await this.deserializeHttpMessage(errorSchema, context, response, dataObject);
|
|
562
756
|
const output = {};
|
|
563
757
|
for (const [name, member] of ns.structIterator()) {
|
|
564
758
|
const target = member.getMergedTraits().jsonName ?? name;
|
|
565
759
|
output[name] = this.codec.createDeserializer().readObject(member, dataObject[target]);
|
|
566
760
|
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
761
|
+
if (this.awsQueryCompatible) {
|
|
762
|
+
this.mixin.queryCompatOutput(dataObject, output);
|
|
763
|
+
}
|
|
764
|
+
throw Object.assign(
|
|
765
|
+
exception,
|
|
766
|
+
errorMetadata,
|
|
767
|
+
{
|
|
768
|
+
$fault: ns.getMergedTraits().error,
|
|
769
|
+
message
|
|
770
|
+
},
|
|
771
|
+
output
|
|
772
|
+
);
|
|
575
773
|
}
|
|
576
774
|
};
|
|
577
775
|
|
|
@@ -580,10 +778,15 @@ var AwsJson1_0Protocol = class extends AwsJsonRpcProtocol {
|
|
|
580
778
|
static {
|
|
581
779
|
__name(this, "AwsJson1_0Protocol");
|
|
582
780
|
}
|
|
583
|
-
constructor({
|
|
781
|
+
constructor({
|
|
782
|
+
defaultNamespace,
|
|
783
|
+
serviceTarget,
|
|
784
|
+
awsQueryCompatible
|
|
785
|
+
}) {
|
|
584
786
|
super({
|
|
585
787
|
defaultNamespace,
|
|
586
|
-
serviceTarget
|
|
788
|
+
serviceTarget,
|
|
789
|
+
awsQueryCompatible
|
|
587
790
|
});
|
|
588
791
|
}
|
|
589
792
|
getShapeId() {
|
|
@@ -605,10 +808,15 @@ var AwsJson1_1Protocol = class extends AwsJsonRpcProtocol {
|
|
|
605
808
|
static {
|
|
606
809
|
__name(this, "AwsJson1_1Protocol");
|
|
607
810
|
}
|
|
608
|
-
constructor({
|
|
811
|
+
constructor({
|
|
812
|
+
defaultNamespace,
|
|
813
|
+
serviceTarget,
|
|
814
|
+
awsQueryCompatible
|
|
815
|
+
}) {
|
|
609
816
|
super({
|
|
610
817
|
defaultNamespace,
|
|
611
|
-
serviceTarget
|
|
818
|
+
serviceTarget,
|
|
819
|
+
awsQueryCompatible
|
|
612
820
|
});
|
|
613
821
|
}
|
|
614
822
|
getShapeId() {
|
|
@@ -627,8 +835,7 @@ var AwsJson1_1Protocol = class extends AwsJsonRpcProtocol {
|
|
|
627
835
|
|
|
628
836
|
// src/submodules/protocols/json/AwsRestJsonProtocol.ts
|
|
629
837
|
var import_protocols2 = require("@smithy/core/protocols");
|
|
630
|
-
var
|
|
631
|
-
var import_util_body_length_browser2 = require("@smithy/util-body-length-browser");
|
|
838
|
+
var import_schema6 = require("@smithy/core/schema");
|
|
632
839
|
var AwsRestJsonProtocol = class extends import_protocols2.HttpBindingProtocol {
|
|
633
840
|
static {
|
|
634
841
|
__name(this, "AwsRestJsonProtocol");
|
|
@@ -636,6 +843,7 @@ var AwsRestJsonProtocol = class extends import_protocols2.HttpBindingProtocol {
|
|
|
636
843
|
serializer;
|
|
637
844
|
deserializer;
|
|
638
845
|
codec;
|
|
846
|
+
mixin = new ProtocolLib();
|
|
639
847
|
constructor({ defaultNamespace }) {
|
|
640
848
|
super({
|
|
641
849
|
defaultNamespace
|
|
@@ -643,7 +851,7 @@ var AwsRestJsonProtocol = class extends import_protocols2.HttpBindingProtocol {
|
|
|
643
851
|
const settings = {
|
|
644
852
|
timestampFormat: {
|
|
645
853
|
useTrait: true,
|
|
646
|
-
default:
|
|
854
|
+
default: import_schema6.SCHEMA.TIMESTAMP_EPOCH_SECONDS
|
|
647
855
|
},
|
|
648
856
|
httpBindings: true,
|
|
649
857
|
jsonName: true
|
|
@@ -664,31 +872,11 @@ var AwsRestJsonProtocol = class extends import_protocols2.HttpBindingProtocol {
|
|
|
664
872
|
}
|
|
665
873
|
async serializeRequest(operationSchema, input, context) {
|
|
666
874
|
const request = await super.serializeRequest(operationSchema, input, context);
|
|
667
|
-
const inputSchema =
|
|
668
|
-
const members = inputSchema.getMemberSchemas();
|
|
875
|
+
const inputSchema = import_schema6.NormalizedSchema.of(operationSchema.input);
|
|
669
876
|
if (!request.headers["content-type"]) {
|
|
670
|
-
const
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
if (httpPayloadMember) {
|
|
674
|
-
const mediaType = httpPayloadMember.getMergedTraits().mediaType;
|
|
675
|
-
if (mediaType) {
|
|
676
|
-
request.headers["content-type"] = mediaType;
|
|
677
|
-
} else if (httpPayloadMember.isStringSchema()) {
|
|
678
|
-
request.headers["content-type"] = "text/plain";
|
|
679
|
-
} else if (httpPayloadMember.isBlobSchema()) {
|
|
680
|
-
request.headers["content-type"] = "application/octet-stream";
|
|
681
|
-
} else {
|
|
682
|
-
request.headers["content-type"] = this.getDefaultContentType();
|
|
683
|
-
}
|
|
684
|
-
} else if (!inputSchema.isUnitSchema()) {
|
|
685
|
-
const hasBody = Object.values(members).find((m) => {
|
|
686
|
-
const { httpQuery, httpQueryParams, httpHeader, httpLabel, httpPrefixHeaders } = m.getMergedTraits();
|
|
687
|
-
return !httpQuery && !httpQueryParams && !httpHeader && !httpLabel && httpPrefixHeaders === void 0;
|
|
688
|
-
});
|
|
689
|
-
if (hasBody) {
|
|
690
|
-
request.headers["content-type"] = this.getDefaultContentType();
|
|
691
|
-
}
|
|
877
|
+
const contentType = this.mixin.resolveRestContentType(this.getDefaultContentType(), inputSchema);
|
|
878
|
+
if (contentType) {
|
|
879
|
+
request.headers["content-type"] = contentType;
|
|
692
880
|
}
|
|
693
881
|
}
|
|
694
882
|
if (request.headers["content-type"] && !request.body) {
|
|
@@ -696,7 +884,7 @@ var AwsRestJsonProtocol = class extends import_protocols2.HttpBindingProtocol {
|
|
|
696
884
|
}
|
|
697
885
|
if (request.body) {
|
|
698
886
|
try {
|
|
699
|
-
request.headers["content-length"] =
|
|
887
|
+
request.headers["content-length"] = this.mixin.calculateContentLength(request.body, this.serdeContext);
|
|
700
888
|
} catch (e) {
|
|
701
889
|
}
|
|
702
890
|
}
|
|
@@ -704,24 +892,14 @@ var AwsRestJsonProtocol = class extends import_protocols2.HttpBindingProtocol {
|
|
|
704
892
|
}
|
|
705
893
|
async handleError(operationSchema, context, response, dataObject, metadata) {
|
|
706
894
|
const errorIdentifier = loadRestJsonErrorCode(response, dataObject) ?? "Unknown";
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
errorSchema = registry.getSchema(errorIdentifier);
|
|
716
|
-
} catch (e) {
|
|
717
|
-
const baseExceptionSchema = import_schema4.TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace).getBaseException();
|
|
718
|
-
if (baseExceptionSchema) {
|
|
719
|
-
const ErrorCtor = baseExceptionSchema.ctor;
|
|
720
|
-
throw Object.assign(new ErrorCtor(errorName), dataObject);
|
|
721
|
-
}
|
|
722
|
-
throw new Error(errorName);
|
|
723
|
-
}
|
|
724
|
-
const ns = import_schema4.NormalizedSchema.of(errorSchema);
|
|
895
|
+
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(
|
|
896
|
+
errorIdentifier,
|
|
897
|
+
this.options.defaultNamespace,
|
|
898
|
+
response,
|
|
899
|
+
dataObject,
|
|
900
|
+
metadata
|
|
901
|
+
);
|
|
902
|
+
const ns = import_schema6.NormalizedSchema.of(errorSchema);
|
|
725
903
|
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
726
904
|
const exception = new errorSchema.ctor(message);
|
|
727
905
|
await this.deserializeHttpMessage(errorSchema, context, response, dataObject);
|
|
@@ -730,14 +908,15 @@ var AwsRestJsonProtocol = class extends import_protocols2.HttpBindingProtocol {
|
|
|
730
908
|
const target = member.getMergedTraits().jsonName ?? name;
|
|
731
909
|
output[name] = this.codec.createDeserializer().readObject(member, dataObject[target]);
|
|
732
910
|
}
|
|
733
|
-
Object.assign(
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
911
|
+
throw Object.assign(
|
|
912
|
+
exception,
|
|
913
|
+
errorMetadata,
|
|
914
|
+
{
|
|
915
|
+
$fault: ns.getMergedTraits().error,
|
|
916
|
+
message
|
|
917
|
+
},
|
|
918
|
+
output
|
|
919
|
+
);
|
|
741
920
|
}
|
|
742
921
|
/**
|
|
743
922
|
* @override
|
|
@@ -761,14 +940,13 @@ var awsExpectUnion = /* @__PURE__ */ __name((value) => {
|
|
|
761
940
|
|
|
762
941
|
// src/submodules/protocols/query/AwsQueryProtocol.ts
|
|
763
942
|
var import_protocols5 = require("@smithy/core/protocols");
|
|
764
|
-
var
|
|
765
|
-
var import_util_body_length_browser3 = require("@smithy/util-body-length-browser");
|
|
943
|
+
var import_schema9 = require("@smithy/core/schema");
|
|
766
944
|
|
|
767
945
|
// src/submodules/protocols/xml/XmlShapeDeserializer.ts
|
|
768
946
|
var import_protocols3 = require("@smithy/core/protocols");
|
|
769
|
-
var
|
|
947
|
+
var import_schema7 = require("@smithy/core/schema");
|
|
770
948
|
var import_smithy_client3 = require("@smithy/smithy-client");
|
|
771
|
-
var
|
|
949
|
+
var import_util_utf82 = require("@smithy/util-utf8");
|
|
772
950
|
var import_fast_xml_parser = require("fast-xml-parser");
|
|
773
951
|
var XmlShapeDeserializer = class extends SerdeContextConfig {
|
|
774
952
|
constructor(settings) {
|
|
@@ -790,7 +968,7 @@ var XmlShapeDeserializer = class extends SerdeContextConfig {
|
|
|
790
968
|
* @param key - used by AwsQuery to step one additional depth into the object before reading it.
|
|
791
969
|
*/
|
|
792
970
|
read(schema, bytes, key) {
|
|
793
|
-
const ns =
|
|
971
|
+
const ns = import_schema7.NormalizedSchema.of(schema);
|
|
794
972
|
const memberSchemas = ns.getMemberSchemas();
|
|
795
973
|
const isEventPayload = ns.isStructSchema() && ns.isMemberSchema() && !!Object.values(memberSchemas).find((memberNs) => {
|
|
796
974
|
return !!memberNs.getMemberTraits().eventPayload;
|
|
@@ -806,12 +984,12 @@ var XmlShapeDeserializer = class extends SerdeContextConfig {
|
|
|
806
984
|
}
|
|
807
985
|
return output;
|
|
808
986
|
}
|
|
809
|
-
const xmlString = (this.serdeContext?.utf8Encoder ??
|
|
987
|
+
const xmlString = (this.serdeContext?.utf8Encoder ?? import_util_utf82.toUtf8)(bytes);
|
|
810
988
|
const parsedObject = this.parseXml(xmlString);
|
|
811
989
|
return this.readSchema(schema, key ? parsedObject[key] : parsedObject);
|
|
812
990
|
}
|
|
813
991
|
readSchema(_schema, value) {
|
|
814
|
-
const ns =
|
|
992
|
+
const ns = import_schema7.NormalizedSchema.of(_schema);
|
|
815
993
|
const traits = ns.getMergedTraits();
|
|
816
994
|
if (ns.isListSchema() && !Array.isArray(value)) {
|
|
817
995
|
return this.readSchema(ns, [value]);
|
|
@@ -918,7 +1096,7 @@ var XmlShapeDeserializer = class extends SerdeContextConfig {
|
|
|
918
1096
|
|
|
919
1097
|
// src/submodules/protocols/query/QueryShapeSerializer.ts
|
|
920
1098
|
var import_protocols4 = require("@smithy/core/protocols");
|
|
921
|
-
var
|
|
1099
|
+
var import_schema8 = require("@smithy/core/schema");
|
|
922
1100
|
var import_serde5 = require("@smithy/core/serde");
|
|
923
1101
|
var import_smithy_client4 = require("@smithy/smithy-client");
|
|
924
1102
|
var import_util_base642 = require("@smithy/util-base64");
|
|
@@ -935,7 +1113,7 @@ var QueryShapeSerializer = class extends SerdeContextConfig {
|
|
|
935
1113
|
if (this.buffer === void 0) {
|
|
936
1114
|
this.buffer = "";
|
|
937
1115
|
}
|
|
938
|
-
const ns =
|
|
1116
|
+
const ns = import_schema8.NormalizedSchema.of(schema);
|
|
939
1117
|
if (prefix && !prefix.endsWith(".")) {
|
|
940
1118
|
prefix += ".";
|
|
941
1119
|
}
|
|
@@ -967,13 +1145,13 @@ var QueryShapeSerializer = class extends SerdeContextConfig {
|
|
|
967
1145
|
this.writeKey(prefix);
|
|
968
1146
|
const format = (0, import_protocols4.determineTimestampFormat)(ns, this.settings);
|
|
969
1147
|
switch (format) {
|
|
970
|
-
case
|
|
1148
|
+
case import_schema8.SCHEMA.TIMESTAMP_DATE_TIME:
|
|
971
1149
|
this.writeValue(value.toISOString().replace(".000Z", "Z"));
|
|
972
1150
|
break;
|
|
973
|
-
case
|
|
1151
|
+
case import_schema8.SCHEMA.TIMESTAMP_HTTP_DATE:
|
|
974
1152
|
this.writeValue((0, import_smithy_client4.dateToUtcString)(value));
|
|
975
1153
|
break;
|
|
976
|
-
case
|
|
1154
|
+
case import_schema8.SCHEMA.TIMESTAMP_EPOCH_SECONDS:
|
|
977
1155
|
this.writeValue(String(value.getTime() / 1e3));
|
|
978
1156
|
break;
|
|
979
1157
|
}
|
|
@@ -1073,7 +1251,7 @@ var AwsQueryProtocol = class extends import_protocols5.RpcProtocol {
|
|
|
1073
1251
|
const settings = {
|
|
1074
1252
|
timestampFormat: {
|
|
1075
1253
|
useTrait: true,
|
|
1076
|
-
default:
|
|
1254
|
+
default: import_schema9.SCHEMA.TIMESTAMP_DATE_TIME
|
|
1077
1255
|
},
|
|
1078
1256
|
httpBindings: false,
|
|
1079
1257
|
xmlNamespace: options.xmlNamespace,
|
|
@@ -1088,6 +1266,7 @@ var AwsQueryProtocol = class extends import_protocols5.RpcProtocol {
|
|
|
1088
1266
|
}
|
|
1089
1267
|
serializer;
|
|
1090
1268
|
deserializer;
|
|
1269
|
+
mixin = new ProtocolLib();
|
|
1091
1270
|
getShapeId() {
|
|
1092
1271
|
return "aws.protocols#awsQuery";
|
|
1093
1272
|
}
|
|
@@ -1106,7 +1285,7 @@ var AwsQueryProtocol = class extends import_protocols5.RpcProtocol {
|
|
|
1106
1285
|
Object.assign(request.headers, {
|
|
1107
1286
|
"content-type": `application/x-www-form-urlencoded`
|
|
1108
1287
|
});
|
|
1109
|
-
if ((0,
|
|
1288
|
+
if ((0, import_schema9.deref)(operationSchema.input) === "unit" || !request.body) {
|
|
1110
1289
|
request.body = "";
|
|
1111
1290
|
}
|
|
1112
1291
|
request.body = `Action=${operationSchema.name.split("#")[1]}&Version=${this.options.version}` + request.body;
|
|
@@ -1114,19 +1293,19 @@ var AwsQueryProtocol = class extends import_protocols5.RpcProtocol {
|
|
|
1114
1293
|
request.body = request.body.slice(-1);
|
|
1115
1294
|
}
|
|
1116
1295
|
try {
|
|
1117
|
-
request.headers["content-length"] =
|
|
1296
|
+
request.headers["content-length"] = this.mixin.calculateContentLength(request.body, this.serdeContext);
|
|
1118
1297
|
} catch (e) {
|
|
1119
1298
|
}
|
|
1120
1299
|
return request;
|
|
1121
1300
|
}
|
|
1122
1301
|
async deserializeResponse(operationSchema, context, response) {
|
|
1123
1302
|
const deserializer = this.deserializer;
|
|
1124
|
-
const ns =
|
|
1303
|
+
const ns = import_schema9.NormalizedSchema.of(operationSchema.output);
|
|
1125
1304
|
const dataObject = {};
|
|
1126
1305
|
if (response.statusCode >= 300) {
|
|
1127
1306
|
const bytes2 = await (0, import_protocols5.collectBody)(response.body, context);
|
|
1128
1307
|
if (bytes2.byteLength > 0) {
|
|
1129
|
-
Object.assign(dataObject, await deserializer.read(
|
|
1308
|
+
Object.assign(dataObject, await deserializer.read(import_schema9.SCHEMA.DOCUMENT, bytes2));
|
|
1130
1309
|
}
|
|
1131
1310
|
await this.handleError(operationSchema, context, response, dataObject, this.deserializeMetadata(response));
|
|
1132
1311
|
}
|
|
@@ -1154,46 +1333,35 @@ var AwsQueryProtocol = class extends import_protocols5.RpcProtocol {
|
|
|
1154
1333
|
}
|
|
1155
1334
|
async handleError(operationSchema, context, response, dataObject, metadata) {
|
|
1156
1335
|
const errorIdentifier = this.loadQueryErrorCode(response, dataObject) ?? "Unknown";
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
if (!errorSchema) {
|
|
1170
|
-
errorSchema = registry.getSchema(errorIdentifier);
|
|
1171
|
-
}
|
|
1172
|
-
} catch (e) {
|
|
1173
|
-
const baseExceptionSchema = import_schema7.TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace).getBaseException();
|
|
1174
|
-
if (baseExceptionSchema) {
|
|
1175
|
-
const ErrorCtor = baseExceptionSchema.ctor;
|
|
1176
|
-
throw Object.assign(new ErrorCtor(errorName), errorDataSource);
|
|
1177
|
-
}
|
|
1178
|
-
throw new Error(errorName);
|
|
1179
|
-
}
|
|
1180
|
-
const ns = import_schema7.NormalizedSchema.of(errorSchema);
|
|
1336
|
+
const errorData = this.loadQueryError(dataObject);
|
|
1337
|
+
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(
|
|
1338
|
+
errorIdentifier,
|
|
1339
|
+
this.options.defaultNamespace,
|
|
1340
|
+
response,
|
|
1341
|
+
errorData,
|
|
1342
|
+
metadata,
|
|
1343
|
+
(registry, errorName) => registry.find(
|
|
1344
|
+
(schema) => import_schema9.NormalizedSchema.of(schema).getMergedTraits().awsQueryError?.[0] === errorName
|
|
1345
|
+
)
|
|
1346
|
+
);
|
|
1347
|
+
const ns = import_schema9.NormalizedSchema.of(errorSchema);
|
|
1181
1348
|
const message = this.loadQueryErrorMessage(dataObject);
|
|
1182
1349
|
const exception = new errorSchema.ctor(message);
|
|
1183
1350
|
const output = {};
|
|
1184
1351
|
for (const [name, member] of ns.structIterator()) {
|
|
1185
1352
|
const target = member.getMergedTraits().xmlName ?? name;
|
|
1186
|
-
const value =
|
|
1353
|
+
const value = errorData[target] ?? dataObject[target];
|
|
1187
1354
|
output[name] = this.deserializer.readSchema(member, value);
|
|
1188
1355
|
}
|
|
1189
|
-
Object.assign(
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1356
|
+
throw Object.assign(
|
|
1357
|
+
exception,
|
|
1358
|
+
errorMetadata,
|
|
1359
|
+
{
|
|
1360
|
+
$fault: ns.getMergedTraits().error,
|
|
1361
|
+
message
|
|
1362
|
+
},
|
|
1363
|
+
output
|
|
1364
|
+
);
|
|
1197
1365
|
}
|
|
1198
1366
|
/**
|
|
1199
1367
|
* The variations in the error and error message locations are attributed to
|
|
@@ -1248,8 +1416,7 @@ var AwsEc2QueryProtocol = class extends AwsQueryProtocol {
|
|
|
1248
1416
|
|
|
1249
1417
|
// src/submodules/protocols/xml/AwsRestXmlProtocol.ts
|
|
1250
1418
|
var import_protocols6 = require("@smithy/core/protocols");
|
|
1251
|
-
var
|
|
1252
|
-
var import_util_body_length_browser4 = require("@smithy/util-body-length-browser");
|
|
1419
|
+
var import_schema11 = require("@smithy/core/schema");
|
|
1253
1420
|
|
|
1254
1421
|
// src/submodules/protocols/xml/parseXmlBody.ts
|
|
1255
1422
|
var import_smithy_client5 = require("@smithy/smithy-client");
|
|
@@ -1310,7 +1477,7 @@ var loadRestXmlErrorCode = /* @__PURE__ */ __name((output, data) => {
|
|
|
1310
1477
|
|
|
1311
1478
|
// src/submodules/protocols/xml/XmlShapeSerializer.ts
|
|
1312
1479
|
var import_xml_builder = require("@aws-sdk/xml-builder");
|
|
1313
|
-
var
|
|
1480
|
+
var import_schema10 = require("@smithy/core/schema");
|
|
1314
1481
|
var import_serde6 = require("@smithy/core/serde");
|
|
1315
1482
|
var import_smithy_client6 = require("@smithy/smithy-client");
|
|
1316
1483
|
var import_util_base643 = require("@smithy/util-base64");
|
|
@@ -1326,7 +1493,7 @@ var XmlShapeSerializer = class extends SerdeContextConfig {
|
|
|
1326
1493
|
byteBuffer;
|
|
1327
1494
|
buffer;
|
|
1328
1495
|
write(schema, value) {
|
|
1329
|
-
const ns =
|
|
1496
|
+
const ns = import_schema10.NormalizedSchema.of(schema);
|
|
1330
1497
|
if (ns.isStringSchema() && typeof value === "string") {
|
|
1331
1498
|
this.stringBuffer = value;
|
|
1332
1499
|
} else if (ns.isBlobSchema()) {
|
|
@@ -1371,9 +1538,6 @@ var XmlShapeSerializer = class extends SerdeContextConfig {
|
|
|
1371
1538
|
}
|
|
1372
1539
|
const structXmlNode = import_xml_builder.XmlNode.of(name);
|
|
1373
1540
|
const [xmlnsAttr, xmlns] = this.getXmlnsAttribute(ns, parentXmlns);
|
|
1374
|
-
if (xmlns) {
|
|
1375
|
-
structXmlNode.addAttribute(xmlnsAttr, xmlns);
|
|
1376
|
-
}
|
|
1377
1541
|
for (const [memberName, memberSchema] of ns.structIterator()) {
|
|
1378
1542
|
const val = value[memberName];
|
|
1379
1543
|
if (val != null || memberSchema.isIdempotencyToken()) {
|
|
@@ -1397,6 +1561,9 @@ var XmlShapeSerializer = class extends SerdeContextConfig {
|
|
|
1397
1561
|
}
|
|
1398
1562
|
}
|
|
1399
1563
|
}
|
|
1564
|
+
if (xmlns) {
|
|
1565
|
+
structXmlNode.addAttribute(xmlnsAttr, xmlns);
|
|
1566
|
+
}
|
|
1400
1567
|
return structXmlNode;
|
|
1401
1568
|
}
|
|
1402
1569
|
writeList(listMember, array, container, parentXmlns) {
|
|
@@ -1513,22 +1680,22 @@ var XmlShapeSerializer = class extends SerdeContextConfig {
|
|
|
1513
1680
|
if (null === value) {
|
|
1514
1681
|
throw new Error("@aws-sdk/core/protocols - (XML serializer) cannot write null value.");
|
|
1515
1682
|
}
|
|
1516
|
-
const ns =
|
|
1683
|
+
const ns = import_schema10.NormalizedSchema.of(_schema);
|
|
1517
1684
|
let nodeContents = null;
|
|
1518
1685
|
if (value && typeof value === "object") {
|
|
1519
1686
|
if (ns.isBlobSchema()) {
|
|
1520
1687
|
nodeContents = (this.serdeContext?.base64Encoder ?? import_util_base643.toBase64)(value);
|
|
1521
1688
|
} else if (ns.isTimestampSchema() && value instanceof Date) {
|
|
1522
1689
|
const options = this.settings.timestampFormat;
|
|
1523
|
-
const format = options.useTrait ? ns.getSchema() ===
|
|
1690
|
+
const format = options.useTrait ? ns.getSchema() === import_schema10.SCHEMA.TIMESTAMP_DEFAULT ? options.default : ns.getSchema() ?? options.default : options.default;
|
|
1524
1691
|
switch (format) {
|
|
1525
|
-
case
|
|
1692
|
+
case import_schema10.SCHEMA.TIMESTAMP_DATE_TIME:
|
|
1526
1693
|
nodeContents = value.toISOString().replace(".000Z", "Z");
|
|
1527
1694
|
break;
|
|
1528
|
-
case
|
|
1695
|
+
case import_schema10.SCHEMA.TIMESTAMP_HTTP_DATE:
|
|
1529
1696
|
nodeContents = (0, import_smithy_client6.dateToUtcString)(value);
|
|
1530
1697
|
break;
|
|
1531
|
-
case
|
|
1698
|
+
case import_schema10.SCHEMA.TIMESTAMP_EPOCH_SECONDS:
|
|
1532
1699
|
nodeContents = String(value.getTime() / 1e3);
|
|
1533
1700
|
break;
|
|
1534
1701
|
default:
|
|
@@ -1570,7 +1737,7 @@ var XmlShapeSerializer = class extends SerdeContextConfig {
|
|
|
1570
1737
|
}
|
|
1571
1738
|
writeSimpleInto(_schema, value, into, parentXmlns) {
|
|
1572
1739
|
const nodeContents = this.writeSimple(_schema, value);
|
|
1573
|
-
const ns =
|
|
1740
|
+
const ns = import_schema10.NormalizedSchema.of(_schema);
|
|
1574
1741
|
const content = new import_xml_builder.XmlText(nodeContents);
|
|
1575
1742
|
const [xmlnsAttr, xmlns] = this.getXmlnsAttribute(ns, parentXmlns);
|
|
1576
1743
|
if (xmlns) {
|
|
@@ -1617,12 +1784,13 @@ var AwsRestXmlProtocol = class extends import_protocols6.HttpBindingProtocol {
|
|
|
1617
1784
|
codec;
|
|
1618
1785
|
serializer;
|
|
1619
1786
|
deserializer;
|
|
1787
|
+
mixin = new ProtocolLib();
|
|
1620
1788
|
constructor(options) {
|
|
1621
1789
|
super(options);
|
|
1622
1790
|
const settings = {
|
|
1623
1791
|
timestampFormat: {
|
|
1624
1792
|
useTrait: true,
|
|
1625
|
-
default:
|
|
1793
|
+
default: import_schema11.SCHEMA.TIMESTAMP_DATE_TIME
|
|
1626
1794
|
},
|
|
1627
1795
|
httpBindings: true,
|
|
1628
1796
|
xmlNamespace: options.xmlNamespace,
|
|
@@ -1640,34 +1808,11 @@ var AwsRestXmlProtocol = class extends import_protocols6.HttpBindingProtocol {
|
|
|
1640
1808
|
}
|
|
1641
1809
|
async serializeRequest(operationSchema, input, context) {
|
|
1642
1810
|
const request = await super.serializeRequest(operationSchema, input, context);
|
|
1643
|
-
const
|
|
1644
|
-
const members = ns.getMemberSchemas();
|
|
1645
|
-
request.path = String(request.path).split("/").filter((segment) => {
|
|
1646
|
-
return segment !== "{Bucket}";
|
|
1647
|
-
}).join("/") || "/";
|
|
1811
|
+
const inputSchema = import_schema11.NormalizedSchema.of(operationSchema.input);
|
|
1648
1812
|
if (!request.headers["content-type"]) {
|
|
1649
|
-
const
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
if (httpPayloadMember) {
|
|
1653
|
-
const mediaType = httpPayloadMember.getMergedTraits().mediaType;
|
|
1654
|
-
if (mediaType) {
|
|
1655
|
-
request.headers["content-type"] = mediaType;
|
|
1656
|
-
} else if (httpPayloadMember.isStringSchema()) {
|
|
1657
|
-
request.headers["content-type"] = "text/plain";
|
|
1658
|
-
} else if (httpPayloadMember.isBlobSchema()) {
|
|
1659
|
-
request.headers["content-type"] = "application/octet-stream";
|
|
1660
|
-
} else {
|
|
1661
|
-
request.headers["content-type"] = this.getDefaultContentType();
|
|
1662
|
-
}
|
|
1663
|
-
} else if (!ns.isUnitSchema()) {
|
|
1664
|
-
const hasBody = Object.values(members).find((m) => {
|
|
1665
|
-
const { httpQuery, httpQueryParams, httpHeader, httpLabel, httpPrefixHeaders } = m.getMergedTraits();
|
|
1666
|
-
return !httpQuery && !httpQueryParams && !httpHeader && !httpLabel && httpPrefixHeaders === void 0;
|
|
1667
|
-
});
|
|
1668
|
-
if (hasBody) {
|
|
1669
|
-
request.headers["content-type"] = this.getDefaultContentType();
|
|
1670
|
-
}
|
|
1813
|
+
const contentType = this.mixin.resolveRestContentType(this.getDefaultContentType(), inputSchema);
|
|
1814
|
+
if (contentType) {
|
|
1815
|
+
request.headers["content-type"] = contentType;
|
|
1671
1816
|
}
|
|
1672
1817
|
}
|
|
1673
1818
|
if (request.headers["content-type"] === this.getDefaultContentType()) {
|
|
@@ -1677,7 +1822,7 @@ var AwsRestXmlProtocol = class extends import_protocols6.HttpBindingProtocol {
|
|
|
1677
1822
|
}
|
|
1678
1823
|
if (request.body) {
|
|
1679
1824
|
try {
|
|
1680
|
-
request.headers["content-length"] =
|
|
1825
|
+
request.headers["content-length"] = this.mixin.calculateContentLength(request.body, this.serdeContext);
|
|
1681
1826
|
} catch (e) {
|
|
1682
1827
|
}
|
|
1683
1828
|
}
|
|
@@ -1688,24 +1833,14 @@ var AwsRestXmlProtocol = class extends import_protocols6.HttpBindingProtocol {
|
|
|
1688
1833
|
}
|
|
1689
1834
|
async handleError(operationSchema, context, response, dataObject, metadata) {
|
|
1690
1835
|
const errorIdentifier = loadRestXmlErrorCode(response, dataObject) ?? "Unknown";
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
errorSchema = registry.getSchema(errorIdentifier);
|
|
1700
|
-
} catch (e) {
|
|
1701
|
-
const baseExceptionSchema = import_schema9.TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace).getBaseException();
|
|
1702
|
-
if (baseExceptionSchema) {
|
|
1703
|
-
const ErrorCtor = baseExceptionSchema.ctor;
|
|
1704
|
-
throw Object.assign(new ErrorCtor(errorName), dataObject);
|
|
1705
|
-
}
|
|
1706
|
-
throw new Error(errorName);
|
|
1707
|
-
}
|
|
1708
|
-
const ns = import_schema9.NormalizedSchema.of(errorSchema);
|
|
1836
|
+
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(
|
|
1837
|
+
errorIdentifier,
|
|
1838
|
+
this.options.defaultNamespace,
|
|
1839
|
+
response,
|
|
1840
|
+
dataObject,
|
|
1841
|
+
metadata
|
|
1842
|
+
);
|
|
1843
|
+
const ns = import_schema11.NormalizedSchema.of(errorSchema);
|
|
1709
1844
|
const message = dataObject.Error?.message ?? dataObject.Error?.Message ?? dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
1710
1845
|
const exception = new errorSchema.ctor(message);
|
|
1711
1846
|
await this.deserializeHttpMessage(errorSchema, context, response, dataObject);
|
|
@@ -1715,14 +1850,15 @@ var AwsRestXmlProtocol = class extends import_protocols6.HttpBindingProtocol {
|
|
|
1715
1850
|
const value = dataObject.Error?.[target] ?? dataObject[target];
|
|
1716
1851
|
output[name] = this.codec.createDeserializer().readSchema(member, value);
|
|
1717
1852
|
}
|
|
1718
|
-
Object.assign(
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1853
|
+
throw Object.assign(
|
|
1854
|
+
exception,
|
|
1855
|
+
errorMetadata,
|
|
1856
|
+
{
|
|
1857
|
+
$fault: ns.getMergedTraits().error,
|
|
1858
|
+
message
|
|
1859
|
+
},
|
|
1860
|
+
output
|
|
1861
|
+
);
|
|
1726
1862
|
}
|
|
1727
1863
|
/**
|
|
1728
1864
|
* @override
|
|
@@ -1740,6 +1876,7 @@ var AwsRestXmlProtocol = class extends import_protocols6.HttpBindingProtocol {
|
|
|
1740
1876
|
AwsQueryProtocol,
|
|
1741
1877
|
AwsRestJsonProtocol,
|
|
1742
1878
|
AwsRestXmlProtocol,
|
|
1879
|
+
AwsSmithyRpcV2CborProtocol,
|
|
1743
1880
|
JsonCodec,
|
|
1744
1881
|
JsonShapeDeserializer,
|
|
1745
1882
|
JsonShapeSerializer,
|