@cdk8s/awscdk-resolver 0.0.303 → 0.0.305
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 +4 -4
- package/lib/resolve.js +1 -1
- package/node_modules/@aws-sdk/client-cloudformation/package.json +5 -5
- package/node_modules/@aws-sdk/client-sso/package.json +4 -4
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js +1466 -14
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/ConfigurableSerdeContext.js +6 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/index.js +13 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsJson1_0Protocol.js +14 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsJson1_1Protocol.js +14 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsJsonRpcProtocol.js +89 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsRestJsonProtocol.js +123 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/JsonCodec.js +20 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/JsonShapeDeserializer.js +105 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/JsonShapeSerializer.js +106 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/jsonReplacer.js +46 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/jsonReviver.js +18 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/query/AwsEc2QueryProtocol.js +3 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/query/AwsQueryProtocol.js +134 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/query/QueryShapeSerializer.js +143 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/xml/AwsRestXmlProtocol.js +131 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/xml/XmlCodec.js +20 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/xml/XmlShapeDeserializer.js +154 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/xml/XmlShapeSerializer.js +279 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/xml/simpleFormatXml.js +27 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/ConfigurableSerdeContext.d.ts +8 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/common.d.ts +2 -2
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/index.d.ts +13 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsJson1_0Protocol.d.ts +12 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsJson1_1Protocol.d.ts +12 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +18 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsRestJsonProtocol.d.ts +19 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/JsonCodec.d.ts +19 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/JsonShapeDeserializer.d.ts +13 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/JsonShapeSerializer.d.ts +15 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/jsonReplacer.d.ts +21 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/jsonReviver.d.ts +15 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/parseJsonBody.d.ts +3 -3
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/query/AwsEc2QueryProtocol.d.ts +6 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/query/AwsQueryProtocol.d.ts +29 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/query/QueryShapeSerializer.d.ts +14 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/xml/AwsRestXmlProtocol.d.ts +21 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/xml/XmlCodec.d.ts +14 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/xml/XmlShapeDeserializer.d.ts +20 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/xml/XmlShapeSerializer.d.ts +21 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/xml/simpleFormatXml.d.ts +6 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/ConfigurableSerdeContext.d.ts +5 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/common.d.ts +2 -2
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/index.d.ts +13 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJson1_0Protocol.d.ts +6 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJson1_1Protocol.d.ts +6 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +33 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsRestJsonProtocol.d.ts +34 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/JsonCodec.d.ts +16 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/JsonShapeDeserializer.d.ts +13 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/JsonShapeSerializer.d.ts +15 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/jsonReplacer.d.ts +7 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/jsonReviver.d.ts +7 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/parseJsonBody.d.ts +3 -3
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/query/AwsEc2QueryProtocol.d.ts +2 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/query/AwsQueryProtocol.d.ts +52 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/query/QueryShapeSerializer.d.ts +14 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/xml/AwsRestXmlProtocol.d.ts +39 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/xml/XmlCodec.d.ts +17 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/xml/XmlShapeDeserializer.d.ts +15 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/xml/XmlShapeSerializer.d.ts +21 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/xml/simpleFormatXml.d.ts +1 -0
- package/node_modules/@aws-sdk/core/package.json +5 -1
- 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/package.json +8 -8
- package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
- package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
- package/node_modules/@aws-sdk/middleware-user-agent/package.json +2 -2
- package/node_modules/@aws-sdk/nested-clients/package.json +4 -4
- package/node_modules/@aws-sdk/token-providers/package.json +3 -3
- package/node_modules/@aws-sdk/util-user-agent-node/package.json +2 -2
- package/node_modules/@aws-sdk/xml-builder/LICENSE +201 -0
- package/node_modules/@aws-sdk/xml-builder/README.md +10 -0
- package/node_modules/@aws-sdk/xml-builder/dist-cjs/index.js +173 -0
- package/node_modules/@aws-sdk/xml-builder/dist-es/XmlNode.js +88 -0
- package/node_modules/@aws-sdk/xml-builder/dist-es/XmlText.js +10 -0
- package/node_modules/@aws-sdk/xml-builder/dist-es/escape-attribute.js +3 -0
- package/node_modules/@aws-sdk/xml-builder/dist-es/escape-element.js +12 -0
- package/node_modules/@aws-sdk/xml-builder/dist-es/index.js +2 -0
- package/node_modules/@aws-sdk/xml-builder/dist-es/stringable.js +1 -0
- package/node_modules/@aws-sdk/xml-builder/dist-types/XmlNode.d.ts +49 -0
- package/node_modules/@aws-sdk/xml-builder/dist-types/XmlText.d.ts +11 -0
- package/node_modules/@aws-sdk/xml-builder/dist-types/escape-attribute.d.ts +6 -0
- package/node_modules/@aws-sdk/xml-builder/dist-types/escape-element.d.ts +6 -0
- package/node_modules/@aws-sdk/xml-builder/dist-types/index.d.ts +8 -0
- package/node_modules/@aws-sdk/xml-builder/dist-types/stringable.d.ts +6 -0
- package/node_modules/@aws-sdk/xml-builder/dist-types/ts3.4/XmlNode.d.ts +29 -0
- package/node_modules/@aws-sdk/xml-builder/dist-types/ts3.4/XmlText.d.ts +6 -0
- package/node_modules/@aws-sdk/xml-builder/dist-types/ts3.4/escape-attribute.d.ts +1 -0
- package/node_modules/@aws-sdk/xml-builder/dist-types/ts3.4/escape-element.d.ts +1 -0
- package/node_modules/@aws-sdk/xml-builder/dist-types/ts3.4/index.d.ts +2 -0
- package/node_modules/@aws-sdk/xml-builder/dist-types/ts3.4/stringable.d.ts +3 -0
- package/node_modules/@aws-sdk/xml-builder/package.json +54 -0
- package/package.json +5 -5
@@ -21,6 +21,19 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
21
21
|
// src/submodules/protocols/index.ts
|
22
22
|
var index_exports = {};
|
23
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
|
+
JsonCodec: () => JsonCodec,
|
32
|
+
JsonShapeDeserializer: () => JsonShapeDeserializer,
|
33
|
+
JsonShapeSerializer: () => JsonShapeSerializer,
|
34
|
+
XmlCodec: () => XmlCodec,
|
35
|
+
XmlShapeDeserializer: () => XmlShapeDeserializer,
|
36
|
+
XmlShapeSerializer: () => XmlShapeSerializer,
|
24
37
|
_toBool: () => _toBool,
|
25
38
|
_toNum: () => _toNum,
|
26
39
|
_toStr: () => _toStr,
|
@@ -89,21 +102,50 @@ var _toNum = /* @__PURE__ */ __name((val) => {
|
|
89
102
|
return val;
|
90
103
|
}, "_toNum");
|
91
104
|
|
92
|
-
// src/submodules/protocols/json/
|
93
|
-
var
|
94
|
-
var
|
95
|
-
|
96
|
-
|
105
|
+
// src/submodules/protocols/json/AwsJsonRpcProtocol.ts
|
106
|
+
var import_protocols = require("@smithy/core/protocols");
|
107
|
+
var import_schema3 = require("@smithy/core/schema");
|
108
|
+
var import_util_body_length_browser = require("@smithy/util-body-length-browser");
|
109
|
+
|
110
|
+
// src/submodules/protocols/ConfigurableSerdeContext.ts
|
111
|
+
var SerdeContextConfig = class {
|
112
|
+
static {
|
113
|
+
__name(this, "SerdeContextConfig");
|
97
114
|
}
|
98
|
-
|
99
|
-
|
115
|
+
serdeContext;
|
116
|
+
setSerdeContext(serdeContext) {
|
117
|
+
this.serdeContext = serdeContext;
|
100
118
|
}
|
101
|
-
|
102
|
-
|
119
|
+
};
|
120
|
+
|
121
|
+
// src/submodules/protocols/json/JsonShapeDeserializer.ts
|
122
|
+
var import_schema = require("@smithy/core/schema");
|
123
|
+
var import_serde2 = require("@smithy/core/serde");
|
124
|
+
var import_util_base64 = require("@smithy/util-base64");
|
125
|
+
|
126
|
+
// src/submodules/protocols/json/jsonReviver.ts
|
127
|
+
var import_serde = require("@smithy/core/serde");
|
128
|
+
function jsonReviver(key, value, context) {
|
129
|
+
if (context?.source) {
|
130
|
+
const numericString = context.source;
|
131
|
+
if (typeof value === "number") {
|
132
|
+
if (value > Number.MAX_SAFE_INTEGER || value < Number.MIN_SAFE_INTEGER || numericString !== String(value)) {
|
133
|
+
const isFractional = numericString.includes(".");
|
134
|
+
if (isFractional) {
|
135
|
+
return new import_serde.NumericValue(numericString, "bigDecimal");
|
136
|
+
} else {
|
137
|
+
return BigInt(numericString);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
}
|
141
|
+
}
|
142
|
+
return value;
|
143
|
+
}
|
144
|
+
__name(jsonReviver, "jsonReviver");
|
103
145
|
|
104
146
|
// src/submodules/protocols/common.ts
|
105
|
-
var
|
106
|
-
var collectBodyString = /* @__PURE__ */ __name((streamBody, context) => (0,
|
147
|
+
var import_smithy_client = require("@smithy/smithy-client");
|
148
|
+
var collectBodyString = /* @__PURE__ */ __name((streamBody, context) => (0, import_smithy_client.collectBody)(streamBody, context).then((body) => context.utf8Encoder(body)), "collectBodyString");
|
107
149
|
|
108
150
|
// src/submodules/protocols/json/parseJsonBody.ts
|
109
151
|
var parseJsonBody = /* @__PURE__ */ __name((streamBody, context) => collectBodyString(streamBody, context).then((encoded) => {
|
@@ -159,12 +201,993 @@ var loadRestJsonErrorCode = /* @__PURE__ */ __name((output, data) => {
|
|
159
201
|
}
|
160
202
|
}, "loadRestJsonErrorCode");
|
161
203
|
|
162
|
-
// src/submodules/protocols/
|
204
|
+
// src/submodules/protocols/json/JsonShapeDeserializer.ts
|
205
|
+
var JsonShapeDeserializer = class extends SerdeContextConfig {
|
206
|
+
constructor(settings) {
|
207
|
+
super();
|
208
|
+
this.settings = settings;
|
209
|
+
}
|
210
|
+
static {
|
211
|
+
__name(this, "JsonShapeDeserializer");
|
212
|
+
}
|
213
|
+
async read(schema, data) {
|
214
|
+
return this._read(
|
215
|
+
schema,
|
216
|
+
typeof data === "string" ? JSON.parse(data, jsonReviver) : await parseJsonBody(data, this.serdeContext)
|
217
|
+
);
|
218
|
+
}
|
219
|
+
readObject(schema, data) {
|
220
|
+
return this._read(schema, data);
|
221
|
+
}
|
222
|
+
_read(schema, value) {
|
223
|
+
const isObject = value !== null && typeof value === "object";
|
224
|
+
const ns = import_schema.NormalizedSchema.of(schema);
|
225
|
+
if (ns.isListSchema() && Array.isArray(value)) {
|
226
|
+
const listMember = ns.getValueSchema();
|
227
|
+
const out = [];
|
228
|
+
const sparse = !!ns.getMergedTraits().sparse;
|
229
|
+
for (const item of value) {
|
230
|
+
if (sparse || item != null) {
|
231
|
+
out.push(this._read(listMember, item));
|
232
|
+
}
|
233
|
+
}
|
234
|
+
return out;
|
235
|
+
} else if (ns.isMapSchema() && isObject) {
|
236
|
+
const mapMember = ns.getValueSchema();
|
237
|
+
const out = {};
|
238
|
+
const sparse = !!ns.getMergedTraits().sparse;
|
239
|
+
for (const [_k, _v] of Object.entries(value)) {
|
240
|
+
if (sparse || _v != null) {
|
241
|
+
out[_k] = this._read(mapMember, _v);
|
242
|
+
}
|
243
|
+
}
|
244
|
+
return out;
|
245
|
+
} else if (ns.isStructSchema() && isObject) {
|
246
|
+
const out = {};
|
247
|
+
for (const [memberName, memberSchema] of ns.structIterator()) {
|
248
|
+
const fromKey = this.settings.jsonName ? memberSchema.getMergedTraits().jsonName ?? memberName : memberName;
|
249
|
+
const deserializedValue = this._read(memberSchema, value[fromKey]);
|
250
|
+
if (deserializedValue != null) {
|
251
|
+
out[memberName] = deserializedValue;
|
252
|
+
}
|
253
|
+
}
|
254
|
+
return out;
|
255
|
+
}
|
256
|
+
if (ns.isBlobSchema() && typeof value === "string") {
|
257
|
+
return (0, import_util_base64.fromBase64)(value);
|
258
|
+
}
|
259
|
+
const mediaType = ns.getMergedTraits().mediaType;
|
260
|
+
if (ns.isStringSchema() && typeof value === "string" && mediaType) {
|
261
|
+
const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
|
262
|
+
if (isJson) {
|
263
|
+
return import_serde2.LazyJsonString.from(value);
|
264
|
+
}
|
265
|
+
}
|
266
|
+
if (ns.isTimestampSchema()) {
|
267
|
+
const options = this.settings.timestampFormat;
|
268
|
+
const format = options.useTrait ? ns.getSchema() === import_schema.SCHEMA.TIMESTAMP_DEFAULT ? options.default : ns.getSchema() ?? options.default : options.default;
|
269
|
+
switch (format) {
|
270
|
+
case import_schema.SCHEMA.TIMESTAMP_DATE_TIME:
|
271
|
+
return (0, import_serde2.parseRfc3339DateTimeWithOffset)(value);
|
272
|
+
case import_schema.SCHEMA.TIMESTAMP_HTTP_DATE:
|
273
|
+
return (0, import_serde2.parseRfc7231DateTime)(value);
|
274
|
+
case import_schema.SCHEMA.TIMESTAMP_EPOCH_SECONDS:
|
275
|
+
return (0, import_serde2.parseEpochTimestamp)(value);
|
276
|
+
default:
|
277
|
+
console.warn("Missing timestamp format, parsing value with Date constructor:", value);
|
278
|
+
return new Date(value);
|
279
|
+
}
|
280
|
+
}
|
281
|
+
if (ns.isBigIntegerSchema() && (typeof value === "number" || typeof value === "string")) {
|
282
|
+
return BigInt(value);
|
283
|
+
}
|
284
|
+
if (ns.isBigDecimalSchema() && value != void 0) {
|
285
|
+
if (value instanceof import_serde2.NumericValue) {
|
286
|
+
return value;
|
287
|
+
}
|
288
|
+
return new import_serde2.NumericValue(String(value), "bigDecimal");
|
289
|
+
}
|
290
|
+
if (ns.isNumericSchema() && typeof value === "string") {
|
291
|
+
switch (value) {
|
292
|
+
case "Infinity":
|
293
|
+
return Infinity;
|
294
|
+
case "-Infinity":
|
295
|
+
return -Infinity;
|
296
|
+
case "NaN":
|
297
|
+
return NaN;
|
298
|
+
}
|
299
|
+
}
|
300
|
+
return value;
|
301
|
+
}
|
302
|
+
};
|
303
|
+
|
304
|
+
// src/submodules/protocols/json/JsonShapeSerializer.ts
|
305
|
+
var import_schema2 = require("@smithy/core/schema");
|
306
|
+
var import_serde4 = require("@smithy/core/serde");
|
307
|
+
var import_serde5 = require("@smithy/core/serde");
|
308
|
+
|
309
|
+
// src/submodules/protocols/json/jsonReplacer.ts
|
310
|
+
var import_serde3 = require("@smithy/core/serde");
|
311
|
+
var NUMERIC_CONTROL_CHAR = String.fromCharCode(925);
|
312
|
+
var JsonReplacer = class {
|
313
|
+
static {
|
314
|
+
__name(this, "JsonReplacer");
|
315
|
+
}
|
316
|
+
/**
|
317
|
+
* Stores placeholder key to true serialized value lookup.
|
318
|
+
*/
|
319
|
+
values = /* @__PURE__ */ new Map();
|
320
|
+
counter = 0;
|
321
|
+
stage = 0;
|
322
|
+
/**
|
323
|
+
* Creates a jsonReplacer function that reserves big integer and big decimal values
|
324
|
+
* for later replacement.
|
325
|
+
*/
|
326
|
+
createReplacer() {
|
327
|
+
if (this.stage === 1) {
|
328
|
+
throw new Error("@aws-sdk/core/protocols - JsonReplacer already created.");
|
329
|
+
}
|
330
|
+
if (this.stage === 2) {
|
331
|
+
throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");
|
332
|
+
}
|
333
|
+
this.stage = 1;
|
334
|
+
return (key, value) => {
|
335
|
+
if (value instanceof import_serde3.NumericValue) {
|
336
|
+
const v = `${NUMERIC_CONTROL_CHAR + +"nv" + this.counter++}_` + value.string;
|
337
|
+
this.values.set(`"${v}"`, value.string);
|
338
|
+
return v;
|
339
|
+
}
|
340
|
+
if (typeof value === "bigint") {
|
341
|
+
const s = value.toString();
|
342
|
+
const v = `${NUMERIC_CONTROL_CHAR + "b" + this.counter++}_` + s;
|
343
|
+
this.values.set(`"${v}"`, s);
|
344
|
+
return v;
|
345
|
+
}
|
346
|
+
return value;
|
347
|
+
};
|
348
|
+
}
|
349
|
+
/**
|
350
|
+
* Replaces placeholder keys with their true values.
|
351
|
+
*/
|
352
|
+
replaceInJson(json) {
|
353
|
+
if (this.stage === 0) {
|
354
|
+
throw new Error("@aws-sdk/core/protocols - JsonReplacer not created yet.");
|
355
|
+
}
|
356
|
+
if (this.stage === 2) {
|
357
|
+
throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");
|
358
|
+
}
|
359
|
+
this.stage = 2;
|
360
|
+
if (this.counter === 0) {
|
361
|
+
return json;
|
362
|
+
}
|
363
|
+
for (const [key, value] of this.values) {
|
364
|
+
json = json.replace(key, value);
|
365
|
+
}
|
366
|
+
return json;
|
367
|
+
}
|
368
|
+
};
|
369
|
+
|
370
|
+
// src/submodules/protocols/json/JsonShapeSerializer.ts
|
371
|
+
var JsonShapeSerializer = class extends SerdeContextConfig {
|
372
|
+
constructor(settings) {
|
373
|
+
super();
|
374
|
+
this.settings = settings;
|
375
|
+
}
|
376
|
+
static {
|
377
|
+
__name(this, "JsonShapeSerializer");
|
378
|
+
}
|
379
|
+
buffer;
|
380
|
+
rootSchema;
|
381
|
+
write(schema, value) {
|
382
|
+
this.rootSchema = import_schema2.NormalizedSchema.of(schema);
|
383
|
+
this.buffer = this._write(this.rootSchema, value);
|
384
|
+
}
|
385
|
+
flush() {
|
386
|
+
if (this.rootSchema?.isStructSchema() || this.rootSchema?.isDocumentSchema()) {
|
387
|
+
const replacer = new JsonReplacer();
|
388
|
+
return replacer.replaceInJson(JSON.stringify(this.buffer, replacer.createReplacer(), 0));
|
389
|
+
}
|
390
|
+
return this.buffer;
|
391
|
+
}
|
392
|
+
_write(schema, value, container) {
|
393
|
+
const isObject = value !== null && typeof value === "object";
|
394
|
+
const ns = import_schema2.NormalizedSchema.of(schema);
|
395
|
+
if (ns.isListSchema() && Array.isArray(value)) {
|
396
|
+
const listMember = ns.getValueSchema();
|
397
|
+
const out = [];
|
398
|
+
const sparse = !!ns.getMergedTraits().sparse;
|
399
|
+
for (const item of value) {
|
400
|
+
if (sparse || item != null) {
|
401
|
+
out.push(this._write(listMember, item));
|
402
|
+
}
|
403
|
+
}
|
404
|
+
return out;
|
405
|
+
} else if (ns.isMapSchema() && isObject) {
|
406
|
+
const mapMember = ns.getValueSchema();
|
407
|
+
const out = {};
|
408
|
+
const sparse = !!ns.getMergedTraits().sparse;
|
409
|
+
for (const [_k, _v] of Object.entries(value)) {
|
410
|
+
if (sparse || _v != null) {
|
411
|
+
out[_k] = this._write(mapMember, _v);
|
412
|
+
}
|
413
|
+
}
|
414
|
+
return out;
|
415
|
+
} else if (ns.isStructSchema() && isObject) {
|
416
|
+
const out = {};
|
417
|
+
for (const [memberName, memberSchema] of ns.structIterator()) {
|
418
|
+
const targetKey = this.settings.jsonName ? memberSchema.getMergedTraits().jsonName ?? memberName : memberName;
|
419
|
+
const serializableValue = this._write(memberSchema, value[memberName], ns);
|
420
|
+
if (serializableValue !== void 0) {
|
421
|
+
out[targetKey] = serializableValue;
|
422
|
+
}
|
423
|
+
}
|
424
|
+
return out;
|
425
|
+
}
|
426
|
+
if (value === null && container?.isStructSchema()) {
|
427
|
+
return void 0;
|
428
|
+
}
|
429
|
+
if (ns.isBlobSchema() && (value instanceof Uint8Array || typeof value === "string")) {
|
430
|
+
if (ns === this.rootSchema) {
|
431
|
+
return value;
|
432
|
+
}
|
433
|
+
if (!this.serdeContext?.base64Encoder) {
|
434
|
+
throw new Error("Missing base64Encoder in serdeContext");
|
435
|
+
}
|
436
|
+
return this.serdeContext?.base64Encoder(value);
|
437
|
+
}
|
438
|
+
if (ns.isTimestampSchema() && value instanceof Date) {
|
439
|
+
const options = this.settings.timestampFormat;
|
440
|
+
const format = options.useTrait ? ns.getSchema() === import_schema2.SCHEMA.TIMESTAMP_DEFAULT ? options.default : ns.getSchema() ?? options.default : options.default;
|
441
|
+
switch (format) {
|
442
|
+
case import_schema2.SCHEMA.TIMESTAMP_DATE_TIME:
|
443
|
+
return value.toISOString().replace(".000Z", "Z");
|
444
|
+
case import_schema2.SCHEMA.TIMESTAMP_HTTP_DATE:
|
445
|
+
return (0, import_serde4.dateToUtcString)(value);
|
446
|
+
case import_schema2.SCHEMA.TIMESTAMP_EPOCH_SECONDS:
|
447
|
+
return value.getTime() / 1e3;
|
448
|
+
default:
|
449
|
+
console.warn("Missing timestamp format, using epoch seconds", value);
|
450
|
+
return value.getTime() / 1e3;
|
451
|
+
}
|
452
|
+
}
|
453
|
+
if (ns.isNumericSchema() && typeof value === "number") {
|
454
|
+
if (Math.abs(value) === Infinity || isNaN(value)) {
|
455
|
+
return String(value);
|
456
|
+
}
|
457
|
+
}
|
458
|
+
const mediaType = ns.getMergedTraits().mediaType;
|
459
|
+
if (ns.isStringSchema() && typeof value === "string" && mediaType) {
|
460
|
+
const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
|
461
|
+
if (isJson) {
|
462
|
+
return import_serde5.LazyJsonString.from(value);
|
463
|
+
}
|
464
|
+
}
|
465
|
+
return value;
|
466
|
+
}
|
467
|
+
};
|
468
|
+
|
469
|
+
// src/submodules/protocols/json/JsonCodec.ts
|
470
|
+
var JsonCodec = class extends SerdeContextConfig {
|
471
|
+
constructor(settings) {
|
472
|
+
super();
|
473
|
+
this.settings = settings;
|
474
|
+
}
|
475
|
+
static {
|
476
|
+
__name(this, "JsonCodec");
|
477
|
+
}
|
478
|
+
createSerializer() {
|
479
|
+
const serializer = new JsonShapeSerializer(this.settings);
|
480
|
+
serializer.setSerdeContext(this.serdeContext);
|
481
|
+
return serializer;
|
482
|
+
}
|
483
|
+
createDeserializer() {
|
484
|
+
const deserializer = new JsonShapeDeserializer(this.settings);
|
485
|
+
deserializer.setSerdeContext(this.serdeContext);
|
486
|
+
return deserializer;
|
487
|
+
}
|
488
|
+
};
|
489
|
+
|
490
|
+
// src/submodules/protocols/json/AwsJsonRpcProtocol.ts
|
491
|
+
var AwsJsonRpcProtocol = class extends import_protocols.RpcProtocol {
|
492
|
+
static {
|
493
|
+
__name(this, "AwsJsonRpcProtocol");
|
494
|
+
}
|
495
|
+
serializer;
|
496
|
+
deserializer;
|
497
|
+
codec;
|
498
|
+
constructor({ defaultNamespace }) {
|
499
|
+
super({
|
500
|
+
defaultNamespace
|
501
|
+
});
|
502
|
+
this.codec = new JsonCodec({
|
503
|
+
timestampFormat: {
|
504
|
+
useTrait: true,
|
505
|
+
default: import_schema3.SCHEMA.TIMESTAMP_EPOCH_SECONDS
|
506
|
+
},
|
507
|
+
jsonName: false
|
508
|
+
});
|
509
|
+
this.serializer = this.codec.createSerializer();
|
510
|
+
this.deserializer = this.codec.createDeserializer();
|
511
|
+
}
|
512
|
+
async serializeRequest(operationSchema, input, context) {
|
513
|
+
const request = await super.serializeRequest(operationSchema, input, context);
|
514
|
+
if (!request.path.endsWith("/")) {
|
515
|
+
request.path += "/";
|
516
|
+
}
|
517
|
+
Object.assign(request.headers, {
|
518
|
+
"content-type": `application/x-amz-json-${this.getJsonRpcVersion()}`,
|
519
|
+
"x-amz-target": (this.getJsonRpcVersion() === "1.0" ? `JsonRpc10.` : `JsonProtocol.`) + import_schema3.NormalizedSchema.of(operationSchema).getName()
|
520
|
+
});
|
521
|
+
if ((0, import_schema3.deref)(operationSchema.input) === "unit" || !request.body) {
|
522
|
+
request.body = "{}";
|
523
|
+
}
|
524
|
+
try {
|
525
|
+
request.headers["content-length"] = String((0, import_util_body_length_browser.calculateBodyLength)(request.body));
|
526
|
+
} catch (e) {
|
527
|
+
}
|
528
|
+
return request;
|
529
|
+
}
|
530
|
+
getPayloadCodec() {
|
531
|
+
return this.codec;
|
532
|
+
}
|
533
|
+
async handleError(operationSchema, context, response, dataObject, metadata) {
|
534
|
+
const errorIdentifier = loadRestJsonErrorCode(response, dataObject) ?? "Unknown";
|
535
|
+
let namespace = this.options.defaultNamespace;
|
536
|
+
let errorName = errorIdentifier;
|
537
|
+
if (errorIdentifier.includes("#")) {
|
538
|
+
[namespace, errorName] = errorIdentifier.split("#");
|
539
|
+
}
|
540
|
+
const registry = import_schema3.TypeRegistry.for(namespace);
|
541
|
+
let errorSchema;
|
542
|
+
try {
|
543
|
+
errorSchema = registry.getSchema(errorIdentifier);
|
544
|
+
} catch (e) {
|
545
|
+
const baseExceptionSchema = import_schema3.TypeRegistry.for("awssdkjs.synthetic." + namespace).getBaseException();
|
546
|
+
if (baseExceptionSchema) {
|
547
|
+
const ErrorCtor = baseExceptionSchema.ctor;
|
548
|
+
throw Object.assign(new ErrorCtor(errorName), dataObject);
|
549
|
+
}
|
550
|
+
throw new Error(errorName);
|
551
|
+
}
|
552
|
+
const ns = import_schema3.NormalizedSchema.of(errorSchema);
|
553
|
+
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
554
|
+
const exception = new errorSchema.ctor(message);
|
555
|
+
const headerBindings = new Set(
|
556
|
+
Object.values(import_schema3.NormalizedSchema.of(errorSchema).getMemberSchemas()).map((schema) => {
|
557
|
+
return schema.getMergedTraits().httpHeader;
|
558
|
+
}).filter(Boolean)
|
559
|
+
);
|
560
|
+
await this.deserializeHttpMessage(errorSchema, context, response, headerBindings, dataObject);
|
561
|
+
const output = {};
|
562
|
+
for (const [name, member] of ns.structIterator()) {
|
563
|
+
const target = member.getMergedTraits().jsonName ?? name;
|
564
|
+
output[name] = this.codec.createDeserializer().readObject(member, dataObject[target]);
|
565
|
+
}
|
566
|
+
Object.assign(exception, {
|
567
|
+
$metadata: metadata,
|
568
|
+
$response: response,
|
569
|
+
$fault: ns.getMergedTraits().error,
|
570
|
+
message,
|
571
|
+
...output
|
572
|
+
});
|
573
|
+
throw exception;
|
574
|
+
}
|
575
|
+
};
|
576
|
+
|
577
|
+
// src/submodules/protocols/json/AwsJson1_0Protocol.ts
|
578
|
+
var AwsJson1_0Protocol = class extends AwsJsonRpcProtocol {
|
579
|
+
static {
|
580
|
+
__name(this, "AwsJson1_0Protocol");
|
581
|
+
}
|
582
|
+
constructor({ defaultNamespace }) {
|
583
|
+
super({
|
584
|
+
defaultNamespace
|
585
|
+
});
|
586
|
+
}
|
587
|
+
getShapeId() {
|
588
|
+
return "aws.protocols#awsJson1_0";
|
589
|
+
}
|
590
|
+
getJsonRpcVersion() {
|
591
|
+
return "1.0";
|
592
|
+
}
|
593
|
+
};
|
594
|
+
|
595
|
+
// src/submodules/protocols/json/AwsJson1_1Protocol.ts
|
596
|
+
var AwsJson1_1Protocol = class extends AwsJsonRpcProtocol {
|
597
|
+
static {
|
598
|
+
__name(this, "AwsJson1_1Protocol");
|
599
|
+
}
|
600
|
+
constructor({ defaultNamespace }) {
|
601
|
+
super({
|
602
|
+
defaultNamespace
|
603
|
+
});
|
604
|
+
}
|
605
|
+
getShapeId() {
|
606
|
+
return "aws.protocols#awsJson1_1";
|
607
|
+
}
|
608
|
+
getJsonRpcVersion() {
|
609
|
+
return "1.1";
|
610
|
+
}
|
611
|
+
};
|
612
|
+
|
613
|
+
// src/submodules/protocols/json/AwsRestJsonProtocol.ts
|
614
|
+
var import_protocols2 = require("@smithy/core/protocols");
|
615
|
+
var import_schema4 = require("@smithy/core/schema");
|
616
|
+
var import_util_body_length_browser2 = require("@smithy/util-body-length-browser");
|
617
|
+
var AwsRestJsonProtocol = class extends import_protocols2.HttpBindingProtocol {
|
618
|
+
static {
|
619
|
+
__name(this, "AwsRestJsonProtocol");
|
620
|
+
}
|
621
|
+
serializer;
|
622
|
+
deserializer;
|
623
|
+
codec;
|
624
|
+
constructor({ defaultNamespace }) {
|
625
|
+
super({
|
626
|
+
defaultNamespace
|
627
|
+
});
|
628
|
+
const settings = {
|
629
|
+
timestampFormat: {
|
630
|
+
useTrait: true,
|
631
|
+
default: import_schema4.SCHEMA.TIMESTAMP_EPOCH_SECONDS
|
632
|
+
},
|
633
|
+
httpBindings: true,
|
634
|
+
jsonName: true
|
635
|
+
};
|
636
|
+
this.codec = new JsonCodec(settings);
|
637
|
+
this.serializer = new import_protocols2.HttpInterceptingShapeSerializer(this.codec.createSerializer(), settings);
|
638
|
+
this.deserializer = new import_protocols2.HttpInterceptingShapeDeserializer(this.codec.createDeserializer(), settings);
|
639
|
+
}
|
640
|
+
getShapeId() {
|
641
|
+
return "aws.protocols#restJson1";
|
642
|
+
}
|
643
|
+
getPayloadCodec() {
|
644
|
+
return this.codec;
|
645
|
+
}
|
646
|
+
setSerdeContext(serdeContext) {
|
647
|
+
this.codec.setSerdeContext(serdeContext);
|
648
|
+
super.setSerdeContext(serdeContext);
|
649
|
+
}
|
650
|
+
async serializeRequest(operationSchema, input, context) {
|
651
|
+
const request = await super.serializeRequest(operationSchema, input, context);
|
652
|
+
const inputSchema = import_schema4.NormalizedSchema.of(operationSchema.input);
|
653
|
+
const members = inputSchema.getMemberSchemas();
|
654
|
+
if (!request.headers["content-type"]) {
|
655
|
+
const httpPayloadMember = Object.values(members).find((m) => {
|
656
|
+
return !!m.getMergedTraits().httpPayload;
|
657
|
+
});
|
658
|
+
if (httpPayloadMember) {
|
659
|
+
const mediaType = httpPayloadMember.getMergedTraits().mediaType;
|
660
|
+
if (mediaType) {
|
661
|
+
request.headers["content-type"] = mediaType;
|
662
|
+
} else if (httpPayloadMember.isStringSchema()) {
|
663
|
+
request.headers["content-type"] = "text/plain";
|
664
|
+
} else if (httpPayloadMember.isBlobSchema()) {
|
665
|
+
request.headers["content-type"] = "application/octet-stream";
|
666
|
+
} else {
|
667
|
+
request.headers["content-type"] = "application/json";
|
668
|
+
}
|
669
|
+
} else if (!inputSchema.isUnitSchema()) {
|
670
|
+
const hasBody = Object.values(members).find((m) => {
|
671
|
+
const { httpQuery, httpQueryParams, httpHeader, httpLabel, httpPrefixHeaders } = m.getMergedTraits();
|
672
|
+
return !httpQuery && !httpQueryParams && !httpHeader && !httpLabel && httpPrefixHeaders === void 0;
|
673
|
+
});
|
674
|
+
if (hasBody) {
|
675
|
+
request.headers["content-type"] = "application/json";
|
676
|
+
}
|
677
|
+
}
|
678
|
+
}
|
679
|
+
if (request.headers["content-type"] && !request.body) {
|
680
|
+
request.body = "{}";
|
681
|
+
}
|
682
|
+
if (request.body) {
|
683
|
+
try {
|
684
|
+
request.headers["content-length"] = String((0, import_util_body_length_browser2.calculateBodyLength)(request.body));
|
685
|
+
} catch (e) {
|
686
|
+
}
|
687
|
+
}
|
688
|
+
return request;
|
689
|
+
}
|
690
|
+
async handleError(operationSchema, context, response, dataObject, metadata) {
|
691
|
+
const errorIdentifier = loadRestJsonErrorCode(response, dataObject) ?? "Unknown";
|
692
|
+
let namespace = this.options.defaultNamespace;
|
693
|
+
let errorName = errorIdentifier;
|
694
|
+
if (errorIdentifier.includes("#")) {
|
695
|
+
[namespace, errorName] = errorIdentifier.split("#");
|
696
|
+
}
|
697
|
+
const registry = import_schema4.TypeRegistry.for(namespace);
|
698
|
+
let errorSchema;
|
699
|
+
try {
|
700
|
+
errorSchema = registry.getSchema(errorIdentifier);
|
701
|
+
} catch (e) {
|
702
|
+
const baseExceptionSchema = import_schema4.TypeRegistry.for("awssdkjs.synthetic." + namespace).getBaseException();
|
703
|
+
if (baseExceptionSchema) {
|
704
|
+
const ErrorCtor = baseExceptionSchema.ctor;
|
705
|
+
throw Object.assign(new ErrorCtor(errorName), dataObject);
|
706
|
+
}
|
707
|
+
throw new Error(errorName);
|
708
|
+
}
|
709
|
+
const ns = import_schema4.NormalizedSchema.of(errorSchema);
|
710
|
+
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
711
|
+
const exception = new errorSchema.ctor(message);
|
712
|
+
const headerBindings = new Set(
|
713
|
+
Object.values(import_schema4.NormalizedSchema.of(errorSchema).getMemberSchemas()).map((schema) => {
|
714
|
+
return schema.getMergedTraits().httpHeader;
|
715
|
+
}).filter(Boolean)
|
716
|
+
);
|
717
|
+
await this.deserializeHttpMessage(errorSchema, context, response, headerBindings, dataObject);
|
718
|
+
const output = {};
|
719
|
+
for (const [name, member] of ns.structIterator()) {
|
720
|
+
const target = member.getMergedTraits().jsonName ?? name;
|
721
|
+
output[name] = this.codec.createDeserializer().readObject(member, dataObject[target]);
|
722
|
+
}
|
723
|
+
Object.assign(exception, {
|
724
|
+
$metadata: metadata,
|
725
|
+
$response: response,
|
726
|
+
$fault: ns.getMergedTraits().error,
|
727
|
+
message,
|
728
|
+
...output
|
729
|
+
});
|
730
|
+
throw exception;
|
731
|
+
}
|
732
|
+
};
|
733
|
+
|
734
|
+
// src/submodules/protocols/json/awsExpectUnion.ts
|
735
|
+
var import_smithy_client2 = require("@smithy/smithy-client");
|
736
|
+
var awsExpectUnion = /* @__PURE__ */ __name((value) => {
|
737
|
+
if (value == null) {
|
738
|
+
return void 0;
|
739
|
+
}
|
740
|
+
if (typeof value === "object" && "__type" in value) {
|
741
|
+
delete value.__type;
|
742
|
+
}
|
743
|
+
return (0, import_smithy_client2.expectUnion)(value);
|
744
|
+
}, "awsExpectUnion");
|
745
|
+
|
746
|
+
// src/submodules/protocols/query/AwsQueryProtocol.ts
|
747
|
+
var import_protocols5 = require("@smithy/core/protocols");
|
748
|
+
var import_schema7 = require("@smithy/core/schema");
|
749
|
+
var import_util_body_length_browser3 = require("@smithy/util-body-length-browser");
|
750
|
+
|
751
|
+
// src/submodules/protocols/xml/XmlShapeDeserializer.ts
|
752
|
+
var import_protocols3 = require("@smithy/core/protocols");
|
753
|
+
var import_schema5 = require("@smithy/core/schema");
|
163
754
|
var import_smithy_client3 = require("@smithy/smithy-client");
|
755
|
+
var import_util_utf8 = require("@smithy/util-utf8");
|
164
756
|
var import_fast_xml_parser = require("fast-xml-parser");
|
757
|
+
var XmlShapeDeserializer = class extends SerdeContextConfig {
|
758
|
+
constructor(settings) {
|
759
|
+
super();
|
760
|
+
this.settings = settings;
|
761
|
+
this.stringDeserializer = new import_protocols3.FromStringShapeDeserializer(settings);
|
762
|
+
}
|
763
|
+
static {
|
764
|
+
__name(this, "XmlShapeDeserializer");
|
765
|
+
}
|
766
|
+
stringDeserializer;
|
767
|
+
setSerdeContext(serdeContext) {
|
768
|
+
this.serdeContext = serdeContext;
|
769
|
+
this.stringDeserializer.setSerdeContext(serdeContext);
|
770
|
+
}
|
771
|
+
/**
|
772
|
+
* @param schema - describing the data.
|
773
|
+
* @param bytes - serialized data.
|
774
|
+
* @param key - used by AwsQuery to step one additional depth into the object before reading it.
|
775
|
+
*/
|
776
|
+
read(schema, bytes, key) {
|
777
|
+
const ns = import_schema5.NormalizedSchema.of(schema);
|
778
|
+
const memberSchemas = ns.getMemberSchemas();
|
779
|
+
const isEventPayload = ns.isStructSchema() && ns.isMemberSchema() && !!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
|
+
} else {
|
789
|
+
output[memberName] = this.read(memberSchemas[memberName], bytes);
|
790
|
+
}
|
791
|
+
return output;
|
792
|
+
}
|
793
|
+
const xmlString = (this.serdeContext?.utf8Encoder ?? import_util_utf8.toUtf8)(bytes);
|
794
|
+
const parsedObject = this.parseXml(xmlString);
|
795
|
+
return this.readSchema(schema, key ? parsedObject[key] : parsedObject);
|
796
|
+
}
|
797
|
+
readSchema(_schema, value) {
|
798
|
+
const ns = import_schema5.NormalizedSchema.of(_schema);
|
799
|
+
const traits = ns.getMergedTraits();
|
800
|
+
const schema = ns.getSchema();
|
801
|
+
if (ns.isListSchema() && !Array.isArray(value)) {
|
802
|
+
return this.readSchema(schema, [value]);
|
803
|
+
}
|
804
|
+
if (value == null) {
|
805
|
+
return value;
|
806
|
+
}
|
807
|
+
if (typeof value === "object") {
|
808
|
+
const sparse = !!traits.sparse;
|
809
|
+
const flat = !!traits.xmlFlattened;
|
810
|
+
if (ns.isListSchema()) {
|
811
|
+
const listValue = ns.getValueSchema();
|
812
|
+
const buffer2 = [];
|
813
|
+
const sourceKey = listValue.getMergedTraits().xmlName ?? "member";
|
814
|
+
const source = flat ? value : (value[0] ?? value)[sourceKey];
|
815
|
+
const sourceArray = Array.isArray(source) ? source : [source];
|
816
|
+
for (const v of sourceArray) {
|
817
|
+
if (v != null || sparse) {
|
818
|
+
buffer2.push(this.readSchema(listValue, v));
|
819
|
+
}
|
820
|
+
}
|
821
|
+
return buffer2;
|
822
|
+
}
|
823
|
+
const buffer = {};
|
824
|
+
if (ns.isMapSchema()) {
|
825
|
+
const keyNs = ns.getKeySchema();
|
826
|
+
const memberNs = ns.getValueSchema();
|
827
|
+
let entries;
|
828
|
+
if (flat) {
|
829
|
+
entries = Array.isArray(value) ? value : [value];
|
830
|
+
} else {
|
831
|
+
entries = Array.isArray(value.entry) ? value.entry : [value.entry];
|
832
|
+
}
|
833
|
+
const keyProperty = keyNs.getMergedTraits().xmlName ?? "key";
|
834
|
+
const valueProperty = memberNs.getMergedTraits().xmlName ?? "value";
|
835
|
+
for (const entry of entries) {
|
836
|
+
const key = entry[keyProperty];
|
837
|
+
const value2 = entry[valueProperty];
|
838
|
+
if (value2 != null || sparse) {
|
839
|
+
buffer[key] = this.readSchema(memberNs, value2);
|
840
|
+
}
|
841
|
+
}
|
842
|
+
return buffer;
|
843
|
+
}
|
844
|
+
if (ns.isStructSchema()) {
|
845
|
+
for (const [memberName, memberSchema] of ns.structIterator()) {
|
846
|
+
const memberTraits = memberSchema.getMergedTraits();
|
847
|
+
const xmlObjectKey = !memberTraits.httpPayload ? memberSchema.getMemberTraits().xmlName ?? memberName : memberTraits.xmlName ?? memberSchema.getName();
|
848
|
+
if (value[xmlObjectKey] != null) {
|
849
|
+
buffer[memberName] = this.readSchema(memberSchema, value[xmlObjectKey]);
|
850
|
+
}
|
851
|
+
}
|
852
|
+
return buffer;
|
853
|
+
}
|
854
|
+
if (ns.isDocumentSchema()) {
|
855
|
+
return value;
|
856
|
+
}
|
857
|
+
throw new Error(`@aws-sdk/core/protocols - xml deserializer unhandled schema type for ${ns.getName(true)}`);
|
858
|
+
} else {
|
859
|
+
if (ns.isListSchema()) {
|
860
|
+
return [];
|
861
|
+
} else if (ns.isMapSchema() || ns.isStructSchema()) {
|
862
|
+
return {};
|
863
|
+
}
|
864
|
+
return this.stringDeserializer.read(ns, value);
|
865
|
+
}
|
866
|
+
}
|
867
|
+
parseXml(xml) {
|
868
|
+
if (xml.length) {
|
869
|
+
const parser = new import_fast_xml_parser.XMLParser({
|
870
|
+
attributeNamePrefix: "",
|
871
|
+
htmlEntities: true,
|
872
|
+
ignoreAttributes: false,
|
873
|
+
ignoreDeclaration: true,
|
874
|
+
parseTagValue: false,
|
875
|
+
trimValues: false,
|
876
|
+
tagValueProcessor: /* @__PURE__ */ __name((_, val) => val.trim() === "" && val.includes("\n") ? "" : void 0, "tagValueProcessor")
|
877
|
+
});
|
878
|
+
parser.addEntity("#xD", "\r");
|
879
|
+
parser.addEntity("#10", "\n");
|
880
|
+
let parsedObj;
|
881
|
+
try {
|
882
|
+
parsedObj = parser.parse(xml, true);
|
883
|
+
} catch (e) {
|
884
|
+
if (e && typeof e === "object") {
|
885
|
+
Object.defineProperty(e, "$responseBodyText", {
|
886
|
+
value: xml
|
887
|
+
});
|
888
|
+
}
|
889
|
+
throw e;
|
890
|
+
}
|
891
|
+
const textNodeName = "#text";
|
892
|
+
const key = Object.keys(parsedObj)[0];
|
893
|
+
const parsedObjToReturn = parsedObj[key];
|
894
|
+
if (parsedObjToReturn[textNodeName]) {
|
895
|
+
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
|
896
|
+
delete parsedObjToReturn[textNodeName];
|
897
|
+
}
|
898
|
+
return (0, import_smithy_client3.getValueFromTextNode)(parsedObjToReturn);
|
899
|
+
}
|
900
|
+
return {};
|
901
|
+
}
|
902
|
+
};
|
903
|
+
|
904
|
+
// src/submodules/protocols/query/QueryShapeSerializer.ts
|
905
|
+
var import_protocols4 = require("@smithy/core/protocols");
|
906
|
+
var import_schema6 = require("@smithy/core/schema");
|
907
|
+
var import_serde6 = require("@smithy/core/serde");
|
908
|
+
var import_smithy_client4 = require("@smithy/smithy-client");
|
909
|
+
var import_util_base642 = require("@smithy/util-base64");
|
910
|
+
var QueryShapeSerializer = class extends SerdeContextConfig {
|
911
|
+
constructor(settings) {
|
912
|
+
super();
|
913
|
+
this.settings = settings;
|
914
|
+
}
|
915
|
+
static {
|
916
|
+
__name(this, "QueryShapeSerializer");
|
917
|
+
}
|
918
|
+
buffer;
|
919
|
+
write(schema, value, prefix = "") {
|
920
|
+
if (this.buffer === void 0) {
|
921
|
+
this.buffer = "";
|
922
|
+
}
|
923
|
+
const ns = import_schema6.NormalizedSchema.of(schema);
|
924
|
+
if (prefix && !prefix.endsWith(".")) {
|
925
|
+
prefix += ".";
|
926
|
+
}
|
927
|
+
if (ns.isBlobSchema()) {
|
928
|
+
if (typeof value === "string" || value instanceof Uint8Array) {
|
929
|
+
this.writeKey(prefix);
|
930
|
+
this.writeValue((this.serdeContext?.base64Encoder ?? import_util_base642.toBase64)(value));
|
931
|
+
}
|
932
|
+
} else if (ns.isBooleanSchema() || ns.isNumericSchema() || ns.isStringSchema()) {
|
933
|
+
if (value != null) {
|
934
|
+
this.writeKey(prefix);
|
935
|
+
this.writeValue(String(value));
|
936
|
+
}
|
937
|
+
} else if (ns.isBigIntegerSchema()) {
|
938
|
+
if (value != null) {
|
939
|
+
this.writeKey(prefix);
|
940
|
+
this.writeValue(String(value));
|
941
|
+
}
|
942
|
+
} else if (ns.isBigDecimalSchema()) {
|
943
|
+
if (value != null) {
|
944
|
+
this.writeKey(prefix);
|
945
|
+
this.writeValue(value instanceof import_serde6.NumericValue ? value.string : String(value));
|
946
|
+
}
|
947
|
+
} else if (ns.isTimestampSchema()) {
|
948
|
+
if (value instanceof Date) {
|
949
|
+
this.writeKey(prefix);
|
950
|
+
const format = (0, import_protocols4.determineTimestampFormat)(ns, this.settings);
|
951
|
+
switch (format) {
|
952
|
+
case import_schema6.SCHEMA.TIMESTAMP_DATE_TIME:
|
953
|
+
this.writeValue(value.toISOString().replace(".000Z", "Z"));
|
954
|
+
break;
|
955
|
+
case import_schema6.SCHEMA.TIMESTAMP_HTTP_DATE:
|
956
|
+
this.writeValue((0, import_smithy_client4.dateToUtcString)(value));
|
957
|
+
break;
|
958
|
+
case import_schema6.SCHEMA.TIMESTAMP_EPOCH_SECONDS:
|
959
|
+
this.writeValue(String(value.getTime() / 1e3));
|
960
|
+
break;
|
961
|
+
}
|
962
|
+
}
|
963
|
+
} else if (ns.isDocumentSchema()) {
|
964
|
+
throw new Error(`@aws-sdk/core/protocols - QuerySerializer unsupported document type ${ns.getName(true)}`);
|
965
|
+
} else if (ns.isListSchema()) {
|
966
|
+
if (Array.isArray(value)) {
|
967
|
+
if (value.length === 0) {
|
968
|
+
this.writeKey(prefix);
|
969
|
+
this.writeValue("");
|
970
|
+
} else {
|
971
|
+
const member = ns.getValueSchema();
|
972
|
+
const flat = ns.getMergedTraits().xmlFlattened;
|
973
|
+
let i = 1;
|
974
|
+
for (const item of value) {
|
975
|
+
if (item == null) {
|
976
|
+
continue;
|
977
|
+
}
|
978
|
+
const suffix = member.getMergedTraits().xmlName ?? "member";
|
979
|
+
const key = flat ? `${prefix}${i}` : `${prefix}${suffix}.${i}`;
|
980
|
+
this.write(member, item, key);
|
981
|
+
++i;
|
982
|
+
}
|
983
|
+
}
|
984
|
+
}
|
985
|
+
} else if (ns.isMapSchema()) {
|
986
|
+
if (value && typeof value === "object") {
|
987
|
+
const keySchema = ns.getKeySchema();
|
988
|
+
const memberSchema = ns.getValueSchema();
|
989
|
+
const flat = ns.getMergedTraits().xmlFlattened;
|
990
|
+
let i = 1;
|
991
|
+
for (const [k, v] of Object.entries(value)) {
|
992
|
+
if (v == null) {
|
993
|
+
continue;
|
994
|
+
}
|
995
|
+
const keySuffix = keySchema.getMergedTraits().xmlName ?? "key";
|
996
|
+
const key = flat ? `${prefix}${i}.${keySuffix}` : `${prefix}entry.${i}.${keySuffix}`;
|
997
|
+
const valueSuffix = memberSchema.getMergedTraits().xmlName ?? "value";
|
998
|
+
const valueKey = flat ? `${prefix}${i}.${valueSuffix}` : `${prefix}entry.${i}.${valueSuffix}`;
|
999
|
+
this.write(keySchema, k, key);
|
1000
|
+
this.write(memberSchema, v, valueKey);
|
1001
|
+
++i;
|
1002
|
+
}
|
1003
|
+
}
|
1004
|
+
} else if (ns.isStructSchema()) {
|
1005
|
+
if (value && typeof value === "object") {
|
1006
|
+
for (const [memberName, member] of ns.structIterator()) {
|
1007
|
+
if (value[memberName] == null) {
|
1008
|
+
continue;
|
1009
|
+
}
|
1010
|
+
const suffix = member.getMergedTraits().xmlName ?? memberName;
|
1011
|
+
const key = `${prefix}${suffix}`;
|
1012
|
+
this.write(member, value[memberName], key);
|
1013
|
+
}
|
1014
|
+
}
|
1015
|
+
} else if (ns.isUnitSchema()) {
|
1016
|
+
} else {
|
1017
|
+
throw new Error(`@aws-sdk/core/protocols - QuerySerializer unrecognized schema type ${ns.getName(true)}`);
|
1018
|
+
}
|
1019
|
+
}
|
1020
|
+
flush() {
|
1021
|
+
if (this.buffer === void 0) {
|
1022
|
+
throw new Error("@aws-sdk/core/protocols - QuerySerializer cannot flush with nothing written to buffer.");
|
1023
|
+
}
|
1024
|
+
const str = this.buffer;
|
1025
|
+
delete this.buffer;
|
1026
|
+
return str;
|
1027
|
+
}
|
1028
|
+
writeKey(key) {
|
1029
|
+
if (key.endsWith(".")) {
|
1030
|
+
key = key.slice(0, key.length - 1);
|
1031
|
+
}
|
1032
|
+
this.buffer += `&${(0, import_protocols4.extendedEncodeURIComponent)(key)}=`;
|
1033
|
+
}
|
1034
|
+
writeValue(value) {
|
1035
|
+
this.buffer += (0, import_protocols4.extendedEncodeURIComponent)(value);
|
1036
|
+
}
|
1037
|
+
};
|
1038
|
+
|
1039
|
+
// src/submodules/protocols/query/AwsQueryProtocol.ts
|
1040
|
+
var AwsQueryProtocol = class extends import_protocols5.RpcProtocol {
|
1041
|
+
constructor(options) {
|
1042
|
+
super({
|
1043
|
+
defaultNamespace: options.defaultNamespace
|
1044
|
+
});
|
1045
|
+
this.options = options;
|
1046
|
+
const settings = {
|
1047
|
+
timestampFormat: {
|
1048
|
+
useTrait: true,
|
1049
|
+
default: import_schema7.SCHEMA.TIMESTAMP_DATE_TIME
|
1050
|
+
},
|
1051
|
+
httpBindings: false,
|
1052
|
+
xmlNamespace: options.xmlNamespace,
|
1053
|
+
serviceNamespace: options.defaultNamespace
|
1054
|
+
};
|
1055
|
+
this.serializer = new QueryShapeSerializer(settings);
|
1056
|
+
this.deserializer = new XmlShapeDeserializer(settings);
|
1057
|
+
}
|
1058
|
+
static {
|
1059
|
+
__name(this, "AwsQueryProtocol");
|
1060
|
+
}
|
1061
|
+
serializer;
|
1062
|
+
deserializer;
|
1063
|
+
getShapeId() {
|
1064
|
+
return "aws.protocols#awsQuery";
|
1065
|
+
}
|
1066
|
+
setSerdeContext(serdeContext) {
|
1067
|
+
this.serializer.setSerdeContext(serdeContext);
|
1068
|
+
this.deserializer.setSerdeContext(serdeContext);
|
1069
|
+
}
|
1070
|
+
getPayloadCodec() {
|
1071
|
+
throw new Error("AWSQuery protocol has no payload codec.");
|
1072
|
+
}
|
1073
|
+
async serializeRequest(operationSchema, input, context) {
|
1074
|
+
const request = await super.serializeRequest(operationSchema, input, context);
|
1075
|
+
if (!request.path.endsWith("/")) {
|
1076
|
+
request.path += "/";
|
1077
|
+
}
|
1078
|
+
Object.assign(request.headers, {
|
1079
|
+
"content-type": `application/x-www-form-urlencoded`
|
1080
|
+
});
|
1081
|
+
if ((0, import_schema7.deref)(operationSchema.input) === "unit" || !request.body) {
|
1082
|
+
request.body = "";
|
1083
|
+
}
|
1084
|
+
request.body = `Action=${operationSchema.name.split("#")[1]}&Version=${this.options.version}` + request.body;
|
1085
|
+
if (request.body.endsWith("&")) {
|
1086
|
+
request.body = request.body.slice(-1);
|
1087
|
+
}
|
1088
|
+
try {
|
1089
|
+
request.headers["content-length"] = String((0, import_util_body_length_browser3.calculateBodyLength)(request.body));
|
1090
|
+
} catch (e) {
|
1091
|
+
}
|
1092
|
+
return request;
|
1093
|
+
}
|
1094
|
+
async deserializeResponse(operationSchema, context, response) {
|
1095
|
+
const deserializer = this.deserializer;
|
1096
|
+
const ns = import_schema7.NormalizedSchema.of(operationSchema.output);
|
1097
|
+
const dataObject = {};
|
1098
|
+
if (response.statusCode >= 300) {
|
1099
|
+
const bytes2 = await (0, import_protocols5.collectBody)(response.body, context);
|
1100
|
+
if (bytes2.byteLength > 0) {
|
1101
|
+
Object.assign(dataObject, await deserializer.read(import_schema7.SCHEMA.DOCUMENT, bytes2));
|
1102
|
+
}
|
1103
|
+
await this.handleError(operationSchema, context, response, dataObject, this.deserializeMetadata(response));
|
1104
|
+
}
|
1105
|
+
for (const header in response.headers) {
|
1106
|
+
const value = response.headers[header];
|
1107
|
+
delete response.headers[header];
|
1108
|
+
response.headers[header.toLowerCase()] = value;
|
1109
|
+
}
|
1110
|
+
const awsQueryResultKey = ns.isStructSchema() ? operationSchema.name.split("#")[1] + "Result" : void 0;
|
1111
|
+
const bytes = await (0, import_protocols5.collectBody)(response.body, context);
|
1112
|
+
if (bytes.byteLength > 0) {
|
1113
|
+
Object.assign(dataObject, await deserializer.read(ns, bytes, awsQueryResultKey));
|
1114
|
+
}
|
1115
|
+
const output = {
|
1116
|
+
$metadata: this.deserializeMetadata(response),
|
1117
|
+
...dataObject
|
1118
|
+
};
|
1119
|
+
return output;
|
1120
|
+
}
|
1121
|
+
async handleError(operationSchema, context, response, dataObject, metadata) {
|
1122
|
+
const errorIdentifier = this.loadQueryErrorCode(response, dataObject) ?? "Unknown";
|
1123
|
+
let namespace = this.options.defaultNamespace;
|
1124
|
+
let errorName = errorIdentifier;
|
1125
|
+
if (errorIdentifier.includes("#")) {
|
1126
|
+
[namespace, errorName] = errorIdentifier.split("#");
|
1127
|
+
}
|
1128
|
+
const registry = import_schema7.TypeRegistry.for(namespace);
|
1129
|
+
let errorSchema;
|
1130
|
+
try {
|
1131
|
+
errorSchema = registry.find(
|
1132
|
+
(schema) => import_schema7.NormalizedSchema.of(schema).getMergedTraits().awsQueryError?.[0] === errorName
|
1133
|
+
);
|
1134
|
+
if (!errorSchema) {
|
1135
|
+
errorSchema = registry.getSchema(errorIdentifier);
|
1136
|
+
}
|
1137
|
+
} catch (e) {
|
1138
|
+
const baseExceptionSchema = import_schema7.TypeRegistry.for("awssdkjs.synthetic." + namespace).getBaseException();
|
1139
|
+
if (baseExceptionSchema) {
|
1140
|
+
const ErrorCtor = baseExceptionSchema.ctor;
|
1141
|
+
throw Object.assign(new ErrorCtor(errorName), dataObject);
|
1142
|
+
}
|
1143
|
+
throw new Error(errorName);
|
1144
|
+
}
|
1145
|
+
const ns = import_schema7.NormalizedSchema.of(errorSchema);
|
1146
|
+
const message = dataObject.Error?.message ?? dataObject.Error?.Message ?? dataObject.message ?? dataObject.Message ?? "Unknown";
|
1147
|
+
const exception = new errorSchema.ctor(message);
|
1148
|
+
const output = {};
|
1149
|
+
for (const [name, member] of ns.structIterator()) {
|
1150
|
+
const target = member.getMergedTraits().xmlName ?? name;
|
1151
|
+
const value = dataObject.Error?.[target] ?? dataObject[target];
|
1152
|
+
output[name] = this.deserializer.readSchema(member, value);
|
1153
|
+
}
|
1154
|
+
Object.assign(exception, {
|
1155
|
+
$metadata: metadata,
|
1156
|
+
$response: response,
|
1157
|
+
$fault: ns.getMergedTraits().error,
|
1158
|
+
message,
|
1159
|
+
...output
|
1160
|
+
});
|
1161
|
+
throw exception;
|
1162
|
+
}
|
1163
|
+
loadQueryErrorCode(output, data) {
|
1164
|
+
if (data.Error?.Code !== void 0) {
|
1165
|
+
return data.Error.Code;
|
1166
|
+
}
|
1167
|
+
if (output.statusCode == 404) {
|
1168
|
+
return "NotFound";
|
1169
|
+
}
|
1170
|
+
}
|
1171
|
+
};
|
1172
|
+
|
1173
|
+
// src/submodules/protocols/query/AwsEc2QueryProtocol.ts
|
1174
|
+
var AwsEc2QueryProtocol = class extends AwsQueryProtocol {
|
1175
|
+
static {
|
1176
|
+
__name(this, "AwsEc2QueryProtocol");
|
1177
|
+
}
|
1178
|
+
};
|
1179
|
+
|
1180
|
+
// src/submodules/protocols/xml/AwsRestXmlProtocol.ts
|
1181
|
+
var import_protocols6 = require("@smithy/core/protocols");
|
1182
|
+
var import_schema9 = require("@smithy/core/schema");
|
1183
|
+
var import_util_body_length_browser4 = require("@smithy/util-body-length-browser");
|
1184
|
+
|
1185
|
+
// src/submodules/protocols/xml/parseXmlBody.ts
|
1186
|
+
var import_smithy_client5 = require("@smithy/smithy-client");
|
1187
|
+
var import_fast_xml_parser2 = require("fast-xml-parser");
|
165
1188
|
var parseXmlBody = /* @__PURE__ */ __name((streamBody, context) => collectBodyString(streamBody, context).then((encoded) => {
|
166
1189
|
if (encoded.length) {
|
167
|
-
const parser = new
|
1190
|
+
const parser = new import_fast_xml_parser2.XMLParser({
|
168
1191
|
attributeNamePrefix: "",
|
169
1192
|
htmlEntities: true,
|
170
1193
|
ignoreAttributes: false,
|
@@ -193,7 +1216,7 @@ var parseXmlBody = /* @__PURE__ */ __name((streamBody, context) => collectBodySt
|
|
193
1216
|
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
|
194
1217
|
delete parsedObjToReturn[textNodeName];
|
195
1218
|
}
|
196
|
-
return (0,
|
1219
|
+
return (0, import_smithy_client5.getValueFromTextNode)(parsedObjToReturn);
|
197
1220
|
}
|
198
1221
|
return {};
|
199
1222
|
}), "parseXmlBody");
|
@@ -215,8 +1238,437 @@ var loadRestXmlErrorCode = /* @__PURE__ */ __name((output, data) => {
|
|
215
1238
|
return "NotFound";
|
216
1239
|
}
|
217
1240
|
}, "loadRestXmlErrorCode");
|
1241
|
+
|
1242
|
+
// src/submodules/protocols/xml/XmlShapeSerializer.ts
|
1243
|
+
var import_xml_builder = require("@aws-sdk/xml-builder");
|
1244
|
+
var import_schema8 = require("@smithy/core/schema");
|
1245
|
+
var import_serde7 = require("@smithy/core/serde");
|
1246
|
+
var import_smithy_client6 = require("@smithy/smithy-client");
|
1247
|
+
var import_util_base643 = require("@smithy/util-base64");
|
1248
|
+
var XmlShapeSerializer = class extends SerdeContextConfig {
|
1249
|
+
constructor(settings) {
|
1250
|
+
super();
|
1251
|
+
this.settings = settings;
|
1252
|
+
}
|
1253
|
+
static {
|
1254
|
+
__name(this, "XmlShapeSerializer");
|
1255
|
+
}
|
1256
|
+
stringBuffer;
|
1257
|
+
byteBuffer;
|
1258
|
+
buffer;
|
1259
|
+
write(schema, value) {
|
1260
|
+
const ns = import_schema8.NormalizedSchema.of(schema);
|
1261
|
+
if (ns.isStringSchema() && typeof value === "string") {
|
1262
|
+
this.stringBuffer = value;
|
1263
|
+
} else if (ns.isBlobSchema()) {
|
1264
|
+
this.byteBuffer = "byteLength" in value ? value : (this.serdeContext?.base64Decoder ?? import_util_base643.fromBase64)(value);
|
1265
|
+
} else {
|
1266
|
+
this.buffer = this.writeStruct(ns, value, void 0);
|
1267
|
+
const traits = ns.getMergedTraits();
|
1268
|
+
if (traits.httpPayload && !traits.xmlName) {
|
1269
|
+
this.buffer.withName(ns.getName());
|
1270
|
+
}
|
1271
|
+
}
|
1272
|
+
}
|
1273
|
+
flush() {
|
1274
|
+
if (this.byteBuffer !== void 0) {
|
1275
|
+
const bytes = this.byteBuffer;
|
1276
|
+
delete this.byteBuffer;
|
1277
|
+
return bytes;
|
1278
|
+
}
|
1279
|
+
if (this.stringBuffer !== void 0) {
|
1280
|
+
const str = this.stringBuffer;
|
1281
|
+
delete this.stringBuffer;
|
1282
|
+
return str;
|
1283
|
+
}
|
1284
|
+
const buffer = this.buffer;
|
1285
|
+
if (this.settings.xmlNamespace) {
|
1286
|
+
if (!buffer?.attributes?.["xmlns"]) {
|
1287
|
+
buffer.addAttribute("xmlns", this.settings.xmlNamespace);
|
1288
|
+
}
|
1289
|
+
}
|
1290
|
+
delete this.buffer;
|
1291
|
+
return buffer.toString();
|
1292
|
+
}
|
1293
|
+
writeStruct(ns, value, parentXmlns) {
|
1294
|
+
const traits = ns.getMergedTraits();
|
1295
|
+
const name = ns.isMemberSchema() && !traits.httpPayload ? ns.getMemberTraits().xmlName ?? ns.getMemberName() : traits.xmlName ?? ns.getName();
|
1296
|
+
if (!name || !ns.isStructSchema()) {
|
1297
|
+
throw new Error(
|
1298
|
+
`@aws-sdk/core/protocols - xml serializer, cannot write struct with empty name or non-struct, schema=${ns.getName(
|
1299
|
+
true
|
1300
|
+
)}.`
|
1301
|
+
);
|
1302
|
+
}
|
1303
|
+
const structXmlNode = import_xml_builder.XmlNode.of(name);
|
1304
|
+
const [xmlnsAttr, xmlns] = this.getXmlnsAttribute(ns, parentXmlns);
|
1305
|
+
if (xmlns) {
|
1306
|
+
structXmlNode.addAttribute(xmlnsAttr, xmlns);
|
1307
|
+
}
|
1308
|
+
for (const [memberName, memberSchema] of ns.structIterator()) {
|
1309
|
+
const val = value[memberName];
|
1310
|
+
if (val != null) {
|
1311
|
+
if (memberSchema.getMergedTraits().xmlAttribute) {
|
1312
|
+
structXmlNode.addAttribute(
|
1313
|
+
memberSchema.getMergedTraits().xmlName ?? memberName,
|
1314
|
+
this.writeSimple(memberSchema, val)
|
1315
|
+
);
|
1316
|
+
continue;
|
1317
|
+
}
|
1318
|
+
if (memberSchema.isListSchema()) {
|
1319
|
+
this.writeList(memberSchema, val, structXmlNode, xmlns);
|
1320
|
+
} else if (memberSchema.isMapSchema()) {
|
1321
|
+
this.writeMap(memberSchema, val, structXmlNode, xmlns);
|
1322
|
+
} else if (memberSchema.isStructSchema()) {
|
1323
|
+
structXmlNode.addChildNode(this.writeStruct(memberSchema, val, xmlns));
|
1324
|
+
} else {
|
1325
|
+
const memberNode = import_xml_builder.XmlNode.of(memberSchema.getMergedTraits().xmlName ?? memberSchema.getMemberName());
|
1326
|
+
this.writeSimpleInto(memberSchema, val, memberNode, xmlns);
|
1327
|
+
structXmlNode.addChildNode(memberNode);
|
1328
|
+
}
|
1329
|
+
}
|
1330
|
+
}
|
1331
|
+
return structXmlNode;
|
1332
|
+
}
|
1333
|
+
writeList(listMember, array, container, parentXmlns) {
|
1334
|
+
if (!listMember.isMemberSchema()) {
|
1335
|
+
throw new Error(
|
1336
|
+
`@aws-sdk/core/protocols - xml serializer, cannot write non-member list: ${listMember.getName(true)}`
|
1337
|
+
);
|
1338
|
+
}
|
1339
|
+
const listTraits = listMember.getMergedTraits();
|
1340
|
+
const listValueSchema = listMember.getValueSchema();
|
1341
|
+
const listValueTraits = listValueSchema.getMergedTraits();
|
1342
|
+
const sparse = !!listValueTraits.sparse;
|
1343
|
+
const flat = !!listTraits.xmlFlattened;
|
1344
|
+
const [xmlnsAttr, xmlns] = this.getXmlnsAttribute(listMember, parentXmlns);
|
1345
|
+
const writeItem = /* @__PURE__ */ __name((container2, value) => {
|
1346
|
+
if (listValueSchema.isListSchema()) {
|
1347
|
+
this.writeList(listValueSchema, Array.isArray(value) ? value : [value], container2, xmlns);
|
1348
|
+
} else if (listValueSchema.isMapSchema()) {
|
1349
|
+
this.writeMap(listValueSchema, value, container2, xmlns);
|
1350
|
+
} else if (listValueSchema.isStructSchema()) {
|
1351
|
+
const struct = this.writeStruct(listValueSchema, value, xmlns);
|
1352
|
+
container2.addChildNode(
|
1353
|
+
struct.withName(flat ? listTraits.xmlName ?? listMember.getMemberName() : listValueTraits.xmlName ?? "member")
|
1354
|
+
);
|
1355
|
+
} else {
|
1356
|
+
const listItemNode = import_xml_builder.XmlNode.of(
|
1357
|
+
flat ? listTraits.xmlName ?? listMember.getMemberName() : listValueTraits.xmlName ?? "member"
|
1358
|
+
);
|
1359
|
+
this.writeSimpleInto(listValueSchema, value, listItemNode, xmlns);
|
1360
|
+
container2.addChildNode(listItemNode);
|
1361
|
+
}
|
1362
|
+
}, "writeItem");
|
1363
|
+
if (flat) {
|
1364
|
+
for (const value of array) {
|
1365
|
+
if (sparse || value != null) {
|
1366
|
+
writeItem(container, value);
|
1367
|
+
}
|
1368
|
+
}
|
1369
|
+
} else {
|
1370
|
+
const listNode = import_xml_builder.XmlNode.of(listTraits.xmlName ?? listMember.getMemberName());
|
1371
|
+
if (xmlns) {
|
1372
|
+
listNode.addAttribute(xmlnsAttr, xmlns);
|
1373
|
+
}
|
1374
|
+
for (const value of array) {
|
1375
|
+
if (sparse || value != null) {
|
1376
|
+
writeItem(listNode, value);
|
1377
|
+
}
|
1378
|
+
}
|
1379
|
+
container.addChildNode(listNode);
|
1380
|
+
}
|
1381
|
+
}
|
1382
|
+
writeMap(mapMember, map, container, parentXmlns, containerIsMap = false) {
|
1383
|
+
if (!mapMember.isMemberSchema()) {
|
1384
|
+
throw new Error(
|
1385
|
+
`@aws-sdk/core/protocols - xml serializer, cannot write non-member map: ${mapMember.getName(true)}`
|
1386
|
+
);
|
1387
|
+
}
|
1388
|
+
const mapTraits = mapMember.getMergedTraits();
|
1389
|
+
const mapKeySchema = mapMember.getKeySchema();
|
1390
|
+
const mapKeyTraits = mapKeySchema.getMergedTraits();
|
1391
|
+
const keyTag = mapKeyTraits.xmlName ?? "key";
|
1392
|
+
const mapValueSchema = mapMember.getValueSchema();
|
1393
|
+
const mapValueTraits = mapValueSchema.getMergedTraits();
|
1394
|
+
const valueTag = mapValueTraits.xmlName ?? "value";
|
1395
|
+
const sparse = !!mapValueTraits.sparse;
|
1396
|
+
const flat = !!mapTraits.xmlFlattened;
|
1397
|
+
const [xmlnsAttr, xmlns] = this.getXmlnsAttribute(mapMember, parentXmlns);
|
1398
|
+
const addKeyValue = /* @__PURE__ */ __name((entry, key, val) => {
|
1399
|
+
const keyNode = import_xml_builder.XmlNode.of(keyTag, key);
|
1400
|
+
const [keyXmlnsAttr, keyXmlns] = this.getXmlnsAttribute(mapKeySchema, xmlns);
|
1401
|
+
if (keyXmlns) {
|
1402
|
+
keyNode.addAttribute(keyXmlnsAttr, keyXmlns);
|
1403
|
+
}
|
1404
|
+
entry.addChildNode(keyNode);
|
1405
|
+
let valueNode = import_xml_builder.XmlNode.of(valueTag);
|
1406
|
+
if (mapValueSchema.isListSchema()) {
|
1407
|
+
this.writeList(mapValueSchema, val, valueNode, xmlns);
|
1408
|
+
} else if (mapValueSchema.isMapSchema()) {
|
1409
|
+
this.writeMap(mapValueSchema, val, valueNode, xmlns, true);
|
1410
|
+
} else if (mapValueSchema.isStructSchema()) {
|
1411
|
+
valueNode = this.writeStruct(mapValueSchema, val, xmlns);
|
1412
|
+
} else {
|
1413
|
+
this.writeSimpleInto(mapValueSchema, val, valueNode, xmlns);
|
1414
|
+
}
|
1415
|
+
entry.addChildNode(valueNode);
|
1416
|
+
}, "addKeyValue");
|
1417
|
+
if (flat) {
|
1418
|
+
for (const [key, val] of Object.entries(map)) {
|
1419
|
+
if (sparse || val != null) {
|
1420
|
+
const entry = import_xml_builder.XmlNode.of(mapTraits.xmlName ?? mapMember.getMemberName());
|
1421
|
+
addKeyValue(entry, key, val);
|
1422
|
+
container.addChildNode(entry);
|
1423
|
+
}
|
1424
|
+
}
|
1425
|
+
} else {
|
1426
|
+
let mapNode;
|
1427
|
+
if (!containerIsMap) {
|
1428
|
+
mapNode = import_xml_builder.XmlNode.of(mapTraits.xmlName ?? mapMember.getMemberName());
|
1429
|
+
if (xmlns) {
|
1430
|
+
mapNode.addAttribute(xmlnsAttr, xmlns);
|
1431
|
+
}
|
1432
|
+
container.addChildNode(mapNode);
|
1433
|
+
}
|
1434
|
+
for (const [key, val] of Object.entries(map)) {
|
1435
|
+
if (sparse || val != null) {
|
1436
|
+
const entry = import_xml_builder.XmlNode.of("entry");
|
1437
|
+
addKeyValue(entry, key, val);
|
1438
|
+
(containerIsMap ? container : mapNode).addChildNode(entry);
|
1439
|
+
}
|
1440
|
+
}
|
1441
|
+
}
|
1442
|
+
}
|
1443
|
+
writeSimple(_schema, value) {
|
1444
|
+
if (null === value) {
|
1445
|
+
throw new Error("@aws-sdk/core/protocols - (XML serializer) cannot write null value.");
|
1446
|
+
}
|
1447
|
+
const ns = import_schema8.NormalizedSchema.of(_schema);
|
1448
|
+
let nodeContents = null;
|
1449
|
+
if (value && typeof value === "object") {
|
1450
|
+
if (ns.isBlobSchema()) {
|
1451
|
+
nodeContents = (this.serdeContext?.base64Encoder ?? import_util_base643.toBase64)(value);
|
1452
|
+
} else if (ns.isTimestampSchema() && value instanceof Date) {
|
1453
|
+
const options = this.settings.timestampFormat;
|
1454
|
+
const format = options.useTrait ? ns.getSchema() === import_schema8.SCHEMA.TIMESTAMP_DEFAULT ? options.default : ns.getSchema() ?? options.default : options.default;
|
1455
|
+
switch (format) {
|
1456
|
+
case import_schema8.SCHEMA.TIMESTAMP_DATE_TIME:
|
1457
|
+
nodeContents = value.toISOString().replace(".000Z", "Z");
|
1458
|
+
break;
|
1459
|
+
case import_schema8.SCHEMA.TIMESTAMP_HTTP_DATE:
|
1460
|
+
nodeContents = (0, import_smithy_client6.dateToUtcString)(value);
|
1461
|
+
break;
|
1462
|
+
case import_schema8.SCHEMA.TIMESTAMP_EPOCH_SECONDS:
|
1463
|
+
nodeContents = String(value.getTime() / 1e3);
|
1464
|
+
break;
|
1465
|
+
default:
|
1466
|
+
console.warn("Missing timestamp format, using http date", value);
|
1467
|
+
nodeContents = (0, import_smithy_client6.dateToUtcString)(value);
|
1468
|
+
break;
|
1469
|
+
}
|
1470
|
+
} else if (ns.isBigDecimalSchema() && value) {
|
1471
|
+
if (value instanceof import_serde7.NumericValue) {
|
1472
|
+
return value.string;
|
1473
|
+
}
|
1474
|
+
return String(value);
|
1475
|
+
} else if (ns.isMapSchema() || ns.isListSchema()) {
|
1476
|
+
throw new Error(
|
1477
|
+
"@aws-sdk/core/protocols - xml serializer, cannot call _write() on List/Map schema, call writeList or writeMap() instead."
|
1478
|
+
);
|
1479
|
+
} else {
|
1480
|
+
throw new Error(
|
1481
|
+
`@aws-sdk/core/protocols - xml serializer, unhandled schema type for object value and schema: ${ns.getName(
|
1482
|
+
true
|
1483
|
+
)}`
|
1484
|
+
);
|
1485
|
+
}
|
1486
|
+
}
|
1487
|
+
if (ns.isStringSchema() || ns.isBooleanSchema() || ns.isNumericSchema() || ns.isBigIntegerSchema() || ns.isBigDecimalSchema()) {
|
1488
|
+
nodeContents = String(value);
|
1489
|
+
}
|
1490
|
+
if (nodeContents === null) {
|
1491
|
+
throw new Error(`Unhandled schema-value pair ${ns.getName(true)}=${value}`);
|
1492
|
+
}
|
1493
|
+
return nodeContents;
|
1494
|
+
}
|
1495
|
+
writeSimpleInto(_schema, value, into, parentXmlns) {
|
1496
|
+
const nodeContents = this.writeSimple(_schema, value);
|
1497
|
+
const ns = import_schema8.NormalizedSchema.of(_schema);
|
1498
|
+
const content = new import_xml_builder.XmlText(nodeContents);
|
1499
|
+
const [xmlnsAttr, xmlns] = this.getXmlnsAttribute(ns, parentXmlns);
|
1500
|
+
if (xmlns) {
|
1501
|
+
into.addAttribute(xmlnsAttr, xmlns);
|
1502
|
+
}
|
1503
|
+
into.addChildNode(content);
|
1504
|
+
}
|
1505
|
+
getXmlnsAttribute(ns, parentXmlns) {
|
1506
|
+
const traits = ns.getMergedTraits();
|
1507
|
+
const [prefix, xmlns] = traits.xmlNamespace ?? [];
|
1508
|
+
if (xmlns && xmlns !== parentXmlns) {
|
1509
|
+
return [prefix ? `xmlns:${prefix}` : "xmlns", xmlns];
|
1510
|
+
}
|
1511
|
+
return [void 0, void 0];
|
1512
|
+
}
|
1513
|
+
};
|
1514
|
+
|
1515
|
+
// src/submodules/protocols/xml/XmlCodec.ts
|
1516
|
+
var XmlCodec = class extends SerdeContextConfig {
|
1517
|
+
constructor(settings) {
|
1518
|
+
super();
|
1519
|
+
this.settings = settings;
|
1520
|
+
}
|
1521
|
+
static {
|
1522
|
+
__name(this, "XmlCodec");
|
1523
|
+
}
|
1524
|
+
createSerializer() {
|
1525
|
+
const serializer = new XmlShapeSerializer(this.settings);
|
1526
|
+
serializer.setSerdeContext(this.serdeContext);
|
1527
|
+
return serializer;
|
1528
|
+
}
|
1529
|
+
createDeserializer() {
|
1530
|
+
const deserializer = new XmlShapeDeserializer(this.settings);
|
1531
|
+
deserializer.setSerdeContext(this.serdeContext);
|
1532
|
+
return deserializer;
|
1533
|
+
}
|
1534
|
+
};
|
1535
|
+
|
1536
|
+
// src/submodules/protocols/xml/AwsRestXmlProtocol.ts
|
1537
|
+
var AwsRestXmlProtocol = class extends import_protocols6.HttpBindingProtocol {
|
1538
|
+
static {
|
1539
|
+
__name(this, "AwsRestXmlProtocol");
|
1540
|
+
}
|
1541
|
+
codec;
|
1542
|
+
serializer;
|
1543
|
+
deserializer;
|
1544
|
+
constructor(options) {
|
1545
|
+
super(options);
|
1546
|
+
const settings = {
|
1547
|
+
timestampFormat: {
|
1548
|
+
useTrait: true,
|
1549
|
+
default: import_schema9.SCHEMA.TIMESTAMP_DATE_TIME
|
1550
|
+
},
|
1551
|
+
httpBindings: true,
|
1552
|
+
xmlNamespace: options.xmlNamespace,
|
1553
|
+
serviceNamespace: options.defaultNamespace
|
1554
|
+
};
|
1555
|
+
this.codec = new XmlCodec(settings);
|
1556
|
+
this.serializer = new import_protocols6.HttpInterceptingShapeSerializer(this.codec.createSerializer(), settings);
|
1557
|
+
this.deserializer = new import_protocols6.HttpInterceptingShapeDeserializer(this.codec.createDeserializer(), settings);
|
1558
|
+
}
|
1559
|
+
getPayloadCodec() {
|
1560
|
+
return this.codec;
|
1561
|
+
}
|
1562
|
+
getShapeId() {
|
1563
|
+
return "aws.protocols#restXml";
|
1564
|
+
}
|
1565
|
+
async serializeRequest(operationSchema, input, context) {
|
1566
|
+
const request = await super.serializeRequest(operationSchema, input, context);
|
1567
|
+
const ns = import_schema9.NormalizedSchema.of(operationSchema.input);
|
1568
|
+
const members = ns.getMemberSchemas();
|
1569
|
+
request.path = String(request.path).split("/").filter((segment) => {
|
1570
|
+
return segment !== "{Bucket}";
|
1571
|
+
}).join("/") || "/";
|
1572
|
+
if (!request.headers["content-type"]) {
|
1573
|
+
const httpPayloadMember = Object.values(members).find((m) => {
|
1574
|
+
return !!m.getMergedTraits().httpPayload;
|
1575
|
+
});
|
1576
|
+
if (httpPayloadMember) {
|
1577
|
+
const mediaType = httpPayloadMember.getMergedTraits().mediaType;
|
1578
|
+
if (mediaType) {
|
1579
|
+
request.headers["content-type"] = mediaType;
|
1580
|
+
} else if (httpPayloadMember.isStringSchema()) {
|
1581
|
+
request.headers["content-type"] = "text/plain";
|
1582
|
+
} else if (httpPayloadMember.isBlobSchema()) {
|
1583
|
+
request.headers["content-type"] = "application/octet-stream";
|
1584
|
+
} else {
|
1585
|
+
request.headers["content-type"] = "application/xml";
|
1586
|
+
}
|
1587
|
+
} else if (!ns.isUnitSchema()) {
|
1588
|
+
const hasBody = Object.values(members).find((m) => {
|
1589
|
+
const { httpQuery, httpQueryParams, httpHeader, httpLabel, httpPrefixHeaders } = m.getMergedTraits();
|
1590
|
+
return !httpQuery && !httpQueryParams && !httpHeader && !httpLabel && httpPrefixHeaders === void 0;
|
1591
|
+
});
|
1592
|
+
if (hasBody) {
|
1593
|
+
request.headers["content-type"] = "application/xml";
|
1594
|
+
}
|
1595
|
+
}
|
1596
|
+
}
|
1597
|
+
if (request.headers["content-type"] === "application/xml") {
|
1598
|
+
if (typeof request.body === "string") {
|
1599
|
+
request.body = '<?xml version="1.0" encoding="UTF-8"?>' + request.body;
|
1600
|
+
}
|
1601
|
+
}
|
1602
|
+
if (request.body) {
|
1603
|
+
try {
|
1604
|
+
request.headers["content-length"] = String((0, import_util_body_length_browser4.calculateBodyLength)(request.body));
|
1605
|
+
} catch (e) {
|
1606
|
+
}
|
1607
|
+
}
|
1608
|
+
return request;
|
1609
|
+
}
|
1610
|
+
async deserializeResponse(operationSchema, context, response) {
|
1611
|
+
return super.deserializeResponse(operationSchema, context, response);
|
1612
|
+
}
|
1613
|
+
async handleError(operationSchema, context, response, dataObject, metadata) {
|
1614
|
+
const errorIdentifier = loadRestXmlErrorCode(response, dataObject) ?? "Unknown";
|
1615
|
+
let namespace = this.options.defaultNamespace;
|
1616
|
+
let errorName = errorIdentifier;
|
1617
|
+
if (errorIdentifier.includes("#")) {
|
1618
|
+
[namespace, errorName] = errorIdentifier.split("#");
|
1619
|
+
}
|
1620
|
+
const registry = import_schema9.TypeRegistry.for(namespace);
|
1621
|
+
let errorSchema;
|
1622
|
+
try {
|
1623
|
+
errorSchema = registry.getSchema(errorIdentifier);
|
1624
|
+
} catch (e) {
|
1625
|
+
const baseExceptionSchema = import_schema9.TypeRegistry.for("awssdkjs.synthetic." + namespace).getBaseException();
|
1626
|
+
if (baseExceptionSchema) {
|
1627
|
+
const ErrorCtor = baseExceptionSchema.ctor;
|
1628
|
+
throw Object.assign(new ErrorCtor(errorName), dataObject);
|
1629
|
+
}
|
1630
|
+
throw new Error(errorName);
|
1631
|
+
}
|
1632
|
+
const ns = import_schema9.NormalizedSchema.of(errorSchema);
|
1633
|
+
const message = dataObject.Error?.message ?? dataObject.Error?.Message ?? dataObject.message ?? dataObject.Message ?? "Unknown";
|
1634
|
+
const exception = new errorSchema.ctor(message);
|
1635
|
+
const headerBindings = new Set(
|
1636
|
+
Object.values(import_schema9.NormalizedSchema.of(errorSchema).getMemberSchemas()).map((schema) => {
|
1637
|
+
return schema.getMergedTraits().httpHeader;
|
1638
|
+
}).filter(Boolean)
|
1639
|
+
);
|
1640
|
+
await this.deserializeHttpMessage(errorSchema, context, response, headerBindings, dataObject);
|
1641
|
+
const output = {};
|
1642
|
+
for (const [name, member] of ns.structIterator()) {
|
1643
|
+
const target = member.getMergedTraits().xmlName ?? name;
|
1644
|
+
const value = dataObject.Error?.[target] ?? dataObject[target];
|
1645
|
+
output[name] = this.codec.createDeserializer().readSchema(member, value);
|
1646
|
+
}
|
1647
|
+
Object.assign(exception, {
|
1648
|
+
$metadata: metadata,
|
1649
|
+
$response: response,
|
1650
|
+
$fault: ns.getMergedTraits().error,
|
1651
|
+
message,
|
1652
|
+
...output
|
1653
|
+
});
|
1654
|
+
throw exception;
|
1655
|
+
}
|
1656
|
+
};
|
218
1657
|
// Annotate the CommonJS export names for ESM import in node:
|
219
1658
|
0 && (module.exports = {
|
1659
|
+
AwsEc2QueryProtocol,
|
1660
|
+
AwsJson1_0Protocol,
|
1661
|
+
AwsJson1_1Protocol,
|
1662
|
+
AwsJsonRpcProtocol,
|
1663
|
+
AwsQueryProtocol,
|
1664
|
+
AwsRestJsonProtocol,
|
1665
|
+
AwsRestXmlProtocol,
|
1666
|
+
JsonCodec,
|
1667
|
+
JsonShapeDeserializer,
|
1668
|
+
JsonShapeSerializer,
|
1669
|
+
XmlCodec,
|
1670
|
+
XmlShapeDeserializer,
|
1671
|
+
XmlShapeSerializer,
|
220
1672
|
_toBool,
|
221
1673
|
_toNum,
|
222
1674
|
_toStr,
|