@jjrawlins/cdk-iam-policy-builder-helper 0.0.51 → 0.0.53
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/.jsii +3 -3
- package/cdk-iam-policy-builder-helper/go.mod +1 -1
- package/cdk-iam-policy-builder-helper/jsii/jsii.go +2 -2
- package/cdk-iam-policy-builder-helper/version +1 -1
- package/node_modules/@aws-sdk/client-iam/dist-cjs/index.js +13439 -13574
- package/node_modules/@aws-sdk/client-iam/package.json +5 -5
- package/node_modules/@aws-sdk/client-sso/dist-cjs/index.js +478 -596
- package/node_modules/@aws-sdk/client-sso/package.json +4 -4
- package/node_modules/@aws-sdk/core/dist-cjs/index.js +1969 -6
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/account-id-endpoint/index.js +48 -88
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/client/index.js +35 -74
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/httpAuthSchemes/index.js +273 -365
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js +1581 -1863
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsJsonRpcProtocol.js +2 -2
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsRestJsonProtocol.js +2 -2
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/JsonShapeDeserializer.js +4 -4
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/JsonShapeSerializer.js +4 -4
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/query/AwsQueryProtocol.js +3 -3
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/query/QueryShapeSerializer.js +4 -4
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/xml/AwsRestXmlProtocol.js +2 -2
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/xml/XmlShapeSerializer.js +4 -4
- package/node_modules/@aws-sdk/core/dist-types/submodules/account-id-endpoint/AccountIdEndpointModeConfigResolver.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4ASigner.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4AConfig.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/ConfigurableSerdeContext.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/JsonCodec.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/JsonShapeDeserializer.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/JsonShapeSerializer.d.ts +2 -2
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/query/QuerySerializerSettings.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/xml/XmlCodec.d.ts +1 -1
- package/node_modules/@aws-sdk/core/package.json +1 -1
- package/node_modules/@aws-sdk/credential-provider-env/dist-cjs/index.js +38 -73
- package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-http/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-ini/dist-cjs/index.js +194 -259
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +8 -8
- package/node_modules/@aws-sdk/credential-provider-node/dist-cjs/index.js +72 -132
- package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
- package/node_modules/@aws-sdk/credential-provider-process/dist-cjs/index.js +71 -107
- package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-sso/dist-cjs/index.js +176 -249
- package/node_modules/@aws-sdk/credential-provider-sso/dist-cjs/loadSso-CVy8iqsZ.js +14 -0
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-web-identity/dist-cjs/index.js +16 -25
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
- package/node_modules/@aws-sdk/middleware-user-agent/dist-cjs/index.js +170 -203
- package/node_modules/@aws-sdk/middleware-user-agent/package.json +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/index.js +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +583 -858
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +795 -928
- package/node_modules/@aws-sdk/nested-clients/package.json +4 -4
- package/node_modules/@aws-sdk/token-providers/dist-cjs/index.js +147 -222
- package/node_modules/@aws-sdk/token-providers/package.json +3 -3
- package/node_modules/@aws-sdk/util-user-agent-node/dist-cjs/index.js +50 -94
- package/node_modules/@aws-sdk/util-user-agent-node/package.json +2 -2
- package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +1 -1
- package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.js +5 -3
- package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +32 -30
- package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +133 -202
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js +126 -34
- package/node_modules/@smithy/core/dist-es/submodules/cbor/CborCodec.js +2 -2
- package/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js +5 -3
- package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpBindingProtocol.js +4 -4
- package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +3 -3
- package/node_modules/@smithy/core/dist-es/submodules/protocols/RpcProtocol.js +2 -2
- package/node_modules/@smithy/core/dist-es/submodules/protocols/serde/FromStringShapeDeserializer.js +19 -17
- package/node_modules/@smithy/core/dist-es/submodules/protocols/serde/ToStringShapeSerializer.js +4 -4
- package/node_modules/@smithy/core/dist-es/submodules/protocols/serde/determineTimestampFormat.js +5 -6
- package/node_modules/@smithy/core/dist-es/submodules/schema/index.js +1 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/NormalizedSchema.js +82 -176
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/translateTraits.js +22 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/index.js +1 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/schema-serde-lib/schema-date-utils.js +110 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/value/NumericValue.js +4 -26
- package/node_modules/@smithy/core/dist-types/submodules/schema/index.d.ts +1 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/NormalizedSchema.d.ts +5 -24
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/sentinels.d.ts +2 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/translateTraits.d.ts +7 -0
- package/node_modules/@smithy/core/dist-types/submodules/serde/index.d.ts +1 -0
- package/node_modules/@smithy/core/dist-types/submodules/serde/schema-serde-lib/schema-date-utils.d.ts +47 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/index.d.ts +1 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/NormalizedSchema.d.ts +5 -24
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/sentinels.d.ts +2 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/translateTraits.d.ts +7 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/serde/index.d.ts +1 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/serde/schema-serde-lib/schema-date-utils.d.ts +47 -0
- package/node_modules/@smithy/core/package.json +3 -3
- package/node_modules/@smithy/fetch-http-handler/package.json +2 -2
- package/node_modules/@smithy/middleware-endpoint/package.json +2 -2
- package/node_modules/@smithy/middleware-retry/package.json +2 -2
- package/node_modules/@smithy/smithy-client/package.json +4 -4
- package/node_modules/@smithy/util-base64/dist-cjs/constants.browser.js +9 -32
- package/node_modules/@smithy/util-base64/dist-es/constants.browser.js +9 -28
- package/node_modules/@smithy/util-base64/dist-types/constants.browser.d.ts +5 -6
- package/node_modules/@smithy/util-base64/dist-types/ts3.4/constants.browser.d.ts +5 -6
- package/node_modules/@smithy/util-base64/package.json +1 -1
- package/node_modules/@smithy/util-body-length-node/dist-cjs/index.js +8 -6
- package/node_modules/@smithy/util-body-length-node/dist-es/calculateBodyLength.js +8 -6
- package/node_modules/@smithy/util-body-length-node/package.json +1 -1
- package/node_modules/@smithy/util-defaults-mode-browser/dist-cjs/resolveDefaultsModeConfig.js +11 -9
- package/node_modules/@smithy/util-defaults-mode-browser/dist-es/resolveDefaultsModeConfig.js +11 -8
- package/node_modules/@smithy/util-defaults-mode-browser/package.json +2 -3
- package/node_modules/@smithy/util-defaults-mode-node/package.json +2 -2
- package/node_modules/@smithy/util-stream/dist-cjs/index.js +3 -5
- package/node_modules/@smithy/util-stream/dist-es/blob/Uint8ArrayBlobAdapter.js +3 -5
- package/node_modules/@smithy/util-stream/dist-types/blob/Uint8ArrayBlobAdapter.d.ts +1 -0
- package/node_modules/@smithy/util-stream/dist-types/ts3.4/blob/Uint8ArrayBlobAdapter.d.ts +1 -0
- package/node_modules/@smithy/util-stream/package.json +3 -3
- package/package.json +3 -3
|
@@ -1,1906 +1,1624 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/submodules/protocols/index.ts
|
|
22
|
-
var index_exports = {};
|
|
23
|
-
__export(index_exports, {
|
|
24
|
-
AwsEc2QueryProtocol: () => AwsEc2QueryProtocol,
|
|
25
|
-
AwsJson1_0Protocol: () => AwsJson1_0Protocol,
|
|
26
|
-
AwsJson1_1Protocol: () => AwsJson1_1Protocol,
|
|
27
|
-
AwsJsonRpcProtocol: () => AwsJsonRpcProtocol,
|
|
28
|
-
AwsQueryProtocol: () => AwsQueryProtocol,
|
|
29
|
-
AwsRestJsonProtocol: () => AwsRestJsonProtocol,
|
|
30
|
-
AwsRestXmlProtocol: () => AwsRestXmlProtocol,
|
|
31
|
-
AwsSmithyRpcV2CborProtocol: () => AwsSmithyRpcV2CborProtocol,
|
|
32
|
-
JsonCodec: () => JsonCodec,
|
|
33
|
-
JsonShapeDeserializer: () => JsonShapeDeserializer,
|
|
34
|
-
JsonShapeSerializer: () => JsonShapeSerializer,
|
|
35
|
-
XmlCodec: () => XmlCodec,
|
|
36
|
-
XmlShapeDeserializer: () => XmlShapeDeserializer,
|
|
37
|
-
XmlShapeSerializer: () => XmlShapeSerializer,
|
|
38
|
-
_toBool: () => _toBool,
|
|
39
|
-
_toNum: () => _toNum,
|
|
40
|
-
_toStr: () => _toStr,
|
|
41
|
-
awsExpectUnion: () => awsExpectUnion,
|
|
42
|
-
loadRestJsonErrorCode: () => loadRestJsonErrorCode,
|
|
43
|
-
loadRestXmlErrorCode: () => loadRestXmlErrorCode,
|
|
44
|
-
parseJsonBody: () => parseJsonBody,
|
|
45
|
-
parseJsonErrorBody: () => parseJsonErrorBody,
|
|
46
|
-
parseXmlBody: () => parseXmlBody,
|
|
47
|
-
parseXmlErrorBody: () => parseXmlErrorBody
|
|
48
|
-
});
|
|
49
|
-
module.exports = __toCommonJS(index_exports);
|
|
1
|
+
'use strict';
|
|
50
2
|
|
|
51
|
-
|
|
52
|
-
var
|
|
53
|
-
var
|
|
3
|
+
var cbor = require('@smithy/core/cbor');
|
|
4
|
+
var schema = require('@smithy/core/schema');
|
|
5
|
+
var protocols = require('@smithy/core/protocols');
|
|
6
|
+
var serde = require('@smithy/core/serde');
|
|
7
|
+
var utilBase64 = require('@smithy/util-base64');
|
|
8
|
+
var smithyClient = require('@smithy/smithy-client');
|
|
9
|
+
var utilUtf8 = require('@smithy/util-utf8');
|
|
10
|
+
var xmlBuilder = require('@aws-sdk/xml-builder');
|
|
54
11
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
Object.assign(output, Error2);
|
|
144
|
-
for (const [k, v] of entries) {
|
|
145
|
-
Error2[k] = v;
|
|
146
|
-
}
|
|
147
|
-
delete Error2.__type;
|
|
148
|
-
output.Error = Error2;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Assigns Error, Type, Code from the awsQuery error object to the output error object.
|
|
153
|
-
* @param queryCompatErrorData - query compat error object.
|
|
154
|
-
* @param errorData - canonical error object returned to the caller.
|
|
155
|
-
*/
|
|
156
|
-
queryCompatOutput(queryCompatErrorData, errorData) {
|
|
157
|
-
if (queryCompatErrorData.Error) {
|
|
158
|
-
errorData.Error = queryCompatErrorData.Error;
|
|
159
|
-
}
|
|
160
|
-
if (queryCompatErrorData.Type) {
|
|
161
|
-
errorData.Type = queryCompatErrorData.Type;
|
|
162
|
-
}
|
|
163
|
-
if (queryCompatErrorData.Code) {
|
|
164
|
-
errorData.Code = queryCompatErrorData.Code;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
};
|
|
12
|
+
class ProtocolLib {
|
|
13
|
+
resolveRestContentType(defaultContentType, inputSchema) {
|
|
14
|
+
const members = inputSchema.getMemberSchemas();
|
|
15
|
+
const httpPayloadMember = Object.values(members).find((m) => {
|
|
16
|
+
return !!m.getMergedTraits().httpPayload;
|
|
17
|
+
});
|
|
18
|
+
if (httpPayloadMember) {
|
|
19
|
+
const mediaType = httpPayloadMember.getMergedTraits().mediaType;
|
|
20
|
+
if (mediaType) {
|
|
21
|
+
return mediaType;
|
|
22
|
+
}
|
|
23
|
+
else if (httpPayloadMember.isStringSchema()) {
|
|
24
|
+
return "text/plain";
|
|
25
|
+
}
|
|
26
|
+
else if (httpPayloadMember.isBlobSchema()) {
|
|
27
|
+
return "application/octet-stream";
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return defaultContentType;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else if (!inputSchema.isUnitSchema()) {
|
|
34
|
+
const hasBody = Object.values(members).find((m) => {
|
|
35
|
+
const { httpQuery, httpQueryParams, httpHeader, httpLabel, httpPrefixHeaders } = m.getMergedTraits();
|
|
36
|
+
const noPrefixHeaders = httpPrefixHeaders === void 0;
|
|
37
|
+
return !httpQuery && !httpQueryParams && !httpHeader && !httpLabel && noPrefixHeaders;
|
|
38
|
+
});
|
|
39
|
+
if (hasBody) {
|
|
40
|
+
return defaultContentType;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async getErrorSchemaOrThrowBaseException(errorIdentifier, defaultNamespace, response, dataObject, metadata, getErrorSchema) {
|
|
45
|
+
let namespace = defaultNamespace;
|
|
46
|
+
let errorName = errorIdentifier;
|
|
47
|
+
if (errorIdentifier.includes("#")) {
|
|
48
|
+
[namespace, errorName] = errorIdentifier.split("#");
|
|
49
|
+
}
|
|
50
|
+
const errorMetadata = {
|
|
51
|
+
$metadata: metadata,
|
|
52
|
+
$response: response,
|
|
53
|
+
$fault: response.statusCode < 500 ? "client" : "server",
|
|
54
|
+
};
|
|
55
|
+
const registry = schema.TypeRegistry.for(namespace);
|
|
56
|
+
try {
|
|
57
|
+
const errorSchema = getErrorSchema?.(registry, errorName) ?? registry.getSchema(errorIdentifier);
|
|
58
|
+
return { errorSchema, errorMetadata };
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
dataObject.message = dataObject.message ?? dataObject.Message ?? "UnknownError";
|
|
62
|
+
const synthetic = schema.TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace);
|
|
63
|
+
const baseExceptionSchema = synthetic.getBaseException();
|
|
64
|
+
if (baseExceptionSchema) {
|
|
65
|
+
const ErrorCtor = synthetic.getErrorCtor(baseExceptionSchema) ?? Error;
|
|
66
|
+
throw Object.assign(new ErrorCtor({ name: errorName }), errorMetadata, dataObject);
|
|
67
|
+
}
|
|
68
|
+
throw Object.assign(new Error(errorName), errorMetadata, dataObject);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
setQueryCompatError(output, response) {
|
|
72
|
+
const queryErrorHeader = response.headers?.["x-amzn-query-error"];
|
|
73
|
+
if (output !== undefined && queryErrorHeader != null) {
|
|
74
|
+
const [Code, Type] = queryErrorHeader.split(";");
|
|
75
|
+
const entries = Object.entries(output);
|
|
76
|
+
const Error = {
|
|
77
|
+
Code,
|
|
78
|
+
Type,
|
|
79
|
+
};
|
|
80
|
+
Object.assign(output, Error);
|
|
81
|
+
for (const [k, v] of entries) {
|
|
82
|
+
Error[k] = v;
|
|
83
|
+
}
|
|
84
|
+
delete Error.__type;
|
|
85
|
+
output.Error = Error;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
queryCompatOutput(queryCompatErrorData, errorData) {
|
|
89
|
+
if (queryCompatErrorData.Error) {
|
|
90
|
+
errorData.Error = queryCompatErrorData.Error;
|
|
91
|
+
}
|
|
92
|
+
if (queryCompatErrorData.Type) {
|
|
93
|
+
errorData.Type = queryCompatErrorData.Type;
|
|
94
|
+
}
|
|
95
|
+
if (queryCompatErrorData.Code) {
|
|
96
|
+
errorData.Code = queryCompatErrorData.Code;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
168
100
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
metadata
|
|
207
|
-
);
|
|
208
|
-
const ns = import_schema2.NormalizedSchema.of(errorSchema);
|
|
209
|
-
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
210
|
-
const ErrorCtor = import_schema2.TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
|
|
211
|
-
const exception = new ErrorCtor(message);
|
|
212
|
-
const output = {};
|
|
213
|
-
for (const [name, member] of ns.structIterator()) {
|
|
214
|
-
output[name] = this.deserializer.readValue(member, dataObject[name]);
|
|
215
|
-
}
|
|
216
|
-
if (this.awsQueryCompatible) {
|
|
217
|
-
this.mixin.queryCompatOutput(dataObject, output);
|
|
218
|
-
}
|
|
219
|
-
throw Object.assign(
|
|
220
|
-
exception,
|
|
221
|
-
errorMetadata,
|
|
222
|
-
{
|
|
223
|
-
$fault: ns.getMergedTraits().error,
|
|
224
|
-
message
|
|
225
|
-
},
|
|
226
|
-
output
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
};
|
|
101
|
+
class AwsSmithyRpcV2CborProtocol extends cbor.SmithyRpcV2CborProtocol {
|
|
102
|
+
awsQueryCompatible;
|
|
103
|
+
mixin = new ProtocolLib();
|
|
104
|
+
constructor({ defaultNamespace, awsQueryCompatible, }) {
|
|
105
|
+
super({ defaultNamespace });
|
|
106
|
+
this.awsQueryCompatible = !!awsQueryCompatible;
|
|
107
|
+
}
|
|
108
|
+
async serializeRequest(operationSchema, input, context) {
|
|
109
|
+
const request = await super.serializeRequest(operationSchema, input, context);
|
|
110
|
+
if (this.awsQueryCompatible) {
|
|
111
|
+
request.headers["x-amzn-query-mode"] = "true";
|
|
112
|
+
}
|
|
113
|
+
return request;
|
|
114
|
+
}
|
|
115
|
+
async handleError(operationSchema, context, response, dataObject, metadata) {
|
|
116
|
+
if (this.awsQueryCompatible) {
|
|
117
|
+
this.mixin.setQueryCompatError(dataObject, response);
|
|
118
|
+
}
|
|
119
|
+
const errorName = cbor.loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
|
|
120
|
+
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorName, this.options.defaultNamespace, response, dataObject, metadata);
|
|
121
|
+
const ns = schema.NormalizedSchema.of(errorSchema);
|
|
122
|
+
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
123
|
+
const ErrorCtor = schema.TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
|
|
124
|
+
const exception = new ErrorCtor(message);
|
|
125
|
+
const output = {};
|
|
126
|
+
for (const [name, member] of ns.structIterator()) {
|
|
127
|
+
output[name] = this.deserializer.readValue(member, dataObject[name]);
|
|
128
|
+
}
|
|
129
|
+
if (this.awsQueryCompatible) {
|
|
130
|
+
this.mixin.queryCompatOutput(dataObject, output);
|
|
131
|
+
}
|
|
132
|
+
throw Object.assign(exception, errorMetadata, {
|
|
133
|
+
$fault: ns.getMergedTraits().error,
|
|
134
|
+
message,
|
|
135
|
+
}, output);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
230
138
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
139
|
+
const _toStr = (val) => {
|
|
140
|
+
if (val == null) {
|
|
141
|
+
return val;
|
|
142
|
+
}
|
|
143
|
+
if (typeof val === "number" || typeof val === "bigint") {
|
|
144
|
+
const warning = new Error(`Received number ${val} where a string was expected.`);
|
|
145
|
+
warning.name = "Warning";
|
|
146
|
+
console.warn(warning);
|
|
147
|
+
return String(val);
|
|
148
|
+
}
|
|
149
|
+
if (typeof val === "boolean") {
|
|
150
|
+
const warning = new Error(`Received boolean ${val} where a string was expected.`);
|
|
151
|
+
warning.name = "Warning";
|
|
152
|
+
console.warn(warning);
|
|
153
|
+
return String(val);
|
|
154
|
+
}
|
|
234
155
|
return val;
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}, "_toStr");
|
|
250
|
-
var _toBool = /* @__PURE__ */ __name((val) => {
|
|
251
|
-
if (val == null) {
|
|
156
|
+
};
|
|
157
|
+
const _toBool = (val) => {
|
|
158
|
+
if (val == null) {
|
|
159
|
+
return val;
|
|
160
|
+
}
|
|
161
|
+
if (typeof val === "string") {
|
|
162
|
+
const lowercase = val.toLowerCase();
|
|
163
|
+
if (val !== "" && lowercase !== "false" && lowercase !== "true") {
|
|
164
|
+
const warning = new Error(`Received string "${val}" where a boolean was expected.`);
|
|
165
|
+
warning.name = "Warning";
|
|
166
|
+
console.warn(warning);
|
|
167
|
+
}
|
|
168
|
+
return val !== "" && lowercase !== "false";
|
|
169
|
+
}
|
|
252
170
|
return val;
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
if (val
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
if (val == null) {
|
|
171
|
+
};
|
|
172
|
+
const _toNum = (val) => {
|
|
173
|
+
if (val == null) {
|
|
174
|
+
return val;
|
|
175
|
+
}
|
|
176
|
+
if (typeof val === "string") {
|
|
177
|
+
const num = Number(val);
|
|
178
|
+
if (num.toString() !== val) {
|
|
179
|
+
const warning = new Error(`Received string "${val}" where a number was expected.`);
|
|
180
|
+
warning.name = "Warning";
|
|
181
|
+
console.warn(warning);
|
|
182
|
+
return val;
|
|
183
|
+
}
|
|
184
|
+
return num;
|
|
185
|
+
}
|
|
269
186
|
return val;
|
|
270
|
-
}
|
|
271
|
-
if (typeof val === "boolean") {
|
|
272
|
-
}
|
|
273
|
-
if (typeof val === "string") {
|
|
274
|
-
const num = Number(val);
|
|
275
|
-
if (num.toString() !== val) {
|
|
276
|
-
const warning = new Error(`Received string "${val}" where a number was expected.`);
|
|
277
|
-
warning.name = "Warning";
|
|
278
|
-
console.warn(warning);
|
|
279
|
-
return val;
|
|
280
|
-
}
|
|
281
|
-
return num;
|
|
282
|
-
}
|
|
283
|
-
return val;
|
|
284
|
-
}, "_toNum");
|
|
285
|
-
|
|
286
|
-
// src/submodules/protocols/json/AwsJsonRpcProtocol.ts
|
|
287
|
-
var import_protocols3 = require("@smithy/core/protocols");
|
|
288
|
-
var import_schema5 = require("@smithy/core/schema");
|
|
289
|
-
|
|
290
|
-
// src/submodules/protocols/ConfigurableSerdeContext.ts
|
|
291
|
-
var SerdeContextConfig = class {
|
|
292
|
-
static {
|
|
293
|
-
__name(this, "SerdeContextConfig");
|
|
294
|
-
}
|
|
295
|
-
serdeContext;
|
|
296
|
-
setSerdeContext(serdeContext) {
|
|
297
|
-
this.serdeContext = serdeContext;
|
|
298
|
-
}
|
|
299
187
|
};
|
|
300
188
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
189
|
+
class SerdeContextConfig {
|
|
190
|
+
serdeContext;
|
|
191
|
+
setSerdeContext(serdeContext) {
|
|
192
|
+
this.serdeContext = serdeContext;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
306
195
|
|
|
307
|
-
// src/submodules/protocols/json/jsonReviver.ts
|
|
308
|
-
var import_serde = require("@smithy/core/serde");
|
|
309
196
|
function jsonReviver(key, value, context) {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
197
|
+
if (context?.source) {
|
|
198
|
+
const numericString = context.source;
|
|
199
|
+
if (typeof value === "number") {
|
|
200
|
+
if (value > Number.MAX_SAFE_INTEGER || value < Number.MIN_SAFE_INTEGER || numericString !== String(value)) {
|
|
201
|
+
const isFractional = numericString.includes(".");
|
|
202
|
+
if (isFractional) {
|
|
203
|
+
return new serde.NumericValue(numericString, "bigDecimal");
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
return BigInt(numericString);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return value;
|
|
324
212
|
}
|
|
325
|
-
__name(jsonReviver, "jsonReviver");
|
|
326
213
|
|
|
327
|
-
|
|
328
|
-
var import_smithy_client = require("@smithy/smithy-client");
|
|
329
|
-
var import_util_utf8 = require("@smithy/util-utf8");
|
|
330
|
-
var collectBodyString = /* @__PURE__ */ __name((streamBody, context) => (0, import_smithy_client.collectBody)(streamBody, context).then((body) => (context?.utf8Encoder ?? import_util_utf8.toUtf8)(body)), "collectBodyString");
|
|
214
|
+
const collectBodyString = (streamBody, context) => smithyClient.collectBody(streamBody, context).then((body) => (context?.utf8Encoder ?? utilUtf8.toUtf8)(body));
|
|
331
215
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}
|
|
346
|
-
return {};
|
|
347
|
-
}), "parseJsonBody");
|
|
348
|
-
var parseJsonErrorBody = /* @__PURE__ */ __name(async (errorBody, context) => {
|
|
349
|
-
const value = await parseJsonBody(errorBody, context);
|
|
350
|
-
value.message = value.message ?? value.Message;
|
|
351
|
-
return value;
|
|
352
|
-
}, "parseJsonErrorBody");
|
|
353
|
-
var loadRestJsonErrorCode = /* @__PURE__ */ __name((output, data) => {
|
|
354
|
-
const findKey = /* @__PURE__ */ __name((object, key) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()), "findKey");
|
|
355
|
-
const sanitizeErrorCode = /* @__PURE__ */ __name((rawValue) => {
|
|
356
|
-
let cleanValue = rawValue;
|
|
357
|
-
if (typeof cleanValue === "number") {
|
|
358
|
-
cleanValue = cleanValue.toString();
|
|
359
|
-
}
|
|
360
|
-
if (cleanValue.indexOf(",") >= 0) {
|
|
361
|
-
cleanValue = cleanValue.split(",")[0];
|
|
362
|
-
}
|
|
363
|
-
if (cleanValue.indexOf(":") >= 0) {
|
|
364
|
-
cleanValue = cleanValue.split(":")[0];
|
|
365
|
-
}
|
|
366
|
-
if (cleanValue.indexOf("#") >= 0) {
|
|
367
|
-
cleanValue = cleanValue.split("#")[1];
|
|
368
|
-
}
|
|
369
|
-
return cleanValue;
|
|
370
|
-
}, "sanitizeErrorCode");
|
|
371
|
-
const headerKey = findKey(output.headers, "x-amzn-errortype");
|
|
372
|
-
if (headerKey !== void 0) {
|
|
373
|
-
return sanitizeErrorCode(output.headers[headerKey]);
|
|
374
|
-
}
|
|
375
|
-
if (data && typeof data === "object") {
|
|
376
|
-
const codeKey = findKey(data, "code");
|
|
377
|
-
if (codeKey && data[codeKey] !== void 0) {
|
|
378
|
-
return sanitizeErrorCode(data[codeKey]);
|
|
379
|
-
}
|
|
380
|
-
if (data["__type"] !== void 0) {
|
|
381
|
-
return sanitizeErrorCode(data["__type"]);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
}, "loadRestJsonErrorCode");
|
|
385
|
-
|
|
386
|
-
// src/submodules/protocols/json/JsonShapeDeserializer.ts
|
|
387
|
-
var JsonShapeDeserializer = class extends SerdeContextConfig {
|
|
388
|
-
constructor(settings) {
|
|
389
|
-
super();
|
|
390
|
-
this.settings = settings;
|
|
391
|
-
}
|
|
392
|
-
static {
|
|
393
|
-
__name(this, "JsonShapeDeserializer");
|
|
394
|
-
}
|
|
395
|
-
async read(schema, data) {
|
|
396
|
-
return this._read(
|
|
397
|
-
schema,
|
|
398
|
-
typeof data === "string" ? JSON.parse(data, jsonReviver) : await parseJsonBody(data, this.serdeContext)
|
|
399
|
-
);
|
|
400
|
-
}
|
|
401
|
-
readObject(schema, data) {
|
|
402
|
-
return this._read(schema, data);
|
|
403
|
-
}
|
|
404
|
-
_read(schema, value) {
|
|
405
|
-
const isObject = value !== null && typeof value === "object";
|
|
406
|
-
const ns = import_schema3.NormalizedSchema.of(schema);
|
|
407
|
-
if (ns.isListSchema() && Array.isArray(value)) {
|
|
408
|
-
const listMember = ns.getValueSchema();
|
|
409
|
-
const out = [];
|
|
410
|
-
const sparse = !!ns.getMergedTraits().sparse;
|
|
411
|
-
for (const item of value) {
|
|
412
|
-
if (sparse || item != null) {
|
|
413
|
-
out.push(this._read(listMember, item));
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
return out;
|
|
417
|
-
} else if (ns.isMapSchema() && isObject) {
|
|
418
|
-
const mapMember = ns.getValueSchema();
|
|
419
|
-
const out = {};
|
|
420
|
-
const sparse = !!ns.getMergedTraits().sparse;
|
|
421
|
-
for (const [_k, _v] of Object.entries(value)) {
|
|
422
|
-
if (sparse || _v != null) {
|
|
423
|
-
out[_k] = this._read(mapMember, _v);
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
return out;
|
|
427
|
-
} else if (ns.isStructSchema() && isObject) {
|
|
428
|
-
const out = {};
|
|
429
|
-
for (const [memberName, memberSchema] of ns.structIterator()) {
|
|
430
|
-
const fromKey = this.settings.jsonName ? memberSchema.getMergedTraits().jsonName ?? memberName : memberName;
|
|
431
|
-
const deserializedValue = this._read(memberSchema, value[fromKey]);
|
|
432
|
-
if (deserializedValue != null) {
|
|
433
|
-
out[memberName] = deserializedValue;
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
return out;
|
|
437
|
-
}
|
|
438
|
-
if (ns.isBlobSchema() && typeof value === "string") {
|
|
439
|
-
return (0, import_util_base64.fromBase64)(value);
|
|
440
|
-
}
|
|
441
|
-
const mediaType = ns.getMergedTraits().mediaType;
|
|
442
|
-
if (ns.isStringSchema() && typeof value === "string" && mediaType) {
|
|
443
|
-
const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
|
|
444
|
-
if (isJson) {
|
|
445
|
-
return import_serde2.LazyJsonString.from(value);
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
if (ns.isTimestampSchema() && value != null) {
|
|
449
|
-
const format = (0, import_protocols.determineTimestampFormat)(ns, this.settings);
|
|
450
|
-
switch (format) {
|
|
451
|
-
case import_schema3.SCHEMA.TIMESTAMP_DATE_TIME:
|
|
452
|
-
return (0, import_serde2.parseRfc3339DateTimeWithOffset)(value);
|
|
453
|
-
case import_schema3.SCHEMA.TIMESTAMP_HTTP_DATE:
|
|
454
|
-
return (0, import_serde2.parseRfc7231DateTime)(value);
|
|
455
|
-
case import_schema3.SCHEMA.TIMESTAMP_EPOCH_SECONDS:
|
|
456
|
-
return (0, import_serde2.parseEpochTimestamp)(value);
|
|
457
|
-
default:
|
|
458
|
-
console.warn("Missing timestamp format, parsing value with Date constructor:", value);
|
|
459
|
-
return new Date(value);
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
if (ns.isBigIntegerSchema() && (typeof value === "number" || typeof value === "string")) {
|
|
463
|
-
return BigInt(value);
|
|
464
|
-
}
|
|
465
|
-
if (ns.isBigDecimalSchema() && value != void 0) {
|
|
466
|
-
if (value instanceof import_serde2.NumericValue) {
|
|
467
|
-
return value;
|
|
468
|
-
}
|
|
469
|
-
const untyped = value;
|
|
470
|
-
if (untyped.type === "bigDecimal" && "string" in untyped) {
|
|
471
|
-
return new import_serde2.NumericValue(untyped.string, untyped.type);
|
|
472
|
-
}
|
|
473
|
-
return new import_serde2.NumericValue(String(value), "bigDecimal");
|
|
474
|
-
}
|
|
475
|
-
if (ns.isNumericSchema() && typeof value === "string") {
|
|
476
|
-
switch (value) {
|
|
477
|
-
case "Infinity":
|
|
478
|
-
return Infinity;
|
|
479
|
-
case "-Infinity":
|
|
480
|
-
return -Infinity;
|
|
481
|
-
case "NaN":
|
|
482
|
-
return NaN;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
if (ns.isDocumentSchema()) {
|
|
486
|
-
if (isObject) {
|
|
487
|
-
const out = Array.isArray(value) ? [] : {};
|
|
488
|
-
for (const [k, v] of Object.entries(value)) {
|
|
489
|
-
if (v instanceof import_serde2.NumericValue) {
|
|
490
|
-
out[k] = v;
|
|
491
|
-
} else {
|
|
492
|
-
out[k] = this._read(ns, v);
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
return out;
|
|
496
|
-
} else {
|
|
497
|
-
return structuredClone(value);
|
|
498
|
-
}
|
|
216
|
+
const parseJsonBody = (streamBody, context) => collectBodyString(streamBody, context).then((encoded) => {
|
|
217
|
+
if (encoded.length) {
|
|
218
|
+
try {
|
|
219
|
+
return JSON.parse(encoded);
|
|
220
|
+
}
|
|
221
|
+
catch (e) {
|
|
222
|
+
if (e?.name === "SyntaxError") {
|
|
223
|
+
Object.defineProperty(e, "$responseBodyText", {
|
|
224
|
+
value: encoded,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
throw e;
|
|
228
|
+
}
|
|
499
229
|
}
|
|
230
|
+
return {};
|
|
231
|
+
});
|
|
232
|
+
const parseJsonErrorBody = async (errorBody, context) => {
|
|
233
|
+
const value = await parseJsonBody(errorBody, context);
|
|
234
|
+
value.message = value.message ?? value.Message;
|
|
500
235
|
return value;
|
|
501
|
-
}
|
|
502
236
|
};
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
values = /* @__PURE__ */ new Map();
|
|
521
|
-
counter = 0;
|
|
522
|
-
stage = 0;
|
|
523
|
-
/**
|
|
524
|
-
* Creates a jsonReplacer function that reserves big integer and big decimal values
|
|
525
|
-
* for later replacement.
|
|
526
|
-
*/
|
|
527
|
-
createReplacer() {
|
|
528
|
-
if (this.stage === 1) {
|
|
529
|
-
throw new Error("@aws-sdk/core/protocols - JsonReplacer already created.");
|
|
530
|
-
}
|
|
531
|
-
if (this.stage === 2) {
|
|
532
|
-
throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");
|
|
533
|
-
}
|
|
534
|
-
this.stage = 1;
|
|
535
|
-
return (key, value) => {
|
|
536
|
-
if (value instanceof import_serde3.NumericValue) {
|
|
537
|
-
const v = `${NUMERIC_CONTROL_CHAR + "nv" + this.counter++}_` + value.string;
|
|
538
|
-
this.values.set(`"${v}"`, value.string);
|
|
539
|
-
return v;
|
|
540
|
-
}
|
|
541
|
-
if (typeof value === "bigint") {
|
|
542
|
-
const s = value.toString();
|
|
543
|
-
const v = `${NUMERIC_CONTROL_CHAR + "b" + this.counter++}_` + s;
|
|
544
|
-
this.values.set(`"${v}"`, s);
|
|
545
|
-
return v;
|
|
546
|
-
}
|
|
547
|
-
return value;
|
|
237
|
+
const loadRestJsonErrorCode = (output, data) => {
|
|
238
|
+
const findKey = (object, key) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase());
|
|
239
|
+
const sanitizeErrorCode = (rawValue) => {
|
|
240
|
+
let cleanValue = rawValue;
|
|
241
|
+
if (typeof cleanValue === "number") {
|
|
242
|
+
cleanValue = cleanValue.toString();
|
|
243
|
+
}
|
|
244
|
+
if (cleanValue.indexOf(",") >= 0) {
|
|
245
|
+
cleanValue = cleanValue.split(",")[0];
|
|
246
|
+
}
|
|
247
|
+
if (cleanValue.indexOf(":") >= 0) {
|
|
248
|
+
cleanValue = cleanValue.split(":")[0];
|
|
249
|
+
}
|
|
250
|
+
if (cleanValue.indexOf("#") >= 0) {
|
|
251
|
+
cleanValue = cleanValue.split("#")[1];
|
|
252
|
+
}
|
|
253
|
+
return cleanValue;
|
|
548
254
|
};
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
return json;
|
|
563
|
-
}
|
|
564
|
-
for (const [key, value] of this.values) {
|
|
565
|
-
json = json.replace(key, value);
|
|
566
|
-
}
|
|
567
|
-
return json;
|
|
568
|
-
}
|
|
255
|
+
const headerKey = findKey(output.headers, "x-amzn-errortype");
|
|
256
|
+
if (headerKey !== undefined) {
|
|
257
|
+
return sanitizeErrorCode(output.headers[headerKey]);
|
|
258
|
+
}
|
|
259
|
+
if (data && typeof data === "object") {
|
|
260
|
+
const codeKey = findKey(data, "code");
|
|
261
|
+
if (codeKey && data[codeKey] !== undefined) {
|
|
262
|
+
return sanitizeErrorCode(data[codeKey]);
|
|
263
|
+
}
|
|
264
|
+
if (data["__type"] !== undefined) {
|
|
265
|
+
return sanitizeErrorCode(data["__type"]);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
569
268
|
};
|
|
570
269
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
270
|
+
class JsonShapeDeserializer extends SerdeContextConfig {
|
|
271
|
+
settings;
|
|
272
|
+
constructor(settings) {
|
|
273
|
+
super();
|
|
274
|
+
this.settings = settings;
|
|
275
|
+
}
|
|
276
|
+
async read(schema, data) {
|
|
277
|
+
return this._read(schema, typeof data === "string" ? JSON.parse(data, jsonReviver) : await parseJsonBody(data, this.serdeContext));
|
|
278
|
+
}
|
|
279
|
+
readObject(schema, data) {
|
|
280
|
+
return this._read(schema, data);
|
|
281
|
+
}
|
|
282
|
+
_read(schema$1, value) {
|
|
283
|
+
const isObject = value !== null && typeof value === "object";
|
|
284
|
+
const ns = schema.NormalizedSchema.of(schema$1);
|
|
285
|
+
if (ns.isListSchema() && Array.isArray(value)) {
|
|
286
|
+
const listMember = ns.getValueSchema();
|
|
287
|
+
const out = [];
|
|
288
|
+
const sparse = !!ns.getMergedTraits().sparse;
|
|
289
|
+
for (const item of value) {
|
|
290
|
+
if (sparse || item != null) {
|
|
291
|
+
out.push(this._read(listMember, item));
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return out;
|
|
295
|
+
}
|
|
296
|
+
else if (ns.isMapSchema() && isObject) {
|
|
297
|
+
const mapMember = ns.getValueSchema();
|
|
298
|
+
const out = {};
|
|
299
|
+
const sparse = !!ns.getMergedTraits().sparse;
|
|
300
|
+
for (const [_k, _v] of Object.entries(value)) {
|
|
301
|
+
if (sparse || _v != null) {
|
|
302
|
+
out[_k] = this._read(mapMember, _v);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return out;
|
|
306
|
+
}
|
|
307
|
+
else if (ns.isStructSchema() && isObject) {
|
|
308
|
+
const out = {};
|
|
309
|
+
for (const [memberName, memberSchema] of ns.structIterator()) {
|
|
310
|
+
const fromKey = this.settings.jsonName ? memberSchema.getMergedTraits().jsonName ?? memberName : memberName;
|
|
311
|
+
const deserializedValue = this._read(memberSchema, value[fromKey]);
|
|
312
|
+
if (deserializedValue != null) {
|
|
313
|
+
out[memberName] = deserializedValue;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return out;
|
|
317
|
+
}
|
|
318
|
+
if (ns.isBlobSchema() && typeof value === "string") {
|
|
319
|
+
return utilBase64.fromBase64(value);
|
|
320
|
+
}
|
|
321
|
+
const mediaType = ns.getMergedTraits().mediaType;
|
|
322
|
+
if (ns.isStringSchema() && typeof value === "string" && mediaType) {
|
|
323
|
+
const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
|
|
324
|
+
if (isJson) {
|
|
325
|
+
return serde.LazyJsonString.from(value);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
if (ns.isTimestampSchema() && value != null) {
|
|
329
|
+
const format = protocols.determineTimestampFormat(ns, this.settings);
|
|
330
|
+
switch (format) {
|
|
331
|
+
case 5:
|
|
332
|
+
return serde.parseRfc3339DateTimeWithOffset(value);
|
|
333
|
+
case 6:
|
|
334
|
+
return serde.parseRfc7231DateTime(value);
|
|
335
|
+
case 7:
|
|
336
|
+
return serde.parseEpochTimestamp(value);
|
|
337
|
+
default:
|
|
338
|
+
console.warn("Missing timestamp format, parsing value with Date constructor:", value);
|
|
339
|
+
return new Date(value);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
if (ns.isBigIntegerSchema() && (typeof value === "number" || typeof value === "string")) {
|
|
343
|
+
return BigInt(value);
|
|
344
|
+
}
|
|
345
|
+
if (ns.isBigDecimalSchema() && value != undefined) {
|
|
346
|
+
if (value instanceof serde.NumericValue) {
|
|
347
|
+
return value;
|
|
348
|
+
}
|
|
349
|
+
const untyped = value;
|
|
350
|
+
if (untyped.type === "bigDecimal" && "string" in untyped) {
|
|
351
|
+
return new serde.NumericValue(untyped.string, untyped.type);
|
|
352
|
+
}
|
|
353
|
+
return new serde.NumericValue(String(value), "bigDecimal");
|
|
354
|
+
}
|
|
355
|
+
if (ns.isNumericSchema() && typeof value === "string") {
|
|
356
|
+
switch (value) {
|
|
357
|
+
case "Infinity":
|
|
358
|
+
return Infinity;
|
|
359
|
+
case "-Infinity":
|
|
360
|
+
return -Infinity;
|
|
361
|
+
case "NaN":
|
|
362
|
+
return NaN;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
if (ns.isDocumentSchema()) {
|
|
366
|
+
if (isObject) {
|
|
367
|
+
const out = Array.isArray(value) ? [] : {};
|
|
368
|
+
for (const [k, v] of Object.entries(value)) {
|
|
369
|
+
if (v instanceof serde.NumericValue) {
|
|
370
|
+
out[k] = v;
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
out[k] = this._read(ns, v);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return out;
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
return structuredClone(value);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
643
382
|
return value;
|
|
644
|
-
}
|
|
645
|
-
if (!this.serdeContext?.base64Encoder) {
|
|
646
|
-
return (0, import_util_base642.toBase64)(value);
|
|
647
|
-
}
|
|
648
|
-
return this.serdeContext?.base64Encoder(value);
|
|
649
|
-
}
|
|
650
|
-
if ((ns.isTimestampSchema() || ns.isDocumentSchema()) && value instanceof Date) {
|
|
651
|
-
const format = (0, import_protocols2.determineTimestampFormat)(ns, this.settings);
|
|
652
|
-
switch (format) {
|
|
653
|
-
case import_schema4.SCHEMA.TIMESTAMP_DATE_TIME:
|
|
654
|
-
return value.toISOString().replace(".000Z", "Z");
|
|
655
|
-
case import_schema4.SCHEMA.TIMESTAMP_HTTP_DATE:
|
|
656
|
-
return (0, import_serde4.dateToUtcString)(value);
|
|
657
|
-
case import_schema4.SCHEMA.TIMESTAMP_EPOCH_SECONDS:
|
|
658
|
-
return value.getTime() / 1e3;
|
|
659
|
-
default:
|
|
660
|
-
console.warn("Missing timestamp format, using epoch seconds", value);
|
|
661
|
-
return value.getTime() / 1e3;
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
if (ns.isNumericSchema() && typeof value === "number") {
|
|
665
|
-
if (Math.abs(value) === Infinity || isNaN(value)) {
|
|
666
|
-
return String(value);
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
if (ns.isStringSchema()) {
|
|
670
|
-
if (typeof value === "undefined" && ns.isIdempotencyToken()) {
|
|
671
|
-
return (0, import_serde4.generateIdempotencyToken)();
|
|
672
|
-
}
|
|
673
|
-
const mediaType = ns.getMergedTraits().mediaType;
|
|
674
|
-
if (value != null && mediaType) {
|
|
675
|
-
const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
|
|
676
|
-
if (isJson) {
|
|
677
|
-
return import_serde4.LazyJsonString.from(value);
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
if (ns.isDocumentSchema()) {
|
|
682
|
-
if (isObject) {
|
|
683
|
-
const out = Array.isArray(value) ? [] : {};
|
|
684
|
-
for (const [k, v] of Object.entries(value)) {
|
|
685
|
-
if (v instanceof import_serde4.NumericValue) {
|
|
686
|
-
out[k] = v;
|
|
687
|
-
} else {
|
|
688
|
-
out[k] = this._write(ns, v);
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
return out;
|
|
692
|
-
} else {
|
|
693
|
-
return structuredClone(value);
|
|
694
|
-
}
|
|
695
383
|
}
|
|
696
|
-
|
|
697
|
-
}
|
|
698
|
-
};
|
|
699
|
-
|
|
700
|
-
// src/submodules/protocols/json/JsonCodec.ts
|
|
701
|
-
var JsonCodec = class extends SerdeContextConfig {
|
|
702
|
-
constructor(settings) {
|
|
703
|
-
super();
|
|
704
|
-
this.settings = settings;
|
|
705
|
-
}
|
|
706
|
-
static {
|
|
707
|
-
__name(this, "JsonCodec");
|
|
708
|
-
}
|
|
709
|
-
createSerializer() {
|
|
710
|
-
const serializer = new JsonShapeSerializer(this.settings);
|
|
711
|
-
serializer.setSerdeContext(this.serdeContext);
|
|
712
|
-
return serializer;
|
|
713
|
-
}
|
|
714
|
-
createDeserializer() {
|
|
715
|
-
const deserializer = new JsonShapeDeserializer(this.settings);
|
|
716
|
-
deserializer.setSerdeContext(this.serdeContext);
|
|
717
|
-
return deserializer;
|
|
718
|
-
}
|
|
719
|
-
};
|
|
384
|
+
}
|
|
720
385
|
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
}
|
|
767
|
-
return request;
|
|
768
|
-
}
|
|
769
|
-
getPayloadCodec() {
|
|
770
|
-
return this.codec;
|
|
771
|
-
}
|
|
772
|
-
async handleError(operationSchema, context, response, dataObject, metadata) {
|
|
773
|
-
if (this.awsQueryCompatible) {
|
|
774
|
-
this.mixin.setQueryCompatError(dataObject, response);
|
|
775
|
-
}
|
|
776
|
-
const errorIdentifier = loadRestJsonErrorCode(response, dataObject) ?? "Unknown";
|
|
777
|
-
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(
|
|
778
|
-
errorIdentifier,
|
|
779
|
-
this.options.defaultNamespace,
|
|
780
|
-
response,
|
|
781
|
-
dataObject,
|
|
782
|
-
metadata
|
|
783
|
-
);
|
|
784
|
-
const ns = import_schema5.NormalizedSchema.of(errorSchema);
|
|
785
|
-
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
786
|
-
const ErrorCtor = import_schema5.TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
|
|
787
|
-
const exception = new ErrorCtor(message);
|
|
788
|
-
const output = {};
|
|
789
|
-
for (const [name, member] of ns.structIterator()) {
|
|
790
|
-
const target = member.getMergedTraits().jsonName ?? name;
|
|
791
|
-
output[name] = this.codec.createDeserializer().readObject(member, dataObject[target]);
|
|
792
|
-
}
|
|
793
|
-
if (this.awsQueryCompatible) {
|
|
794
|
-
this.mixin.queryCompatOutput(dataObject, output);
|
|
795
|
-
}
|
|
796
|
-
throw Object.assign(
|
|
797
|
-
exception,
|
|
798
|
-
errorMetadata,
|
|
799
|
-
{
|
|
800
|
-
$fault: ns.getMergedTraits().error,
|
|
801
|
-
message
|
|
802
|
-
},
|
|
803
|
-
output
|
|
804
|
-
);
|
|
805
|
-
}
|
|
806
|
-
};
|
|
386
|
+
const NUMERIC_CONTROL_CHAR = String.fromCharCode(925);
|
|
387
|
+
class JsonReplacer {
|
|
388
|
+
values = new Map();
|
|
389
|
+
counter = 0;
|
|
390
|
+
stage = 0;
|
|
391
|
+
createReplacer() {
|
|
392
|
+
if (this.stage === 1) {
|
|
393
|
+
throw new Error("@aws-sdk/core/protocols - JsonReplacer already created.");
|
|
394
|
+
}
|
|
395
|
+
if (this.stage === 2) {
|
|
396
|
+
throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");
|
|
397
|
+
}
|
|
398
|
+
this.stage = 1;
|
|
399
|
+
return (key, value) => {
|
|
400
|
+
if (value instanceof serde.NumericValue) {
|
|
401
|
+
const v = `${NUMERIC_CONTROL_CHAR + "nv" + this.counter++}_` + value.string;
|
|
402
|
+
this.values.set(`"${v}"`, value.string);
|
|
403
|
+
return v;
|
|
404
|
+
}
|
|
405
|
+
if (typeof value === "bigint") {
|
|
406
|
+
const s = value.toString();
|
|
407
|
+
const v = `${NUMERIC_CONTROL_CHAR + "b" + this.counter++}_` + s;
|
|
408
|
+
this.values.set(`"${v}"`, s);
|
|
409
|
+
return v;
|
|
410
|
+
}
|
|
411
|
+
return value;
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
replaceInJson(json) {
|
|
415
|
+
if (this.stage === 0) {
|
|
416
|
+
throw new Error("@aws-sdk/core/protocols - JsonReplacer not created yet.");
|
|
417
|
+
}
|
|
418
|
+
if (this.stage === 2) {
|
|
419
|
+
throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");
|
|
420
|
+
}
|
|
421
|
+
this.stage = 2;
|
|
422
|
+
if (this.counter === 0) {
|
|
423
|
+
return json;
|
|
424
|
+
}
|
|
425
|
+
for (const [key, value] of this.values) {
|
|
426
|
+
json = json.replace(key, value);
|
|
427
|
+
}
|
|
428
|
+
return json;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
807
431
|
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
432
|
+
class JsonShapeSerializer extends SerdeContextConfig {
|
|
433
|
+
settings;
|
|
434
|
+
buffer;
|
|
435
|
+
rootSchema;
|
|
436
|
+
constructor(settings) {
|
|
437
|
+
super();
|
|
438
|
+
this.settings = settings;
|
|
439
|
+
}
|
|
440
|
+
write(schema$1, value) {
|
|
441
|
+
this.rootSchema = schema.NormalizedSchema.of(schema$1);
|
|
442
|
+
this.buffer = this._write(this.rootSchema, value);
|
|
443
|
+
}
|
|
444
|
+
writeDiscriminatedDocument(schema$1, value) {
|
|
445
|
+
this.write(schema$1, value);
|
|
446
|
+
if (typeof this.buffer === "object") {
|
|
447
|
+
this.buffer.__type = schema.NormalizedSchema.of(schema$1).getName(true);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
flush() {
|
|
451
|
+
const { rootSchema } = this;
|
|
452
|
+
this.rootSchema = undefined;
|
|
453
|
+
if (rootSchema?.isStructSchema() || rootSchema?.isDocumentSchema()) {
|
|
454
|
+
const replacer = new JsonReplacer();
|
|
455
|
+
return replacer.replaceInJson(JSON.stringify(this.buffer, replacer.createReplacer(), 0));
|
|
456
|
+
}
|
|
457
|
+
return this.buffer;
|
|
458
|
+
}
|
|
459
|
+
_write(schema$1, value, container) {
|
|
460
|
+
const isObject = value !== null && typeof value === "object";
|
|
461
|
+
const ns = schema.NormalizedSchema.of(schema$1);
|
|
462
|
+
if (ns.isListSchema() && Array.isArray(value)) {
|
|
463
|
+
const listMember = ns.getValueSchema();
|
|
464
|
+
const out = [];
|
|
465
|
+
const sparse = !!ns.getMergedTraits().sparse;
|
|
466
|
+
for (const item of value) {
|
|
467
|
+
if (sparse || item != null) {
|
|
468
|
+
out.push(this._write(listMember, item));
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
return out;
|
|
472
|
+
}
|
|
473
|
+
else if (ns.isMapSchema() && isObject) {
|
|
474
|
+
const mapMember = ns.getValueSchema();
|
|
475
|
+
const out = {};
|
|
476
|
+
const sparse = !!ns.getMergedTraits().sparse;
|
|
477
|
+
for (const [_k, _v] of Object.entries(value)) {
|
|
478
|
+
if (sparse || _v != null) {
|
|
479
|
+
out[_k] = this._write(mapMember, _v);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
return out;
|
|
483
|
+
}
|
|
484
|
+
else if (ns.isStructSchema() && isObject) {
|
|
485
|
+
const out = {};
|
|
486
|
+
for (const [memberName, memberSchema] of ns.structIterator()) {
|
|
487
|
+
const targetKey = this.settings.jsonName ? memberSchema.getMergedTraits().jsonName ?? memberName : memberName;
|
|
488
|
+
const serializableValue = this._write(memberSchema, value[memberName], ns);
|
|
489
|
+
if (serializableValue !== undefined) {
|
|
490
|
+
out[targetKey] = serializableValue;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
return out;
|
|
494
|
+
}
|
|
495
|
+
if (value === null && container?.isStructSchema()) {
|
|
496
|
+
return void 0;
|
|
497
|
+
}
|
|
498
|
+
if ((ns.isBlobSchema() && (value instanceof Uint8Array || typeof value === "string")) ||
|
|
499
|
+
(ns.isDocumentSchema() && value instanceof Uint8Array)) {
|
|
500
|
+
if (ns === this.rootSchema) {
|
|
501
|
+
return value;
|
|
502
|
+
}
|
|
503
|
+
if (!this.serdeContext?.base64Encoder) {
|
|
504
|
+
return utilBase64.toBase64(value);
|
|
505
|
+
}
|
|
506
|
+
return this.serdeContext?.base64Encoder(value);
|
|
507
|
+
}
|
|
508
|
+
if ((ns.isTimestampSchema() || ns.isDocumentSchema()) && value instanceof Date) {
|
|
509
|
+
const format = protocols.determineTimestampFormat(ns, this.settings);
|
|
510
|
+
switch (format) {
|
|
511
|
+
case 5:
|
|
512
|
+
return value.toISOString().replace(".000Z", "Z");
|
|
513
|
+
case 6:
|
|
514
|
+
return serde.dateToUtcString(value);
|
|
515
|
+
case 7:
|
|
516
|
+
return value.getTime() / 1000;
|
|
517
|
+
default:
|
|
518
|
+
console.warn("Missing timestamp format, using epoch seconds", value);
|
|
519
|
+
return value.getTime() / 1000;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
if (ns.isNumericSchema() && typeof value === "number") {
|
|
523
|
+
if (Math.abs(value) === Infinity || isNaN(value)) {
|
|
524
|
+
return String(value);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
if (ns.isStringSchema()) {
|
|
528
|
+
if (typeof value === "undefined" && ns.isIdempotencyToken()) {
|
|
529
|
+
return serde.generateIdempotencyToken();
|
|
530
|
+
}
|
|
531
|
+
const mediaType = ns.getMergedTraits().mediaType;
|
|
532
|
+
if (value != null && mediaType) {
|
|
533
|
+
const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
|
|
534
|
+
if (isJson) {
|
|
535
|
+
return serde.LazyJsonString.from(value);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
if (ns.isDocumentSchema()) {
|
|
540
|
+
if (isObject) {
|
|
541
|
+
const out = Array.isArray(value) ? [] : {};
|
|
542
|
+
for (const [k, v] of Object.entries(value)) {
|
|
543
|
+
if (v instanceof serde.NumericValue) {
|
|
544
|
+
out[k] = v;
|
|
545
|
+
}
|
|
546
|
+
else {
|
|
547
|
+
out[k] = this._write(ns, v);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
return out;
|
|
551
|
+
}
|
|
552
|
+
else {
|
|
553
|
+
return structuredClone(value);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
return value;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
837
559
|
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
return "aws.protocols#awsJson1_1";
|
|
856
|
-
}
|
|
857
|
-
getJsonRpcVersion() {
|
|
858
|
-
return "1.1";
|
|
859
|
-
}
|
|
860
|
-
/**
|
|
861
|
-
* @override
|
|
862
|
-
*/
|
|
863
|
-
getDefaultContentType() {
|
|
864
|
-
return "application/x-amz-json-1.1";
|
|
865
|
-
}
|
|
866
|
-
};
|
|
560
|
+
class JsonCodec extends SerdeContextConfig {
|
|
561
|
+
settings;
|
|
562
|
+
constructor(settings) {
|
|
563
|
+
super();
|
|
564
|
+
this.settings = settings;
|
|
565
|
+
}
|
|
566
|
+
createSerializer() {
|
|
567
|
+
const serializer = new JsonShapeSerializer(this.settings);
|
|
568
|
+
serializer.setSerdeContext(this.serdeContext);
|
|
569
|
+
return serializer;
|
|
570
|
+
}
|
|
571
|
+
createDeserializer() {
|
|
572
|
+
const deserializer = new JsonShapeDeserializer(this.settings);
|
|
573
|
+
deserializer.setSerdeContext(this.serdeContext);
|
|
574
|
+
return deserializer;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
867
577
|
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
}
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
const target = member.getMergedTraits().jsonName ?? name;
|
|
936
|
-
output[name] = this.codec.createDeserializer().readObject(member, dataObject[target]);
|
|
937
|
-
}
|
|
938
|
-
throw Object.assign(
|
|
939
|
-
exception,
|
|
940
|
-
errorMetadata,
|
|
941
|
-
{
|
|
942
|
-
$fault: ns.getMergedTraits().error,
|
|
943
|
-
message
|
|
944
|
-
},
|
|
945
|
-
output
|
|
946
|
-
);
|
|
947
|
-
}
|
|
948
|
-
/**
|
|
949
|
-
* @override
|
|
950
|
-
*/
|
|
951
|
-
getDefaultContentType() {
|
|
952
|
-
return "application/json";
|
|
953
|
-
}
|
|
954
|
-
};
|
|
578
|
+
class AwsJsonRpcProtocol extends protocols.RpcProtocol {
|
|
579
|
+
serializer;
|
|
580
|
+
deserializer;
|
|
581
|
+
serviceTarget;
|
|
582
|
+
codec;
|
|
583
|
+
mixin = new ProtocolLib();
|
|
584
|
+
awsQueryCompatible;
|
|
585
|
+
constructor({ defaultNamespace, serviceTarget, awsQueryCompatible, }) {
|
|
586
|
+
super({
|
|
587
|
+
defaultNamespace,
|
|
588
|
+
});
|
|
589
|
+
this.serviceTarget = serviceTarget;
|
|
590
|
+
this.codec = new JsonCodec({
|
|
591
|
+
timestampFormat: {
|
|
592
|
+
useTrait: true,
|
|
593
|
+
default: 7,
|
|
594
|
+
},
|
|
595
|
+
jsonName: false,
|
|
596
|
+
});
|
|
597
|
+
this.serializer = this.codec.createSerializer();
|
|
598
|
+
this.deserializer = this.codec.createDeserializer();
|
|
599
|
+
this.awsQueryCompatible = !!awsQueryCompatible;
|
|
600
|
+
}
|
|
601
|
+
async serializeRequest(operationSchema, input, context) {
|
|
602
|
+
const request = await super.serializeRequest(operationSchema, input, context);
|
|
603
|
+
if (!request.path.endsWith("/")) {
|
|
604
|
+
request.path += "/";
|
|
605
|
+
}
|
|
606
|
+
Object.assign(request.headers, {
|
|
607
|
+
"content-type": `application/x-amz-json-${this.getJsonRpcVersion()}`,
|
|
608
|
+
"x-amz-target": `${this.serviceTarget}.${schema.NormalizedSchema.of(operationSchema).getName()}`,
|
|
609
|
+
});
|
|
610
|
+
if (this.awsQueryCompatible) {
|
|
611
|
+
request.headers["x-amzn-query-mode"] = "true";
|
|
612
|
+
}
|
|
613
|
+
if (schema.deref(operationSchema.input) === "unit" || !request.body) {
|
|
614
|
+
request.body = "{}";
|
|
615
|
+
}
|
|
616
|
+
return request;
|
|
617
|
+
}
|
|
618
|
+
getPayloadCodec() {
|
|
619
|
+
return this.codec;
|
|
620
|
+
}
|
|
621
|
+
async handleError(operationSchema, context, response, dataObject, metadata) {
|
|
622
|
+
if (this.awsQueryCompatible) {
|
|
623
|
+
this.mixin.setQueryCompatError(dataObject, response);
|
|
624
|
+
}
|
|
625
|
+
const errorIdentifier = loadRestJsonErrorCode(response, dataObject) ?? "Unknown";
|
|
626
|
+
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata);
|
|
627
|
+
const ns = schema.NormalizedSchema.of(errorSchema);
|
|
628
|
+
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
629
|
+
const ErrorCtor = schema.TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
|
|
630
|
+
const exception = new ErrorCtor(message);
|
|
631
|
+
const output = {};
|
|
632
|
+
for (const [name, member] of ns.structIterator()) {
|
|
633
|
+
const target = member.getMergedTraits().jsonName ?? name;
|
|
634
|
+
output[name] = this.codec.createDeserializer().readObject(member, dataObject[target]);
|
|
635
|
+
}
|
|
636
|
+
if (this.awsQueryCompatible) {
|
|
637
|
+
this.mixin.queryCompatOutput(dataObject, output);
|
|
638
|
+
}
|
|
639
|
+
throw Object.assign(exception, errorMetadata, {
|
|
640
|
+
$fault: ns.getMergedTraits().error,
|
|
641
|
+
message,
|
|
642
|
+
}, output);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
955
645
|
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
}
|
|
646
|
+
class AwsJson1_0Protocol extends AwsJsonRpcProtocol {
|
|
647
|
+
constructor({ defaultNamespace, serviceTarget, awsQueryCompatible, }) {
|
|
648
|
+
super({
|
|
649
|
+
defaultNamespace,
|
|
650
|
+
serviceTarget,
|
|
651
|
+
awsQueryCompatible,
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
getShapeId() {
|
|
655
|
+
return "aws.protocols#awsJson1_0";
|
|
656
|
+
}
|
|
657
|
+
getJsonRpcVersion() {
|
|
658
|
+
return "1.0";
|
|
659
|
+
}
|
|
660
|
+
getDefaultContentType() {
|
|
661
|
+
return "application/x-amz-json-1.0";
|
|
662
|
+
}
|
|
663
|
+
}
|
|
967
664
|
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
665
|
+
class AwsJson1_1Protocol extends AwsJsonRpcProtocol {
|
|
666
|
+
constructor({ defaultNamespace, serviceTarget, awsQueryCompatible, }) {
|
|
667
|
+
super({
|
|
668
|
+
defaultNamespace,
|
|
669
|
+
serviceTarget,
|
|
670
|
+
awsQueryCompatible,
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
getShapeId() {
|
|
674
|
+
return "aws.protocols#awsJson1_1";
|
|
675
|
+
}
|
|
676
|
+
getJsonRpcVersion() {
|
|
677
|
+
return "1.1";
|
|
678
|
+
}
|
|
679
|
+
getDefaultContentType() {
|
|
680
|
+
return "application/x-amz-json-1.1";
|
|
681
|
+
}
|
|
682
|
+
}
|
|
971
683
|
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
684
|
+
class AwsRestJsonProtocol extends protocols.HttpBindingProtocol {
|
|
685
|
+
serializer;
|
|
686
|
+
deserializer;
|
|
687
|
+
codec;
|
|
688
|
+
mixin = new ProtocolLib();
|
|
689
|
+
constructor({ defaultNamespace }) {
|
|
690
|
+
super({
|
|
691
|
+
defaultNamespace,
|
|
692
|
+
});
|
|
693
|
+
const settings = {
|
|
694
|
+
timestampFormat: {
|
|
695
|
+
useTrait: true,
|
|
696
|
+
default: 7,
|
|
697
|
+
},
|
|
698
|
+
httpBindings: true,
|
|
699
|
+
jsonName: true,
|
|
700
|
+
};
|
|
701
|
+
this.codec = new JsonCodec(settings);
|
|
702
|
+
this.serializer = new protocols.HttpInterceptingShapeSerializer(this.codec.createSerializer(), settings);
|
|
703
|
+
this.deserializer = new protocols.HttpInterceptingShapeDeserializer(this.codec.createDeserializer(), settings);
|
|
704
|
+
}
|
|
705
|
+
getShapeId() {
|
|
706
|
+
return "aws.protocols#restJson1";
|
|
707
|
+
}
|
|
708
|
+
getPayloadCodec() {
|
|
709
|
+
return this.codec;
|
|
710
|
+
}
|
|
711
|
+
setSerdeContext(serdeContext) {
|
|
712
|
+
this.codec.setSerdeContext(serdeContext);
|
|
713
|
+
super.setSerdeContext(serdeContext);
|
|
714
|
+
}
|
|
715
|
+
async serializeRequest(operationSchema, input, context) {
|
|
716
|
+
const request = await super.serializeRequest(operationSchema, input, context);
|
|
717
|
+
const inputSchema = schema.NormalizedSchema.of(operationSchema.input);
|
|
718
|
+
if (!request.headers["content-type"]) {
|
|
719
|
+
const contentType = this.mixin.resolveRestContentType(this.getDefaultContentType(), inputSchema);
|
|
720
|
+
if (contentType) {
|
|
721
|
+
request.headers["content-type"] = contentType;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
if (request.headers["content-type"] && !request.body) {
|
|
725
|
+
request.body = "{}";
|
|
726
|
+
}
|
|
727
|
+
return request;
|
|
728
|
+
}
|
|
729
|
+
async handleError(operationSchema, context, response, dataObject, metadata) {
|
|
730
|
+
const errorIdentifier = loadRestJsonErrorCode(response, dataObject) ?? "Unknown";
|
|
731
|
+
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata);
|
|
732
|
+
const ns = schema.NormalizedSchema.of(errorSchema);
|
|
733
|
+
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
734
|
+
const ErrorCtor = schema.TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
|
|
735
|
+
const exception = new ErrorCtor(message);
|
|
736
|
+
await this.deserializeHttpMessage(errorSchema, context, response, dataObject);
|
|
737
|
+
const output = {};
|
|
738
|
+
for (const [name, member] of ns.structIterator()) {
|
|
739
|
+
const target = member.getMergedTraits().jsonName ?? name;
|
|
740
|
+
output[name] = this.codec.createDeserializer().readObject(member, dataObject[target]);
|
|
741
|
+
}
|
|
742
|
+
throw Object.assign(exception, errorMetadata, {
|
|
743
|
+
$fault: ns.getMergedTraits().error,
|
|
744
|
+
message,
|
|
745
|
+
}, output);
|
|
746
|
+
}
|
|
747
|
+
getDefaultContentType() {
|
|
748
|
+
return "application/json";
|
|
1026
749
|
}
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
const awsExpectUnion = (value) => {
|
|
1027
753
|
if (value == null) {
|
|
1028
|
-
|
|
1029
|
-
}
|
|
1030
|
-
if (typeof value === "object") {
|
|
1031
|
-
const sparse = !!traits.sparse;
|
|
1032
|
-
const flat = !!traits.xmlFlattened;
|
|
1033
|
-
if (ns.isListSchema()) {
|
|
1034
|
-
const listValue = ns.getValueSchema();
|
|
1035
|
-
const buffer2 = [];
|
|
1036
|
-
const sourceKey = listValue.getMergedTraits().xmlName ?? "member";
|
|
1037
|
-
const source = flat ? value : (value[0] ?? value)[sourceKey];
|
|
1038
|
-
const sourceArray = Array.isArray(source) ? source : [source];
|
|
1039
|
-
for (const v of sourceArray) {
|
|
1040
|
-
if (v != null || sparse) {
|
|
1041
|
-
buffer2.push(this.readSchema(listValue, v));
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
return buffer2;
|
|
1045
|
-
}
|
|
1046
|
-
const buffer = {};
|
|
1047
|
-
if (ns.isMapSchema()) {
|
|
1048
|
-
const keyNs = ns.getKeySchema();
|
|
1049
|
-
const memberNs = ns.getValueSchema();
|
|
1050
|
-
let entries;
|
|
1051
|
-
if (flat) {
|
|
1052
|
-
entries = Array.isArray(value) ? value : [value];
|
|
1053
|
-
} else {
|
|
1054
|
-
entries = Array.isArray(value.entry) ? value.entry : [value.entry];
|
|
1055
|
-
}
|
|
1056
|
-
const keyProperty = keyNs.getMergedTraits().xmlName ?? "key";
|
|
1057
|
-
const valueProperty = memberNs.getMergedTraits().xmlName ?? "value";
|
|
1058
|
-
for (const entry of entries) {
|
|
1059
|
-
const key = entry[keyProperty];
|
|
1060
|
-
const value2 = entry[valueProperty];
|
|
1061
|
-
if (value2 != null || sparse) {
|
|
1062
|
-
buffer[key] = this.readSchema(memberNs, value2);
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
return buffer;
|
|
1066
|
-
}
|
|
1067
|
-
if (ns.isStructSchema()) {
|
|
1068
|
-
for (const [memberName, memberSchema] of ns.structIterator()) {
|
|
1069
|
-
const memberTraits = memberSchema.getMergedTraits();
|
|
1070
|
-
const xmlObjectKey = !memberTraits.httpPayload ? memberSchema.getMemberTraits().xmlName ?? memberName : memberTraits.xmlName ?? memberSchema.getName();
|
|
1071
|
-
if (value[xmlObjectKey] != null) {
|
|
1072
|
-
buffer[memberName] = this.readSchema(memberSchema, value[xmlObjectKey]);
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
return buffer;
|
|
1076
|
-
}
|
|
1077
|
-
if (ns.isDocumentSchema()) {
|
|
1078
|
-
return value;
|
|
1079
|
-
}
|
|
1080
|
-
throw new Error(`@aws-sdk/core/protocols - xml deserializer unhandled schema type for ${ns.getName(true)}`);
|
|
1081
|
-
}
|
|
1082
|
-
if (ns.isListSchema()) {
|
|
1083
|
-
return [];
|
|
1084
|
-
}
|
|
1085
|
-
if (ns.isMapSchema() || ns.isStructSchema()) {
|
|
1086
|
-
return {};
|
|
1087
|
-
}
|
|
1088
|
-
return this.stringDeserializer.read(ns, value);
|
|
1089
|
-
}
|
|
1090
|
-
parseXml(xml) {
|
|
1091
|
-
if (xml.length) {
|
|
1092
|
-
let parsedObj;
|
|
1093
|
-
try {
|
|
1094
|
-
parsedObj = (0, import_xml_builder.parseXML)(xml);
|
|
1095
|
-
} catch (e) {
|
|
1096
|
-
if (e && typeof e === "object") {
|
|
1097
|
-
Object.defineProperty(e, "$responseBodyText", {
|
|
1098
|
-
value: xml
|
|
1099
|
-
});
|
|
1100
|
-
}
|
|
1101
|
-
throw e;
|
|
1102
|
-
}
|
|
1103
|
-
const textNodeName = "#text";
|
|
1104
|
-
const key = Object.keys(parsedObj)[0];
|
|
1105
|
-
const parsedObjToReturn = parsedObj[key];
|
|
1106
|
-
if (parsedObjToReturn[textNodeName]) {
|
|
1107
|
-
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
|
|
1108
|
-
delete parsedObjToReturn[textNodeName];
|
|
1109
|
-
}
|
|
1110
|
-
return (0, import_smithy_client3.getValueFromTextNode)(parsedObjToReturn);
|
|
754
|
+
return undefined;
|
|
1111
755
|
}
|
|
1112
|
-
|
|
1113
|
-
|
|
756
|
+
if (typeof value === "object" && "__type" in value) {
|
|
757
|
+
delete value.__type;
|
|
758
|
+
}
|
|
759
|
+
return smithyClient.expectUnion(value);
|
|
1114
760
|
};
|
|
1115
761
|
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
this.
|
|
1150
|
-
this.
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
if (key.endsWith(".")) {
|
|
1254
|
-
key = key.slice(0, key.length - 1);
|
|
1255
|
-
}
|
|
1256
|
-
this.buffer += `&${(0, import_protocols6.extendedEncodeURIComponent)(key)}=`;
|
|
1257
|
-
}
|
|
1258
|
-
writeValue(value) {
|
|
1259
|
-
this.buffer += (0, import_protocols6.extendedEncodeURIComponent)(value);
|
|
1260
|
-
}
|
|
1261
|
-
};
|
|
762
|
+
class XmlShapeDeserializer extends SerdeContextConfig {
|
|
763
|
+
settings;
|
|
764
|
+
stringDeserializer;
|
|
765
|
+
constructor(settings) {
|
|
766
|
+
super();
|
|
767
|
+
this.settings = settings;
|
|
768
|
+
this.stringDeserializer = new protocols.FromStringShapeDeserializer(settings);
|
|
769
|
+
}
|
|
770
|
+
setSerdeContext(serdeContext) {
|
|
771
|
+
this.serdeContext = serdeContext;
|
|
772
|
+
this.stringDeserializer.setSerdeContext(serdeContext);
|
|
773
|
+
}
|
|
774
|
+
read(schema$1, bytes, key) {
|
|
775
|
+
const ns = schema.NormalizedSchema.of(schema$1);
|
|
776
|
+
const memberSchemas = ns.getMemberSchemas();
|
|
777
|
+
const isEventPayload = ns.isStructSchema() &&
|
|
778
|
+
ns.isMemberSchema() &&
|
|
779
|
+
!!Object.values(memberSchemas).find((memberNs) => {
|
|
780
|
+
return !!memberNs.getMemberTraits().eventPayload;
|
|
781
|
+
});
|
|
782
|
+
if (isEventPayload) {
|
|
783
|
+
const output = {};
|
|
784
|
+
const memberName = Object.keys(memberSchemas)[0];
|
|
785
|
+
const eventMemberSchema = memberSchemas[memberName];
|
|
786
|
+
if (eventMemberSchema.isBlobSchema()) {
|
|
787
|
+
output[memberName] = bytes;
|
|
788
|
+
}
|
|
789
|
+
else {
|
|
790
|
+
output[memberName] = this.read(memberSchemas[memberName], bytes);
|
|
791
|
+
}
|
|
792
|
+
return output;
|
|
793
|
+
}
|
|
794
|
+
const xmlString = (this.serdeContext?.utf8Encoder ?? utilUtf8.toUtf8)(bytes);
|
|
795
|
+
const parsedObject = this.parseXml(xmlString);
|
|
796
|
+
return this.readSchema(schema$1, key ? parsedObject[key] : parsedObject);
|
|
797
|
+
}
|
|
798
|
+
readSchema(_schema, value) {
|
|
799
|
+
const ns = schema.NormalizedSchema.of(_schema);
|
|
800
|
+
if (ns.isUnitSchema()) {
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
803
|
+
const traits = ns.getMergedTraits();
|
|
804
|
+
if (ns.isListSchema() && !Array.isArray(value)) {
|
|
805
|
+
return this.readSchema(ns, [value]);
|
|
806
|
+
}
|
|
807
|
+
if (value == null) {
|
|
808
|
+
return value;
|
|
809
|
+
}
|
|
810
|
+
if (typeof value === "object") {
|
|
811
|
+
const sparse = !!traits.sparse;
|
|
812
|
+
const flat = !!traits.xmlFlattened;
|
|
813
|
+
if (ns.isListSchema()) {
|
|
814
|
+
const listValue = ns.getValueSchema();
|
|
815
|
+
const buffer = [];
|
|
816
|
+
const sourceKey = listValue.getMergedTraits().xmlName ?? "member";
|
|
817
|
+
const source = flat ? value : (value[0] ?? value)[sourceKey];
|
|
818
|
+
const sourceArray = Array.isArray(source) ? source : [source];
|
|
819
|
+
for (const v of sourceArray) {
|
|
820
|
+
if (v != null || sparse) {
|
|
821
|
+
buffer.push(this.readSchema(listValue, v));
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
return buffer;
|
|
825
|
+
}
|
|
826
|
+
const buffer = {};
|
|
827
|
+
if (ns.isMapSchema()) {
|
|
828
|
+
const keyNs = ns.getKeySchema();
|
|
829
|
+
const memberNs = ns.getValueSchema();
|
|
830
|
+
let entries;
|
|
831
|
+
if (flat) {
|
|
832
|
+
entries = Array.isArray(value) ? value : [value];
|
|
833
|
+
}
|
|
834
|
+
else {
|
|
835
|
+
entries = Array.isArray(value.entry) ? value.entry : [value.entry];
|
|
836
|
+
}
|
|
837
|
+
const keyProperty = keyNs.getMergedTraits().xmlName ?? "key";
|
|
838
|
+
const valueProperty = memberNs.getMergedTraits().xmlName ?? "value";
|
|
839
|
+
for (const entry of entries) {
|
|
840
|
+
const key = entry[keyProperty];
|
|
841
|
+
const value = entry[valueProperty];
|
|
842
|
+
if (value != null || sparse) {
|
|
843
|
+
buffer[key] = this.readSchema(memberNs, value);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
return buffer;
|
|
847
|
+
}
|
|
848
|
+
if (ns.isStructSchema()) {
|
|
849
|
+
for (const [memberName, memberSchema] of ns.structIterator()) {
|
|
850
|
+
const memberTraits = memberSchema.getMergedTraits();
|
|
851
|
+
const xmlObjectKey = !memberTraits.httpPayload
|
|
852
|
+
? memberSchema.getMemberTraits().xmlName ?? memberName
|
|
853
|
+
: memberTraits.xmlName ?? memberSchema.getName();
|
|
854
|
+
if (value[xmlObjectKey] != null) {
|
|
855
|
+
buffer[memberName] = this.readSchema(memberSchema, value[xmlObjectKey]);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
return buffer;
|
|
859
|
+
}
|
|
860
|
+
if (ns.isDocumentSchema()) {
|
|
861
|
+
return value;
|
|
862
|
+
}
|
|
863
|
+
throw new Error(`@aws-sdk/core/protocols - xml deserializer unhandled schema type for ${ns.getName(true)}`);
|
|
864
|
+
}
|
|
865
|
+
if (ns.isListSchema()) {
|
|
866
|
+
return [];
|
|
867
|
+
}
|
|
868
|
+
if (ns.isMapSchema() || ns.isStructSchema()) {
|
|
869
|
+
return {};
|
|
870
|
+
}
|
|
871
|
+
return this.stringDeserializer.read(ns, value);
|
|
872
|
+
}
|
|
873
|
+
parseXml(xml) {
|
|
874
|
+
if (xml.length) {
|
|
875
|
+
let parsedObj;
|
|
876
|
+
try {
|
|
877
|
+
parsedObj = xmlBuilder.parseXML(xml);
|
|
878
|
+
}
|
|
879
|
+
catch (e) {
|
|
880
|
+
if (e && typeof e === "object") {
|
|
881
|
+
Object.defineProperty(e, "$responseBodyText", {
|
|
882
|
+
value: xml,
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
throw e;
|
|
886
|
+
}
|
|
887
|
+
const textNodeName = "#text";
|
|
888
|
+
const key = Object.keys(parsedObj)[0];
|
|
889
|
+
const parsedObjToReturn = parsedObj[key];
|
|
890
|
+
if (parsedObjToReturn[textNodeName]) {
|
|
891
|
+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
|
|
892
|
+
delete parsedObjToReturn[textNodeName];
|
|
893
|
+
}
|
|
894
|
+
return smithyClient.getValueFromTextNode(parsedObjToReturn);
|
|
895
|
+
}
|
|
896
|
+
return {};
|
|
897
|
+
}
|
|
898
|
+
}
|
|
1262
899
|
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
$fault: ns.getMergedTraits().error,
|
|
1387
|
-
message
|
|
1388
|
-
},
|
|
1389
|
-
output
|
|
1390
|
-
);
|
|
1391
|
-
}
|
|
1392
|
-
/**
|
|
1393
|
-
* The variations in the error and error message locations are attributed to
|
|
1394
|
-
* divergence between AWS Query and EC2 Query behavior.
|
|
1395
|
-
*/
|
|
1396
|
-
loadQueryErrorCode(output, data) {
|
|
1397
|
-
const code = (data.Errors?.[0]?.Error ?? data.Errors?.Error ?? data.Error)?.Code;
|
|
1398
|
-
if (code !== void 0) {
|
|
1399
|
-
return code;
|
|
900
|
+
class QueryShapeSerializer extends SerdeContextConfig {
|
|
901
|
+
settings;
|
|
902
|
+
buffer;
|
|
903
|
+
constructor(settings) {
|
|
904
|
+
super();
|
|
905
|
+
this.settings = settings;
|
|
906
|
+
}
|
|
907
|
+
write(schema$1, value, prefix = "") {
|
|
908
|
+
if (this.buffer === undefined) {
|
|
909
|
+
this.buffer = "";
|
|
910
|
+
}
|
|
911
|
+
const ns = schema.NormalizedSchema.of(schema$1);
|
|
912
|
+
if (prefix && !prefix.endsWith(".")) {
|
|
913
|
+
prefix += ".";
|
|
914
|
+
}
|
|
915
|
+
if (ns.isBlobSchema()) {
|
|
916
|
+
if (typeof value === "string" || value instanceof Uint8Array) {
|
|
917
|
+
this.writeKey(prefix);
|
|
918
|
+
this.writeValue((this.serdeContext?.base64Encoder ?? utilBase64.toBase64)(value));
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
else if (ns.isBooleanSchema() || ns.isNumericSchema() || ns.isStringSchema()) {
|
|
922
|
+
if (value != null) {
|
|
923
|
+
this.writeKey(prefix);
|
|
924
|
+
this.writeValue(String(value));
|
|
925
|
+
}
|
|
926
|
+
else if (ns.isIdempotencyToken()) {
|
|
927
|
+
this.writeKey(prefix);
|
|
928
|
+
this.writeValue(serde.generateIdempotencyToken());
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
else if (ns.isBigIntegerSchema()) {
|
|
932
|
+
if (value != null) {
|
|
933
|
+
this.writeKey(prefix);
|
|
934
|
+
this.writeValue(String(value));
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
else if (ns.isBigDecimalSchema()) {
|
|
938
|
+
if (value != null) {
|
|
939
|
+
this.writeKey(prefix);
|
|
940
|
+
this.writeValue(value instanceof serde.NumericValue ? value.string : String(value));
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
else if (ns.isTimestampSchema()) {
|
|
944
|
+
if (value instanceof Date) {
|
|
945
|
+
this.writeKey(prefix);
|
|
946
|
+
const format = protocols.determineTimestampFormat(ns, this.settings);
|
|
947
|
+
switch (format) {
|
|
948
|
+
case 5:
|
|
949
|
+
this.writeValue(value.toISOString().replace(".000Z", "Z"));
|
|
950
|
+
break;
|
|
951
|
+
case 6:
|
|
952
|
+
this.writeValue(smithyClient.dateToUtcString(value));
|
|
953
|
+
break;
|
|
954
|
+
case 7:
|
|
955
|
+
this.writeValue(String(value.getTime() / 1000));
|
|
956
|
+
break;
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
else if (ns.isDocumentSchema()) {
|
|
961
|
+
throw new Error(`@aws-sdk/core/protocols - QuerySerializer unsupported document type ${ns.getName(true)}`);
|
|
962
|
+
}
|
|
963
|
+
else if (ns.isListSchema()) {
|
|
964
|
+
if (Array.isArray(value)) {
|
|
965
|
+
if (value.length === 0) {
|
|
966
|
+
if (this.settings.serializeEmptyLists) {
|
|
967
|
+
this.writeKey(prefix);
|
|
968
|
+
this.writeValue("");
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
else {
|
|
972
|
+
const member = ns.getValueSchema();
|
|
973
|
+
const flat = this.settings.flattenLists || ns.getMergedTraits().xmlFlattened;
|
|
974
|
+
let i = 1;
|
|
975
|
+
for (const item of value) {
|
|
976
|
+
if (item == null) {
|
|
977
|
+
continue;
|
|
978
|
+
}
|
|
979
|
+
const suffix = this.getKey("member", member.getMergedTraits().xmlName);
|
|
980
|
+
const key = flat ? `${prefix}${i}` : `${prefix}${suffix}.${i}`;
|
|
981
|
+
this.write(member, item, key);
|
|
982
|
+
++i;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
else if (ns.isMapSchema()) {
|
|
988
|
+
if (value && typeof value === "object") {
|
|
989
|
+
const keySchema = ns.getKeySchema();
|
|
990
|
+
const memberSchema = ns.getValueSchema();
|
|
991
|
+
const flat = ns.getMergedTraits().xmlFlattened;
|
|
992
|
+
let i = 1;
|
|
993
|
+
for (const [k, v] of Object.entries(value)) {
|
|
994
|
+
if (v == null) {
|
|
995
|
+
continue;
|
|
996
|
+
}
|
|
997
|
+
const keySuffix = this.getKey("key", keySchema.getMergedTraits().xmlName);
|
|
998
|
+
const key = flat ? `${prefix}${i}.${keySuffix}` : `${prefix}entry.${i}.${keySuffix}`;
|
|
999
|
+
const valueSuffix = this.getKey("value", memberSchema.getMergedTraits().xmlName);
|
|
1000
|
+
const valueKey = flat ? `${prefix}${i}.${valueSuffix}` : `${prefix}entry.${i}.${valueSuffix}`;
|
|
1001
|
+
this.write(keySchema, k, key);
|
|
1002
|
+
this.write(memberSchema, v, valueKey);
|
|
1003
|
+
++i;
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
else if (ns.isStructSchema()) {
|
|
1008
|
+
if (value && typeof value === "object") {
|
|
1009
|
+
for (const [memberName, member] of ns.structIterator()) {
|
|
1010
|
+
if (value[memberName] == null && !member.isIdempotencyToken()) {
|
|
1011
|
+
continue;
|
|
1012
|
+
}
|
|
1013
|
+
const suffix = this.getKey(memberName, member.getMergedTraits().xmlName);
|
|
1014
|
+
const key = `${prefix}${suffix}`;
|
|
1015
|
+
this.write(member, value[memberName], key);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
else if (ns.isUnitSchema()) ;
|
|
1020
|
+
else {
|
|
1021
|
+
throw new Error(`@aws-sdk/core/protocols - QuerySerializer unrecognized schema type ${ns.getName(true)}`);
|
|
1022
|
+
}
|
|
1400
1023
|
}
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1024
|
+
flush() {
|
|
1025
|
+
if (this.buffer === undefined) {
|
|
1026
|
+
throw new Error("@aws-sdk/core/protocols - QuerySerializer cannot flush with nothing written to buffer.");
|
|
1027
|
+
}
|
|
1028
|
+
const str = this.buffer;
|
|
1029
|
+
delete this.buffer;
|
|
1030
|
+
return str;
|
|
1031
|
+
}
|
|
1032
|
+
getKey(memberName, xmlName) {
|
|
1033
|
+
const key = xmlName ?? memberName;
|
|
1034
|
+
if (this.settings.capitalizeKeys) {
|
|
1035
|
+
return key[0].toUpperCase() + key.slice(1);
|
|
1036
|
+
}
|
|
1037
|
+
return key;
|
|
1038
|
+
}
|
|
1039
|
+
writeKey(key) {
|
|
1040
|
+
if (key.endsWith(".")) {
|
|
1041
|
+
key = key.slice(0, key.length - 1);
|
|
1042
|
+
}
|
|
1043
|
+
this.buffer += `&${protocols.extendedEncodeURIComponent(key)}=`;
|
|
1044
|
+
}
|
|
1045
|
+
writeValue(value) {
|
|
1046
|
+
this.buffer += protocols.extendedEncodeURIComponent(value);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1419
1049
|
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1050
|
+
class AwsQueryProtocol extends protocols.RpcProtocol {
|
|
1051
|
+
options;
|
|
1052
|
+
serializer;
|
|
1053
|
+
deserializer;
|
|
1054
|
+
mixin = new ProtocolLib();
|
|
1055
|
+
constructor(options) {
|
|
1056
|
+
super({
|
|
1057
|
+
defaultNamespace: options.defaultNamespace,
|
|
1058
|
+
});
|
|
1059
|
+
this.options = options;
|
|
1060
|
+
const settings = {
|
|
1061
|
+
timestampFormat: {
|
|
1062
|
+
useTrait: true,
|
|
1063
|
+
default: 5,
|
|
1064
|
+
},
|
|
1065
|
+
httpBindings: false,
|
|
1066
|
+
xmlNamespace: options.xmlNamespace,
|
|
1067
|
+
serviceNamespace: options.defaultNamespace,
|
|
1068
|
+
serializeEmptyLists: true,
|
|
1069
|
+
};
|
|
1070
|
+
this.serializer = new QueryShapeSerializer(settings);
|
|
1071
|
+
this.deserializer = new XmlShapeDeserializer(settings);
|
|
1072
|
+
}
|
|
1073
|
+
getShapeId() {
|
|
1074
|
+
return "aws.protocols#awsQuery";
|
|
1075
|
+
}
|
|
1076
|
+
setSerdeContext(serdeContext) {
|
|
1077
|
+
this.serializer.setSerdeContext(serdeContext);
|
|
1078
|
+
this.deserializer.setSerdeContext(serdeContext);
|
|
1079
|
+
}
|
|
1080
|
+
getPayloadCodec() {
|
|
1081
|
+
throw new Error("AWSQuery protocol has no payload codec.");
|
|
1082
|
+
}
|
|
1083
|
+
async serializeRequest(operationSchema, input, context) {
|
|
1084
|
+
const request = await super.serializeRequest(operationSchema, input, context);
|
|
1085
|
+
if (!request.path.endsWith("/")) {
|
|
1086
|
+
request.path += "/";
|
|
1087
|
+
}
|
|
1088
|
+
Object.assign(request.headers, {
|
|
1089
|
+
"content-type": `application/x-www-form-urlencoded`,
|
|
1090
|
+
});
|
|
1091
|
+
if (schema.deref(operationSchema.input) === "unit" || !request.body) {
|
|
1092
|
+
request.body = "";
|
|
1093
|
+
}
|
|
1094
|
+
const action = operationSchema.name.split("#")[1] ?? operationSchema.name;
|
|
1095
|
+
request.body = `Action=${action}&Version=${this.options.version}` + request.body;
|
|
1096
|
+
if (request.body.endsWith("&")) {
|
|
1097
|
+
request.body = request.body.slice(-1);
|
|
1098
|
+
}
|
|
1099
|
+
return request;
|
|
1100
|
+
}
|
|
1101
|
+
async deserializeResponse(operationSchema, context, response) {
|
|
1102
|
+
const deserializer = this.deserializer;
|
|
1103
|
+
const ns = schema.NormalizedSchema.of(operationSchema.output);
|
|
1104
|
+
const dataObject = {};
|
|
1105
|
+
if (response.statusCode >= 300) {
|
|
1106
|
+
const bytes = await protocols.collectBody(response.body, context);
|
|
1107
|
+
if (bytes.byteLength > 0) {
|
|
1108
|
+
Object.assign(dataObject, await deserializer.read(15, bytes));
|
|
1109
|
+
}
|
|
1110
|
+
await this.handleError(operationSchema, context, response, dataObject, this.deserializeMetadata(response));
|
|
1111
|
+
}
|
|
1112
|
+
for (const header in response.headers) {
|
|
1113
|
+
const value = response.headers[header];
|
|
1114
|
+
delete response.headers[header];
|
|
1115
|
+
response.headers[header.toLowerCase()] = value;
|
|
1116
|
+
}
|
|
1117
|
+
const shortName = operationSchema.name.split("#")[1] ?? operationSchema.name;
|
|
1118
|
+
const awsQueryResultKey = ns.isStructSchema() && this.useNestedResult() ? shortName + "Result" : undefined;
|
|
1119
|
+
const bytes = await protocols.collectBody(response.body, context);
|
|
1120
|
+
if (bytes.byteLength > 0) {
|
|
1121
|
+
Object.assign(dataObject, await deserializer.read(ns, bytes, awsQueryResultKey));
|
|
1122
|
+
}
|
|
1123
|
+
const output = {
|
|
1124
|
+
$metadata: this.deserializeMetadata(response),
|
|
1125
|
+
...dataObject,
|
|
1126
|
+
};
|
|
1127
|
+
return output;
|
|
1128
|
+
}
|
|
1129
|
+
useNestedResult() {
|
|
1130
|
+
return true;
|
|
1131
|
+
}
|
|
1132
|
+
async handleError(operationSchema, context, response, dataObject, metadata) {
|
|
1133
|
+
const errorIdentifier = this.loadQueryErrorCode(response, dataObject) ?? "Unknown";
|
|
1134
|
+
const errorData = this.loadQueryError(dataObject);
|
|
1135
|
+
const message = this.loadQueryErrorMessage(dataObject);
|
|
1136
|
+
errorData.message = message;
|
|
1137
|
+
errorData.Error = {
|
|
1138
|
+
Type: errorData.Type,
|
|
1139
|
+
Code: errorData.Code,
|
|
1140
|
+
Message: message,
|
|
1141
|
+
};
|
|
1142
|
+
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, errorData, metadata, (registry, errorName) => registry.find((schema$1) => schema.NormalizedSchema.of(schema$1).getMergedTraits().awsQueryError?.[0] === errorName));
|
|
1143
|
+
const ns = schema.NormalizedSchema.of(errorSchema);
|
|
1144
|
+
const ErrorCtor = schema.TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
|
|
1145
|
+
const exception = new ErrorCtor(message);
|
|
1146
|
+
const output = {
|
|
1147
|
+
Error: errorData.Error,
|
|
1148
|
+
};
|
|
1149
|
+
for (const [name, member] of ns.structIterator()) {
|
|
1150
|
+
const target = member.getMergedTraits().xmlName ?? name;
|
|
1151
|
+
const value = errorData[target] ?? dataObject[target];
|
|
1152
|
+
output[name] = this.deserializer.readSchema(member, value);
|
|
1153
|
+
}
|
|
1154
|
+
throw Object.assign(exception, errorMetadata, {
|
|
1155
|
+
$fault: ns.getMergedTraits().error,
|
|
1156
|
+
message,
|
|
1157
|
+
}, output);
|
|
1158
|
+
}
|
|
1159
|
+
loadQueryErrorCode(output, data) {
|
|
1160
|
+
const code = (data.Errors?.[0]?.Error ?? data.Errors?.Error ?? data.Error)?.Code;
|
|
1161
|
+
if (code !== undefined) {
|
|
1162
|
+
return code;
|
|
1163
|
+
}
|
|
1164
|
+
if (output.statusCode == 404) {
|
|
1165
|
+
return "NotFound";
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
loadQueryError(data) {
|
|
1169
|
+
return data.Errors?.[0]?.Error ?? data.Errors?.Error ?? data.Error;
|
|
1170
|
+
}
|
|
1171
|
+
loadQueryErrorMessage(data) {
|
|
1172
|
+
const errorData = this.loadQueryError(data);
|
|
1173
|
+
return errorData?.message ?? errorData?.Message ?? data.message ?? data.Message ?? "Unknown";
|
|
1174
|
+
}
|
|
1175
|
+
getDefaultContentType() {
|
|
1176
|
+
return "application/x-www-form-urlencoded";
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1442
1179
|
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1180
|
+
class AwsEc2QueryProtocol extends AwsQueryProtocol {
|
|
1181
|
+
options;
|
|
1182
|
+
constructor(options) {
|
|
1183
|
+
super(options);
|
|
1184
|
+
this.options = options;
|
|
1185
|
+
const ec2Settings = {
|
|
1186
|
+
capitalizeKeys: true,
|
|
1187
|
+
flattenLists: true,
|
|
1188
|
+
serializeEmptyLists: false,
|
|
1189
|
+
};
|
|
1190
|
+
Object.assign(this.serializer.settings, ec2Settings);
|
|
1191
|
+
}
|
|
1192
|
+
useNestedResult() {
|
|
1193
|
+
return false;
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1446
1196
|
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
}
|
|
1470
|
-
return
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
}
|
|
1491
|
-
}, "loadRestXmlErrorCode");
|
|
1197
|
+
const parseXmlBody = (streamBody, context) => collectBodyString(streamBody, context).then((encoded) => {
|
|
1198
|
+
if (encoded.length) {
|
|
1199
|
+
let parsedObj;
|
|
1200
|
+
try {
|
|
1201
|
+
parsedObj = xmlBuilder.parseXML(encoded);
|
|
1202
|
+
}
|
|
1203
|
+
catch (e) {
|
|
1204
|
+
if (e && typeof e === "object") {
|
|
1205
|
+
Object.defineProperty(e, "$responseBodyText", {
|
|
1206
|
+
value: encoded,
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
throw e;
|
|
1210
|
+
}
|
|
1211
|
+
const textNodeName = "#text";
|
|
1212
|
+
const key = Object.keys(parsedObj)[0];
|
|
1213
|
+
const parsedObjToReturn = parsedObj[key];
|
|
1214
|
+
if (parsedObjToReturn[textNodeName]) {
|
|
1215
|
+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
|
|
1216
|
+
delete parsedObjToReturn[textNodeName];
|
|
1217
|
+
}
|
|
1218
|
+
return smithyClient.getValueFromTextNode(parsedObjToReturn);
|
|
1219
|
+
}
|
|
1220
|
+
return {};
|
|
1221
|
+
});
|
|
1222
|
+
const parseXmlErrorBody = async (errorBody, context) => {
|
|
1223
|
+
const value = await parseXmlBody(errorBody, context);
|
|
1224
|
+
if (value.Error) {
|
|
1225
|
+
value.Error.message = value.Error.message ?? value.Error.Message;
|
|
1226
|
+
}
|
|
1227
|
+
return value;
|
|
1228
|
+
};
|
|
1229
|
+
const loadRestXmlErrorCode = (output, data) => {
|
|
1230
|
+
if (data?.Error?.Code !== undefined) {
|
|
1231
|
+
return data.Error.Code;
|
|
1232
|
+
}
|
|
1233
|
+
if (data?.Code !== undefined) {
|
|
1234
|
+
return data.Code;
|
|
1235
|
+
}
|
|
1236
|
+
if (output.statusCode == 404) {
|
|
1237
|
+
return "NotFound";
|
|
1238
|
+
}
|
|
1239
|
+
};
|
|
1492
1240
|
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
buffer.
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
}
|
|
1574
|
-
const memberNode = import_xml_builder3.XmlNode.of(memberSchema.getMergedTraits().xmlName ?? memberSchema.getMemberName());
|
|
1575
|
-
this.writeSimpleInto(memberSchema, val, memberNode, xmlns);
|
|
1576
|
-
structXmlNode.addChildNode(memberNode);
|
|
1577
|
-
}
|
|
1578
|
-
}
|
|
1579
|
-
}
|
|
1580
|
-
if (xmlns) {
|
|
1581
|
-
structXmlNode.addAttribute(xmlnsAttr, xmlns);
|
|
1582
|
-
}
|
|
1583
|
-
return structXmlNode;
|
|
1584
|
-
}
|
|
1585
|
-
writeList(listMember, array, container, parentXmlns) {
|
|
1586
|
-
if (!listMember.isMemberSchema()) {
|
|
1587
|
-
throw new Error(
|
|
1588
|
-
`@aws-sdk/core/protocols - xml serializer, cannot write non-member list: ${listMember.getName(true)}`
|
|
1589
|
-
);
|
|
1590
|
-
}
|
|
1591
|
-
const listTraits = listMember.getMergedTraits();
|
|
1592
|
-
const listValueSchema = listMember.getValueSchema();
|
|
1593
|
-
const listValueTraits = listValueSchema.getMergedTraits();
|
|
1594
|
-
const sparse = !!listValueTraits.sparse;
|
|
1595
|
-
const flat = !!listTraits.xmlFlattened;
|
|
1596
|
-
const [xmlnsAttr, xmlns] = this.getXmlnsAttribute(listMember, parentXmlns);
|
|
1597
|
-
const writeItem = /* @__PURE__ */ __name((container2, value) => {
|
|
1598
|
-
if (listValueSchema.isListSchema()) {
|
|
1599
|
-
this.writeList(listValueSchema, Array.isArray(value) ? value : [value], container2, xmlns);
|
|
1600
|
-
} else if (listValueSchema.isMapSchema()) {
|
|
1601
|
-
this.writeMap(listValueSchema, value, container2, xmlns);
|
|
1602
|
-
} else if (listValueSchema.isStructSchema()) {
|
|
1603
|
-
const struct = this.writeStruct(listValueSchema, value, xmlns);
|
|
1604
|
-
container2.addChildNode(
|
|
1605
|
-
struct.withName(flat ? listTraits.xmlName ?? listMember.getMemberName() : listValueTraits.xmlName ?? "member")
|
|
1606
|
-
);
|
|
1607
|
-
} else {
|
|
1608
|
-
const listItemNode = import_xml_builder3.XmlNode.of(
|
|
1609
|
-
flat ? listTraits.xmlName ?? listMember.getMemberName() : listValueTraits.xmlName ?? "member"
|
|
1610
|
-
);
|
|
1611
|
-
this.writeSimpleInto(listValueSchema, value, listItemNode, xmlns);
|
|
1612
|
-
container2.addChildNode(listItemNode);
|
|
1613
|
-
}
|
|
1614
|
-
}, "writeItem");
|
|
1615
|
-
if (flat) {
|
|
1616
|
-
for (const value of array) {
|
|
1617
|
-
if (sparse || value != null) {
|
|
1618
|
-
writeItem(container, value);
|
|
1619
|
-
}
|
|
1620
|
-
}
|
|
1621
|
-
} else {
|
|
1622
|
-
const listNode = import_xml_builder3.XmlNode.of(listTraits.xmlName ?? listMember.getMemberName());
|
|
1623
|
-
if (xmlns) {
|
|
1624
|
-
listNode.addAttribute(xmlnsAttr, xmlns);
|
|
1625
|
-
}
|
|
1626
|
-
for (const value of array) {
|
|
1627
|
-
if (sparse || value != null) {
|
|
1628
|
-
writeItem(listNode, value);
|
|
1629
|
-
}
|
|
1630
|
-
}
|
|
1631
|
-
container.addChildNode(listNode);
|
|
1632
|
-
}
|
|
1633
|
-
}
|
|
1634
|
-
writeMap(mapMember, map, container, parentXmlns, containerIsMap = false) {
|
|
1635
|
-
if (!mapMember.isMemberSchema()) {
|
|
1636
|
-
throw new Error(
|
|
1637
|
-
`@aws-sdk/core/protocols - xml serializer, cannot write non-member map: ${mapMember.getName(true)}`
|
|
1638
|
-
);
|
|
1639
|
-
}
|
|
1640
|
-
const mapTraits = mapMember.getMergedTraits();
|
|
1641
|
-
const mapKeySchema = mapMember.getKeySchema();
|
|
1642
|
-
const mapKeyTraits = mapKeySchema.getMergedTraits();
|
|
1643
|
-
const keyTag = mapKeyTraits.xmlName ?? "key";
|
|
1644
|
-
const mapValueSchema = mapMember.getValueSchema();
|
|
1645
|
-
const mapValueTraits = mapValueSchema.getMergedTraits();
|
|
1646
|
-
const valueTag = mapValueTraits.xmlName ?? "value";
|
|
1647
|
-
const sparse = !!mapValueTraits.sparse;
|
|
1648
|
-
const flat = !!mapTraits.xmlFlattened;
|
|
1649
|
-
const [xmlnsAttr, xmlns] = this.getXmlnsAttribute(mapMember, parentXmlns);
|
|
1650
|
-
const addKeyValue = /* @__PURE__ */ __name((entry, key, val) => {
|
|
1651
|
-
const keyNode = import_xml_builder3.XmlNode.of(keyTag, key);
|
|
1652
|
-
const [keyXmlnsAttr, keyXmlns] = this.getXmlnsAttribute(mapKeySchema, xmlns);
|
|
1653
|
-
if (keyXmlns) {
|
|
1654
|
-
keyNode.addAttribute(keyXmlnsAttr, keyXmlns);
|
|
1655
|
-
}
|
|
1656
|
-
entry.addChildNode(keyNode);
|
|
1657
|
-
let valueNode = import_xml_builder3.XmlNode.of(valueTag);
|
|
1658
|
-
if (mapValueSchema.isListSchema()) {
|
|
1659
|
-
this.writeList(mapValueSchema, val, valueNode, xmlns);
|
|
1660
|
-
} else if (mapValueSchema.isMapSchema()) {
|
|
1661
|
-
this.writeMap(mapValueSchema, val, valueNode, xmlns, true);
|
|
1662
|
-
} else if (mapValueSchema.isStructSchema()) {
|
|
1663
|
-
valueNode = this.writeStruct(mapValueSchema, val, xmlns);
|
|
1664
|
-
} else {
|
|
1665
|
-
this.writeSimpleInto(mapValueSchema, val, valueNode, xmlns);
|
|
1666
|
-
}
|
|
1667
|
-
entry.addChildNode(valueNode);
|
|
1668
|
-
}, "addKeyValue");
|
|
1669
|
-
if (flat) {
|
|
1670
|
-
for (const [key, val] of Object.entries(map)) {
|
|
1671
|
-
if (sparse || val != null) {
|
|
1672
|
-
const entry = import_xml_builder3.XmlNode.of(mapTraits.xmlName ?? mapMember.getMemberName());
|
|
1673
|
-
addKeyValue(entry, key, val);
|
|
1674
|
-
container.addChildNode(entry);
|
|
1675
|
-
}
|
|
1676
|
-
}
|
|
1677
|
-
} else {
|
|
1678
|
-
let mapNode;
|
|
1679
|
-
if (!containerIsMap) {
|
|
1680
|
-
mapNode = import_xml_builder3.XmlNode.of(mapTraits.xmlName ?? mapMember.getMemberName());
|
|
1241
|
+
class XmlShapeSerializer extends SerdeContextConfig {
|
|
1242
|
+
settings;
|
|
1243
|
+
stringBuffer;
|
|
1244
|
+
byteBuffer;
|
|
1245
|
+
buffer;
|
|
1246
|
+
constructor(settings) {
|
|
1247
|
+
super();
|
|
1248
|
+
this.settings = settings;
|
|
1249
|
+
}
|
|
1250
|
+
write(schema$1, value) {
|
|
1251
|
+
const ns = schema.NormalizedSchema.of(schema$1);
|
|
1252
|
+
if (ns.isStringSchema() && typeof value === "string") {
|
|
1253
|
+
this.stringBuffer = value;
|
|
1254
|
+
}
|
|
1255
|
+
else if (ns.isBlobSchema()) {
|
|
1256
|
+
this.byteBuffer =
|
|
1257
|
+
"byteLength" in value
|
|
1258
|
+
? value
|
|
1259
|
+
: (this.serdeContext?.base64Decoder ?? utilBase64.fromBase64)(value);
|
|
1260
|
+
}
|
|
1261
|
+
else {
|
|
1262
|
+
this.buffer = this.writeStruct(ns, value, undefined);
|
|
1263
|
+
const traits = ns.getMergedTraits();
|
|
1264
|
+
if (traits.httpPayload && !traits.xmlName) {
|
|
1265
|
+
this.buffer.withName(ns.getName());
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
flush() {
|
|
1270
|
+
if (this.byteBuffer !== undefined) {
|
|
1271
|
+
const bytes = this.byteBuffer;
|
|
1272
|
+
delete this.byteBuffer;
|
|
1273
|
+
return bytes;
|
|
1274
|
+
}
|
|
1275
|
+
if (this.stringBuffer !== undefined) {
|
|
1276
|
+
const str = this.stringBuffer;
|
|
1277
|
+
delete this.stringBuffer;
|
|
1278
|
+
return str;
|
|
1279
|
+
}
|
|
1280
|
+
const buffer = this.buffer;
|
|
1281
|
+
if (this.settings.xmlNamespace) {
|
|
1282
|
+
if (!buffer?.attributes?.["xmlns"]) {
|
|
1283
|
+
buffer.addAttribute("xmlns", this.settings.xmlNamespace);
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
delete this.buffer;
|
|
1287
|
+
return buffer.toString();
|
|
1288
|
+
}
|
|
1289
|
+
writeStruct(ns, value, parentXmlns) {
|
|
1290
|
+
const traits = ns.getMergedTraits();
|
|
1291
|
+
const name = ns.isMemberSchema() && !traits.httpPayload
|
|
1292
|
+
? ns.getMemberTraits().xmlName ?? ns.getMemberName()
|
|
1293
|
+
: traits.xmlName ?? ns.getName();
|
|
1294
|
+
if (!name || !ns.isStructSchema()) {
|
|
1295
|
+
throw new Error(`@aws-sdk/core/protocols - xml serializer, cannot write struct with empty name or non-struct, schema=${ns.getName(true)}.`);
|
|
1296
|
+
}
|
|
1297
|
+
const structXmlNode = xmlBuilder.XmlNode.of(name);
|
|
1298
|
+
const [xmlnsAttr, xmlns] = this.getXmlnsAttribute(ns, parentXmlns);
|
|
1299
|
+
for (const [memberName, memberSchema] of ns.structIterator()) {
|
|
1300
|
+
const val = value[memberName];
|
|
1301
|
+
if (val != null || memberSchema.isIdempotencyToken()) {
|
|
1302
|
+
if (memberSchema.getMergedTraits().xmlAttribute) {
|
|
1303
|
+
structXmlNode.addAttribute(memberSchema.getMergedTraits().xmlName ?? memberName, this.writeSimple(memberSchema, val));
|
|
1304
|
+
continue;
|
|
1305
|
+
}
|
|
1306
|
+
if (memberSchema.isListSchema()) {
|
|
1307
|
+
this.writeList(memberSchema, val, structXmlNode, xmlns);
|
|
1308
|
+
}
|
|
1309
|
+
else if (memberSchema.isMapSchema()) {
|
|
1310
|
+
this.writeMap(memberSchema, val, structXmlNode, xmlns);
|
|
1311
|
+
}
|
|
1312
|
+
else if (memberSchema.isStructSchema()) {
|
|
1313
|
+
structXmlNode.addChildNode(this.writeStruct(memberSchema, val, xmlns));
|
|
1314
|
+
}
|
|
1315
|
+
else {
|
|
1316
|
+
const memberNode = xmlBuilder.XmlNode.of(memberSchema.getMergedTraits().xmlName ?? memberSchema.getMemberName());
|
|
1317
|
+
this.writeSimpleInto(memberSchema, val, memberNode, xmlns);
|
|
1318
|
+
structXmlNode.addChildNode(memberNode);
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1681
1322
|
if (xmlns) {
|
|
1682
|
-
|
|
1683
|
-
}
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
if (
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1323
|
+
structXmlNode.addAttribute(xmlnsAttr, xmlns);
|
|
1324
|
+
}
|
|
1325
|
+
return structXmlNode;
|
|
1326
|
+
}
|
|
1327
|
+
writeList(listMember, array, container, parentXmlns) {
|
|
1328
|
+
if (!listMember.isMemberSchema()) {
|
|
1329
|
+
throw new Error(`@aws-sdk/core/protocols - xml serializer, cannot write non-member list: ${listMember.getName(true)}`);
|
|
1330
|
+
}
|
|
1331
|
+
const listTraits = listMember.getMergedTraits();
|
|
1332
|
+
const listValueSchema = listMember.getValueSchema();
|
|
1333
|
+
const listValueTraits = listValueSchema.getMergedTraits();
|
|
1334
|
+
const sparse = !!listValueTraits.sparse;
|
|
1335
|
+
const flat = !!listTraits.xmlFlattened;
|
|
1336
|
+
const [xmlnsAttr, xmlns] = this.getXmlnsAttribute(listMember, parentXmlns);
|
|
1337
|
+
const writeItem = (container, value) => {
|
|
1338
|
+
if (listValueSchema.isListSchema()) {
|
|
1339
|
+
this.writeList(listValueSchema, Array.isArray(value) ? value : [value], container, xmlns);
|
|
1340
|
+
}
|
|
1341
|
+
else if (listValueSchema.isMapSchema()) {
|
|
1342
|
+
this.writeMap(listValueSchema, value, container, xmlns);
|
|
1343
|
+
}
|
|
1344
|
+
else if (listValueSchema.isStructSchema()) {
|
|
1345
|
+
const struct = this.writeStruct(listValueSchema, value, xmlns);
|
|
1346
|
+
container.addChildNode(struct.withName(flat ? listTraits.xmlName ?? listMember.getMemberName() : listValueTraits.xmlName ?? "member"));
|
|
1347
|
+
}
|
|
1348
|
+
else {
|
|
1349
|
+
const listItemNode = xmlBuilder.XmlNode.of(flat ? listTraits.xmlName ?? listMember.getMemberName() : listValueTraits.xmlName ?? "member");
|
|
1350
|
+
this.writeSimpleInto(listValueSchema, value, listItemNode, xmlns);
|
|
1351
|
+
container.addChildNode(listItemNode);
|
|
1352
|
+
}
|
|
1353
|
+
};
|
|
1354
|
+
if (flat) {
|
|
1355
|
+
for (const value of array) {
|
|
1356
|
+
if (sparse || value != null) {
|
|
1357
|
+
writeItem(container, value);
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
else {
|
|
1362
|
+
const listNode = xmlBuilder.XmlNode.of(listTraits.xmlName ?? listMember.getMemberName());
|
|
1363
|
+
if (xmlns) {
|
|
1364
|
+
listNode.addAttribute(xmlnsAttr, xmlns);
|
|
1365
|
+
}
|
|
1366
|
+
for (const value of array) {
|
|
1367
|
+
if (sparse || value != null) {
|
|
1368
|
+
writeItem(listNode, value);
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
container.addChildNode(listNode);
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
writeMap(mapMember, map, container, parentXmlns, containerIsMap = false) {
|
|
1375
|
+
if (!mapMember.isMemberSchema()) {
|
|
1376
|
+
throw new Error(`@aws-sdk/core/protocols - xml serializer, cannot write non-member map: ${mapMember.getName(true)}`);
|
|
1377
|
+
}
|
|
1378
|
+
const mapTraits = mapMember.getMergedTraits();
|
|
1379
|
+
const mapKeySchema = mapMember.getKeySchema();
|
|
1380
|
+
const mapKeyTraits = mapKeySchema.getMergedTraits();
|
|
1381
|
+
const keyTag = mapKeyTraits.xmlName ?? "key";
|
|
1382
|
+
const mapValueSchema = mapMember.getValueSchema();
|
|
1383
|
+
const mapValueTraits = mapValueSchema.getMergedTraits();
|
|
1384
|
+
const valueTag = mapValueTraits.xmlName ?? "value";
|
|
1385
|
+
const sparse = !!mapValueTraits.sparse;
|
|
1386
|
+
const flat = !!mapTraits.xmlFlattened;
|
|
1387
|
+
const [xmlnsAttr, xmlns] = this.getXmlnsAttribute(mapMember, parentXmlns);
|
|
1388
|
+
const addKeyValue = (entry, key, val) => {
|
|
1389
|
+
const keyNode = xmlBuilder.XmlNode.of(keyTag, key);
|
|
1390
|
+
const [keyXmlnsAttr, keyXmlns] = this.getXmlnsAttribute(mapKeySchema, xmlns);
|
|
1391
|
+
if (keyXmlns) {
|
|
1392
|
+
keyNode.addAttribute(keyXmlnsAttr, keyXmlns);
|
|
1393
|
+
}
|
|
1394
|
+
entry.addChildNode(keyNode);
|
|
1395
|
+
let valueNode = xmlBuilder.XmlNode.of(valueTag);
|
|
1396
|
+
if (mapValueSchema.isListSchema()) {
|
|
1397
|
+
this.writeList(mapValueSchema, val, valueNode, xmlns);
|
|
1398
|
+
}
|
|
1399
|
+
else if (mapValueSchema.isMapSchema()) {
|
|
1400
|
+
this.writeMap(mapValueSchema, val, valueNode, xmlns, true);
|
|
1401
|
+
}
|
|
1402
|
+
else if (mapValueSchema.isStructSchema()) {
|
|
1403
|
+
valueNode = this.writeStruct(mapValueSchema, val, xmlns);
|
|
1404
|
+
}
|
|
1405
|
+
else {
|
|
1406
|
+
this.writeSimpleInto(mapValueSchema, val, valueNode, xmlns);
|
|
1407
|
+
}
|
|
1408
|
+
entry.addChildNode(valueNode);
|
|
1409
|
+
};
|
|
1410
|
+
if (flat) {
|
|
1411
|
+
for (const [key, val] of Object.entries(map)) {
|
|
1412
|
+
if (sparse || val != null) {
|
|
1413
|
+
const entry = xmlBuilder.XmlNode.of(mapTraits.xmlName ?? mapMember.getMemberName());
|
|
1414
|
+
addKeyValue(entry, key, val);
|
|
1415
|
+
container.addChildNode(entry);
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
else {
|
|
1420
|
+
let mapNode;
|
|
1421
|
+
if (!containerIsMap) {
|
|
1422
|
+
mapNode = xmlBuilder.XmlNode.of(mapTraits.xmlName ?? mapMember.getMemberName());
|
|
1423
|
+
if (xmlns) {
|
|
1424
|
+
mapNode.addAttribute(xmlnsAttr, xmlns);
|
|
1425
|
+
}
|
|
1426
|
+
container.addChildNode(mapNode);
|
|
1427
|
+
}
|
|
1428
|
+
for (const [key, val] of Object.entries(map)) {
|
|
1429
|
+
if (sparse || val != null) {
|
|
1430
|
+
const entry = xmlBuilder.XmlNode.of("entry");
|
|
1431
|
+
addKeyValue(entry, key, val);
|
|
1432
|
+
(containerIsMap ? container : mapNode).addChildNode(entry);
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
writeSimple(_schema, value) {
|
|
1438
|
+
if (null === value) {
|
|
1439
|
+
throw new Error("@aws-sdk/core/protocols - (XML serializer) cannot write null value.");
|
|
1440
|
+
}
|
|
1441
|
+
const ns = schema.NormalizedSchema.of(_schema);
|
|
1442
|
+
let nodeContents = null;
|
|
1443
|
+
if (value && typeof value === "object") {
|
|
1444
|
+
if (ns.isBlobSchema()) {
|
|
1445
|
+
nodeContents = (this.serdeContext?.base64Encoder ?? utilBase64.toBase64)(value);
|
|
1446
|
+
}
|
|
1447
|
+
else if (ns.isTimestampSchema() && value instanceof Date) {
|
|
1448
|
+
const format = protocols.determineTimestampFormat(ns, this.settings);
|
|
1449
|
+
switch (format) {
|
|
1450
|
+
case 5:
|
|
1451
|
+
nodeContents = value.toISOString().replace(".000Z", "Z");
|
|
1452
|
+
break;
|
|
1453
|
+
case 6:
|
|
1454
|
+
nodeContents = smithyClient.dateToUtcString(value);
|
|
1455
|
+
break;
|
|
1456
|
+
case 7:
|
|
1457
|
+
nodeContents = String(value.getTime() / 1000);
|
|
1458
|
+
break;
|
|
1459
|
+
default:
|
|
1460
|
+
console.warn("Missing timestamp format, using http date", value);
|
|
1461
|
+
nodeContents = smithyClient.dateToUtcString(value);
|
|
1462
|
+
break;
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
else if (ns.isBigDecimalSchema() && value) {
|
|
1466
|
+
if (value instanceof serde.NumericValue) {
|
|
1467
|
+
return value.string;
|
|
1468
|
+
}
|
|
1469
|
+
return String(value);
|
|
1470
|
+
}
|
|
1471
|
+
else if (ns.isMapSchema() || ns.isListSchema()) {
|
|
1472
|
+
throw new Error("@aws-sdk/core/protocols - xml serializer, cannot call _write() on List/Map schema, call writeList or writeMap() instead.");
|
|
1473
|
+
}
|
|
1474
|
+
else {
|
|
1475
|
+
throw new Error(`@aws-sdk/core/protocols - xml serializer, unhandled schema type for object value and schema: ${ns.getName(true)}`);
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
if (ns.isBooleanSchema() || ns.isNumericSchema() || ns.isBigIntegerSchema() || ns.isBigDecimalSchema()) {
|
|
1479
|
+
nodeContents = String(value);
|
|
1480
|
+
}
|
|
1481
|
+
if (ns.isStringSchema()) {
|
|
1482
|
+
if (value === undefined && ns.isIdempotencyToken()) {
|
|
1483
|
+
nodeContents = serde.generateIdempotencyToken();
|
|
1484
|
+
}
|
|
1485
|
+
else {
|
|
1486
|
+
nodeContents = String(value);
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
if (nodeContents === null) {
|
|
1490
|
+
throw new Error(`Unhandled schema-value pair ${ns.getName(true)}=${value}`);
|
|
1491
|
+
}
|
|
1492
|
+
return nodeContents;
|
|
1493
|
+
}
|
|
1494
|
+
writeSimpleInto(_schema, value, into, parentXmlns) {
|
|
1495
|
+
const nodeContents = this.writeSimple(_schema, value);
|
|
1496
|
+
const ns = schema.NormalizedSchema.of(_schema);
|
|
1497
|
+
const content = new xmlBuilder.XmlText(nodeContents);
|
|
1498
|
+
const [xmlnsAttr, xmlns] = this.getXmlnsAttribute(ns, parentXmlns);
|
|
1499
|
+
if (xmlns) {
|
|
1500
|
+
into.addAttribute(xmlnsAttr, xmlns);
|
|
1501
|
+
}
|
|
1502
|
+
into.addChildNode(content);
|
|
1503
|
+
}
|
|
1504
|
+
getXmlnsAttribute(ns, parentXmlns) {
|
|
1505
|
+
const traits = ns.getMergedTraits();
|
|
1506
|
+
const [prefix, xmlns] = traits.xmlNamespace ?? [];
|
|
1507
|
+
if (xmlns && xmlns !== parentXmlns) {
|
|
1508
|
+
return [prefix ? `xmlns:${prefix}` : "xmlns", xmlns];
|
|
1509
|
+
}
|
|
1510
|
+
return [void 0, void 0];
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1772
1513
|
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
return deserializer;
|
|
1791
|
-
}
|
|
1792
|
-
};
|
|
1514
|
+
class XmlCodec extends SerdeContextConfig {
|
|
1515
|
+
settings;
|
|
1516
|
+
constructor(settings) {
|
|
1517
|
+
super();
|
|
1518
|
+
this.settings = settings;
|
|
1519
|
+
}
|
|
1520
|
+
createSerializer() {
|
|
1521
|
+
const serializer = new XmlShapeSerializer(this.settings);
|
|
1522
|
+
serializer.setSerdeContext(this.serdeContext);
|
|
1523
|
+
return serializer;
|
|
1524
|
+
}
|
|
1525
|
+
createDeserializer() {
|
|
1526
|
+
const deserializer = new XmlShapeDeserializer(this.settings);
|
|
1527
|
+
deserializer.setSerdeContext(this.serdeContext);
|
|
1528
|
+
return deserializer;
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1793
1531
|
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
}
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
AwsRestJsonProtocol,
|
|
1888
|
-
AwsRestXmlProtocol,
|
|
1889
|
-
AwsSmithyRpcV2CborProtocol,
|
|
1890
|
-
JsonCodec,
|
|
1891
|
-
JsonShapeDeserializer,
|
|
1892
|
-
JsonShapeSerializer,
|
|
1893
|
-
XmlCodec,
|
|
1894
|
-
XmlShapeDeserializer,
|
|
1895
|
-
XmlShapeSerializer,
|
|
1896
|
-
_toBool,
|
|
1897
|
-
_toNum,
|
|
1898
|
-
_toStr,
|
|
1899
|
-
awsExpectUnion,
|
|
1900
|
-
loadRestJsonErrorCode,
|
|
1901
|
-
loadRestXmlErrorCode,
|
|
1902
|
-
parseJsonBody,
|
|
1903
|
-
parseJsonErrorBody,
|
|
1904
|
-
parseXmlBody,
|
|
1905
|
-
parseXmlErrorBody
|
|
1906
|
-
});
|
|
1532
|
+
class AwsRestXmlProtocol extends protocols.HttpBindingProtocol {
|
|
1533
|
+
codec;
|
|
1534
|
+
serializer;
|
|
1535
|
+
deserializer;
|
|
1536
|
+
mixin = new ProtocolLib();
|
|
1537
|
+
constructor(options) {
|
|
1538
|
+
super(options);
|
|
1539
|
+
const settings = {
|
|
1540
|
+
timestampFormat: {
|
|
1541
|
+
useTrait: true,
|
|
1542
|
+
default: 5,
|
|
1543
|
+
},
|
|
1544
|
+
httpBindings: true,
|
|
1545
|
+
xmlNamespace: options.xmlNamespace,
|
|
1546
|
+
serviceNamespace: options.defaultNamespace,
|
|
1547
|
+
};
|
|
1548
|
+
this.codec = new XmlCodec(settings);
|
|
1549
|
+
this.serializer = new protocols.HttpInterceptingShapeSerializer(this.codec.createSerializer(), settings);
|
|
1550
|
+
this.deserializer = new protocols.HttpInterceptingShapeDeserializer(this.codec.createDeserializer(), settings);
|
|
1551
|
+
}
|
|
1552
|
+
getPayloadCodec() {
|
|
1553
|
+
return this.codec;
|
|
1554
|
+
}
|
|
1555
|
+
getShapeId() {
|
|
1556
|
+
return "aws.protocols#restXml";
|
|
1557
|
+
}
|
|
1558
|
+
async serializeRequest(operationSchema, input, context) {
|
|
1559
|
+
const request = await super.serializeRequest(operationSchema, input, context);
|
|
1560
|
+
const inputSchema = schema.NormalizedSchema.of(operationSchema.input);
|
|
1561
|
+
if (!request.headers["content-type"]) {
|
|
1562
|
+
const contentType = this.mixin.resolveRestContentType(this.getDefaultContentType(), inputSchema);
|
|
1563
|
+
if (contentType) {
|
|
1564
|
+
request.headers["content-type"] = contentType;
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
if (request.headers["content-type"] === this.getDefaultContentType()) {
|
|
1568
|
+
if (typeof request.body === "string") {
|
|
1569
|
+
request.body = '<?xml version="1.0" encoding="UTF-8"?>' + request.body;
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
return request;
|
|
1573
|
+
}
|
|
1574
|
+
async deserializeResponse(operationSchema, context, response) {
|
|
1575
|
+
return super.deserializeResponse(operationSchema, context, response);
|
|
1576
|
+
}
|
|
1577
|
+
async handleError(operationSchema, context, response, dataObject, metadata) {
|
|
1578
|
+
const errorIdentifier = loadRestXmlErrorCode(response, dataObject) ?? "Unknown";
|
|
1579
|
+
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata);
|
|
1580
|
+
const ns = schema.NormalizedSchema.of(errorSchema);
|
|
1581
|
+
const message = dataObject.Error?.message ?? dataObject.Error?.Message ?? dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
1582
|
+
const ErrorCtor = schema.TypeRegistry.for(errorSchema.namespace).getErrorCtor(errorSchema) ?? Error;
|
|
1583
|
+
const exception = new ErrorCtor(message);
|
|
1584
|
+
await this.deserializeHttpMessage(errorSchema, context, response, dataObject);
|
|
1585
|
+
const output = {};
|
|
1586
|
+
for (const [name, member] of ns.structIterator()) {
|
|
1587
|
+
const target = member.getMergedTraits().xmlName ?? name;
|
|
1588
|
+
const value = dataObject.Error?.[target] ?? dataObject[target];
|
|
1589
|
+
output[name] = this.codec.createDeserializer().readSchema(member, value);
|
|
1590
|
+
}
|
|
1591
|
+
throw Object.assign(exception, errorMetadata, {
|
|
1592
|
+
$fault: ns.getMergedTraits().error,
|
|
1593
|
+
message,
|
|
1594
|
+
}, output);
|
|
1595
|
+
}
|
|
1596
|
+
getDefaultContentType() {
|
|
1597
|
+
return "application/xml";
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
exports.AwsEc2QueryProtocol = AwsEc2QueryProtocol;
|
|
1602
|
+
exports.AwsJson1_0Protocol = AwsJson1_0Protocol;
|
|
1603
|
+
exports.AwsJson1_1Protocol = AwsJson1_1Protocol;
|
|
1604
|
+
exports.AwsJsonRpcProtocol = AwsJsonRpcProtocol;
|
|
1605
|
+
exports.AwsQueryProtocol = AwsQueryProtocol;
|
|
1606
|
+
exports.AwsRestJsonProtocol = AwsRestJsonProtocol;
|
|
1607
|
+
exports.AwsRestXmlProtocol = AwsRestXmlProtocol;
|
|
1608
|
+
exports.AwsSmithyRpcV2CborProtocol = AwsSmithyRpcV2CborProtocol;
|
|
1609
|
+
exports.JsonCodec = JsonCodec;
|
|
1610
|
+
exports.JsonShapeDeserializer = JsonShapeDeserializer;
|
|
1611
|
+
exports.JsonShapeSerializer = JsonShapeSerializer;
|
|
1612
|
+
exports.XmlCodec = XmlCodec;
|
|
1613
|
+
exports.XmlShapeDeserializer = XmlShapeDeserializer;
|
|
1614
|
+
exports.XmlShapeSerializer = XmlShapeSerializer;
|
|
1615
|
+
exports._toBool = _toBool;
|
|
1616
|
+
exports._toNum = _toNum;
|
|
1617
|
+
exports._toStr = _toStr;
|
|
1618
|
+
exports.awsExpectUnion = awsExpectUnion;
|
|
1619
|
+
exports.loadRestJsonErrorCode = loadRestJsonErrorCode;
|
|
1620
|
+
exports.loadRestXmlErrorCode = loadRestXmlErrorCode;
|
|
1621
|
+
exports.parseJsonBody = parseJsonBody;
|
|
1622
|
+
exports.parseJsonErrorBody = parseJsonErrorBody;
|
|
1623
|
+
exports.parseXmlBody = parseXmlBody;
|
|
1624
|
+
exports.parseXmlErrorBody = parseXmlErrorBody;
|