@cdk8s/awscdk-resolver 0.0.348 → 0.0.350

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.
Files changed (104) hide show
  1. package/.jsii +3 -3
  2. package/lib/resolve.js +1 -1
  3. package/node_modules/@aws-sdk/client-cloudformation/package.json +12 -12
  4. package/node_modules/@aws-sdk/client-sso/package.json +11 -11
  5. package/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js +320 -216
  6. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/ProtocolLib.js +94 -0
  7. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/cbor/AwsSmithyRpcV2CborProtocol.js +39 -0
  8. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/common.js +2 -1
  9. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/index.js +1 -0
  10. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsJson1_0Protocol.js +2 -1
  11. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsJson1_1Protocol.js +2 -1
  12. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsJsonRpcProtocol.js +17 -31
  13. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsRestJsonProtocol.js +8 -56
  14. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/query/AwsQueryProtocol.js +5 -32
  15. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/xml/AwsRestXmlProtocol.js +9 -57
  16. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/ProtocolLib.d.ts +57 -0
  17. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/cbor/AwsSmithyRpcV2CborProtocol.d.ts +23 -0
  18. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/index.d.ts +1 -0
  19. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsJson1_0Protocol.d.ts +2 -1
  20. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsJson1_1Protocol.d.ts +2 -1
  21. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +6 -3
  22. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsRestJsonProtocol.d.ts +2 -1
  23. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/query/AwsQueryProtocol.d.ts +2 -2
  24. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/xml/AwsRestXmlProtocol.d.ts +1 -0
  25. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/ProtocolLib.d.ts +39 -0
  26. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/cbor/AwsSmithyRpcV2CborProtocol.d.ts +33 -0
  27. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/index.d.ts +1 -0
  28. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJson1_0Protocol.d.ts +2 -0
  29. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJson1_1Protocol.d.ts +2 -0
  30. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +5 -1
  31. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsRestJsonProtocol.d.ts +1 -0
  32. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/query/AwsQueryProtocol.d.ts +2 -1
  33. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/xml/AwsRestXmlProtocol.d.ts +1 -0
  34. package/node_modules/@aws-sdk/core/package.json +3 -3
  35. package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
  36. package/node_modules/@aws-sdk/credential-provider-http/package.json +3 -3
  37. package/node_modules/@aws-sdk/credential-provider-ini/package.json +8 -8
  38. package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
  39. package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
  40. package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
  41. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
  42. package/node_modules/@aws-sdk/middleware-user-agent/package.json +4 -4
  43. package/node_modules/@aws-sdk/nested-clients/package.json +11 -11
  44. package/node_modules/@aws-sdk/token-providers/package.json +3 -3
  45. package/node_modules/@aws-sdk/util-endpoints/dist-cjs/index.js +4 -1
  46. package/node_modules/@aws-sdk/util-endpoints/dist-cjs/lib/aws/partitions.json +4 -1
  47. package/node_modules/@aws-sdk/util-endpoints/dist-es/lib/aws/partitions.json +4 -1
  48. package/node_modules/@aws-sdk/util-endpoints/package.json +1 -1
  49. package/node_modules/@aws-sdk/util-user-agent-node/package.json +2 -2
  50. package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +44 -15
  51. package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.js +261 -0
  52. package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +129 -39
  53. package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +25 -0
  54. package/node_modules/@smithy/core/dist-es/submodules/cbor/SmithyRpcV2CborProtocol.js +36 -15
  55. package/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js +200 -0
  56. package/node_modules/@smithy/core/dist-es/submodules/event-streams/index.js +1 -0
  57. package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpBindingProtocol.js +11 -26
  58. package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +36 -0
  59. package/node_modules/@smithy/core/dist-es/submodules/protocols/RpcProtocol.js +36 -10
  60. package/node_modules/@smithy/core/dist-es/submodules/protocols/index.js +1 -0
  61. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/NormalizedSchema.js +17 -0
  62. package/node_modules/@smithy/core/dist-types/submodules/cbor/CborCodec.d.ts +6 -2
  63. package/node_modules/@smithy/core/dist-types/submodules/cbor/SmithyRpcV2CborProtocol.d.ts +1 -0
  64. package/node_modules/@smithy/core/dist-types/submodules/cbor/parseCborBody.d.ts +1 -1
  65. package/node_modules/@smithy/core/dist-types/submodules/event-streams/EventStreamSerde.d.ts +60 -0
  66. package/node_modules/@smithy/core/dist-types/submodules/event-streams/index.d.ts +1 -0
  67. package/node_modules/@smithy/core/dist-types/submodules/protocols/HttpBindingProtocol.d.ts +1 -1
  68. package/node_modules/@smithy/core/dist-types/submodules/protocols/HttpProtocol.d.ts +39 -1
  69. package/node_modules/@smithy/core/dist-types/submodules/protocols/RpcProtocol.d.ts +1 -1
  70. package/node_modules/@smithy/core/dist-types/submodules/protocols/index.d.ts +1 -0
  71. package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/FromStringShapeDeserializer.d.ts +1 -1
  72. package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/HttpInterceptingShapeDeserializer.d.ts +1 -1
  73. package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/HttpInterceptingShapeSerializer.d.ts +1 -1
  74. package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/ToStringShapeSerializer.d.ts +1 -1
  75. package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/determineTimestampFormat.d.ts +1 -1
  76. package/node_modules/@smithy/core/dist-types/submodules/schema/middleware/getSchemaSerdePlugin.d.ts +1 -1
  77. package/node_modules/@smithy/core/dist-types/submodules/schema/middleware/schemaDeserializationMiddleware.d.ts +1 -1
  78. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/NormalizedSchema.d.ts +10 -0
  79. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/SimpleSchema.d.ts +1 -1
  80. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/sentinels.d.ts +1 -1
  81. package/node_modules/@smithy/core/dist-types/submodules/serde/copyDocumentWithTransform.d.ts +1 -1
  82. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/CborCodec.d.ts +5 -1
  83. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/SmithyRpcV2CborProtocol.d.ts +1 -0
  84. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/event-streams/EventStreamSerde.d.ts +60 -0
  85. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/event-streams/index.d.ts +1 -0
  86. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/HttpProtocol.d.ts +39 -1
  87. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/index.d.ts +1 -0
  88. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/serde/determineTimestampFormat.d.ts +1 -1
  89. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/NormalizedSchema.d.ts +10 -0
  90. package/node_modules/@smithy/core/event-streams.d.ts +7 -0
  91. package/node_modules/@smithy/core/event-streams.js +6 -0
  92. package/node_modules/@smithy/core/package.json +11 -1
  93. package/node_modules/@smithy/middleware-endpoint/package.json +2 -2
  94. package/node_modules/@smithy/middleware-retry/package.json +4 -4
  95. package/node_modules/@smithy/smithy-client/dist-cjs/index.js +43 -6
  96. package/node_modules/@smithy/smithy-client/dist-cjs/schemaLogFilter.js +1 -0
  97. package/node_modules/@smithy/smithy-client/dist-es/command.js +7 -4
  98. package/node_modules/@smithy/smithy-client/dist-es/schemaLogFilter.js +34 -0
  99. package/node_modules/@smithy/smithy-client/dist-types/schemaLogFilter.d.ts +9 -0
  100. package/node_modules/@smithy/smithy-client/dist-types/ts3.4/schemaLogFilter.d.ts +9 -0
  101. package/node_modules/@smithy/smithy-client/package.json +3 -3
  102. package/node_modules/@smithy/util-defaults-mode-browser/package.json +2 -2
  103. package/node_modules/@smithy/util-defaults-mode-node/package.json +2 -2
  104. package/package.json +4 -4
@@ -28,6 +28,7 @@ __export(index_exports, {
28
28
  AwsQueryProtocol: () => AwsQueryProtocol,
29
29
  AwsRestJsonProtocol: () => AwsRestJsonProtocol,
30
30
  AwsRestXmlProtocol: () => AwsRestXmlProtocol,
31
+ AwsSmithyRpcV2CborProtocol: () => AwsSmithyRpcV2CborProtocol,
31
32
  JsonCodec: () => JsonCodec,
32
33
  JsonShapeDeserializer: () => JsonShapeDeserializer,
33
34
  JsonShapeSerializer: () => JsonShapeSerializer,
@@ -47,6 +48,197 @@ __export(index_exports, {
47
48
  });
48
49
  module.exports = __toCommonJS(index_exports);
49
50
 
51
+ // src/submodules/protocols/cbor/AwsSmithyRpcV2CborProtocol.ts
52
+ var import_cbor = require("@smithy/core/cbor");
53
+ var import_schema2 = require("@smithy/core/schema");
54
+
55
+ // src/submodules/protocols/ProtocolLib.ts
56
+ var import_schema = require("@smithy/core/schema");
57
+ var import_util_body_length_browser = require("@smithy/util-body-length-browser");
58
+ var ProtocolLib = class {
59
+ static {
60
+ __name(this, "ProtocolLib");
61
+ }
62
+ /**
63
+ * @param body - to be inspected.
64
+ * @param serdeContext - this is a subset type but in practice is the client.config having a property called bodyLengthChecker.
65
+ *
66
+ * @returns content-length value for the body if possible.
67
+ * @throws Error and should be caught and handled if not possible to determine length.
68
+ */
69
+ calculateContentLength(body, serdeContext) {
70
+ const bodyLengthCalculator = serdeContext?.bodyLengthChecker ?? import_util_body_length_browser.calculateBodyLength;
71
+ return String(bodyLengthCalculator(body));
72
+ }
73
+ /**
74
+ * This is only for REST protocols.
75
+ *
76
+ * @param defaultContentType - of the protocol.
77
+ * @param inputSchema - schema for which to determine content type.
78
+ *
79
+ * @returns content-type header value or undefined when not applicable.
80
+ */
81
+ resolveRestContentType(defaultContentType, inputSchema) {
82
+ const members = inputSchema.getMemberSchemas();
83
+ const httpPayloadMember = Object.values(members).find((m) => {
84
+ return !!m.getMergedTraits().httpPayload;
85
+ });
86
+ if (httpPayloadMember) {
87
+ const mediaType = httpPayloadMember.getMergedTraits().mediaType;
88
+ if (mediaType) {
89
+ return mediaType;
90
+ } else if (httpPayloadMember.isStringSchema()) {
91
+ return "text/plain";
92
+ } else if (httpPayloadMember.isBlobSchema()) {
93
+ return "application/octet-stream";
94
+ } else {
95
+ return defaultContentType;
96
+ }
97
+ } else if (!inputSchema.isUnitSchema()) {
98
+ const hasBody = Object.values(members).find((m) => {
99
+ const { httpQuery, httpQueryParams, httpHeader, httpLabel, httpPrefixHeaders } = m.getMergedTraits();
100
+ return !httpQuery && !httpQueryParams && !httpHeader && !httpLabel && httpPrefixHeaders === void 0;
101
+ });
102
+ if (hasBody) {
103
+ return defaultContentType;
104
+ }
105
+ }
106
+ }
107
+ /**
108
+ * Shared code for finding error schema or throwing an unmodeled base error.
109
+ * @returns error schema and error metadata.
110
+ *
111
+ * @throws ServiceBaseException or generic Error if no error schema could be found.
112
+ */
113
+ async getErrorSchemaOrThrowBaseException(errorIdentifier, defaultNamespace, response, dataObject, metadata, getErrorSchema) {
114
+ let namespace = defaultNamespace;
115
+ let errorName = errorIdentifier;
116
+ if (errorIdentifier.includes("#")) {
117
+ [namespace, errorName] = errorIdentifier.split("#");
118
+ }
119
+ const errorMetadata = {
120
+ $metadata: metadata,
121
+ $response: response,
122
+ $fault: response.statusCode < 500 ? "client" : "server"
123
+ };
124
+ const registry = import_schema.TypeRegistry.for(namespace);
125
+ try {
126
+ const errorSchema = getErrorSchema?.(registry, errorName) ?? registry.getSchema(errorIdentifier);
127
+ return { errorSchema, errorMetadata };
128
+ } catch (e) {
129
+ if (dataObject.Message) {
130
+ dataObject.message = dataObject.Message;
131
+ }
132
+ const baseExceptionSchema = import_schema.TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace).getBaseException();
133
+ if (baseExceptionSchema) {
134
+ const ErrorCtor = baseExceptionSchema.ctor;
135
+ throw Object.assign(new ErrorCtor({ name: errorName }), errorMetadata, dataObject);
136
+ }
137
+ throw Object.assign(new Error(errorName), errorMetadata, dataObject);
138
+ }
139
+ }
140
+ /**
141
+ * Reads the x-amzn-query-error header for awsQuery compatibility.
142
+ *
143
+ * @param output - values that will be assigned to an error object.
144
+ * @param response - from which to read awsQueryError headers.
145
+ */
146
+ setQueryCompatError(output, response) {
147
+ const queryErrorHeader = response.headers?.["x-amzn-query-error"];
148
+ if (output !== void 0 && queryErrorHeader != null) {
149
+ const [Code, Type] = queryErrorHeader.split(";");
150
+ const entries = Object.entries(output);
151
+ const Error2 = {
152
+ Code,
153
+ Type
154
+ };
155
+ Object.assign(output, Error2);
156
+ for (const [k, v] of entries) {
157
+ Error2[k] = v;
158
+ }
159
+ delete Error2.__type;
160
+ output.Error = Error2;
161
+ }
162
+ }
163
+ /**
164
+ * Assigns Error, Type, Code from the awsQuery error object to the output error object.
165
+ * @param queryCompatErrorData - query compat error object.
166
+ * @param errorData - canonical error object returned to the caller.
167
+ */
168
+ queryCompatOutput(queryCompatErrorData, errorData) {
169
+ if (queryCompatErrorData.Error) {
170
+ errorData.Error = queryCompatErrorData.Error;
171
+ }
172
+ if (queryCompatErrorData.Type) {
173
+ errorData.Type = queryCompatErrorData.Type;
174
+ }
175
+ if (queryCompatErrorData.Code) {
176
+ errorData.Code = queryCompatErrorData.Code;
177
+ }
178
+ }
179
+ };
180
+
181
+ // src/submodules/protocols/cbor/AwsSmithyRpcV2CborProtocol.ts
182
+ var AwsSmithyRpcV2CborProtocol = class extends import_cbor.SmithyRpcV2CborProtocol {
183
+ static {
184
+ __name(this, "AwsSmithyRpcV2CborProtocol");
185
+ }
186
+ awsQueryCompatible;
187
+ mixin = new ProtocolLib();
188
+ constructor({
189
+ defaultNamespace,
190
+ awsQueryCompatible
191
+ }) {
192
+ super({ defaultNamespace });
193
+ this.awsQueryCompatible = !!awsQueryCompatible;
194
+ }
195
+ /**
196
+ * @override
197
+ */
198
+ async serializeRequest(operationSchema, input, context) {
199
+ const request = await super.serializeRequest(operationSchema, input, context);
200
+ if (this.awsQueryCompatible) {
201
+ request.headers["x-amzn-query-mode"] = "true";
202
+ }
203
+ return request;
204
+ }
205
+ /**
206
+ * @override
207
+ */
208
+ async handleError(operationSchema, context, response, dataObject, metadata) {
209
+ if (this.awsQueryCompatible) {
210
+ this.mixin.setQueryCompatError(dataObject, response);
211
+ }
212
+ const errorName = (0, import_cbor.loadSmithyRpcV2CborErrorCode)(response, dataObject) ?? "Unknown";
213
+ const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(
214
+ errorName,
215
+ this.options.defaultNamespace,
216
+ response,
217
+ dataObject,
218
+ metadata
219
+ );
220
+ const ns = import_schema2.NormalizedSchema.of(errorSchema);
221
+ const message = dataObject.message ?? dataObject.Message ?? "Unknown";
222
+ const exception = new errorSchema.ctor(message);
223
+ const output = {};
224
+ for (const [name, member] of ns.structIterator()) {
225
+ output[name] = this.deserializer.readValue(member, dataObject[name]);
226
+ }
227
+ if (this.awsQueryCompatible) {
228
+ this.mixin.queryCompatOutput(dataObject, output);
229
+ }
230
+ throw Object.assign(
231
+ exception,
232
+ errorMetadata,
233
+ {
234
+ $fault: ns.getMergedTraits().error,
235
+ message
236
+ },
237
+ output
238
+ );
239
+ }
240
+ };
241
+
50
242
  // src/submodules/protocols/coercing-serializers.ts
51
243
  var _toStr = /* @__PURE__ */ __name((val) => {
52
244
  if (val == null) {
@@ -104,8 +296,7 @@ var _toNum = /* @__PURE__ */ __name((val) => {
104
296
 
105
297
  // src/submodules/protocols/json/AwsJsonRpcProtocol.ts
106
298
  var import_protocols = require("@smithy/core/protocols");
107
- var import_schema3 = require("@smithy/core/schema");
108
- var import_util_body_length_browser = require("@smithy/util-body-length-browser");
299
+ var import_schema5 = require("@smithy/core/schema");
109
300
 
110
301
  // src/submodules/protocols/ConfigurableSerdeContext.ts
111
302
  var SerdeContextConfig = class {
@@ -119,7 +310,7 @@ var SerdeContextConfig = class {
119
310
  };
120
311
 
121
312
  // src/submodules/protocols/json/JsonShapeDeserializer.ts
122
- var import_schema = require("@smithy/core/schema");
313
+ var import_schema3 = require("@smithy/core/schema");
123
314
  var import_serde2 = require("@smithy/core/serde");
124
315
  var import_util_base64 = require("@smithy/util-base64");
125
316
 
@@ -145,7 +336,8 @@ __name(jsonReviver, "jsonReviver");
145
336
 
146
337
  // src/submodules/protocols/common.ts
147
338
  var import_smithy_client = require("@smithy/smithy-client");
148
- var collectBodyString = /* @__PURE__ */ __name((streamBody, context) => (0, import_smithy_client.collectBody)(streamBody, context).then((body) => context.utf8Encoder(body)), "collectBodyString");
339
+ var import_util_utf8 = require("@smithy/util-utf8");
340
+ var collectBodyString = /* @__PURE__ */ __name((streamBody, context) => (0, import_smithy_client.collectBody)(streamBody, context).then((body) => (context?.utf8Encoder ?? import_util_utf8.toUtf8)(body)), "collectBodyString");
149
341
 
150
342
  // src/submodules/protocols/json/parseJsonBody.ts
151
343
  var parseJsonBody = /* @__PURE__ */ __name((streamBody, context) => collectBodyString(streamBody, context).then((encoded) => {
@@ -221,7 +413,7 @@ var JsonShapeDeserializer = class extends SerdeContextConfig {
221
413
  }
222
414
  _read(schema, value) {
223
415
  const isObject = value !== null && typeof value === "object";
224
- const ns = import_schema.NormalizedSchema.of(schema);
416
+ const ns = import_schema3.NormalizedSchema.of(schema);
225
417
  if (ns.isListSchema() && Array.isArray(value)) {
226
418
  const listMember = ns.getValueSchema();
227
419
  const out = [];
@@ -265,13 +457,13 @@ var JsonShapeDeserializer = class extends SerdeContextConfig {
265
457
  }
266
458
  if (ns.isTimestampSchema()) {
267
459
  const options = this.settings.timestampFormat;
268
- const format = options.useTrait ? ns.getSchema() === import_schema.SCHEMA.TIMESTAMP_DEFAULT ? options.default : ns.getSchema() ?? options.default : options.default;
460
+ const format = options.useTrait ? ns.getSchema() === import_schema3.SCHEMA.TIMESTAMP_DEFAULT ? options.default : ns.getSchema() ?? options.default : options.default;
269
461
  switch (format) {
270
- case import_schema.SCHEMA.TIMESTAMP_DATE_TIME:
462
+ case import_schema3.SCHEMA.TIMESTAMP_DATE_TIME:
271
463
  return (0, import_serde2.parseRfc3339DateTimeWithOffset)(value);
272
- case import_schema.SCHEMA.TIMESTAMP_HTTP_DATE:
464
+ case import_schema3.SCHEMA.TIMESTAMP_HTTP_DATE:
273
465
  return (0, import_serde2.parseRfc7231DateTime)(value);
274
- case import_schema.SCHEMA.TIMESTAMP_EPOCH_SECONDS:
466
+ case import_schema3.SCHEMA.TIMESTAMP_EPOCH_SECONDS:
275
467
  return (0, import_serde2.parseEpochTimestamp)(value);
276
468
  default:
277
469
  console.warn("Missing timestamp format, parsing value with Date constructor:", value);
@@ -302,7 +494,7 @@ var JsonShapeDeserializer = class extends SerdeContextConfig {
302
494
  };
303
495
 
304
496
  // src/submodules/protocols/json/JsonShapeSerializer.ts
305
- var import_schema2 = require("@smithy/core/schema");
497
+ var import_schema4 = require("@smithy/core/schema");
306
498
  var import_serde4 = require("@smithy/core/serde");
307
499
 
308
500
  // src/submodules/protocols/json/jsonReplacer.ts
@@ -378,7 +570,7 @@ var JsonShapeSerializer = class extends SerdeContextConfig {
378
570
  buffer;
379
571
  rootSchema;
380
572
  write(schema, value) {
381
- this.rootSchema = import_schema2.NormalizedSchema.of(schema);
573
+ this.rootSchema = import_schema4.NormalizedSchema.of(schema);
382
574
  this.buffer = this._write(this.rootSchema, value);
383
575
  }
384
576
  flush() {
@@ -390,7 +582,7 @@ var JsonShapeSerializer = class extends SerdeContextConfig {
390
582
  }
391
583
  _write(schema, value, container) {
392
584
  const isObject = value !== null && typeof value === "object";
393
- const ns = import_schema2.NormalizedSchema.of(schema);
585
+ const ns = import_schema4.NormalizedSchema.of(schema);
394
586
  if (ns.isListSchema() && Array.isArray(value)) {
395
587
  const listMember = ns.getValueSchema();
396
588
  const out = [];
@@ -436,13 +628,13 @@ var JsonShapeSerializer = class extends SerdeContextConfig {
436
628
  }
437
629
  if (ns.isTimestampSchema() && value instanceof Date) {
438
630
  const options = this.settings.timestampFormat;
439
- const format = options.useTrait ? ns.getSchema() === import_schema2.SCHEMA.TIMESTAMP_DEFAULT ? options.default : ns.getSchema() ?? options.default : options.default;
631
+ const format = options.useTrait ? ns.getSchema() === import_schema4.SCHEMA.TIMESTAMP_DEFAULT ? options.default : ns.getSchema() ?? options.default : options.default;
440
632
  switch (format) {
441
- case import_schema2.SCHEMA.TIMESTAMP_DATE_TIME:
633
+ case import_schema4.SCHEMA.TIMESTAMP_DATE_TIME:
442
634
  return value.toISOString().replace(".000Z", "Z");
443
- case import_schema2.SCHEMA.TIMESTAMP_HTTP_DATE:
635
+ case import_schema4.SCHEMA.TIMESTAMP_HTTP_DATE:
444
636
  return (0, import_serde4.dateToUtcString)(value);
445
- case import_schema2.SCHEMA.TIMESTAMP_EPOCH_SECONDS:
637
+ case import_schema4.SCHEMA.TIMESTAMP_EPOCH_SECONDS:
446
638
  return value.getTime() / 1e3;
447
639
  default:
448
640
  console.warn("Missing timestamp format, using epoch seconds", value);
@@ -500,7 +692,13 @@ var AwsJsonRpcProtocol = class extends import_protocols.RpcProtocol {
500
692
  deserializer;
501
693
  serviceTarget;
502
694
  codec;
503
- constructor({ defaultNamespace, serviceTarget }) {
695
+ mixin = new ProtocolLib();
696
+ awsQueryCompatible;
697
+ constructor({
698
+ defaultNamespace,
699
+ serviceTarget,
700
+ awsQueryCompatible
701
+ }) {
504
702
  super({
505
703
  defaultNamespace
506
704
  });
@@ -508,12 +706,13 @@ var AwsJsonRpcProtocol = class extends import_protocols.RpcProtocol {
508
706
  this.codec = new JsonCodec({
509
707
  timestampFormat: {
510
708
  useTrait: true,
511
- default: import_schema3.SCHEMA.TIMESTAMP_EPOCH_SECONDS
709
+ default: import_schema5.SCHEMA.TIMESTAMP_EPOCH_SECONDS
512
710
  },
513
711
  jsonName: false
514
712
  });
515
713
  this.serializer = this.codec.createSerializer();
516
714
  this.deserializer = this.codec.createDeserializer();
715
+ this.awsQueryCompatible = !!awsQueryCompatible;
517
716
  }
518
717
  async serializeRequest(operationSchema, input, context) {
519
718
  const request = await super.serializeRequest(operationSchema, input, context);
@@ -522,13 +721,16 @@ var AwsJsonRpcProtocol = class extends import_protocols.RpcProtocol {
522
721
  }
523
722
  Object.assign(request.headers, {
524
723
  "content-type": `application/x-amz-json-${this.getJsonRpcVersion()}`,
525
- "x-amz-target": `${this.serviceTarget}.${import_schema3.NormalizedSchema.of(operationSchema).getName()}`
724
+ "x-amz-target": `${this.serviceTarget}.${import_schema5.NormalizedSchema.of(operationSchema).getName()}`
526
725
  });
527
- if ((0, import_schema3.deref)(operationSchema.input) === "unit" || !request.body) {
726
+ if (this.awsQueryCompatible) {
727
+ request.headers["x-amzn-query-mode"] = "true";
728
+ }
729
+ if ((0, import_schema5.deref)(operationSchema.input) === "unit" || !request.body) {
528
730
  request.body = "{}";
529
731
  }
530
732
  try {
531
- request.headers["content-length"] = String((0, import_util_body_length_browser.calculateBodyLength)(request.body));
733
+ request.headers["content-length"] = this.mixin.calculateContentLength(request.body, this.serdeContext);
532
734
  } catch (e) {
533
735
  }
534
736
  return request;
@@ -537,41 +739,28 @@ var AwsJsonRpcProtocol = class extends import_protocols.RpcProtocol {
537
739
  return this.codec;
538
740
  }
539
741
  async handleError(operationSchema, context, response, dataObject, metadata) {
540
- const errorIdentifier = loadRestJsonErrorCode(response, dataObject) ?? "Unknown";
541
- let namespace = this.options.defaultNamespace;
542
- let errorName = errorIdentifier;
543
- if (errorIdentifier.includes("#")) {
544
- [namespace, errorName] = errorIdentifier.split("#");
545
- }
546
- const errorMetadata = {
547
- $metadata: metadata,
548
- $response: response,
549
- $fault: response.statusCode <= 500 ? "client" : "server"
550
- };
551
- const registry = import_schema3.TypeRegistry.for(namespace);
552
- let errorSchema;
553
- try {
554
- errorSchema = registry.getSchema(errorIdentifier);
555
- } catch (e) {
556
- if (dataObject.Message) {
557
- dataObject.message = dataObject.Message;
558
- }
559
- const baseExceptionSchema = import_schema3.TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace).getBaseException();
560
- if (baseExceptionSchema) {
561
- const ErrorCtor = baseExceptionSchema.ctor;
562
- throw Object.assign(new ErrorCtor({ name: errorName }), errorMetadata, dataObject);
563
- }
564
- throw Object.assign(new Error(errorName), errorMetadata, dataObject);
742
+ if (this.awsQueryCompatible) {
743
+ this.mixin.setQueryCompatError(dataObject, response);
565
744
  }
566
- const ns = import_schema3.NormalizedSchema.of(errorSchema);
745
+ const errorIdentifier = loadRestJsonErrorCode(response, dataObject) ?? "Unknown";
746
+ const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(
747
+ errorIdentifier,
748
+ this.options.defaultNamespace,
749
+ response,
750
+ dataObject,
751
+ metadata
752
+ );
753
+ const ns = import_schema5.NormalizedSchema.of(errorSchema);
567
754
  const message = dataObject.message ?? dataObject.Message ?? "Unknown";
568
755
  const exception = new errorSchema.ctor(message);
569
- await this.deserializeHttpMessage(errorSchema, context, response, dataObject);
570
756
  const output = {};
571
757
  for (const [name, member] of ns.structIterator()) {
572
758
  const target = member.getMergedTraits().jsonName ?? name;
573
759
  output[name] = this.codec.createDeserializer().readObject(member, dataObject[target]);
574
760
  }
761
+ if (this.awsQueryCompatible) {
762
+ this.mixin.queryCompatOutput(dataObject, output);
763
+ }
575
764
  throw Object.assign(
576
765
  exception,
577
766
  errorMetadata,
@@ -589,10 +778,15 @@ var AwsJson1_0Protocol = class extends AwsJsonRpcProtocol {
589
778
  static {
590
779
  __name(this, "AwsJson1_0Protocol");
591
780
  }
592
- constructor({ defaultNamespace, serviceTarget }) {
781
+ constructor({
782
+ defaultNamespace,
783
+ serviceTarget,
784
+ awsQueryCompatible
785
+ }) {
593
786
  super({
594
787
  defaultNamespace,
595
- serviceTarget
788
+ serviceTarget,
789
+ awsQueryCompatible
596
790
  });
597
791
  }
598
792
  getShapeId() {
@@ -614,10 +808,15 @@ var AwsJson1_1Protocol = class extends AwsJsonRpcProtocol {
614
808
  static {
615
809
  __name(this, "AwsJson1_1Protocol");
616
810
  }
617
- constructor({ defaultNamespace, serviceTarget }) {
811
+ constructor({
812
+ defaultNamespace,
813
+ serviceTarget,
814
+ awsQueryCompatible
815
+ }) {
618
816
  super({
619
817
  defaultNamespace,
620
- serviceTarget
818
+ serviceTarget,
819
+ awsQueryCompatible
621
820
  });
622
821
  }
623
822
  getShapeId() {
@@ -636,8 +835,7 @@ var AwsJson1_1Protocol = class extends AwsJsonRpcProtocol {
636
835
 
637
836
  // src/submodules/protocols/json/AwsRestJsonProtocol.ts
638
837
  var import_protocols2 = require("@smithy/core/protocols");
639
- var import_schema4 = require("@smithy/core/schema");
640
- var import_util_body_length_browser2 = require("@smithy/util-body-length-browser");
838
+ var import_schema6 = require("@smithy/core/schema");
641
839
  var AwsRestJsonProtocol = class extends import_protocols2.HttpBindingProtocol {
642
840
  static {
643
841
  __name(this, "AwsRestJsonProtocol");
@@ -645,6 +843,7 @@ var AwsRestJsonProtocol = class extends import_protocols2.HttpBindingProtocol {
645
843
  serializer;
646
844
  deserializer;
647
845
  codec;
846
+ mixin = new ProtocolLib();
648
847
  constructor({ defaultNamespace }) {
649
848
  super({
650
849
  defaultNamespace
@@ -652,7 +851,7 @@ var AwsRestJsonProtocol = class extends import_protocols2.HttpBindingProtocol {
652
851
  const settings = {
653
852
  timestampFormat: {
654
853
  useTrait: true,
655
- default: import_schema4.SCHEMA.TIMESTAMP_EPOCH_SECONDS
854
+ default: import_schema6.SCHEMA.TIMESTAMP_EPOCH_SECONDS
656
855
  },
657
856
  httpBindings: true,
658
857
  jsonName: true
@@ -673,31 +872,11 @@ var AwsRestJsonProtocol = class extends import_protocols2.HttpBindingProtocol {
673
872
  }
674
873
  async serializeRequest(operationSchema, input, context) {
675
874
  const request = await super.serializeRequest(operationSchema, input, context);
676
- const inputSchema = import_schema4.NormalizedSchema.of(operationSchema.input);
677
- const members = inputSchema.getMemberSchemas();
875
+ const inputSchema = import_schema6.NormalizedSchema.of(operationSchema.input);
678
876
  if (!request.headers["content-type"]) {
679
- const httpPayloadMember = Object.values(members).find((m) => {
680
- return !!m.getMergedTraits().httpPayload;
681
- });
682
- if (httpPayloadMember) {
683
- const mediaType = httpPayloadMember.getMergedTraits().mediaType;
684
- if (mediaType) {
685
- request.headers["content-type"] = mediaType;
686
- } else if (httpPayloadMember.isStringSchema()) {
687
- request.headers["content-type"] = "text/plain";
688
- } else if (httpPayloadMember.isBlobSchema()) {
689
- request.headers["content-type"] = "application/octet-stream";
690
- } else {
691
- request.headers["content-type"] = this.getDefaultContentType();
692
- }
693
- } else if (!inputSchema.isUnitSchema()) {
694
- const hasBody = Object.values(members).find((m) => {
695
- const { httpQuery, httpQueryParams, httpHeader, httpLabel, httpPrefixHeaders } = m.getMergedTraits();
696
- return !httpQuery && !httpQueryParams && !httpHeader && !httpLabel && httpPrefixHeaders === void 0;
697
- });
698
- if (hasBody) {
699
- request.headers["content-type"] = this.getDefaultContentType();
700
- }
877
+ const contentType = this.mixin.resolveRestContentType(this.getDefaultContentType(), inputSchema);
878
+ if (contentType) {
879
+ request.headers["content-type"] = contentType;
701
880
  }
702
881
  }
703
882
  if (request.headers["content-type"] && !request.body) {
@@ -705,7 +884,7 @@ var AwsRestJsonProtocol = class extends import_protocols2.HttpBindingProtocol {
705
884
  }
706
885
  if (request.body) {
707
886
  try {
708
- request.headers["content-length"] = String((0, import_util_body_length_browser2.calculateBodyLength)(request.body));
887
+ request.headers["content-length"] = this.mixin.calculateContentLength(request.body, this.serdeContext);
709
888
  } catch (e) {
710
889
  }
711
890
  }
@@ -713,32 +892,14 @@ var AwsRestJsonProtocol = class extends import_protocols2.HttpBindingProtocol {
713
892
  }
714
893
  async handleError(operationSchema, context, response, dataObject, metadata) {
715
894
  const errorIdentifier = loadRestJsonErrorCode(response, dataObject) ?? "Unknown";
716
- let namespace = this.options.defaultNamespace;
717
- let errorName = errorIdentifier;
718
- if (errorIdentifier.includes("#")) {
719
- [namespace, errorName] = errorIdentifier.split("#");
720
- }
721
- const errorMetadata = {
722
- $metadata: metadata,
723
- $response: response,
724
- $fault: response.statusCode <= 500 ? "client" : "server"
725
- };
726
- const registry = import_schema4.TypeRegistry.for(namespace);
727
- let errorSchema;
728
- try {
729
- errorSchema = registry.getSchema(errorIdentifier);
730
- } catch (e) {
731
- if (dataObject.Message) {
732
- dataObject.message = dataObject.Message;
733
- }
734
- const baseExceptionSchema = import_schema4.TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace).getBaseException();
735
- if (baseExceptionSchema) {
736
- const ErrorCtor = baseExceptionSchema.ctor;
737
- throw Object.assign(new ErrorCtor({ name: errorName }), errorMetadata, dataObject);
738
- }
739
- throw Object.assign(new Error(errorName), errorMetadata, dataObject);
740
- }
741
- const ns = import_schema4.NormalizedSchema.of(errorSchema);
895
+ const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(
896
+ errorIdentifier,
897
+ this.options.defaultNamespace,
898
+ response,
899
+ dataObject,
900
+ metadata
901
+ );
902
+ const ns = import_schema6.NormalizedSchema.of(errorSchema);
742
903
  const message = dataObject.message ?? dataObject.Message ?? "Unknown";
743
904
  const exception = new errorSchema.ctor(message);
744
905
  await this.deserializeHttpMessage(errorSchema, context, response, dataObject);
@@ -779,14 +940,13 @@ var awsExpectUnion = /* @__PURE__ */ __name((value) => {
779
940
 
780
941
  // src/submodules/protocols/query/AwsQueryProtocol.ts
781
942
  var import_protocols5 = require("@smithy/core/protocols");
782
- var import_schema7 = require("@smithy/core/schema");
783
- var import_util_body_length_browser3 = require("@smithy/util-body-length-browser");
943
+ var import_schema9 = require("@smithy/core/schema");
784
944
 
785
945
  // src/submodules/protocols/xml/XmlShapeDeserializer.ts
786
946
  var import_protocols3 = require("@smithy/core/protocols");
787
- var import_schema5 = require("@smithy/core/schema");
947
+ var import_schema7 = require("@smithy/core/schema");
788
948
  var import_smithy_client3 = require("@smithy/smithy-client");
789
- var import_util_utf8 = require("@smithy/util-utf8");
949
+ var import_util_utf82 = require("@smithy/util-utf8");
790
950
  var import_fast_xml_parser = require("fast-xml-parser");
791
951
  var XmlShapeDeserializer = class extends SerdeContextConfig {
792
952
  constructor(settings) {
@@ -808,7 +968,7 @@ var XmlShapeDeserializer = class extends SerdeContextConfig {
808
968
  * @param key - used by AwsQuery to step one additional depth into the object before reading it.
809
969
  */
810
970
  read(schema, bytes, key) {
811
- const ns = import_schema5.NormalizedSchema.of(schema);
971
+ const ns = import_schema7.NormalizedSchema.of(schema);
812
972
  const memberSchemas = ns.getMemberSchemas();
813
973
  const isEventPayload = ns.isStructSchema() && ns.isMemberSchema() && !!Object.values(memberSchemas).find((memberNs) => {
814
974
  return !!memberNs.getMemberTraits().eventPayload;
@@ -824,12 +984,12 @@ var XmlShapeDeserializer = class extends SerdeContextConfig {
824
984
  }
825
985
  return output;
826
986
  }
827
- const xmlString = (this.serdeContext?.utf8Encoder ?? import_util_utf8.toUtf8)(bytes);
987
+ const xmlString = (this.serdeContext?.utf8Encoder ?? import_util_utf82.toUtf8)(bytes);
828
988
  const parsedObject = this.parseXml(xmlString);
829
989
  return this.readSchema(schema, key ? parsedObject[key] : parsedObject);
830
990
  }
831
991
  readSchema(_schema, value) {
832
- const ns = import_schema5.NormalizedSchema.of(_schema);
992
+ const ns = import_schema7.NormalizedSchema.of(_schema);
833
993
  const traits = ns.getMergedTraits();
834
994
  if (ns.isListSchema() && !Array.isArray(value)) {
835
995
  return this.readSchema(ns, [value]);
@@ -936,7 +1096,7 @@ var XmlShapeDeserializer = class extends SerdeContextConfig {
936
1096
 
937
1097
  // src/submodules/protocols/query/QueryShapeSerializer.ts
938
1098
  var import_protocols4 = require("@smithy/core/protocols");
939
- var import_schema6 = require("@smithy/core/schema");
1099
+ var import_schema8 = require("@smithy/core/schema");
940
1100
  var import_serde5 = require("@smithy/core/serde");
941
1101
  var import_smithy_client4 = require("@smithy/smithy-client");
942
1102
  var import_util_base642 = require("@smithy/util-base64");
@@ -953,7 +1113,7 @@ var QueryShapeSerializer = class extends SerdeContextConfig {
953
1113
  if (this.buffer === void 0) {
954
1114
  this.buffer = "";
955
1115
  }
956
- const ns = import_schema6.NormalizedSchema.of(schema);
1116
+ const ns = import_schema8.NormalizedSchema.of(schema);
957
1117
  if (prefix && !prefix.endsWith(".")) {
958
1118
  prefix += ".";
959
1119
  }
@@ -985,13 +1145,13 @@ var QueryShapeSerializer = class extends SerdeContextConfig {
985
1145
  this.writeKey(prefix);
986
1146
  const format = (0, import_protocols4.determineTimestampFormat)(ns, this.settings);
987
1147
  switch (format) {
988
- case import_schema6.SCHEMA.TIMESTAMP_DATE_TIME:
1148
+ case import_schema8.SCHEMA.TIMESTAMP_DATE_TIME:
989
1149
  this.writeValue(value.toISOString().replace(".000Z", "Z"));
990
1150
  break;
991
- case import_schema6.SCHEMA.TIMESTAMP_HTTP_DATE:
1151
+ case import_schema8.SCHEMA.TIMESTAMP_HTTP_DATE:
992
1152
  this.writeValue((0, import_smithy_client4.dateToUtcString)(value));
993
1153
  break;
994
- case import_schema6.SCHEMA.TIMESTAMP_EPOCH_SECONDS:
1154
+ case import_schema8.SCHEMA.TIMESTAMP_EPOCH_SECONDS:
995
1155
  this.writeValue(String(value.getTime() / 1e3));
996
1156
  break;
997
1157
  }
@@ -1091,7 +1251,7 @@ var AwsQueryProtocol = class extends import_protocols5.RpcProtocol {
1091
1251
  const settings = {
1092
1252
  timestampFormat: {
1093
1253
  useTrait: true,
1094
- default: import_schema7.SCHEMA.TIMESTAMP_DATE_TIME
1254
+ default: import_schema9.SCHEMA.TIMESTAMP_DATE_TIME
1095
1255
  },
1096
1256
  httpBindings: false,
1097
1257
  xmlNamespace: options.xmlNamespace,
@@ -1106,6 +1266,7 @@ var AwsQueryProtocol = class extends import_protocols5.RpcProtocol {
1106
1266
  }
1107
1267
  serializer;
1108
1268
  deserializer;
1269
+ mixin = new ProtocolLib();
1109
1270
  getShapeId() {
1110
1271
  return "aws.protocols#awsQuery";
1111
1272
  }
@@ -1124,7 +1285,7 @@ var AwsQueryProtocol = class extends import_protocols5.RpcProtocol {
1124
1285
  Object.assign(request.headers, {
1125
1286
  "content-type": `application/x-www-form-urlencoded`
1126
1287
  });
1127
- if ((0, import_schema7.deref)(operationSchema.input) === "unit" || !request.body) {
1288
+ if ((0, import_schema9.deref)(operationSchema.input) === "unit" || !request.body) {
1128
1289
  request.body = "";
1129
1290
  }
1130
1291
  request.body = `Action=${operationSchema.name.split("#")[1]}&Version=${this.options.version}` + request.body;
@@ -1132,19 +1293,19 @@ var AwsQueryProtocol = class extends import_protocols5.RpcProtocol {
1132
1293
  request.body = request.body.slice(-1);
1133
1294
  }
1134
1295
  try {
1135
- request.headers["content-length"] = String((0, import_util_body_length_browser3.calculateBodyLength)(request.body));
1296
+ request.headers["content-length"] = this.mixin.calculateContentLength(request.body, this.serdeContext);
1136
1297
  } catch (e) {
1137
1298
  }
1138
1299
  return request;
1139
1300
  }
1140
1301
  async deserializeResponse(operationSchema, context, response) {
1141
1302
  const deserializer = this.deserializer;
1142
- const ns = import_schema7.NormalizedSchema.of(operationSchema.output);
1303
+ const ns = import_schema9.NormalizedSchema.of(operationSchema.output);
1143
1304
  const dataObject = {};
1144
1305
  if (response.statusCode >= 300) {
1145
1306
  const bytes2 = await (0, import_protocols5.collectBody)(response.body, context);
1146
1307
  if (bytes2.byteLength > 0) {
1147
- Object.assign(dataObject, await deserializer.read(import_schema7.SCHEMA.DOCUMENT, bytes2));
1308
+ Object.assign(dataObject, await deserializer.read(import_schema9.SCHEMA.DOCUMENT, bytes2));
1148
1309
  }
1149
1310
  await this.handleError(operationSchema, context, response, dataObject, this.deserializeMetadata(response));
1150
1311
  }
@@ -1172,38 +1333,18 @@ var AwsQueryProtocol = class extends import_protocols5.RpcProtocol {
1172
1333
  }
1173
1334
  async handleError(operationSchema, context, response, dataObject, metadata) {
1174
1335
  const errorIdentifier = this.loadQueryErrorCode(response, dataObject) ?? "Unknown";
1175
- let namespace = this.options.defaultNamespace;
1176
- let errorName = errorIdentifier;
1177
- if (errorIdentifier.includes("#")) {
1178
- [namespace, errorName] = errorIdentifier.split("#");
1179
- }
1180
1336
  const errorData = this.loadQueryError(dataObject);
1181
- const errorMetadata = {
1182
- $metadata: metadata,
1183
- $response: response,
1184
- $fault: response.statusCode <= 500 ? "client" : "server"
1185
- };
1186
- const registry = import_schema7.TypeRegistry.for(namespace);
1187
- let errorSchema;
1188
- try {
1189
- errorSchema = registry.find(
1190
- (schema) => import_schema7.NormalizedSchema.of(schema).getMergedTraits().awsQueryError?.[0] === errorName
1191
- );
1192
- if (!errorSchema) {
1193
- errorSchema = registry.getSchema(errorIdentifier);
1194
- }
1195
- } catch (e) {
1196
- if (errorData.Message) {
1197
- errorData.message = errorData.Message;
1198
- }
1199
- const baseExceptionSchema = import_schema7.TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace).getBaseException();
1200
- if (baseExceptionSchema) {
1201
- const ErrorCtor = baseExceptionSchema.ctor;
1202
- throw Object.assign(new ErrorCtor({ name: errorName }), errorMetadata, dataObject);
1203
- }
1204
- throw Object.assign(new Error(errorName), errorMetadata, errorData);
1205
- }
1206
- const ns = import_schema7.NormalizedSchema.of(errorSchema);
1337
+ const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(
1338
+ errorIdentifier,
1339
+ this.options.defaultNamespace,
1340
+ response,
1341
+ errorData,
1342
+ metadata,
1343
+ (registry, errorName) => registry.find(
1344
+ (schema) => import_schema9.NormalizedSchema.of(schema).getMergedTraits().awsQueryError?.[0] === errorName
1345
+ )
1346
+ );
1347
+ const ns = import_schema9.NormalizedSchema.of(errorSchema);
1207
1348
  const message = this.loadQueryErrorMessage(dataObject);
1208
1349
  const exception = new errorSchema.ctor(message);
1209
1350
  const output = {};
@@ -1275,8 +1416,7 @@ var AwsEc2QueryProtocol = class extends AwsQueryProtocol {
1275
1416
 
1276
1417
  // src/submodules/protocols/xml/AwsRestXmlProtocol.ts
1277
1418
  var import_protocols6 = require("@smithy/core/protocols");
1278
- var import_schema9 = require("@smithy/core/schema");
1279
- var import_util_body_length_browser4 = require("@smithy/util-body-length-browser");
1419
+ var import_schema11 = require("@smithy/core/schema");
1280
1420
 
1281
1421
  // src/submodules/protocols/xml/parseXmlBody.ts
1282
1422
  var import_smithy_client5 = require("@smithy/smithy-client");
@@ -1337,7 +1477,7 @@ var loadRestXmlErrorCode = /* @__PURE__ */ __name((output, data) => {
1337
1477
 
1338
1478
  // src/submodules/protocols/xml/XmlShapeSerializer.ts
1339
1479
  var import_xml_builder = require("@aws-sdk/xml-builder");
1340
- var import_schema8 = require("@smithy/core/schema");
1480
+ var import_schema10 = require("@smithy/core/schema");
1341
1481
  var import_serde6 = require("@smithy/core/serde");
1342
1482
  var import_smithy_client6 = require("@smithy/smithy-client");
1343
1483
  var import_util_base643 = require("@smithy/util-base64");
@@ -1353,7 +1493,7 @@ var XmlShapeSerializer = class extends SerdeContextConfig {
1353
1493
  byteBuffer;
1354
1494
  buffer;
1355
1495
  write(schema, value) {
1356
- const ns = import_schema8.NormalizedSchema.of(schema);
1496
+ const ns = import_schema10.NormalizedSchema.of(schema);
1357
1497
  if (ns.isStringSchema() && typeof value === "string") {
1358
1498
  this.stringBuffer = value;
1359
1499
  } else if (ns.isBlobSchema()) {
@@ -1540,22 +1680,22 @@ var XmlShapeSerializer = class extends SerdeContextConfig {
1540
1680
  if (null === value) {
1541
1681
  throw new Error("@aws-sdk/core/protocols - (XML serializer) cannot write null value.");
1542
1682
  }
1543
- const ns = import_schema8.NormalizedSchema.of(_schema);
1683
+ const ns = import_schema10.NormalizedSchema.of(_schema);
1544
1684
  let nodeContents = null;
1545
1685
  if (value && typeof value === "object") {
1546
1686
  if (ns.isBlobSchema()) {
1547
1687
  nodeContents = (this.serdeContext?.base64Encoder ?? import_util_base643.toBase64)(value);
1548
1688
  } else if (ns.isTimestampSchema() && value instanceof Date) {
1549
1689
  const options = this.settings.timestampFormat;
1550
- const format = options.useTrait ? ns.getSchema() === import_schema8.SCHEMA.TIMESTAMP_DEFAULT ? options.default : ns.getSchema() ?? options.default : options.default;
1690
+ const format = options.useTrait ? ns.getSchema() === import_schema10.SCHEMA.TIMESTAMP_DEFAULT ? options.default : ns.getSchema() ?? options.default : options.default;
1551
1691
  switch (format) {
1552
- case import_schema8.SCHEMA.TIMESTAMP_DATE_TIME:
1692
+ case import_schema10.SCHEMA.TIMESTAMP_DATE_TIME:
1553
1693
  nodeContents = value.toISOString().replace(".000Z", "Z");
1554
1694
  break;
1555
- case import_schema8.SCHEMA.TIMESTAMP_HTTP_DATE:
1695
+ case import_schema10.SCHEMA.TIMESTAMP_HTTP_DATE:
1556
1696
  nodeContents = (0, import_smithy_client6.dateToUtcString)(value);
1557
1697
  break;
1558
- case import_schema8.SCHEMA.TIMESTAMP_EPOCH_SECONDS:
1698
+ case import_schema10.SCHEMA.TIMESTAMP_EPOCH_SECONDS:
1559
1699
  nodeContents = String(value.getTime() / 1e3);
1560
1700
  break;
1561
1701
  default:
@@ -1597,7 +1737,7 @@ var XmlShapeSerializer = class extends SerdeContextConfig {
1597
1737
  }
1598
1738
  writeSimpleInto(_schema, value, into, parentXmlns) {
1599
1739
  const nodeContents = this.writeSimple(_schema, value);
1600
- const ns = import_schema8.NormalizedSchema.of(_schema);
1740
+ const ns = import_schema10.NormalizedSchema.of(_schema);
1601
1741
  const content = new import_xml_builder.XmlText(nodeContents);
1602
1742
  const [xmlnsAttr, xmlns] = this.getXmlnsAttribute(ns, parentXmlns);
1603
1743
  if (xmlns) {
@@ -1644,12 +1784,13 @@ var AwsRestXmlProtocol = class extends import_protocols6.HttpBindingProtocol {
1644
1784
  codec;
1645
1785
  serializer;
1646
1786
  deserializer;
1787
+ mixin = new ProtocolLib();
1647
1788
  constructor(options) {
1648
1789
  super(options);
1649
1790
  const settings = {
1650
1791
  timestampFormat: {
1651
1792
  useTrait: true,
1652
- default: import_schema9.SCHEMA.TIMESTAMP_DATE_TIME
1793
+ default: import_schema11.SCHEMA.TIMESTAMP_DATE_TIME
1653
1794
  },
1654
1795
  httpBindings: true,
1655
1796
  xmlNamespace: options.xmlNamespace,
@@ -1667,31 +1808,11 @@ var AwsRestXmlProtocol = class extends import_protocols6.HttpBindingProtocol {
1667
1808
  }
1668
1809
  async serializeRequest(operationSchema, input, context) {
1669
1810
  const request = await super.serializeRequest(operationSchema, input, context);
1670
- const ns = import_schema9.NormalizedSchema.of(operationSchema.input);
1671
- const members = ns.getMemberSchemas();
1811
+ const inputSchema = import_schema11.NormalizedSchema.of(operationSchema.input);
1672
1812
  if (!request.headers["content-type"]) {
1673
- const httpPayloadMember = Object.values(members).find((m) => {
1674
- return !!m.getMergedTraits().httpPayload;
1675
- });
1676
- if (httpPayloadMember) {
1677
- const mediaType = httpPayloadMember.getMergedTraits().mediaType;
1678
- if (mediaType) {
1679
- request.headers["content-type"] = mediaType;
1680
- } else if (httpPayloadMember.isStringSchema()) {
1681
- request.headers["content-type"] = "text/plain";
1682
- } else if (httpPayloadMember.isBlobSchema()) {
1683
- request.headers["content-type"] = "application/octet-stream";
1684
- } else {
1685
- request.headers["content-type"] = this.getDefaultContentType();
1686
- }
1687
- } else if (!ns.isUnitSchema()) {
1688
- const hasBody = Object.values(members).find((m) => {
1689
- const { httpQuery, httpQueryParams, httpHeader, httpLabel, httpPrefixHeaders } = m.getMergedTraits();
1690
- return !httpQuery && !httpQueryParams && !httpHeader && !httpLabel && httpPrefixHeaders === void 0;
1691
- });
1692
- if (hasBody) {
1693
- request.headers["content-type"] = this.getDefaultContentType();
1694
- }
1813
+ const contentType = this.mixin.resolveRestContentType(this.getDefaultContentType(), inputSchema);
1814
+ if (contentType) {
1815
+ request.headers["content-type"] = contentType;
1695
1816
  }
1696
1817
  }
1697
1818
  if (request.headers["content-type"] === this.getDefaultContentType()) {
@@ -1701,7 +1822,7 @@ var AwsRestXmlProtocol = class extends import_protocols6.HttpBindingProtocol {
1701
1822
  }
1702
1823
  if (request.body) {
1703
1824
  try {
1704
- request.headers["content-length"] = String((0, import_util_body_length_browser4.calculateBodyLength)(request.body));
1825
+ request.headers["content-length"] = this.mixin.calculateContentLength(request.body, this.serdeContext);
1705
1826
  } catch (e) {
1706
1827
  }
1707
1828
  }
@@ -1712,32 +1833,14 @@ var AwsRestXmlProtocol = class extends import_protocols6.HttpBindingProtocol {
1712
1833
  }
1713
1834
  async handleError(operationSchema, context, response, dataObject, metadata) {
1714
1835
  const errorIdentifier = loadRestXmlErrorCode(response, dataObject) ?? "Unknown";
1715
- let namespace = this.options.defaultNamespace;
1716
- let errorName = errorIdentifier;
1717
- if (errorIdentifier.includes("#")) {
1718
- [namespace, errorName] = errorIdentifier.split("#");
1719
- }
1720
- const errorMetadata = {
1721
- $metadata: metadata,
1722
- $response: response,
1723
- $fault: response.statusCode <= 500 ? "client" : "server"
1724
- };
1725
- const registry = import_schema9.TypeRegistry.for(namespace);
1726
- let errorSchema;
1727
- try {
1728
- errorSchema = registry.getSchema(errorIdentifier);
1729
- } catch (e) {
1730
- if (dataObject.Message) {
1731
- dataObject.message = dataObject.Message;
1732
- }
1733
- const baseExceptionSchema = import_schema9.TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace).getBaseException();
1734
- if (baseExceptionSchema) {
1735
- const ErrorCtor = baseExceptionSchema.ctor;
1736
- throw Object.assign(new ErrorCtor({ name: errorName }), errorMetadata, dataObject);
1737
- }
1738
- throw Object.assign(new Error(errorName), errorMetadata, dataObject);
1739
- }
1740
- const ns = import_schema9.NormalizedSchema.of(errorSchema);
1836
+ const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(
1837
+ errorIdentifier,
1838
+ this.options.defaultNamespace,
1839
+ response,
1840
+ dataObject,
1841
+ metadata
1842
+ );
1843
+ const ns = import_schema11.NormalizedSchema.of(errorSchema);
1741
1844
  const message = dataObject.Error?.message ?? dataObject.Error?.Message ?? dataObject.message ?? dataObject.Message ?? "Unknown";
1742
1845
  const exception = new errorSchema.ctor(message);
1743
1846
  await this.deserializeHttpMessage(errorSchema, context, response, dataObject);
@@ -1773,6 +1876,7 @@ var AwsRestXmlProtocol = class extends import_protocols6.HttpBindingProtocol {
1773
1876
  AwsQueryProtocol,
1774
1877
  AwsRestJsonProtocol,
1775
1878
  AwsRestXmlProtocol,
1879
+ AwsSmithyRpcV2CborProtocol,
1776
1880
  JsonCodec,
1777
1881
  JsonShapeDeserializer,
1778
1882
  JsonShapeSerializer,