@aws-sdk/client-lex-runtime-v2 3.141.0 → 3.150.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,46 +10,10 @@ const serializeAws_restJson1DeleteSessionCommand = async (input, context) => {
10
10
  const headers = {};
11
11
  let resolvedPath = `${(basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}` +
12
12
  "/bots/{botId}/botAliases/{botAliasId}/botLocales/{localeId}/sessions/{sessionId}";
13
- if (input.botId !== undefined) {
14
- const labelValue = input.botId;
15
- if (labelValue.length <= 0) {
16
- throw new Error("Empty value provided for input HTTP label: botId.");
17
- }
18
- resolvedPath = resolvedPath.replace("{botId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
19
- }
20
- else {
21
- throw new Error("No value provided for input HTTP label: botId.");
22
- }
23
- if (input.botAliasId !== undefined) {
24
- const labelValue = input.botAliasId;
25
- if (labelValue.length <= 0) {
26
- throw new Error("Empty value provided for input HTTP label: botAliasId.");
27
- }
28
- resolvedPath = resolvedPath.replace("{botAliasId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
29
- }
30
- else {
31
- throw new Error("No value provided for input HTTP label: botAliasId.");
32
- }
33
- if (input.localeId !== undefined) {
34
- const labelValue = input.localeId;
35
- if (labelValue.length <= 0) {
36
- throw new Error("Empty value provided for input HTTP label: localeId.");
37
- }
38
- resolvedPath = resolvedPath.replace("{localeId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
39
- }
40
- else {
41
- throw new Error("No value provided for input HTTP label: localeId.");
42
- }
43
- if (input.sessionId !== undefined) {
44
- const labelValue = input.sessionId;
45
- if (labelValue.length <= 0) {
46
- throw new Error("Empty value provided for input HTTP label: sessionId.");
47
- }
48
- resolvedPath = resolvedPath.replace("{sessionId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
49
- }
50
- else {
51
- throw new Error("No value provided for input HTTP label: sessionId.");
52
- }
13
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "botId", () => input.botId, "{botId}", false);
14
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "botAliasId", () => input.botAliasId, "{botAliasId}", false);
15
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "localeId", () => input.localeId, "{localeId}", false);
16
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "sessionId", () => input.sessionId, "{sessionId}", false);
53
17
  let body;
54
18
  return new protocol_http_1.HttpRequest({
55
19
  protocol,
@@ -67,46 +31,10 @@ const serializeAws_restJson1GetSessionCommand = async (input, context) => {
67
31
  const headers = {};
68
32
  let resolvedPath = `${(basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}` +
69
33
  "/bots/{botId}/botAliases/{botAliasId}/botLocales/{localeId}/sessions/{sessionId}";
70
- if (input.botId !== undefined) {
71
- const labelValue = input.botId;
72
- if (labelValue.length <= 0) {
73
- throw new Error("Empty value provided for input HTTP label: botId.");
74
- }
75
- resolvedPath = resolvedPath.replace("{botId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
76
- }
77
- else {
78
- throw new Error("No value provided for input HTTP label: botId.");
79
- }
80
- if (input.botAliasId !== undefined) {
81
- const labelValue = input.botAliasId;
82
- if (labelValue.length <= 0) {
83
- throw new Error("Empty value provided for input HTTP label: botAliasId.");
84
- }
85
- resolvedPath = resolvedPath.replace("{botAliasId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
86
- }
87
- else {
88
- throw new Error("No value provided for input HTTP label: botAliasId.");
89
- }
90
- if (input.localeId !== undefined) {
91
- const labelValue = input.localeId;
92
- if (labelValue.length <= 0) {
93
- throw new Error("Empty value provided for input HTTP label: localeId.");
94
- }
95
- resolvedPath = resolvedPath.replace("{localeId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
96
- }
97
- else {
98
- throw new Error("No value provided for input HTTP label: localeId.");
99
- }
100
- if (input.sessionId !== undefined) {
101
- const labelValue = input.sessionId;
102
- if (labelValue.length <= 0) {
103
- throw new Error("Empty value provided for input HTTP label: sessionId.");
104
- }
105
- resolvedPath = resolvedPath.replace("{sessionId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
106
- }
107
- else {
108
- throw new Error("No value provided for input HTTP label: sessionId.");
109
- }
34
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "botId", () => input.botId, "{botId}", false);
35
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "botAliasId", () => input.botAliasId, "{botAliasId}", false);
36
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "localeId", () => input.localeId, "{localeId}", false);
37
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "sessionId", () => input.sessionId, "{sessionId}", false);
110
38
  let body;
111
39
  return new protocol_http_1.HttpRequest({
112
40
  protocol,
@@ -121,52 +49,16 @@ const serializeAws_restJson1GetSessionCommand = async (input, context) => {
121
49
  exports.serializeAws_restJson1GetSessionCommand = serializeAws_restJson1GetSessionCommand;
122
50
  const serializeAws_restJson1PutSessionCommand = async (input, context) => {
123
51
  const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
124
- const headers = {
52
+ const headers = map({}, isSerializableHeaderValue, {
125
53
  "content-type": "application/json",
126
- ...(isSerializableHeaderValue(input.responseContentType) && { responsecontenttype: input.responseContentType }),
127
- };
54
+ responsecontenttype: input.responseContentType,
55
+ });
128
56
  let resolvedPath = `${(basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}` +
129
57
  "/bots/{botId}/botAliases/{botAliasId}/botLocales/{localeId}/sessions/{sessionId}";
130
- if (input.botId !== undefined) {
131
- const labelValue = input.botId;
132
- if (labelValue.length <= 0) {
133
- throw new Error("Empty value provided for input HTTP label: botId.");
134
- }
135
- resolvedPath = resolvedPath.replace("{botId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
136
- }
137
- else {
138
- throw new Error("No value provided for input HTTP label: botId.");
139
- }
140
- if (input.botAliasId !== undefined) {
141
- const labelValue = input.botAliasId;
142
- if (labelValue.length <= 0) {
143
- throw new Error("Empty value provided for input HTTP label: botAliasId.");
144
- }
145
- resolvedPath = resolvedPath.replace("{botAliasId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
146
- }
147
- else {
148
- throw new Error("No value provided for input HTTP label: botAliasId.");
149
- }
150
- if (input.localeId !== undefined) {
151
- const labelValue = input.localeId;
152
- if (labelValue.length <= 0) {
153
- throw new Error("Empty value provided for input HTTP label: localeId.");
154
- }
155
- resolvedPath = resolvedPath.replace("{localeId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
156
- }
157
- else {
158
- throw new Error("No value provided for input HTTP label: localeId.");
159
- }
160
- if (input.sessionId !== undefined) {
161
- const labelValue = input.sessionId;
162
- if (labelValue.length <= 0) {
163
- throw new Error("Empty value provided for input HTTP label: sessionId.");
164
- }
165
- resolvedPath = resolvedPath.replace("{sessionId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
166
- }
167
- else {
168
- throw new Error("No value provided for input HTTP label: sessionId.");
169
- }
58
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "botId", () => input.botId, "{botId}", false);
59
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "botAliasId", () => input.botAliasId, "{botAliasId}", false);
60
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "localeId", () => input.localeId, "{localeId}", false);
61
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "sessionId", () => input.sessionId, "{sessionId}", false);
170
62
  let body;
171
63
  body = JSON.stringify({
172
64
  ...(input.messages != null && { messages: serializeAws_restJson1Messages(input.messages, context) }),
@@ -195,46 +87,10 @@ const serializeAws_restJson1RecognizeTextCommand = async (input, context) => {
195
87
  };
196
88
  let resolvedPath = `${(basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}` +
197
89
  "/bots/{botId}/botAliases/{botAliasId}/botLocales/{localeId}/sessions/{sessionId}/text";
198
- if (input.botId !== undefined) {
199
- const labelValue = input.botId;
200
- if (labelValue.length <= 0) {
201
- throw new Error("Empty value provided for input HTTP label: botId.");
202
- }
203
- resolvedPath = resolvedPath.replace("{botId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
204
- }
205
- else {
206
- throw new Error("No value provided for input HTTP label: botId.");
207
- }
208
- if (input.botAliasId !== undefined) {
209
- const labelValue = input.botAliasId;
210
- if (labelValue.length <= 0) {
211
- throw new Error("Empty value provided for input HTTP label: botAliasId.");
212
- }
213
- resolvedPath = resolvedPath.replace("{botAliasId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
214
- }
215
- else {
216
- throw new Error("No value provided for input HTTP label: botAliasId.");
217
- }
218
- if (input.localeId !== undefined) {
219
- const labelValue = input.localeId;
220
- if (labelValue.length <= 0) {
221
- throw new Error("Empty value provided for input HTTP label: localeId.");
222
- }
223
- resolvedPath = resolvedPath.replace("{localeId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
224
- }
225
- else {
226
- throw new Error("No value provided for input HTTP label: localeId.");
227
- }
228
- if (input.sessionId !== undefined) {
229
- const labelValue = input.sessionId;
230
- if (labelValue.length <= 0) {
231
- throw new Error("Empty value provided for input HTTP label: sessionId.");
232
- }
233
- resolvedPath = resolvedPath.replace("{sessionId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
234
- }
235
- else {
236
- throw new Error("No value provided for input HTTP label: sessionId.");
237
- }
90
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "botId", () => input.botId, "{botId}", false);
91
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "botAliasId", () => input.botAliasId, "{botAliasId}", false);
92
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "localeId", () => input.localeId, "{localeId}", false);
93
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "sessionId", () => input.sessionId, "{sessionId}", false);
238
94
  let body;
239
95
  body = JSON.stringify({
240
96
  ...(input.requestAttributes != null && {
@@ -258,60 +114,19 @@ const serializeAws_restJson1RecognizeTextCommand = async (input, context) => {
258
114
  exports.serializeAws_restJson1RecognizeTextCommand = serializeAws_restJson1RecognizeTextCommand;
259
115
  const serializeAws_restJson1RecognizeUtteranceCommand = async (input, context) => {
260
116
  const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
261
- const headers = {
262
- "content-type": "application/octet-stream",
117
+ const headers = map({}, isSerializableHeaderValue, {
263
118
  "x-amz-content-sha256": "UNSIGNED-PAYLOAD",
264
- ...(isSerializableHeaderValue(input.sessionState) && { "x-amz-lex-session-state": input.sessionState }),
265
- ...(isSerializableHeaderValue(input.requestAttributes) && {
266
- "x-amz-lex-request-attributes": input.requestAttributes,
267
- }),
268
- ...(isSerializableHeaderValue(input.requestContentType) && { "content-type": input.requestContentType }),
269
- ...(isSerializableHeaderValue(input.responseContentType) && {
270
- "response-content-type": input.responseContentType,
271
- }),
272
- };
119
+ "content-type": input.requestContentType || "application/octet-stream",
120
+ "x-amz-lex-session-state": input.sessionState,
121
+ "x-amz-lex-request-attributes": input.requestAttributes,
122
+ "response-content-type": input.responseContentType,
123
+ });
273
124
  let resolvedPath = `${(basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}` +
274
125
  "/bots/{botId}/botAliases/{botAliasId}/botLocales/{localeId}/sessions/{sessionId}/utterance";
275
- if (input.botId !== undefined) {
276
- const labelValue = input.botId;
277
- if (labelValue.length <= 0) {
278
- throw new Error("Empty value provided for input HTTP label: botId.");
279
- }
280
- resolvedPath = resolvedPath.replace("{botId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
281
- }
282
- else {
283
- throw new Error("No value provided for input HTTP label: botId.");
284
- }
285
- if (input.botAliasId !== undefined) {
286
- const labelValue = input.botAliasId;
287
- if (labelValue.length <= 0) {
288
- throw new Error("Empty value provided for input HTTP label: botAliasId.");
289
- }
290
- resolvedPath = resolvedPath.replace("{botAliasId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
291
- }
292
- else {
293
- throw new Error("No value provided for input HTTP label: botAliasId.");
294
- }
295
- if (input.localeId !== undefined) {
296
- const labelValue = input.localeId;
297
- if (labelValue.length <= 0) {
298
- throw new Error("Empty value provided for input HTTP label: localeId.");
299
- }
300
- resolvedPath = resolvedPath.replace("{localeId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
301
- }
302
- else {
303
- throw new Error("No value provided for input HTTP label: localeId.");
304
- }
305
- if (input.sessionId !== undefined) {
306
- const labelValue = input.sessionId;
307
- if (labelValue.length <= 0) {
308
- throw new Error("Empty value provided for input HTTP label: sessionId.");
309
- }
310
- resolvedPath = resolvedPath.replace("{sessionId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
311
- }
312
- else {
313
- throw new Error("No value provided for input HTTP label: sessionId.");
314
- }
126
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "botId", () => input.botId, "{botId}", false);
127
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "botAliasId", () => input.botAliasId, "{botAliasId}", false);
128
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "localeId", () => input.localeId, "{localeId}", false);
129
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "sessionId", () => input.sessionId, "{sessionId}", false);
315
130
  let body;
316
131
  if (input.inputStream !== undefined) {
317
132
  body = input.inputStream;
@@ -329,53 +144,15 @@ const serializeAws_restJson1RecognizeUtteranceCommand = async (input, context) =
329
144
  exports.serializeAws_restJson1RecognizeUtteranceCommand = serializeAws_restJson1RecognizeUtteranceCommand;
330
145
  const serializeAws_restJson1StartConversationCommand = async (input, context) => {
331
146
  const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
332
- const headers = {
333
- ...(isSerializableHeaderValue(input.conversationMode) && {
334
- "x-amz-lex-conversation-mode": input.conversationMode,
335
- }),
336
- };
147
+ const headers = map({}, isSerializableHeaderValue, {
148
+ "x-amz-lex-conversation-mode": input.conversationMode,
149
+ });
337
150
  let resolvedPath = `${(basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}` +
338
151
  "/bots/{botId}/botAliases/{botAliasId}/botLocales/{localeId}/sessions/{sessionId}/conversation";
339
- if (input.botId !== undefined) {
340
- const labelValue = input.botId;
341
- if (labelValue.length <= 0) {
342
- throw new Error("Empty value provided for input HTTP label: botId.");
343
- }
344
- resolvedPath = resolvedPath.replace("{botId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
345
- }
346
- else {
347
- throw new Error("No value provided for input HTTP label: botId.");
348
- }
349
- if (input.botAliasId !== undefined) {
350
- const labelValue = input.botAliasId;
351
- if (labelValue.length <= 0) {
352
- throw new Error("Empty value provided for input HTTP label: botAliasId.");
353
- }
354
- resolvedPath = resolvedPath.replace("{botAliasId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
355
- }
356
- else {
357
- throw new Error("No value provided for input HTTP label: botAliasId.");
358
- }
359
- if (input.localeId !== undefined) {
360
- const labelValue = input.localeId;
361
- if (labelValue.length <= 0) {
362
- throw new Error("Empty value provided for input HTTP label: localeId.");
363
- }
364
- resolvedPath = resolvedPath.replace("{localeId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
365
- }
366
- else {
367
- throw new Error("No value provided for input HTTP label: localeId.");
368
- }
369
- if (input.sessionId !== undefined) {
370
- const labelValue = input.sessionId;
371
- if (labelValue.length <= 0) {
372
- throw new Error("Empty value provided for input HTTP label: sessionId.");
373
- }
374
- resolvedPath = resolvedPath.replace("{sessionId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
375
- }
376
- else {
377
- throw new Error("No value provided for input HTTP label: sessionId.");
378
- }
152
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "botId", () => input.botId, "{botId}", false);
153
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "botAliasId", () => input.botAliasId, "{botAliasId}", false);
154
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "localeId", () => input.localeId, "{localeId}", false);
155
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "sessionId", () => input.sessionId, "{sessionId}", false);
379
156
  let body;
380
157
  if (input.requestEventStream !== undefined) {
381
158
  body = serializeAws_restJson1StartConversationRequestEventStream(input.requestEventStream, context);
@@ -395,27 +172,23 @@ const deserializeAws_restJson1DeleteSessionCommand = async (output, context) =>
395
172
  if (output.statusCode !== 200 && output.statusCode >= 300) {
396
173
  return deserializeAws_restJson1DeleteSessionCommandError(output, context);
397
174
  }
398
- const contents = {
175
+ const contents = map({
399
176
  $metadata: deserializeMetadata(output),
400
- botAliasId: undefined,
401
- botId: undefined,
402
- localeId: undefined,
403
- sessionId: undefined,
404
- };
177
+ });
405
178
  const data = (0, smithy_client_1.expectNonNull)((0, smithy_client_1.expectObject)(await parseBody(output.body, context)), "body");
406
- if (data.botAliasId !== undefined && data.botAliasId !== null) {
179
+ if (data.botAliasId != null) {
407
180
  contents.botAliasId = (0, smithy_client_1.expectString)(data.botAliasId);
408
181
  }
409
- if (data.botId !== undefined && data.botId !== null) {
182
+ if (data.botId != null) {
410
183
  contents.botId = (0, smithy_client_1.expectString)(data.botId);
411
184
  }
412
- if (data.localeId !== undefined && data.localeId !== null) {
185
+ if (data.localeId != null) {
413
186
  contents.localeId = (0, smithy_client_1.expectString)(data.localeId);
414
187
  }
415
- if (data.sessionId !== undefined && data.sessionId !== null) {
188
+ if (data.sessionId != null) {
416
189
  contents.sessionId = (0, smithy_client_1.expectString)(data.sessionId);
417
190
  }
418
- return Promise.resolve(contents);
191
+ return contents;
419
192
  };
420
193
  exports.deserializeAws_restJson1DeleteSessionCommand = deserializeAws_restJson1DeleteSessionCommand;
421
194
  const deserializeAws_restJson1DeleteSessionCommandError = async (output, context) => {
@@ -423,7 +196,6 @@ const deserializeAws_restJson1DeleteSessionCommandError = async (output, context
423
196
  ...output,
424
197
  body: await parseBody(output.body, context),
425
198
  };
426
- let response;
427
199
  const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
428
200
  switch (errorCode) {
429
201
  case "AccessDeniedException":
@@ -446,41 +218,35 @@ const deserializeAws_restJson1DeleteSessionCommandError = async (output, context
446
218
  throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context);
447
219
  default:
448
220
  const parsedBody = parsedOutput.body;
449
- const $metadata = deserializeMetadata(output);
450
- const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
451
- response = new LexRuntimeV2ServiceException_1.LexRuntimeV2ServiceException({
452
- name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
453
- $fault: "client",
454
- $metadata,
221
+ (0, smithy_client_1.throwDefaultError)({
222
+ output,
223
+ parsedBody,
224
+ exceptionCtor: LexRuntimeV2ServiceException_1.LexRuntimeV2ServiceException,
225
+ errorCode,
455
226
  });
456
- throw (0, smithy_client_1.decorateServiceException)(response, parsedBody);
457
227
  }
458
228
  };
459
229
  const deserializeAws_restJson1GetSessionCommand = async (output, context) => {
460
230
  if (output.statusCode !== 200 && output.statusCode >= 300) {
461
231
  return deserializeAws_restJson1GetSessionCommandError(output, context);
462
232
  }
463
- const contents = {
233
+ const contents = map({
464
234
  $metadata: deserializeMetadata(output),
465
- interpretations: undefined,
466
- messages: undefined,
467
- sessionId: undefined,
468
- sessionState: undefined,
469
- };
235
+ });
470
236
  const data = (0, smithy_client_1.expectNonNull)((0, smithy_client_1.expectObject)(await parseBody(output.body, context)), "body");
471
- if (data.interpretations !== undefined && data.interpretations !== null) {
237
+ if (data.interpretations != null) {
472
238
  contents.interpretations = deserializeAws_restJson1Interpretations(data.interpretations, context);
473
239
  }
474
- if (data.messages !== undefined && data.messages !== null) {
240
+ if (data.messages != null) {
475
241
  contents.messages = deserializeAws_restJson1Messages(data.messages, context);
476
242
  }
477
- if (data.sessionId !== undefined && data.sessionId !== null) {
243
+ if (data.sessionId != null) {
478
244
  contents.sessionId = (0, smithy_client_1.expectString)(data.sessionId);
479
245
  }
480
- if (data.sessionState !== undefined && data.sessionState !== null) {
246
+ if (data.sessionState != null) {
481
247
  contents.sessionState = deserializeAws_restJson1SessionState(data.sessionState, context);
482
248
  }
483
- return Promise.resolve(contents);
249
+ return contents;
484
250
  };
485
251
  exports.deserializeAws_restJson1GetSessionCommand = deserializeAws_restJson1GetSessionCommand;
486
252
  const deserializeAws_restJson1GetSessionCommandError = async (output, context) => {
@@ -488,7 +254,6 @@ const deserializeAws_restJson1GetSessionCommandError = async (output, context) =
488
254
  ...output,
489
255
  body: await parseBody(output.body, context),
490
256
  };
491
- let response;
492
257
  const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
493
258
  switch (errorCode) {
494
259
  case "AccessDeniedException":
@@ -508,47 +273,29 @@ const deserializeAws_restJson1GetSessionCommandError = async (output, context) =
508
273
  throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context);
509
274
  default:
510
275
  const parsedBody = parsedOutput.body;
511
- const $metadata = deserializeMetadata(output);
512
- const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
513
- response = new LexRuntimeV2ServiceException_1.LexRuntimeV2ServiceException({
514
- name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
515
- $fault: "client",
516
- $metadata,
276
+ (0, smithy_client_1.throwDefaultError)({
277
+ output,
278
+ parsedBody,
279
+ exceptionCtor: LexRuntimeV2ServiceException_1.LexRuntimeV2ServiceException,
280
+ errorCode,
517
281
  });
518
- throw (0, smithy_client_1.decorateServiceException)(response, parsedBody);
519
282
  }
520
283
  };
521
284
  const deserializeAws_restJson1PutSessionCommand = async (output, context) => {
522
285
  if (output.statusCode !== 200 && output.statusCode >= 300) {
523
286
  return deserializeAws_restJson1PutSessionCommandError(output, context);
524
287
  }
525
- const contents = {
288
+ const contents = map({
526
289
  $metadata: deserializeMetadata(output),
527
- audioStream: undefined,
528
- contentType: undefined,
529
- messages: undefined,
530
- requestAttributes: undefined,
531
- sessionId: undefined,
532
- sessionState: undefined,
533
- };
534
- if (output.headers["content-type"] !== undefined) {
535
- contents.contentType = output.headers["content-type"];
536
- }
537
- if (output.headers["x-amz-lex-messages"] !== undefined) {
538
- contents.messages = output.headers["x-amz-lex-messages"];
539
- }
540
- if (output.headers["x-amz-lex-session-state"] !== undefined) {
541
- contents.sessionState = output.headers["x-amz-lex-session-state"];
542
- }
543
- if (output.headers["x-amz-lex-request-attributes"] !== undefined) {
544
- contents.requestAttributes = output.headers["x-amz-lex-request-attributes"];
545
- }
546
- if (output.headers["x-amz-lex-session-id"] !== undefined) {
547
- contents.sessionId = output.headers["x-amz-lex-session-id"];
548
- }
290
+ contentType: [, output.headers["content-type"]],
291
+ messages: [, output.headers["x-amz-lex-messages"]],
292
+ sessionState: [, output.headers["x-amz-lex-session-state"]],
293
+ requestAttributes: [, output.headers["x-amz-lex-request-attributes"]],
294
+ sessionId: [, output.headers["x-amz-lex-session-id"]],
295
+ });
549
296
  const data = output.body;
550
297
  contents.audioStream = data;
551
- return Promise.resolve(contents);
298
+ return contents;
552
299
  };
553
300
  exports.deserializeAws_restJson1PutSessionCommand = deserializeAws_restJson1PutSessionCommand;
554
301
  const deserializeAws_restJson1PutSessionCommandError = async (output, context) => {
@@ -556,7 +303,6 @@ const deserializeAws_restJson1PutSessionCommandError = async (output, context) =
556
303
  ...output,
557
304
  body: await parseBody(output.body, context),
558
305
  };
559
- let response;
560
306
  const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
561
307
  switch (errorCode) {
562
308
  case "AccessDeniedException":
@@ -585,45 +331,38 @@ const deserializeAws_restJson1PutSessionCommandError = async (output, context) =
585
331
  throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context);
586
332
  default:
587
333
  const parsedBody = parsedOutput.body;
588
- const $metadata = deserializeMetadata(output);
589
- const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
590
- response = new LexRuntimeV2ServiceException_1.LexRuntimeV2ServiceException({
591
- name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
592
- $fault: "client",
593
- $metadata,
334
+ (0, smithy_client_1.throwDefaultError)({
335
+ output,
336
+ parsedBody,
337
+ exceptionCtor: LexRuntimeV2ServiceException_1.LexRuntimeV2ServiceException,
338
+ errorCode,
594
339
  });
595
- throw (0, smithy_client_1.decorateServiceException)(response, parsedBody);
596
340
  }
597
341
  };
598
342
  const deserializeAws_restJson1RecognizeTextCommand = async (output, context) => {
599
343
  if (output.statusCode !== 200 && output.statusCode >= 300) {
600
344
  return deserializeAws_restJson1RecognizeTextCommandError(output, context);
601
345
  }
602
- const contents = {
346
+ const contents = map({
603
347
  $metadata: deserializeMetadata(output),
604
- interpretations: undefined,
605
- messages: undefined,
606
- requestAttributes: undefined,
607
- sessionId: undefined,
608
- sessionState: undefined,
609
- };
348
+ });
610
349
  const data = (0, smithy_client_1.expectNonNull)((0, smithy_client_1.expectObject)(await parseBody(output.body, context)), "body");
611
- if (data.interpretations !== undefined && data.interpretations !== null) {
350
+ if (data.interpretations != null) {
612
351
  contents.interpretations = deserializeAws_restJson1Interpretations(data.interpretations, context);
613
352
  }
614
- if (data.messages !== undefined && data.messages !== null) {
353
+ if (data.messages != null) {
615
354
  contents.messages = deserializeAws_restJson1Messages(data.messages, context);
616
355
  }
617
- if (data.requestAttributes !== undefined && data.requestAttributes !== null) {
356
+ if (data.requestAttributes != null) {
618
357
  contents.requestAttributes = deserializeAws_restJson1StringMap(data.requestAttributes, context);
619
358
  }
620
- if (data.sessionId !== undefined && data.sessionId !== null) {
359
+ if (data.sessionId != null) {
621
360
  contents.sessionId = (0, smithy_client_1.expectString)(data.sessionId);
622
361
  }
623
- if (data.sessionState !== undefined && data.sessionState !== null) {
362
+ if (data.sessionState != null) {
624
363
  contents.sessionState = deserializeAws_restJson1SessionState(data.sessionState, context);
625
364
  }
626
- return Promise.resolve(contents);
365
+ return contents;
627
366
  };
628
367
  exports.deserializeAws_restJson1RecognizeTextCommand = deserializeAws_restJson1RecognizeTextCommand;
629
368
  const deserializeAws_restJson1RecognizeTextCommandError = async (output, context) => {
@@ -631,7 +370,6 @@ const deserializeAws_restJson1RecognizeTextCommandError = async (output, context
631
370
  ...output,
632
371
  body: await parseBody(output.body, context),
633
372
  };
634
- let response;
635
373
  const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
636
374
  switch (errorCode) {
637
375
  case "AccessDeniedException":
@@ -660,59 +398,32 @@ const deserializeAws_restJson1RecognizeTextCommandError = async (output, context
660
398
  throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context);
661
399
  default:
662
400
  const parsedBody = parsedOutput.body;
663
- const $metadata = deserializeMetadata(output);
664
- const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
665
- response = new LexRuntimeV2ServiceException_1.LexRuntimeV2ServiceException({
666
- name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
667
- $fault: "client",
668
- $metadata,
401
+ (0, smithy_client_1.throwDefaultError)({
402
+ output,
403
+ parsedBody,
404
+ exceptionCtor: LexRuntimeV2ServiceException_1.LexRuntimeV2ServiceException,
405
+ errorCode,
669
406
  });
670
- throw (0, smithy_client_1.decorateServiceException)(response, parsedBody);
671
407
  }
672
408
  };
673
409
  const deserializeAws_restJson1RecognizeUtteranceCommand = async (output, context) => {
674
410
  if (output.statusCode !== 200 && output.statusCode >= 300) {
675
411
  return deserializeAws_restJson1RecognizeUtteranceCommandError(output, context);
676
412
  }
677
- const contents = {
413
+ const contents = map({
678
414
  $metadata: deserializeMetadata(output),
679
- audioStream: undefined,
680
- contentType: undefined,
681
- inputMode: undefined,
682
- inputTranscript: undefined,
683
- interpretations: undefined,
684
- messages: undefined,
685
- requestAttributes: undefined,
686
- sessionId: undefined,
687
- sessionState: undefined,
688
- };
689
- if (output.headers["x-amz-lex-input-mode"] !== undefined) {
690
- contents.inputMode = output.headers["x-amz-lex-input-mode"];
691
- }
692
- if (output.headers["content-type"] !== undefined) {
693
- contents.contentType = output.headers["content-type"];
694
- }
695
- if (output.headers["x-amz-lex-messages"] !== undefined) {
696
- contents.messages = output.headers["x-amz-lex-messages"];
697
- }
698
- if (output.headers["x-amz-lex-interpretations"] !== undefined) {
699
- contents.interpretations = output.headers["x-amz-lex-interpretations"];
700
- }
701
- if (output.headers["x-amz-lex-session-state"] !== undefined) {
702
- contents.sessionState = output.headers["x-amz-lex-session-state"];
703
- }
704
- if (output.headers["x-amz-lex-request-attributes"] !== undefined) {
705
- contents.requestAttributes = output.headers["x-amz-lex-request-attributes"];
706
- }
707
- if (output.headers["x-amz-lex-session-id"] !== undefined) {
708
- contents.sessionId = output.headers["x-amz-lex-session-id"];
709
- }
710
- if (output.headers["x-amz-lex-input-transcript"] !== undefined) {
711
- contents.inputTranscript = output.headers["x-amz-lex-input-transcript"];
712
- }
415
+ inputMode: [, output.headers["x-amz-lex-input-mode"]],
416
+ contentType: [, output.headers["content-type"]],
417
+ messages: [, output.headers["x-amz-lex-messages"]],
418
+ interpretations: [, output.headers["x-amz-lex-interpretations"]],
419
+ sessionState: [, output.headers["x-amz-lex-session-state"]],
420
+ requestAttributes: [, output.headers["x-amz-lex-request-attributes"]],
421
+ sessionId: [, output.headers["x-amz-lex-session-id"]],
422
+ inputTranscript: [, output.headers["x-amz-lex-input-transcript"]],
423
+ });
713
424
  const data = output.body;
714
425
  contents.audioStream = data;
715
- return Promise.resolve(contents);
426
+ return contents;
716
427
  };
717
428
  exports.deserializeAws_restJson1RecognizeUtteranceCommand = deserializeAws_restJson1RecognizeUtteranceCommand;
718
429
  const deserializeAws_restJson1RecognizeUtteranceCommandError = async (output, context) => {
@@ -720,7 +431,6 @@ const deserializeAws_restJson1RecognizeUtteranceCommandError = async (output, co
720
431
  ...output,
721
432
  body: await parseBody(output.body, context),
722
433
  };
723
- let response;
724
434
  const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
725
435
  switch (errorCode) {
726
436
  case "AccessDeniedException":
@@ -749,27 +459,24 @@ const deserializeAws_restJson1RecognizeUtteranceCommandError = async (output, co
749
459
  throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context);
750
460
  default:
751
461
  const parsedBody = parsedOutput.body;
752
- const $metadata = deserializeMetadata(output);
753
- const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
754
- response = new LexRuntimeV2ServiceException_1.LexRuntimeV2ServiceException({
755
- name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
756
- $fault: "client",
757
- $metadata,
462
+ (0, smithy_client_1.throwDefaultError)({
463
+ output,
464
+ parsedBody,
465
+ exceptionCtor: LexRuntimeV2ServiceException_1.LexRuntimeV2ServiceException,
466
+ errorCode,
758
467
  });
759
- throw (0, smithy_client_1.decorateServiceException)(response, parsedBody);
760
468
  }
761
469
  };
762
470
  const deserializeAws_restJson1StartConversationCommand = async (output, context) => {
763
471
  if (output.statusCode !== 200 && output.statusCode >= 300) {
764
472
  return deserializeAws_restJson1StartConversationCommandError(output, context);
765
473
  }
766
- const contents = {
474
+ const contents = map({
767
475
  $metadata: deserializeMetadata(output),
768
- responseEventStream: undefined,
769
- };
476
+ });
770
477
  const data = output.body;
771
478
  contents.responseEventStream = deserializeAws_restJson1StartConversationResponseEventStream(data, context);
772
- return Promise.resolve(contents);
479
+ return contents;
773
480
  };
774
481
  exports.deserializeAws_restJson1StartConversationCommand = deserializeAws_restJson1StartConversationCommand;
775
482
  const deserializeAws_restJson1StartConversationCommandError = async (output, context) => {
@@ -777,7 +484,6 @@ const deserializeAws_restJson1StartConversationCommandError = async (output, con
777
484
  ...output,
778
485
  body: await parseBody(output.body, context),
779
486
  };
780
- let response;
781
487
  const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
782
488
  switch (errorCode) {
783
489
  case "AccessDeniedException":
@@ -794,20 +500,19 @@ const deserializeAws_restJson1StartConversationCommandError = async (output, con
794
500
  throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context);
795
501
  default:
796
502
  const parsedBody = parsedOutput.body;
797
- const $metadata = deserializeMetadata(output);
798
- const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
799
- response = new LexRuntimeV2ServiceException_1.LexRuntimeV2ServiceException({
800
- name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
801
- $fault: "client",
802
- $metadata,
503
+ (0, smithy_client_1.throwDefaultError)({
504
+ output,
505
+ parsedBody,
506
+ exceptionCtor: LexRuntimeV2ServiceException_1.LexRuntimeV2ServiceException,
507
+ errorCode,
803
508
  });
804
- throw (0, smithy_client_1.decorateServiceException)(response, parsedBody);
805
509
  }
806
510
  };
511
+ const map = smithy_client_1.map;
807
512
  const deserializeAws_restJson1AccessDeniedExceptionResponse = async (parsedOutput, context) => {
808
- const contents = {};
513
+ const contents = map({});
809
514
  const data = parsedOutput.body;
810
- if (data.message !== undefined && data.message !== null) {
515
+ if (data.message != null) {
811
516
  contents.message = (0, smithy_client_1.expectString)(data.message);
812
517
  }
813
518
  const exception = new models_0_1.AccessDeniedException({
@@ -817,9 +522,9 @@ const deserializeAws_restJson1AccessDeniedExceptionResponse = async (parsedOutpu
817
522
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
818
523
  };
819
524
  const deserializeAws_restJson1BadGatewayExceptionResponse = async (parsedOutput, context) => {
820
- const contents = {};
525
+ const contents = map({});
821
526
  const data = parsedOutput.body;
822
- if (data.message !== undefined && data.message !== null) {
527
+ if (data.message != null) {
823
528
  contents.message = (0, smithy_client_1.expectString)(data.message);
824
529
  }
825
530
  const exception = new models_0_1.BadGatewayException({
@@ -829,9 +534,9 @@ const deserializeAws_restJson1BadGatewayExceptionResponse = async (parsedOutput,
829
534
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
830
535
  };
831
536
  const deserializeAws_restJson1ConflictExceptionResponse = async (parsedOutput, context) => {
832
- const contents = {};
537
+ const contents = map({});
833
538
  const data = parsedOutput.body;
834
- if (data.message !== undefined && data.message !== null) {
539
+ if (data.message != null) {
835
540
  contents.message = (0, smithy_client_1.expectString)(data.message);
836
541
  }
837
542
  const exception = new models_0_1.ConflictException({
@@ -841,9 +546,9 @@ const deserializeAws_restJson1ConflictExceptionResponse = async (parsedOutput, c
841
546
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
842
547
  };
843
548
  const deserializeAws_restJson1DependencyFailedExceptionResponse = async (parsedOutput, context) => {
844
- const contents = {};
549
+ const contents = map({});
845
550
  const data = parsedOutput.body;
846
- if (data.message !== undefined && data.message !== null) {
551
+ if (data.message != null) {
847
552
  contents.message = (0, smithy_client_1.expectString)(data.message);
848
553
  }
849
554
  const exception = new models_0_1.DependencyFailedException({
@@ -853,9 +558,9 @@ const deserializeAws_restJson1DependencyFailedExceptionResponse = async (parsedO
853
558
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
854
559
  };
855
560
  const deserializeAws_restJson1InternalServerExceptionResponse = async (parsedOutput, context) => {
856
- const contents = {};
561
+ const contents = map({});
857
562
  const data = parsedOutput.body;
858
- if (data.message !== undefined && data.message !== null) {
563
+ if (data.message != null) {
859
564
  contents.message = (0, smithy_client_1.expectString)(data.message);
860
565
  }
861
566
  const exception = new models_0_1.InternalServerException({
@@ -865,9 +570,9 @@ const deserializeAws_restJson1InternalServerExceptionResponse = async (parsedOut
865
570
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
866
571
  };
867
572
  const deserializeAws_restJson1ResourceNotFoundExceptionResponse = async (parsedOutput, context) => {
868
- const contents = {};
573
+ const contents = map({});
869
574
  const data = parsedOutput.body;
870
- if (data.message !== undefined && data.message !== null) {
575
+ if (data.message != null) {
871
576
  contents.message = (0, smithy_client_1.expectString)(data.message);
872
577
  }
873
578
  const exception = new models_0_1.ResourceNotFoundException({
@@ -877,9 +582,9 @@ const deserializeAws_restJson1ResourceNotFoundExceptionResponse = async (parsedO
877
582
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
878
583
  };
879
584
  const deserializeAws_restJson1ThrottlingExceptionResponse = async (parsedOutput, context) => {
880
- const contents = {};
585
+ const contents = map({});
881
586
  const data = parsedOutput.body;
882
- if (data.message !== undefined && data.message !== null) {
587
+ if (data.message != null) {
883
588
  contents.message = (0, smithy_client_1.expectString)(data.message);
884
589
  }
885
590
  const exception = new models_0_1.ThrottlingException({
@@ -889,9 +594,9 @@ const deserializeAws_restJson1ThrottlingExceptionResponse = async (parsedOutput,
889
594
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
890
595
  };
891
596
  const deserializeAws_restJson1ValidationExceptionResponse = async (parsedOutput, context) => {
892
- const contents = {};
597
+ const contents = map({});
893
598
  const data = parsedOutput.body;
894
- if (data.message !== undefined && data.message !== null) {
599
+ if (data.message != null) {
895
600
  contents.message = (0, smithy_client_1.expectString)(data.message);
896
601
  }
897
602
  const exception = new models_0_1.ValidationException({
@@ -1171,9 +876,6 @@ const serializeAws_restJson1ActiveContextsList = (input, context) => {
1171
876
  return input
1172
877
  .filter((e) => e != null)
1173
878
  .map((entry) => {
1174
- if (entry === null) {
1175
- return null;
1176
- }
1177
879
  return serializeAws_restJson1ActiveContext(entry, context);
1178
880
  });
1179
881
  };
@@ -1201,9 +903,6 @@ const serializeAws_restJson1ButtonsList = (input, context) => {
1201
903
  return input
1202
904
  .filter((e) => e != null)
1203
905
  .map((entry) => {
1204
- if (entry === null) {
1205
- return null;
1206
- }
1207
906
  return serializeAws_restJson1Button(entry, context);
1208
907
  });
1209
908
  };
@@ -1273,9 +972,6 @@ const serializeAws_restJson1Messages = (input, context) => {
1273
972
  return input
1274
973
  .filter((e) => e != null)
1275
974
  .map((entry) => {
1276
- if (entry === null) {
1277
- return null;
1278
- }
1279
975
  return serializeAws_restJson1Message(entry, context);
1280
976
  });
1281
977
  };
@@ -1306,9 +1002,6 @@ const serializeAws_restJson1RuntimeHintValuesList = (input, context) => {
1306
1002
  return input
1307
1003
  .filter((e) => e != null)
1308
1004
  .map((entry) => {
1309
- if (entry === null) {
1310
- return null;
1311
- }
1312
1005
  return serializeAws_restJson1RuntimeHintValue(entry, context);
1313
1006
  });
1314
1007
  };
@@ -1374,9 +1067,6 @@ const serializeAws_restJson1StringList = (input, context) => {
1374
1067
  return input
1375
1068
  .filter((e) => e != null)
1376
1069
  .map((entry) => {
1377
- if (entry === null) {
1378
- return null;
1379
- }
1380
1070
  return entry;
1381
1071
  });
1382
1072
  };
@@ -1411,9 +1101,6 @@ const serializeAws_restJson1Values = (input, context) => {
1411
1101
  return input
1412
1102
  .filter((e) => e != null)
1413
1103
  .map((entry) => {
1414
- if (entry === null) {
1415
- return null;
1416
- }
1417
1104
  return serializeAws_restJson1Slot(entry, context);
1418
1105
  });
1419
1106
  };