@aws-sdk/client-polly 3.141.0 → 3.142.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.
@@ -9,16 +9,7 @@ const serializeAws_restJson1DeleteLexiconCommand = async (input, context) => {
9
9
  const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
10
10
  const headers = {};
11
11
  let resolvedPath = `${(basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}` + "/v1/lexicons/{Name}";
12
- if (input.Name !== undefined) {
13
- const labelValue = input.Name;
14
- if (labelValue.length <= 0) {
15
- throw new Error("Empty value provided for input HTTP label: Name.");
16
- }
17
- resolvedPath = resolvedPath.replace("{Name}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
18
- }
19
- else {
20
- throw new Error("No value provided for input HTTP label: Name.");
21
- }
12
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "Name", () => input.Name, "{Name}", false);
22
13
  let body;
23
14
  return new protocol_http_1.HttpRequest({
24
15
  protocol,
@@ -35,14 +26,15 @@ const serializeAws_restJson1DescribeVoicesCommand = async (input, context) => {
35
26
  const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
36
27
  const headers = {};
37
28
  const resolvedPath = `${(basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}` + "/v1/voices";
38
- const query = {
39
- ...(input.Engine !== undefined && { Engine: input.Engine }),
40
- ...(input.LanguageCode !== undefined && { LanguageCode: input.LanguageCode }),
41
- ...(input.IncludeAdditionalLanguageCodes !== undefined && {
42
- IncludeAdditionalLanguageCodes: input.IncludeAdditionalLanguageCodes.toString(),
43
- }),
44
- ...(input.NextToken !== undefined && { NextToken: input.NextToken }),
45
- };
29
+ const query = map({
30
+ Engine: [, input.Engine],
31
+ LanguageCode: [, input.LanguageCode],
32
+ IncludeAdditionalLanguageCodes: [
33
+ () => input.IncludeAdditionalLanguageCodes !== void 0,
34
+ () => input.IncludeAdditionalLanguageCodes.toString(),
35
+ ],
36
+ NextToken: [, input.NextToken],
37
+ });
46
38
  let body;
47
39
  return new protocol_http_1.HttpRequest({
48
40
  protocol,
@@ -60,16 +52,7 @@ const serializeAws_restJson1GetLexiconCommand = async (input, context) => {
60
52
  const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
61
53
  const headers = {};
62
54
  let resolvedPath = `${(basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}` + "/v1/lexicons/{Name}";
63
- if (input.Name !== undefined) {
64
- const labelValue = input.Name;
65
- if (labelValue.length <= 0) {
66
- throw new Error("Empty value provided for input HTTP label: Name.");
67
- }
68
- resolvedPath = resolvedPath.replace("{Name}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
69
- }
70
- else {
71
- throw new Error("No value provided for input HTTP label: Name.");
72
- }
55
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "Name", () => input.Name, "{Name}", false);
73
56
  let body;
74
57
  return new protocol_http_1.HttpRequest({
75
58
  protocol,
@@ -86,16 +69,7 @@ const serializeAws_restJson1GetSpeechSynthesisTaskCommand = async (input, contex
86
69
  const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
87
70
  const headers = {};
88
71
  let resolvedPath = `${(basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}` + "/v1/synthesisTasks/{TaskId}";
89
- if (input.TaskId !== undefined) {
90
- const labelValue = input.TaskId;
91
- if (labelValue.length <= 0) {
92
- throw new Error("Empty value provided for input HTTP label: TaskId.");
93
- }
94
- resolvedPath = resolvedPath.replace("{TaskId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
95
- }
96
- else {
97
- throw new Error("No value provided for input HTTP label: TaskId.");
98
- }
72
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "TaskId", () => input.TaskId, "{TaskId}", false);
99
73
  let body;
100
74
  return new protocol_http_1.HttpRequest({
101
75
  protocol,
@@ -112,9 +86,9 @@ const serializeAws_restJson1ListLexiconsCommand = async (input, context) => {
112
86
  const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
113
87
  const headers = {};
114
88
  const resolvedPath = `${(basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}` + "/v1/lexicons";
115
- const query = {
116
- ...(input.NextToken !== undefined && { NextToken: input.NextToken }),
117
- };
89
+ const query = map({
90
+ NextToken: [, input.NextToken],
91
+ });
118
92
  let body;
119
93
  return new protocol_http_1.HttpRequest({
120
94
  protocol,
@@ -132,11 +106,11 @@ const serializeAws_restJson1ListSpeechSynthesisTasksCommand = async (input, cont
132
106
  const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
133
107
  const headers = {};
134
108
  const resolvedPath = `${(basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}` + "/v1/synthesisTasks";
135
- const query = {
136
- ...(input.MaxResults !== undefined && { MaxResults: input.MaxResults.toString() }),
137
- ...(input.NextToken !== undefined && { NextToken: input.NextToken }),
138
- ...(input.Status !== undefined && { Status: input.Status }),
139
- };
109
+ const query = map({
110
+ MaxResults: [() => input.MaxResults !== void 0, () => input.MaxResults.toString()],
111
+ NextToken: [, input.NextToken],
112
+ Status: [, input.Status],
113
+ });
140
114
  let body;
141
115
  return new protocol_http_1.HttpRequest({
142
116
  protocol,
@@ -156,16 +130,7 @@ const serializeAws_restJson1PutLexiconCommand = async (input, context) => {
156
130
  "content-type": "application/json",
157
131
  };
158
132
  let resolvedPath = `${(basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}` + "/v1/lexicons/{Name}";
159
- if (input.Name !== undefined) {
160
- const labelValue = input.Name;
161
- if (labelValue.length <= 0) {
162
- throw new Error("Empty value provided for input HTTP label: Name.");
163
- }
164
- resolvedPath = resolvedPath.replace("{Name}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
165
- }
166
- else {
167
- throw new Error("No value provided for input HTTP label: Name.");
168
- }
133
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "Name", () => input.Name, "{Name}", false);
169
134
  let body;
170
135
  body = JSON.stringify({
171
136
  ...(input.Content != null && { Content: input.Content }),
@@ -254,11 +219,11 @@ const deserializeAws_restJson1DeleteLexiconCommand = async (output, context) =>
254
219
  if (output.statusCode !== 200 && output.statusCode >= 300) {
255
220
  return deserializeAws_restJson1DeleteLexiconCommandError(output, context);
256
221
  }
257
- const contents = {
222
+ const contents = map({
258
223
  $metadata: deserializeMetadata(output),
259
- };
224
+ });
260
225
  await collectBody(output.body, context);
261
- return Promise.resolve(contents);
226
+ return contents;
262
227
  };
263
228
  exports.deserializeAws_restJson1DeleteLexiconCommand = deserializeAws_restJson1DeleteLexiconCommand;
264
229
  const deserializeAws_restJson1DeleteLexiconCommandError = async (output, context) => {
@@ -266,7 +231,6 @@ const deserializeAws_restJson1DeleteLexiconCommandError = async (output, context
266
231
  ...output,
267
232
  body: await parseBody(output.body, context),
268
233
  };
269
- let response;
270
234
  const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
271
235
  switch (errorCode) {
272
236
  case "LexiconNotFoundException":
@@ -277,33 +241,29 @@ const deserializeAws_restJson1DeleteLexiconCommandError = async (output, context
277
241
  throw await deserializeAws_restJson1ServiceFailureExceptionResponse(parsedOutput, context);
278
242
  default:
279
243
  const parsedBody = parsedOutput.body;
280
- const $metadata = deserializeMetadata(output);
281
- const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
282
- response = new PollyServiceException_1.PollyServiceException({
283
- name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
284
- $fault: "client",
285
- $metadata,
244
+ (0, smithy_client_1.throwDefaultError)({
245
+ output,
246
+ parsedBody,
247
+ exceptionCtor: PollyServiceException_1.PollyServiceException,
248
+ errorCode,
286
249
  });
287
- throw (0, smithy_client_1.decorateServiceException)(response, parsedBody);
288
250
  }
289
251
  };
290
252
  const deserializeAws_restJson1DescribeVoicesCommand = async (output, context) => {
291
253
  if (output.statusCode !== 200 && output.statusCode >= 300) {
292
254
  return deserializeAws_restJson1DescribeVoicesCommandError(output, context);
293
255
  }
294
- const contents = {
256
+ const contents = map({
295
257
  $metadata: deserializeMetadata(output),
296
- NextToken: undefined,
297
- Voices: undefined,
298
- };
258
+ });
299
259
  const data = (0, smithy_client_1.expectNonNull)((0, smithy_client_1.expectObject)(await parseBody(output.body, context)), "body");
300
- if (data.NextToken !== undefined && data.NextToken !== null) {
260
+ if (data.NextToken != null) {
301
261
  contents.NextToken = (0, smithy_client_1.expectString)(data.NextToken);
302
262
  }
303
- if (data.Voices !== undefined && data.Voices !== null) {
263
+ if (data.Voices != null) {
304
264
  contents.Voices = deserializeAws_restJson1VoiceList(data.Voices, context);
305
265
  }
306
- return Promise.resolve(contents);
266
+ return contents;
307
267
  };
308
268
  exports.deserializeAws_restJson1DescribeVoicesCommand = deserializeAws_restJson1DescribeVoicesCommand;
309
269
  const deserializeAws_restJson1DescribeVoicesCommandError = async (output, context) => {
@@ -311,7 +271,6 @@ const deserializeAws_restJson1DescribeVoicesCommandError = async (output, contex
311
271
  ...output,
312
272
  body: await parseBody(output.body, context),
313
273
  };
314
- let response;
315
274
  const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
316
275
  switch (errorCode) {
317
276
  case "InvalidNextTokenException":
@@ -322,33 +281,29 @@ const deserializeAws_restJson1DescribeVoicesCommandError = async (output, contex
322
281
  throw await deserializeAws_restJson1ServiceFailureExceptionResponse(parsedOutput, context);
323
282
  default:
324
283
  const parsedBody = parsedOutput.body;
325
- const $metadata = deserializeMetadata(output);
326
- const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
327
- response = new PollyServiceException_1.PollyServiceException({
328
- name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
329
- $fault: "client",
330
- $metadata,
284
+ (0, smithy_client_1.throwDefaultError)({
285
+ output,
286
+ parsedBody,
287
+ exceptionCtor: PollyServiceException_1.PollyServiceException,
288
+ errorCode,
331
289
  });
332
- throw (0, smithy_client_1.decorateServiceException)(response, parsedBody);
333
290
  }
334
291
  };
335
292
  const deserializeAws_restJson1GetLexiconCommand = async (output, context) => {
336
293
  if (output.statusCode !== 200 && output.statusCode >= 300) {
337
294
  return deserializeAws_restJson1GetLexiconCommandError(output, context);
338
295
  }
339
- const contents = {
296
+ const contents = map({
340
297
  $metadata: deserializeMetadata(output),
341
- Lexicon: undefined,
342
- LexiconAttributes: undefined,
343
- };
298
+ });
344
299
  const data = (0, smithy_client_1.expectNonNull)((0, smithy_client_1.expectObject)(await parseBody(output.body, context)), "body");
345
- if (data.Lexicon !== undefined && data.Lexicon !== null) {
300
+ if (data.Lexicon != null) {
346
301
  contents.Lexicon = deserializeAws_restJson1Lexicon(data.Lexicon, context);
347
302
  }
348
- if (data.LexiconAttributes !== undefined && data.LexiconAttributes !== null) {
303
+ if (data.LexiconAttributes != null) {
349
304
  contents.LexiconAttributes = deserializeAws_restJson1LexiconAttributes(data.LexiconAttributes, context);
350
305
  }
351
- return Promise.resolve(contents);
306
+ return contents;
352
307
  };
353
308
  exports.deserializeAws_restJson1GetLexiconCommand = deserializeAws_restJson1GetLexiconCommand;
354
309
  const deserializeAws_restJson1GetLexiconCommandError = async (output, context) => {
@@ -356,7 +311,6 @@ const deserializeAws_restJson1GetLexiconCommandError = async (output, context) =
356
311
  ...output,
357
312
  body: await parseBody(output.body, context),
358
313
  };
359
- let response;
360
314
  const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
361
315
  switch (errorCode) {
362
316
  case "LexiconNotFoundException":
@@ -367,29 +321,26 @@ const deserializeAws_restJson1GetLexiconCommandError = async (output, context) =
367
321
  throw await deserializeAws_restJson1ServiceFailureExceptionResponse(parsedOutput, context);
368
322
  default:
369
323
  const parsedBody = parsedOutput.body;
370
- const $metadata = deserializeMetadata(output);
371
- const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
372
- response = new PollyServiceException_1.PollyServiceException({
373
- name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
374
- $fault: "client",
375
- $metadata,
324
+ (0, smithy_client_1.throwDefaultError)({
325
+ output,
326
+ parsedBody,
327
+ exceptionCtor: PollyServiceException_1.PollyServiceException,
328
+ errorCode,
376
329
  });
377
- throw (0, smithy_client_1.decorateServiceException)(response, parsedBody);
378
330
  }
379
331
  };
380
332
  const deserializeAws_restJson1GetSpeechSynthesisTaskCommand = async (output, context) => {
381
333
  if (output.statusCode !== 200 && output.statusCode >= 300) {
382
334
  return deserializeAws_restJson1GetSpeechSynthesisTaskCommandError(output, context);
383
335
  }
384
- const contents = {
336
+ const contents = map({
385
337
  $metadata: deserializeMetadata(output),
386
- SynthesisTask: undefined,
387
- };
338
+ });
388
339
  const data = (0, smithy_client_1.expectNonNull)((0, smithy_client_1.expectObject)(await parseBody(output.body, context)), "body");
389
- if (data.SynthesisTask !== undefined && data.SynthesisTask !== null) {
340
+ if (data.SynthesisTask != null) {
390
341
  contents.SynthesisTask = deserializeAws_restJson1SynthesisTask(data.SynthesisTask, context);
391
342
  }
392
- return Promise.resolve(contents);
343
+ return contents;
393
344
  };
394
345
  exports.deserializeAws_restJson1GetSpeechSynthesisTaskCommand = deserializeAws_restJson1GetSpeechSynthesisTaskCommand;
395
346
  const deserializeAws_restJson1GetSpeechSynthesisTaskCommandError = async (output, context) => {
@@ -397,7 +348,6 @@ const deserializeAws_restJson1GetSpeechSynthesisTaskCommandError = async (output
397
348
  ...output,
398
349
  body: await parseBody(output.body, context),
399
350
  };
400
- let response;
401
351
  const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
402
352
  switch (errorCode) {
403
353
  case "InvalidTaskIdException":
@@ -411,33 +361,29 @@ const deserializeAws_restJson1GetSpeechSynthesisTaskCommandError = async (output
411
361
  throw await deserializeAws_restJson1SynthesisTaskNotFoundExceptionResponse(parsedOutput, context);
412
362
  default:
413
363
  const parsedBody = parsedOutput.body;
414
- const $metadata = deserializeMetadata(output);
415
- const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
416
- response = new PollyServiceException_1.PollyServiceException({
417
- name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
418
- $fault: "client",
419
- $metadata,
364
+ (0, smithy_client_1.throwDefaultError)({
365
+ output,
366
+ parsedBody,
367
+ exceptionCtor: PollyServiceException_1.PollyServiceException,
368
+ errorCode,
420
369
  });
421
- throw (0, smithy_client_1.decorateServiceException)(response, parsedBody);
422
370
  }
423
371
  };
424
372
  const deserializeAws_restJson1ListLexiconsCommand = async (output, context) => {
425
373
  if (output.statusCode !== 200 && output.statusCode >= 300) {
426
374
  return deserializeAws_restJson1ListLexiconsCommandError(output, context);
427
375
  }
428
- const contents = {
376
+ const contents = map({
429
377
  $metadata: deserializeMetadata(output),
430
- Lexicons: undefined,
431
- NextToken: undefined,
432
- };
378
+ });
433
379
  const data = (0, smithy_client_1.expectNonNull)((0, smithy_client_1.expectObject)(await parseBody(output.body, context)), "body");
434
- if (data.Lexicons !== undefined && data.Lexicons !== null) {
380
+ if (data.Lexicons != null) {
435
381
  contents.Lexicons = deserializeAws_restJson1LexiconDescriptionList(data.Lexicons, context);
436
382
  }
437
- if (data.NextToken !== undefined && data.NextToken !== null) {
383
+ if (data.NextToken != null) {
438
384
  contents.NextToken = (0, smithy_client_1.expectString)(data.NextToken);
439
385
  }
440
- return Promise.resolve(contents);
386
+ return contents;
441
387
  };
442
388
  exports.deserializeAws_restJson1ListLexiconsCommand = deserializeAws_restJson1ListLexiconsCommand;
443
389
  const deserializeAws_restJson1ListLexiconsCommandError = async (output, context) => {
@@ -445,7 +391,6 @@ const deserializeAws_restJson1ListLexiconsCommandError = async (output, context)
445
391
  ...output,
446
392
  body: await parseBody(output.body, context),
447
393
  };
448
- let response;
449
394
  const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
450
395
  switch (errorCode) {
451
396
  case "InvalidNextTokenException":
@@ -456,33 +401,29 @@ const deserializeAws_restJson1ListLexiconsCommandError = async (output, context)
456
401
  throw await deserializeAws_restJson1ServiceFailureExceptionResponse(parsedOutput, context);
457
402
  default:
458
403
  const parsedBody = parsedOutput.body;
459
- const $metadata = deserializeMetadata(output);
460
- const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
461
- response = new PollyServiceException_1.PollyServiceException({
462
- name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
463
- $fault: "client",
464
- $metadata,
404
+ (0, smithy_client_1.throwDefaultError)({
405
+ output,
406
+ parsedBody,
407
+ exceptionCtor: PollyServiceException_1.PollyServiceException,
408
+ errorCode,
465
409
  });
466
- throw (0, smithy_client_1.decorateServiceException)(response, parsedBody);
467
410
  }
468
411
  };
469
412
  const deserializeAws_restJson1ListSpeechSynthesisTasksCommand = async (output, context) => {
470
413
  if (output.statusCode !== 200 && output.statusCode >= 300) {
471
414
  return deserializeAws_restJson1ListSpeechSynthesisTasksCommandError(output, context);
472
415
  }
473
- const contents = {
416
+ const contents = map({
474
417
  $metadata: deserializeMetadata(output),
475
- NextToken: undefined,
476
- SynthesisTasks: undefined,
477
- };
418
+ });
478
419
  const data = (0, smithy_client_1.expectNonNull)((0, smithy_client_1.expectObject)(await parseBody(output.body, context)), "body");
479
- if (data.NextToken !== undefined && data.NextToken !== null) {
420
+ if (data.NextToken != null) {
480
421
  contents.NextToken = (0, smithy_client_1.expectString)(data.NextToken);
481
422
  }
482
- if (data.SynthesisTasks !== undefined && data.SynthesisTasks !== null) {
423
+ if (data.SynthesisTasks != null) {
483
424
  contents.SynthesisTasks = deserializeAws_restJson1SynthesisTasks(data.SynthesisTasks, context);
484
425
  }
485
- return Promise.resolve(contents);
426
+ return contents;
486
427
  };
487
428
  exports.deserializeAws_restJson1ListSpeechSynthesisTasksCommand = deserializeAws_restJson1ListSpeechSynthesisTasksCommand;
488
429
  const deserializeAws_restJson1ListSpeechSynthesisTasksCommandError = async (output, context) => {
@@ -490,7 +431,6 @@ const deserializeAws_restJson1ListSpeechSynthesisTasksCommandError = async (outp
490
431
  ...output,
491
432
  body: await parseBody(output.body, context),
492
433
  };
493
- let response;
494
434
  const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
495
435
  switch (errorCode) {
496
436
  case "InvalidNextTokenException":
@@ -501,25 +441,23 @@ const deserializeAws_restJson1ListSpeechSynthesisTasksCommandError = async (outp
501
441
  throw await deserializeAws_restJson1ServiceFailureExceptionResponse(parsedOutput, context);
502
442
  default:
503
443
  const parsedBody = parsedOutput.body;
504
- const $metadata = deserializeMetadata(output);
505
- const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
506
- response = new PollyServiceException_1.PollyServiceException({
507
- name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
508
- $fault: "client",
509
- $metadata,
444
+ (0, smithy_client_1.throwDefaultError)({
445
+ output,
446
+ parsedBody,
447
+ exceptionCtor: PollyServiceException_1.PollyServiceException,
448
+ errorCode,
510
449
  });
511
- throw (0, smithy_client_1.decorateServiceException)(response, parsedBody);
512
450
  }
513
451
  };
514
452
  const deserializeAws_restJson1PutLexiconCommand = async (output, context) => {
515
453
  if (output.statusCode !== 200 && output.statusCode >= 300) {
516
454
  return deserializeAws_restJson1PutLexiconCommandError(output, context);
517
455
  }
518
- const contents = {
456
+ const contents = map({
519
457
  $metadata: deserializeMetadata(output),
520
- };
458
+ });
521
459
  await collectBody(output.body, context);
522
- return Promise.resolve(contents);
460
+ return contents;
523
461
  };
524
462
  exports.deserializeAws_restJson1PutLexiconCommand = deserializeAws_restJson1PutLexiconCommand;
525
463
  const deserializeAws_restJson1PutLexiconCommandError = async (output, context) => {
@@ -527,7 +465,6 @@ const deserializeAws_restJson1PutLexiconCommandError = async (output, context) =
527
465
  ...output,
528
466
  body: await parseBody(output.body, context),
529
467
  };
530
- let response;
531
468
  const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
532
469
  switch (errorCode) {
533
470
  case "InvalidLexiconException":
@@ -553,29 +490,26 @@ const deserializeAws_restJson1PutLexiconCommandError = async (output, context) =
553
490
  throw await deserializeAws_restJson1UnsupportedPlsLanguageExceptionResponse(parsedOutput, context);
554
491
  default:
555
492
  const parsedBody = parsedOutput.body;
556
- const $metadata = deserializeMetadata(output);
557
- const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
558
- response = new PollyServiceException_1.PollyServiceException({
559
- name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
560
- $fault: "client",
561
- $metadata,
493
+ (0, smithy_client_1.throwDefaultError)({
494
+ output,
495
+ parsedBody,
496
+ exceptionCtor: PollyServiceException_1.PollyServiceException,
497
+ errorCode,
562
498
  });
563
- throw (0, smithy_client_1.decorateServiceException)(response, parsedBody);
564
499
  }
565
500
  };
566
501
  const deserializeAws_restJson1StartSpeechSynthesisTaskCommand = async (output, context) => {
567
502
  if (output.statusCode !== 200 && output.statusCode >= 300) {
568
503
  return deserializeAws_restJson1StartSpeechSynthesisTaskCommandError(output, context);
569
504
  }
570
- const contents = {
505
+ const contents = map({
571
506
  $metadata: deserializeMetadata(output),
572
- SynthesisTask: undefined,
573
- };
507
+ });
574
508
  const data = (0, smithy_client_1.expectNonNull)((0, smithy_client_1.expectObject)(await parseBody(output.body, context)), "body");
575
- if (data.SynthesisTask !== undefined && data.SynthesisTask !== null) {
509
+ if (data.SynthesisTask != null) {
576
510
  contents.SynthesisTask = deserializeAws_restJson1SynthesisTask(data.SynthesisTask, context);
577
511
  }
578
- return Promise.resolve(contents);
512
+ return contents;
579
513
  };
580
514
  exports.deserializeAws_restJson1StartSpeechSynthesisTaskCommand = deserializeAws_restJson1StartSpeechSynthesisTaskCommand;
581
515
  const deserializeAws_restJson1StartSpeechSynthesisTaskCommandError = async (output, context) => {
@@ -583,7 +517,6 @@ const deserializeAws_restJson1StartSpeechSynthesisTaskCommandError = async (outp
583
517
  ...output,
584
518
  body: await parseBody(output.body, context),
585
519
  };
586
- let response;
587
520
  const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
588
521
  switch (errorCode) {
589
522
  case "EngineNotSupportedException":
@@ -624,35 +557,29 @@ const deserializeAws_restJson1StartSpeechSynthesisTaskCommandError = async (outp
624
557
  throw await deserializeAws_restJson1TextLengthExceededExceptionResponse(parsedOutput, context);
625
558
  default:
626
559
  const parsedBody = parsedOutput.body;
627
- const $metadata = deserializeMetadata(output);
628
- const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
629
- response = new PollyServiceException_1.PollyServiceException({
630
- name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
631
- $fault: "client",
632
- $metadata,
560
+ (0, smithy_client_1.throwDefaultError)({
561
+ output,
562
+ parsedBody,
563
+ exceptionCtor: PollyServiceException_1.PollyServiceException,
564
+ errorCode,
633
565
  });
634
- throw (0, smithy_client_1.decorateServiceException)(response, parsedBody);
635
566
  }
636
567
  };
637
568
  const deserializeAws_restJson1SynthesizeSpeechCommand = async (output, context) => {
638
569
  if (output.statusCode !== 200 && output.statusCode >= 300) {
639
570
  return deserializeAws_restJson1SynthesizeSpeechCommandError(output, context);
640
571
  }
641
- const contents = {
572
+ const contents = map({
642
573
  $metadata: deserializeMetadata(output),
643
- AudioStream: undefined,
644
- ContentType: undefined,
645
- RequestCharacters: undefined,
646
- };
647
- if (output.headers["content-type"] !== undefined) {
648
- contents.ContentType = output.headers["content-type"];
649
- }
650
- if (output.headers["x-amzn-requestcharacters"] !== undefined) {
651
- contents.RequestCharacters = (0, smithy_client_1.strictParseInt32)(output.headers["x-amzn-requestcharacters"]);
652
- }
574
+ ContentType: [, output.headers["content-type"]],
575
+ RequestCharacters: [
576
+ () => void 0 !== output.headers["x-amzn-requestcharacters"],
577
+ () => (0, smithy_client_1.strictParseInt32)(output.headers["x-amzn-requestcharacters"]),
578
+ ],
579
+ });
653
580
  const data = output.body;
654
581
  contents.AudioStream = data;
655
- return Promise.resolve(contents);
582
+ return contents;
656
583
  };
657
584
  exports.deserializeAws_restJson1SynthesizeSpeechCommand = deserializeAws_restJson1SynthesizeSpeechCommand;
658
585
  const deserializeAws_restJson1SynthesizeSpeechCommandError = async (output, context) => {
@@ -660,7 +587,6 @@ const deserializeAws_restJson1SynthesizeSpeechCommandError = async (output, cont
660
587
  ...output,
661
588
  body: await parseBody(output.body, context),
662
589
  };
663
- let response;
664
590
  const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
665
591
  switch (errorCode) {
666
592
  case "EngineNotSupportedException":
@@ -692,20 +618,19 @@ const deserializeAws_restJson1SynthesizeSpeechCommandError = async (output, cont
692
618
  throw await deserializeAws_restJson1TextLengthExceededExceptionResponse(parsedOutput, context);
693
619
  default:
694
620
  const parsedBody = parsedOutput.body;
695
- const $metadata = deserializeMetadata(output);
696
- const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
697
- response = new PollyServiceException_1.PollyServiceException({
698
- name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
699
- $fault: "client",
700
- $metadata,
621
+ (0, smithy_client_1.throwDefaultError)({
622
+ output,
623
+ parsedBody,
624
+ exceptionCtor: PollyServiceException_1.PollyServiceException,
625
+ errorCode,
701
626
  });
702
- throw (0, smithy_client_1.decorateServiceException)(response, parsedBody);
703
627
  }
704
628
  };
629
+ const map = smithy_client_1.map;
705
630
  const deserializeAws_restJson1EngineNotSupportedExceptionResponse = async (parsedOutput, context) => {
706
- const contents = {};
631
+ const contents = map({});
707
632
  const data = parsedOutput.body;
708
- if (data.message !== undefined && data.message !== null) {
633
+ if (data.message != null) {
709
634
  contents.message = (0, smithy_client_1.expectString)(data.message);
710
635
  }
711
636
  const exception = new models_0_1.EngineNotSupportedException({
@@ -715,9 +640,9 @@ const deserializeAws_restJson1EngineNotSupportedExceptionResponse = async (parse
715
640
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
716
641
  };
717
642
  const deserializeAws_restJson1InvalidLexiconExceptionResponse = async (parsedOutput, context) => {
718
- const contents = {};
643
+ const contents = map({});
719
644
  const data = parsedOutput.body;
720
- if (data.message !== undefined && data.message !== null) {
645
+ if (data.message != null) {
721
646
  contents.message = (0, smithy_client_1.expectString)(data.message);
722
647
  }
723
648
  const exception = new models_0_1.InvalidLexiconException({
@@ -727,9 +652,9 @@ const deserializeAws_restJson1InvalidLexiconExceptionResponse = async (parsedOut
727
652
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
728
653
  };
729
654
  const deserializeAws_restJson1InvalidNextTokenExceptionResponse = async (parsedOutput, context) => {
730
- const contents = {};
655
+ const contents = map({});
731
656
  const data = parsedOutput.body;
732
- if (data.message !== undefined && data.message !== null) {
657
+ if (data.message != null) {
733
658
  contents.message = (0, smithy_client_1.expectString)(data.message);
734
659
  }
735
660
  const exception = new models_0_1.InvalidNextTokenException({
@@ -739,9 +664,9 @@ const deserializeAws_restJson1InvalidNextTokenExceptionResponse = async (parsedO
739
664
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
740
665
  };
741
666
  const deserializeAws_restJson1InvalidS3BucketExceptionResponse = async (parsedOutput, context) => {
742
- const contents = {};
667
+ const contents = map({});
743
668
  const data = parsedOutput.body;
744
- if (data.message !== undefined && data.message !== null) {
669
+ if (data.message != null) {
745
670
  contents.message = (0, smithy_client_1.expectString)(data.message);
746
671
  }
747
672
  const exception = new models_0_1.InvalidS3BucketException({
@@ -751,9 +676,9 @@ const deserializeAws_restJson1InvalidS3BucketExceptionResponse = async (parsedOu
751
676
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
752
677
  };
753
678
  const deserializeAws_restJson1InvalidS3KeyExceptionResponse = async (parsedOutput, context) => {
754
- const contents = {};
679
+ const contents = map({});
755
680
  const data = parsedOutput.body;
756
- if (data.message !== undefined && data.message !== null) {
681
+ if (data.message != null) {
757
682
  contents.message = (0, smithy_client_1.expectString)(data.message);
758
683
  }
759
684
  const exception = new models_0_1.InvalidS3KeyException({
@@ -763,9 +688,9 @@ const deserializeAws_restJson1InvalidS3KeyExceptionResponse = async (parsedOutpu
763
688
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
764
689
  };
765
690
  const deserializeAws_restJson1InvalidSampleRateExceptionResponse = async (parsedOutput, context) => {
766
- const contents = {};
691
+ const contents = map({});
767
692
  const data = parsedOutput.body;
768
- if (data.message !== undefined && data.message !== null) {
693
+ if (data.message != null) {
769
694
  contents.message = (0, smithy_client_1.expectString)(data.message);
770
695
  }
771
696
  const exception = new models_0_1.InvalidSampleRateException({
@@ -775,9 +700,9 @@ const deserializeAws_restJson1InvalidSampleRateExceptionResponse = async (parsed
775
700
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
776
701
  };
777
702
  const deserializeAws_restJson1InvalidSnsTopicArnExceptionResponse = async (parsedOutput, context) => {
778
- const contents = {};
703
+ const contents = map({});
779
704
  const data = parsedOutput.body;
780
- if (data.message !== undefined && data.message !== null) {
705
+ if (data.message != null) {
781
706
  contents.message = (0, smithy_client_1.expectString)(data.message);
782
707
  }
783
708
  const exception = new models_0_1.InvalidSnsTopicArnException({
@@ -787,9 +712,9 @@ const deserializeAws_restJson1InvalidSnsTopicArnExceptionResponse = async (parse
787
712
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
788
713
  };
789
714
  const deserializeAws_restJson1InvalidSsmlExceptionResponse = async (parsedOutput, context) => {
790
- const contents = {};
715
+ const contents = map({});
791
716
  const data = parsedOutput.body;
792
- if (data.message !== undefined && data.message !== null) {
717
+ if (data.message != null) {
793
718
  contents.message = (0, smithy_client_1.expectString)(data.message);
794
719
  }
795
720
  const exception = new models_0_1.InvalidSsmlException({
@@ -799,9 +724,9 @@ const deserializeAws_restJson1InvalidSsmlExceptionResponse = async (parsedOutput
799
724
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
800
725
  };
801
726
  const deserializeAws_restJson1InvalidTaskIdExceptionResponse = async (parsedOutput, context) => {
802
- const contents = {};
727
+ const contents = map({});
803
728
  const data = parsedOutput.body;
804
- if (data.message !== undefined && data.message !== null) {
729
+ if (data.message != null) {
805
730
  contents.message = (0, smithy_client_1.expectString)(data.message);
806
731
  }
807
732
  const exception = new models_0_1.InvalidTaskIdException({
@@ -811,9 +736,9 @@ const deserializeAws_restJson1InvalidTaskIdExceptionResponse = async (parsedOutp
811
736
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
812
737
  };
813
738
  const deserializeAws_restJson1LanguageNotSupportedExceptionResponse = async (parsedOutput, context) => {
814
- const contents = {};
739
+ const contents = map({});
815
740
  const data = parsedOutput.body;
816
- if (data.message !== undefined && data.message !== null) {
741
+ if (data.message != null) {
817
742
  contents.message = (0, smithy_client_1.expectString)(data.message);
818
743
  }
819
744
  const exception = new models_0_1.LanguageNotSupportedException({
@@ -823,9 +748,9 @@ const deserializeAws_restJson1LanguageNotSupportedExceptionResponse = async (par
823
748
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
824
749
  };
825
750
  const deserializeAws_restJson1LexiconNotFoundExceptionResponse = async (parsedOutput, context) => {
826
- const contents = {};
751
+ const contents = map({});
827
752
  const data = parsedOutput.body;
828
- if (data.message !== undefined && data.message !== null) {
753
+ if (data.message != null) {
829
754
  contents.message = (0, smithy_client_1.expectString)(data.message);
830
755
  }
831
756
  const exception = new models_0_1.LexiconNotFoundException({
@@ -835,9 +760,9 @@ const deserializeAws_restJson1LexiconNotFoundExceptionResponse = async (parsedOu
835
760
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
836
761
  };
837
762
  const deserializeAws_restJson1LexiconSizeExceededExceptionResponse = async (parsedOutput, context) => {
838
- const contents = {};
763
+ const contents = map({});
839
764
  const data = parsedOutput.body;
840
- if (data.message !== undefined && data.message !== null) {
765
+ if (data.message != null) {
841
766
  contents.message = (0, smithy_client_1.expectString)(data.message);
842
767
  }
843
768
  const exception = new models_0_1.LexiconSizeExceededException({
@@ -847,9 +772,9 @@ const deserializeAws_restJson1LexiconSizeExceededExceptionResponse = async (pars
847
772
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
848
773
  };
849
774
  const deserializeAws_restJson1MarksNotSupportedForFormatExceptionResponse = async (parsedOutput, context) => {
850
- const contents = {};
775
+ const contents = map({});
851
776
  const data = parsedOutput.body;
852
- if (data.message !== undefined && data.message !== null) {
777
+ if (data.message != null) {
853
778
  contents.message = (0, smithy_client_1.expectString)(data.message);
854
779
  }
855
780
  const exception = new models_0_1.MarksNotSupportedForFormatException({
@@ -859,9 +784,9 @@ const deserializeAws_restJson1MarksNotSupportedForFormatExceptionResponse = asyn
859
784
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
860
785
  };
861
786
  const deserializeAws_restJson1MaxLexemeLengthExceededExceptionResponse = async (parsedOutput, context) => {
862
- const contents = {};
787
+ const contents = map({});
863
788
  const data = parsedOutput.body;
864
- if (data.message !== undefined && data.message !== null) {
789
+ if (data.message != null) {
865
790
  contents.message = (0, smithy_client_1.expectString)(data.message);
866
791
  }
867
792
  const exception = new models_0_1.MaxLexemeLengthExceededException({
@@ -871,9 +796,9 @@ const deserializeAws_restJson1MaxLexemeLengthExceededExceptionResponse = async (
871
796
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
872
797
  };
873
798
  const deserializeAws_restJson1MaxLexiconsNumberExceededExceptionResponse = async (parsedOutput, context) => {
874
- const contents = {};
799
+ const contents = map({});
875
800
  const data = parsedOutput.body;
876
- if (data.message !== undefined && data.message !== null) {
801
+ if (data.message != null) {
877
802
  contents.message = (0, smithy_client_1.expectString)(data.message);
878
803
  }
879
804
  const exception = new models_0_1.MaxLexiconsNumberExceededException({
@@ -883,9 +808,9 @@ const deserializeAws_restJson1MaxLexiconsNumberExceededExceptionResponse = async
883
808
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
884
809
  };
885
810
  const deserializeAws_restJson1ServiceFailureExceptionResponse = async (parsedOutput, context) => {
886
- const contents = {};
811
+ const contents = map({});
887
812
  const data = parsedOutput.body;
888
- if (data.message !== undefined && data.message !== null) {
813
+ if (data.message != null) {
889
814
  contents.message = (0, smithy_client_1.expectString)(data.message);
890
815
  }
891
816
  const exception = new models_0_1.ServiceFailureException({
@@ -895,9 +820,9 @@ const deserializeAws_restJson1ServiceFailureExceptionResponse = async (parsedOut
895
820
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
896
821
  };
897
822
  const deserializeAws_restJson1SsmlMarksNotSupportedForTextTypeExceptionResponse = async (parsedOutput, context) => {
898
- const contents = {};
823
+ const contents = map({});
899
824
  const data = parsedOutput.body;
900
- if (data.message !== undefined && data.message !== null) {
825
+ if (data.message != null) {
901
826
  contents.message = (0, smithy_client_1.expectString)(data.message);
902
827
  }
903
828
  const exception = new models_0_1.SsmlMarksNotSupportedForTextTypeException({
@@ -907,9 +832,9 @@ const deserializeAws_restJson1SsmlMarksNotSupportedForTextTypeExceptionResponse
907
832
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
908
833
  };
909
834
  const deserializeAws_restJson1SynthesisTaskNotFoundExceptionResponse = async (parsedOutput, context) => {
910
- const contents = {};
835
+ const contents = map({});
911
836
  const data = parsedOutput.body;
912
- if (data.message !== undefined && data.message !== null) {
837
+ if (data.message != null) {
913
838
  contents.message = (0, smithy_client_1.expectString)(data.message);
914
839
  }
915
840
  const exception = new models_0_1.SynthesisTaskNotFoundException({
@@ -919,9 +844,9 @@ const deserializeAws_restJson1SynthesisTaskNotFoundExceptionResponse = async (pa
919
844
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
920
845
  };
921
846
  const deserializeAws_restJson1TextLengthExceededExceptionResponse = async (parsedOutput, context) => {
922
- const contents = {};
847
+ const contents = map({});
923
848
  const data = parsedOutput.body;
924
- if (data.message !== undefined && data.message !== null) {
849
+ if (data.message != null) {
925
850
  contents.message = (0, smithy_client_1.expectString)(data.message);
926
851
  }
927
852
  const exception = new models_0_1.TextLengthExceededException({
@@ -931,9 +856,9 @@ const deserializeAws_restJson1TextLengthExceededExceptionResponse = async (parse
931
856
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
932
857
  };
933
858
  const deserializeAws_restJson1UnsupportedPlsAlphabetExceptionResponse = async (parsedOutput, context) => {
934
- const contents = {};
859
+ const contents = map({});
935
860
  const data = parsedOutput.body;
936
- if (data.message !== undefined && data.message !== null) {
861
+ if (data.message != null) {
937
862
  contents.message = (0, smithy_client_1.expectString)(data.message);
938
863
  }
939
864
  const exception = new models_0_1.UnsupportedPlsAlphabetException({
@@ -943,9 +868,9 @@ const deserializeAws_restJson1UnsupportedPlsAlphabetExceptionResponse = async (p
943
868
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
944
869
  };
945
870
  const deserializeAws_restJson1UnsupportedPlsLanguageExceptionResponse = async (parsedOutput, context) => {
946
- const contents = {};
871
+ const contents = map({});
947
872
  const data = parsedOutput.body;
948
- if (data.message !== undefined && data.message !== null) {
873
+ if (data.message != null) {
949
874
  contents.message = (0, smithy_client_1.expectString)(data.message);
950
875
  }
951
876
  const exception = new models_0_1.UnsupportedPlsLanguageException({
@@ -958,9 +883,6 @@ const serializeAws_restJson1LexiconNameList = (input, context) => {
958
883
  return input
959
884
  .filter((e) => e != null)
960
885
  .map((entry) => {
961
- if (entry === null) {
962
- return null;
963
- }
964
886
  return entry;
965
887
  });
966
888
  };
@@ -968,9 +890,6 @@ const serializeAws_restJson1SpeechMarkTypeList = (input, context) => {
968
890
  return input
969
891
  .filter((e) => e != null)
970
892
  .map((entry) => {
971
- if (entry === null) {
972
- return null;
973
- }
974
893
  return entry;
975
894
  });
976
895
  };