@aws-sdk/client-lex-runtime-v2 3.34.0 → 3.37.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.
Files changed (138) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/{dist/cjs → dist-cjs}/LexRuntimeV2.js +1 -5
  3. package/{dist/cjs → dist-cjs}/LexRuntimeV2Client.js +10 -19
  4. package/dist-cjs/commands/DeleteSessionCommand.js +36 -0
  5. package/{dist/cjs → dist-cjs}/commands/GetSessionCommand.js +2 -35
  6. package/{dist/cjs → dist-cjs}/commands/PutSessionCommand.js +2 -29
  7. package/{dist/cjs → dist-cjs}/commands/RecognizeTextCommand.js +2 -31
  8. package/dist-cjs/commands/RecognizeUtteranceCommand.js +36 -0
  9. package/dist-cjs/commands/StartConversationCommand.js +38 -0
  10. package/{dist/cjs → dist-cjs}/endpoints.js +1 -2
  11. package/{dist/cjs → dist-cjs}/index.js +0 -1
  12. package/{dist/cjs → dist-cjs}/models/index.js +0 -1
  13. package/{dist/cjs → dist-cjs}/models/models_0.js +2 -145
  14. package/{dist/cjs → dist-cjs}/protocols/Aws_restJson1.js +1 -7
  15. package/{dist/cjs → dist-cjs}/runtimeConfig.browser.js +1 -5
  16. package/{dist/cjs → dist-cjs}/runtimeConfig.js +1 -5
  17. package/{dist/cjs → dist-cjs}/runtimeConfig.native.js +0 -4
  18. package/{dist/cjs → dist-cjs}/runtimeConfig.shared.js +1 -5
  19. package/{dist/es → dist-es}/LexRuntimeV2.js +1 -2
  20. package/{dist/es → dist-es}/LexRuntimeV2Client.js +1 -2
  21. package/{dist/es → dist-es}/commands/DeleteSessionCommand.js +2 -3
  22. package/{dist/es → dist-es}/commands/GetSessionCommand.js +2 -3
  23. package/{dist/es → dist-es}/commands/PutSessionCommand.js +2 -3
  24. package/{dist/es → dist-es}/commands/RecognizeTextCommand.js +2 -3
  25. package/{dist/es → dist-es}/commands/RecognizeUtteranceCommand.js +2 -3
  26. package/{dist/es → dist-es}/commands/StartConversationCommand.js +2 -3
  27. package/{dist/es → dist-es}/endpoints.js +1 -2
  28. package/{dist/types/index.d.ts → dist-es/index.js} +0 -0
  29. package/{dist/types/models/index.d.ts → dist-es/models/index.js} +0 -0
  30. package/{dist/es → dist-es}/models/models_0.js +2 -1
  31. package/{dist/es → dist-es}/protocols/Aws_restJson1.js +1 -2
  32. package/{dist/es → dist-es}/runtimeConfig.browser.js +1 -2
  33. package/{dist/es → dist-es}/runtimeConfig.js +1 -2
  34. package/{dist/es → dist-es}/runtimeConfig.native.js +0 -1
  35. package/{dist/es → dist-es}/runtimeConfig.shared.js +1 -2
  36. package/{dist/types/ts3.4 → dist-types}/LexRuntimeV2.d.ts +223 -139
  37. package/{dist/types → dist-types}/LexRuntimeV2Client.d.ts +7 -7
  38. package/{dist/types → dist-types}/commands/DeleteSessionCommand.d.ts +2 -2
  39. package/{dist/types → dist-types}/commands/GetSessionCommand.d.ts +2 -2
  40. package/{dist/types → dist-types}/commands/PutSessionCommand.d.ts +2 -2
  41. package/{dist/types → dist-types}/commands/RecognizeTextCommand.d.ts +28 -2
  42. package/{dist/types → dist-types}/commands/RecognizeUtteranceCommand.d.ts +28 -2
  43. package/{dist/types → dist-types}/commands/StartConversationCommand.d.ts +34 -2
  44. package/{dist/types → dist-types}/endpoints.d.ts +0 -0
  45. package/{index.ts → dist-types/index.d.ts} +0 -0
  46. package/{models/index.ts → dist-types/models/index.d.ts} +0 -0
  47. package/{dist/types → dist-types}/models/models_0.d.ts +15 -9
  48. package/{dist/types → dist-types}/protocols/Aws_restJson1.d.ts +2 -2
  49. package/{dist/types → dist-types}/runtimeConfig.browser.d.ts +0 -0
  50. package/{dist/types → dist-types}/runtimeConfig.d.ts +1 -1
  51. package/{dist/types → dist-types}/runtimeConfig.native.d.ts +0 -0
  52. package/{dist/types → dist-types}/runtimeConfig.shared.d.ts +0 -0
  53. package/dist-types/ts3.4/LexRuntimeV2.d.ts +35 -0
  54. package/{dist/types → dist-types}/ts3.4/LexRuntimeV2Client.d.ts +33 -103
  55. package/dist-types/ts3.4/commands/DeleteSessionCommand.d.ts +17 -0
  56. package/dist-types/ts3.4/commands/GetSessionCommand.d.ts +17 -0
  57. package/dist-types/ts3.4/commands/PutSessionCommand.d.ts +17 -0
  58. package/dist-types/ts3.4/commands/RecognizeTextCommand.d.ts +17 -0
  59. package/dist-types/ts3.4/commands/RecognizeUtteranceCommand.d.ts +24 -0
  60. package/dist-types/ts3.4/commands/StartConversationCommand.d.ts +17 -0
  61. package/{dist/types → dist-types}/ts3.4/endpoints.d.ts +0 -0
  62. package/{dist/types → dist-types}/ts3.4/index.d.ts +0 -0
  63. package/{dist/types → dist-types}/ts3.4/models/index.d.ts +0 -0
  64. package/dist-types/ts3.4/models/models_0.d.ts +348 -0
  65. package/{dist/types → dist-types}/ts3.4/protocols/Aws_restJson1.d.ts +2 -2
  66. package/{dist/types → dist-types}/ts3.4/runtimeConfig.browser.d.ts +1 -3
  67. package/{dist/types → dist-types}/ts3.4/runtimeConfig.d.ts +2 -4
  68. package/{dist/types → dist-types}/ts3.4/runtimeConfig.native.d.ts +1 -3
  69. package/{dist/types → dist-types}/ts3.4/runtimeConfig.shared.d.ts +1 -3
  70. package/package.json +50 -47
  71. package/LexRuntimeV2.ts +0 -299
  72. package/LexRuntimeV2Client.ts +0 -282
  73. package/commands/DeleteSessionCommand.ts +0 -107
  74. package/commands/GetSessionCommand.ts +0 -102
  75. package/commands/PutSessionCommand.ts +0 -96
  76. package/commands/RecognizeTextCommand.ts +0 -98
  77. package/commands/RecognizeUtteranceCommand.ts +0 -139
  78. package/commands/StartConversationCommand.ts +0 -130
  79. package/dist/cjs/LexRuntimeV2.js.map +0 -1
  80. package/dist/cjs/LexRuntimeV2Client.js.map +0 -1
  81. package/dist/cjs/commands/DeleteSessionCommand.js +0 -74
  82. package/dist/cjs/commands/DeleteSessionCommand.js.map +0 -1
  83. package/dist/cjs/commands/GetSessionCommand.js.map +0 -1
  84. package/dist/cjs/commands/PutSessionCommand.js.map +0 -1
  85. package/dist/cjs/commands/RecognizeTextCommand.js.map +0 -1
  86. package/dist/cjs/commands/RecognizeUtteranceCommand.js +0 -97
  87. package/dist/cjs/commands/RecognizeUtteranceCommand.js.map +0 -1
  88. package/dist/cjs/commands/StartConversationCommand.js +0 -90
  89. package/dist/cjs/commands/StartConversationCommand.js.map +0 -1
  90. package/dist/cjs/endpoints.js.map +0 -1
  91. package/dist/cjs/index.js.map +0 -1
  92. package/dist/cjs/models/index.js.map +0 -1
  93. package/dist/cjs/models/models_0.js.map +0 -1
  94. package/dist/cjs/package.json +0 -96
  95. package/dist/cjs/protocols/Aws_restJson1.js.map +0 -1
  96. package/dist/cjs/runtimeConfig.browser.js.map +0 -1
  97. package/dist/cjs/runtimeConfig.js.map +0 -1
  98. package/dist/cjs/runtimeConfig.native.js.map +0 -1
  99. package/dist/cjs/runtimeConfig.shared.js.map +0 -1
  100. package/dist/es/LexRuntimeV2.js.map +0 -1
  101. package/dist/es/LexRuntimeV2Client.js.map +0 -1
  102. package/dist/es/commands/DeleteSessionCommand.js.map +0 -1
  103. package/dist/es/commands/GetSessionCommand.js.map +0 -1
  104. package/dist/es/commands/PutSessionCommand.js.map +0 -1
  105. package/dist/es/commands/RecognizeTextCommand.js.map +0 -1
  106. package/dist/es/commands/RecognizeUtteranceCommand.js.map +0 -1
  107. package/dist/es/commands/StartConversationCommand.js.map +0 -1
  108. package/dist/es/endpoints.js.map +0 -1
  109. package/dist/es/index.js +0 -10
  110. package/dist/es/index.js.map +0 -1
  111. package/dist/es/models/index.js +0 -2
  112. package/dist/es/models/index.js.map +0 -1
  113. package/dist/es/models/models_0.js.map +0 -1
  114. package/dist/es/package.json +0 -96
  115. package/dist/es/protocols/Aws_restJson1.js.map +0 -1
  116. package/dist/es/runtimeConfig.browser.js.map +0 -1
  117. package/dist/es/runtimeConfig.js.map +0 -1
  118. package/dist/es/runtimeConfig.native.js.map +0 -1
  119. package/dist/es/runtimeConfig.shared.js.map +0 -1
  120. package/dist/types/LexRuntimeV2.d.ts +0 -139
  121. package/dist/types/ts3.4/commands/DeleteSessionCommand.d.ts +0 -48
  122. package/dist/types/ts3.4/commands/GetSessionCommand.d.ts +0 -43
  123. package/dist/types/ts3.4/commands/PutSessionCommand.d.ts +0 -37
  124. package/dist/types/ts3.4/commands/RecognizeTextCommand.d.ts +0 -39
  125. package/dist/types/ts3.4/commands/RecognizeUtteranceCommand.d.ts +0 -82
  126. package/dist/types/ts3.4/commands/StartConversationCommand.d.ts +0 -62
  127. package/dist/types/ts3.4/models/models_0.d.ts +0 -2035
  128. package/endpoints.ts +0 -57
  129. package/jest.config.js +0 -4
  130. package/models/models_0.ts +0 -2458
  131. package/protocols/Aws_restJson1.ts +0 -2458
  132. package/runtimeConfig.browser.ts +0 -45
  133. package/runtimeConfig.native.ts +0 -20
  134. package/runtimeConfig.shared.ts +0 -16
  135. package/runtimeConfig.ts +0 -49
  136. package/tsconfig.es.json +0 -10
  137. package/tsconfig.json +0 -31
  138. package/tsconfig.types.json +0 -8
@@ -1,2458 +0,0 @@
1
- import { DeleteSessionCommandInput, DeleteSessionCommandOutput } from "../commands/DeleteSessionCommand";
2
- import { GetSessionCommandInput, GetSessionCommandOutput } from "../commands/GetSessionCommand";
3
- import { PutSessionCommandInput, PutSessionCommandOutput } from "../commands/PutSessionCommand";
4
- import { RecognizeTextCommandInput, RecognizeTextCommandOutput } from "../commands/RecognizeTextCommand";
5
- import { RecognizeUtteranceCommandInput, RecognizeUtteranceCommandOutput } from "../commands/RecognizeUtteranceCommand";
6
- import { StartConversationCommandInput, StartConversationCommandOutput } from "../commands/StartConversationCommand";
7
- import {
8
- AccessDeniedException,
9
- ActiveContext,
10
- ActiveContextTimeToLive,
11
- AudioInputEvent,
12
- AudioResponseEvent,
13
- BadGatewayException,
14
- Button,
15
- ConfidenceScore,
16
- ConfigurationEvent,
17
- ConflictException,
18
- DTMFInputEvent,
19
- DependencyFailedException,
20
- DialogAction,
21
- DisconnectionEvent,
22
- HeartbeatEvent,
23
- ImageResponseCard,
24
- Intent,
25
- IntentResultEvent,
26
- InternalServerException,
27
- Interpretation,
28
- Message,
29
- PlaybackCompletionEvent,
30
- PlaybackInterruptionEvent,
31
- ResourceNotFoundException,
32
- SentimentResponse,
33
- SentimentScore,
34
- SessionState,
35
- Slot,
36
- StartConversationRequestEventStream,
37
- StartConversationResponseEventStream,
38
- TextInputEvent,
39
- TextResponseEvent,
40
- ThrottlingException,
41
- TranscriptEvent,
42
- ValidationException,
43
- Value,
44
- } from "../models/models_0";
45
- import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
46
- import {
47
- expectInt32 as __expectInt32,
48
- expectNonNull as __expectNonNull,
49
- expectObject as __expectObject,
50
- expectString as __expectString,
51
- extendedEncodeURIComponent as __extendedEncodeURIComponent,
52
- limitedParseDouble as __limitedParseDouble,
53
- } from "@aws-sdk/smithy-client";
54
- import {
55
- Endpoint as __Endpoint,
56
- EventStreamSerdeContext as __EventStreamSerdeContext,
57
- Message as __Message,
58
- MetadataBearer as __MetadataBearer,
59
- ResponseMetadata as __ResponseMetadata,
60
- SerdeContext as __SerdeContext,
61
- SmithyException as __SmithyException,
62
- } from "@aws-sdk/types";
63
-
64
- export const serializeAws_restJson1DeleteSessionCommand = async (
65
- input: DeleteSessionCommandInput,
66
- context: __SerdeContext
67
- ): Promise<__HttpRequest> => {
68
- const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
69
- const headers: any = {};
70
- let resolvedPath =
71
- `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` +
72
- "/bots/{botId}/botAliases/{botAliasId}/botLocales/{localeId}/sessions/{sessionId}";
73
- if (input.botId !== undefined) {
74
- const labelValue: string = input.botId;
75
- if (labelValue.length <= 0) {
76
- throw new Error("Empty value provided for input HTTP label: botId.");
77
- }
78
- resolvedPath = resolvedPath.replace("{botId}", __extendedEncodeURIComponent(labelValue));
79
- } else {
80
- throw new Error("No value provided for input HTTP label: botId.");
81
- }
82
- if (input.botAliasId !== undefined) {
83
- const labelValue: string = input.botAliasId;
84
- if (labelValue.length <= 0) {
85
- throw new Error("Empty value provided for input HTTP label: botAliasId.");
86
- }
87
- resolvedPath = resolvedPath.replace("{botAliasId}", __extendedEncodeURIComponent(labelValue));
88
- } else {
89
- throw new Error("No value provided for input HTTP label: botAliasId.");
90
- }
91
- if (input.localeId !== undefined) {
92
- const labelValue: string = input.localeId;
93
- if (labelValue.length <= 0) {
94
- throw new Error("Empty value provided for input HTTP label: localeId.");
95
- }
96
- resolvedPath = resolvedPath.replace("{localeId}", __extendedEncodeURIComponent(labelValue));
97
- } else {
98
- throw new Error("No value provided for input HTTP label: localeId.");
99
- }
100
- if (input.sessionId !== undefined) {
101
- const labelValue: string = 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}", __extendedEncodeURIComponent(labelValue));
106
- } else {
107
- throw new Error("No value provided for input HTTP label: sessionId.");
108
- }
109
- let body: any;
110
- return new __HttpRequest({
111
- protocol,
112
- hostname,
113
- port,
114
- method: "DELETE",
115
- headers,
116
- path: resolvedPath,
117
- body,
118
- });
119
- };
120
-
121
- export const serializeAws_restJson1GetSessionCommand = async (
122
- input: GetSessionCommandInput,
123
- context: __SerdeContext
124
- ): Promise<__HttpRequest> => {
125
- const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
126
- const headers: any = {};
127
- let resolvedPath =
128
- `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` +
129
- "/bots/{botId}/botAliases/{botAliasId}/botLocales/{localeId}/sessions/{sessionId}";
130
- if (input.botId !== undefined) {
131
- const labelValue: string = 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}", __extendedEncodeURIComponent(labelValue));
136
- } else {
137
- throw new Error("No value provided for input HTTP label: botId.");
138
- }
139
- if (input.botAliasId !== undefined) {
140
- const labelValue: string = input.botAliasId;
141
- if (labelValue.length <= 0) {
142
- throw new Error("Empty value provided for input HTTP label: botAliasId.");
143
- }
144
- resolvedPath = resolvedPath.replace("{botAliasId}", __extendedEncodeURIComponent(labelValue));
145
- } else {
146
- throw new Error("No value provided for input HTTP label: botAliasId.");
147
- }
148
- if (input.localeId !== undefined) {
149
- const labelValue: string = input.localeId;
150
- if (labelValue.length <= 0) {
151
- throw new Error("Empty value provided for input HTTP label: localeId.");
152
- }
153
- resolvedPath = resolvedPath.replace("{localeId}", __extendedEncodeURIComponent(labelValue));
154
- } else {
155
- throw new Error("No value provided for input HTTP label: localeId.");
156
- }
157
- if (input.sessionId !== undefined) {
158
- const labelValue: string = input.sessionId;
159
- if (labelValue.length <= 0) {
160
- throw new Error("Empty value provided for input HTTP label: sessionId.");
161
- }
162
- resolvedPath = resolvedPath.replace("{sessionId}", __extendedEncodeURIComponent(labelValue));
163
- } else {
164
- throw new Error("No value provided for input HTTP label: sessionId.");
165
- }
166
- let body: any;
167
- return new __HttpRequest({
168
- protocol,
169
- hostname,
170
- port,
171
- method: "GET",
172
- headers,
173
- path: resolvedPath,
174
- body,
175
- });
176
- };
177
-
178
- export const serializeAws_restJson1PutSessionCommand = async (
179
- input: PutSessionCommandInput,
180
- context: __SerdeContext
181
- ): Promise<__HttpRequest> => {
182
- const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
183
- const headers: any = {
184
- "content-type": "application/json",
185
- ...(isSerializableHeaderValue(input.responseContentType) && { responsecontenttype: input.responseContentType! }),
186
- };
187
- let resolvedPath =
188
- `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` +
189
- "/bots/{botId}/botAliases/{botAliasId}/botLocales/{localeId}/sessions/{sessionId}";
190
- if (input.botId !== undefined) {
191
- const labelValue: string = input.botId;
192
- if (labelValue.length <= 0) {
193
- throw new Error("Empty value provided for input HTTP label: botId.");
194
- }
195
- resolvedPath = resolvedPath.replace("{botId}", __extendedEncodeURIComponent(labelValue));
196
- } else {
197
- throw new Error("No value provided for input HTTP label: botId.");
198
- }
199
- if (input.botAliasId !== undefined) {
200
- const labelValue: string = input.botAliasId;
201
- if (labelValue.length <= 0) {
202
- throw new Error("Empty value provided for input HTTP label: botAliasId.");
203
- }
204
- resolvedPath = resolvedPath.replace("{botAliasId}", __extendedEncodeURIComponent(labelValue));
205
- } else {
206
- throw new Error("No value provided for input HTTP label: botAliasId.");
207
- }
208
- if (input.localeId !== undefined) {
209
- const labelValue: string = input.localeId;
210
- if (labelValue.length <= 0) {
211
- throw new Error("Empty value provided for input HTTP label: localeId.");
212
- }
213
- resolvedPath = resolvedPath.replace("{localeId}", __extendedEncodeURIComponent(labelValue));
214
- } else {
215
- throw new Error("No value provided for input HTTP label: localeId.");
216
- }
217
- if (input.sessionId !== undefined) {
218
- const labelValue: string = input.sessionId;
219
- if (labelValue.length <= 0) {
220
- throw new Error("Empty value provided for input HTTP label: sessionId.");
221
- }
222
- resolvedPath = resolvedPath.replace("{sessionId}", __extendedEncodeURIComponent(labelValue));
223
- } else {
224
- throw new Error("No value provided for input HTTP label: sessionId.");
225
- }
226
- let body: any;
227
- body = JSON.stringify({
228
- ...(input.messages !== undefined &&
229
- input.messages !== null && { messages: serializeAws_restJson1Messages(input.messages, context) }),
230
- ...(input.requestAttributes !== undefined &&
231
- input.requestAttributes !== null && {
232
- requestAttributes: serializeAws_restJson1StringMap(input.requestAttributes, context),
233
- }),
234
- ...(input.sessionState !== undefined &&
235
- input.sessionState !== null && { sessionState: serializeAws_restJson1SessionState(input.sessionState, context) }),
236
- });
237
- return new __HttpRequest({
238
- protocol,
239
- hostname,
240
- port,
241
- method: "POST",
242
- headers,
243
- path: resolvedPath,
244
- body,
245
- });
246
- };
247
-
248
- export const serializeAws_restJson1RecognizeTextCommand = async (
249
- input: RecognizeTextCommandInput,
250
- context: __SerdeContext
251
- ): Promise<__HttpRequest> => {
252
- const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
253
- const headers: any = {
254
- "content-type": "application/json",
255
- };
256
- let resolvedPath =
257
- `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` +
258
- "/bots/{botId}/botAliases/{botAliasId}/botLocales/{localeId}/sessions/{sessionId}/text";
259
- if (input.botId !== undefined) {
260
- const labelValue: string = input.botId;
261
- if (labelValue.length <= 0) {
262
- throw new Error("Empty value provided for input HTTP label: botId.");
263
- }
264
- resolvedPath = resolvedPath.replace("{botId}", __extendedEncodeURIComponent(labelValue));
265
- } else {
266
- throw new Error("No value provided for input HTTP label: botId.");
267
- }
268
- if (input.botAliasId !== undefined) {
269
- const labelValue: string = input.botAliasId;
270
- if (labelValue.length <= 0) {
271
- throw new Error("Empty value provided for input HTTP label: botAliasId.");
272
- }
273
- resolvedPath = resolvedPath.replace("{botAliasId}", __extendedEncodeURIComponent(labelValue));
274
- } else {
275
- throw new Error("No value provided for input HTTP label: botAliasId.");
276
- }
277
- if (input.localeId !== undefined) {
278
- const labelValue: string = input.localeId;
279
- if (labelValue.length <= 0) {
280
- throw new Error("Empty value provided for input HTTP label: localeId.");
281
- }
282
- resolvedPath = resolvedPath.replace("{localeId}", __extendedEncodeURIComponent(labelValue));
283
- } else {
284
- throw new Error("No value provided for input HTTP label: localeId.");
285
- }
286
- if (input.sessionId !== undefined) {
287
- const labelValue: string = input.sessionId;
288
- if (labelValue.length <= 0) {
289
- throw new Error("Empty value provided for input HTTP label: sessionId.");
290
- }
291
- resolvedPath = resolvedPath.replace("{sessionId}", __extendedEncodeURIComponent(labelValue));
292
- } else {
293
- throw new Error("No value provided for input HTTP label: sessionId.");
294
- }
295
- let body: any;
296
- body = JSON.stringify({
297
- ...(input.requestAttributes !== undefined &&
298
- input.requestAttributes !== null && {
299
- requestAttributes: serializeAws_restJson1StringMap(input.requestAttributes, context),
300
- }),
301
- ...(input.sessionState !== undefined &&
302
- input.sessionState !== null && { sessionState: serializeAws_restJson1SessionState(input.sessionState, context) }),
303
- ...(input.text !== undefined && input.text !== null && { text: input.text }),
304
- });
305
- return new __HttpRequest({
306
- protocol,
307
- hostname,
308
- port,
309
- method: "POST",
310
- headers,
311
- path: resolvedPath,
312
- body,
313
- });
314
- };
315
-
316
- export const serializeAws_restJson1RecognizeUtteranceCommand = async (
317
- input: RecognizeUtteranceCommandInput,
318
- context: __SerdeContext
319
- ): Promise<__HttpRequest> => {
320
- const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
321
- const headers: any = {
322
- "content-type": "application/octet-stream",
323
- "x-amz-content-sha256": "UNSIGNED-PAYLOAD",
324
- ...(isSerializableHeaderValue(input.sessionState) && { "x-amz-lex-session-state": input.sessionState! }),
325
- ...(isSerializableHeaderValue(input.requestAttributes) && {
326
- "x-amz-lex-request-attributes": input.requestAttributes!,
327
- }),
328
- ...(isSerializableHeaderValue(input.requestContentType) && { "content-type": input.requestContentType! }),
329
- ...(isSerializableHeaderValue(input.responseContentType) && {
330
- "response-content-type": input.responseContentType!,
331
- }),
332
- };
333
- let resolvedPath =
334
- `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` +
335
- "/bots/{botId}/botAliases/{botAliasId}/botLocales/{localeId}/sessions/{sessionId}/utterance";
336
- if (input.botId !== undefined) {
337
- const labelValue: string = input.botId;
338
- if (labelValue.length <= 0) {
339
- throw new Error("Empty value provided for input HTTP label: botId.");
340
- }
341
- resolvedPath = resolvedPath.replace("{botId}", __extendedEncodeURIComponent(labelValue));
342
- } else {
343
- throw new Error("No value provided for input HTTP label: botId.");
344
- }
345
- if (input.botAliasId !== undefined) {
346
- const labelValue: string = input.botAliasId;
347
- if (labelValue.length <= 0) {
348
- throw new Error("Empty value provided for input HTTP label: botAliasId.");
349
- }
350
- resolvedPath = resolvedPath.replace("{botAliasId}", __extendedEncodeURIComponent(labelValue));
351
- } else {
352
- throw new Error("No value provided for input HTTP label: botAliasId.");
353
- }
354
- if (input.localeId !== undefined) {
355
- const labelValue: string = input.localeId;
356
- if (labelValue.length <= 0) {
357
- throw new Error("Empty value provided for input HTTP label: localeId.");
358
- }
359
- resolvedPath = resolvedPath.replace("{localeId}", __extendedEncodeURIComponent(labelValue));
360
- } else {
361
- throw new Error("No value provided for input HTTP label: localeId.");
362
- }
363
- if (input.sessionId !== undefined) {
364
- const labelValue: string = input.sessionId;
365
- if (labelValue.length <= 0) {
366
- throw new Error("Empty value provided for input HTTP label: sessionId.");
367
- }
368
- resolvedPath = resolvedPath.replace("{sessionId}", __extendedEncodeURIComponent(labelValue));
369
- } else {
370
- throw new Error("No value provided for input HTTP label: sessionId.");
371
- }
372
- let body: any;
373
- if (input.inputStream !== undefined) {
374
- body = input.inputStream;
375
- }
376
- return new __HttpRequest({
377
- protocol,
378
- hostname,
379
- port,
380
- method: "POST",
381
- headers,
382
- path: resolvedPath,
383
- body,
384
- });
385
- };
386
-
387
- export const serializeAws_restJson1StartConversationCommand = async (
388
- input: StartConversationCommandInput,
389
- context: __SerdeContext & __EventStreamSerdeContext
390
- ): Promise<__HttpRequest> => {
391
- const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
392
- const headers: any = {
393
- ...(isSerializableHeaderValue(input.conversationMode) && {
394
- "x-amz-lex-conversation-mode": input.conversationMode!,
395
- }),
396
- };
397
- let resolvedPath =
398
- `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` +
399
- "/bots/{botId}/botAliases/{botAliasId}/botLocales/{localeId}/sessions/{sessionId}/conversation";
400
- if (input.botId !== undefined) {
401
- const labelValue: string = input.botId;
402
- if (labelValue.length <= 0) {
403
- throw new Error("Empty value provided for input HTTP label: botId.");
404
- }
405
- resolvedPath = resolvedPath.replace("{botId}", __extendedEncodeURIComponent(labelValue));
406
- } else {
407
- throw new Error("No value provided for input HTTP label: botId.");
408
- }
409
- if (input.botAliasId !== undefined) {
410
- const labelValue: string = input.botAliasId;
411
- if (labelValue.length <= 0) {
412
- throw new Error("Empty value provided for input HTTP label: botAliasId.");
413
- }
414
- resolvedPath = resolvedPath.replace("{botAliasId}", __extendedEncodeURIComponent(labelValue));
415
- } else {
416
- throw new Error("No value provided for input HTTP label: botAliasId.");
417
- }
418
- if (input.localeId !== undefined) {
419
- const labelValue: string = input.localeId;
420
- if (labelValue.length <= 0) {
421
- throw new Error("Empty value provided for input HTTP label: localeId.");
422
- }
423
- resolvedPath = resolvedPath.replace("{localeId}", __extendedEncodeURIComponent(labelValue));
424
- } else {
425
- throw new Error("No value provided for input HTTP label: localeId.");
426
- }
427
- if (input.sessionId !== undefined) {
428
- const labelValue: string = input.sessionId;
429
- if (labelValue.length <= 0) {
430
- throw new Error("Empty value provided for input HTTP label: sessionId.");
431
- }
432
- resolvedPath = resolvedPath.replace("{sessionId}", __extendedEncodeURIComponent(labelValue));
433
- } else {
434
- throw new Error("No value provided for input HTTP label: sessionId.");
435
- }
436
- let body: any;
437
- if (input.requestEventStream !== undefined) {
438
- body = context.eventStreamMarshaller.serialize(input.requestEventStream, (event) =>
439
- serializeAws_restJson1StartConversationRequestEventStream_event(event, context)
440
- );
441
- }
442
- return new __HttpRequest({
443
- protocol,
444
- hostname,
445
- port,
446
- method: "POST",
447
- headers,
448
- path: resolvedPath,
449
- body,
450
- });
451
- };
452
-
453
- export const deserializeAws_restJson1DeleteSessionCommand = async (
454
- output: __HttpResponse,
455
- context: __SerdeContext
456
- ): Promise<DeleteSessionCommandOutput> => {
457
- if (output.statusCode !== 200 && output.statusCode >= 300) {
458
- return deserializeAws_restJson1DeleteSessionCommandError(output, context);
459
- }
460
- const contents: DeleteSessionCommandOutput = {
461
- $metadata: deserializeMetadata(output),
462
- botAliasId: undefined,
463
- botId: undefined,
464
- localeId: undefined,
465
- sessionId: undefined,
466
- };
467
- const data: { [key: string]: any } = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
468
- if (data.botAliasId !== undefined && data.botAliasId !== null) {
469
- contents.botAliasId = __expectString(data.botAliasId);
470
- }
471
- if (data.botId !== undefined && data.botId !== null) {
472
- contents.botId = __expectString(data.botId);
473
- }
474
- if (data.localeId !== undefined && data.localeId !== null) {
475
- contents.localeId = __expectString(data.localeId);
476
- }
477
- if (data.sessionId !== undefined && data.sessionId !== null) {
478
- contents.sessionId = __expectString(data.sessionId);
479
- }
480
- return Promise.resolve(contents);
481
- };
482
-
483
- const deserializeAws_restJson1DeleteSessionCommandError = async (
484
- output: __HttpResponse,
485
- context: __SerdeContext
486
- ): Promise<DeleteSessionCommandOutput> => {
487
- const parsedOutput: any = {
488
- ...output,
489
- body: await parseBody(output.body, context),
490
- };
491
- let response: __SmithyException & __MetadataBearer & { [key: string]: any };
492
- let errorCode: string = "UnknownError";
493
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
494
- switch (errorCode) {
495
- case "AccessDeniedException":
496
- case "com.amazonaws.lexruntimev2#AccessDeniedException":
497
- response = {
498
- ...(await deserializeAws_restJson1AccessDeniedExceptionResponse(parsedOutput, context)),
499
- name: errorCode,
500
- $metadata: deserializeMetadata(output),
501
- };
502
- break;
503
- case "ConflictException":
504
- case "com.amazonaws.lexruntimev2#ConflictException":
505
- response = {
506
- ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
507
- name: errorCode,
508
- $metadata: deserializeMetadata(output),
509
- };
510
- break;
511
- case "InternalServerException":
512
- case "com.amazonaws.lexruntimev2#InternalServerException":
513
- response = {
514
- ...(await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context)),
515
- name: errorCode,
516
- $metadata: deserializeMetadata(output),
517
- };
518
- break;
519
- case "ResourceNotFoundException":
520
- case "com.amazonaws.lexruntimev2#ResourceNotFoundException":
521
- response = {
522
- ...(await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context)),
523
- name: errorCode,
524
- $metadata: deserializeMetadata(output),
525
- };
526
- break;
527
- case "ThrottlingException":
528
- case "com.amazonaws.lexruntimev2#ThrottlingException":
529
- response = {
530
- ...(await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context)),
531
- name: errorCode,
532
- $metadata: deserializeMetadata(output),
533
- };
534
- break;
535
- case "ValidationException":
536
- case "com.amazonaws.lexruntimev2#ValidationException":
537
- response = {
538
- ...(await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context)),
539
- name: errorCode,
540
- $metadata: deserializeMetadata(output),
541
- };
542
- break;
543
- default:
544
- const parsedBody = parsedOutput.body;
545
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
546
- response = {
547
- ...parsedBody,
548
- name: `${errorCode}`,
549
- message: parsedBody.message || parsedBody.Message || errorCode,
550
- $fault: "client",
551
- $metadata: deserializeMetadata(output),
552
- } as any;
553
- }
554
- const message = response.message || response.Message || errorCode;
555
- response.message = message;
556
- delete response.Message;
557
- return Promise.reject(Object.assign(new Error(message), response));
558
- };
559
-
560
- export const deserializeAws_restJson1GetSessionCommand = async (
561
- output: __HttpResponse,
562
- context: __SerdeContext
563
- ): Promise<GetSessionCommandOutput> => {
564
- if (output.statusCode !== 200 && output.statusCode >= 300) {
565
- return deserializeAws_restJson1GetSessionCommandError(output, context);
566
- }
567
- const contents: GetSessionCommandOutput = {
568
- $metadata: deserializeMetadata(output),
569
- interpretations: undefined,
570
- messages: undefined,
571
- sessionId: undefined,
572
- sessionState: undefined,
573
- };
574
- const data: { [key: string]: any } = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
575
- if (data.interpretations !== undefined && data.interpretations !== null) {
576
- contents.interpretations = deserializeAws_restJson1Interpretations(data.interpretations, context);
577
- }
578
- if (data.messages !== undefined && data.messages !== null) {
579
- contents.messages = deserializeAws_restJson1Messages(data.messages, context);
580
- }
581
- if (data.sessionId !== undefined && data.sessionId !== null) {
582
- contents.sessionId = __expectString(data.sessionId);
583
- }
584
- if (data.sessionState !== undefined && data.sessionState !== null) {
585
- contents.sessionState = deserializeAws_restJson1SessionState(data.sessionState, context);
586
- }
587
- return Promise.resolve(contents);
588
- };
589
-
590
- const deserializeAws_restJson1GetSessionCommandError = async (
591
- output: __HttpResponse,
592
- context: __SerdeContext
593
- ): Promise<GetSessionCommandOutput> => {
594
- const parsedOutput: any = {
595
- ...output,
596
- body: await parseBody(output.body, context),
597
- };
598
- let response: __SmithyException & __MetadataBearer & { [key: string]: any };
599
- let errorCode: string = "UnknownError";
600
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
601
- switch (errorCode) {
602
- case "AccessDeniedException":
603
- case "com.amazonaws.lexruntimev2#AccessDeniedException":
604
- response = {
605
- ...(await deserializeAws_restJson1AccessDeniedExceptionResponse(parsedOutput, context)),
606
- name: errorCode,
607
- $metadata: deserializeMetadata(output),
608
- };
609
- break;
610
- case "InternalServerException":
611
- case "com.amazonaws.lexruntimev2#InternalServerException":
612
- response = {
613
- ...(await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context)),
614
- name: errorCode,
615
- $metadata: deserializeMetadata(output),
616
- };
617
- break;
618
- case "ResourceNotFoundException":
619
- case "com.amazonaws.lexruntimev2#ResourceNotFoundException":
620
- response = {
621
- ...(await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context)),
622
- name: errorCode,
623
- $metadata: deserializeMetadata(output),
624
- };
625
- break;
626
- case "ThrottlingException":
627
- case "com.amazonaws.lexruntimev2#ThrottlingException":
628
- response = {
629
- ...(await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context)),
630
- name: errorCode,
631
- $metadata: deserializeMetadata(output),
632
- };
633
- break;
634
- case "ValidationException":
635
- case "com.amazonaws.lexruntimev2#ValidationException":
636
- response = {
637
- ...(await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context)),
638
- name: errorCode,
639
- $metadata: deserializeMetadata(output),
640
- };
641
- break;
642
- default:
643
- const parsedBody = parsedOutput.body;
644
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
645
- response = {
646
- ...parsedBody,
647
- name: `${errorCode}`,
648
- message: parsedBody.message || parsedBody.Message || errorCode,
649
- $fault: "client",
650
- $metadata: deserializeMetadata(output),
651
- } as any;
652
- }
653
- const message = response.message || response.Message || errorCode;
654
- response.message = message;
655
- delete response.Message;
656
- return Promise.reject(Object.assign(new Error(message), response));
657
- };
658
-
659
- export const deserializeAws_restJson1PutSessionCommand = async (
660
- output: __HttpResponse,
661
- context: __SerdeContext
662
- ): Promise<PutSessionCommandOutput> => {
663
- if (output.statusCode !== 200 && output.statusCode >= 300) {
664
- return deserializeAws_restJson1PutSessionCommandError(output, context);
665
- }
666
- const contents: PutSessionCommandOutput = {
667
- $metadata: deserializeMetadata(output),
668
- audioStream: undefined,
669
- contentType: undefined,
670
- messages: undefined,
671
- requestAttributes: undefined,
672
- sessionId: undefined,
673
- sessionState: undefined,
674
- };
675
- if (output.headers["content-type"] !== undefined) {
676
- contents.contentType = output.headers["content-type"];
677
- }
678
- if (output.headers["x-amz-lex-messages"] !== undefined) {
679
- contents.messages = output.headers["x-amz-lex-messages"];
680
- }
681
- if (output.headers["x-amz-lex-session-state"] !== undefined) {
682
- contents.sessionState = output.headers["x-amz-lex-session-state"];
683
- }
684
- if (output.headers["x-amz-lex-request-attributes"] !== undefined) {
685
- contents.requestAttributes = output.headers["x-amz-lex-request-attributes"];
686
- }
687
- if (output.headers["x-amz-lex-session-id"] !== undefined) {
688
- contents.sessionId = output.headers["x-amz-lex-session-id"];
689
- }
690
- const data: any = output.body;
691
- contents.audioStream = data;
692
- return Promise.resolve(contents);
693
- };
694
-
695
- const deserializeAws_restJson1PutSessionCommandError = async (
696
- output: __HttpResponse,
697
- context: __SerdeContext
698
- ): Promise<PutSessionCommandOutput> => {
699
- const parsedOutput: any = {
700
- ...output,
701
- body: await parseBody(output.body, context),
702
- };
703
- let response: __SmithyException & __MetadataBearer & { [key: string]: any };
704
- let errorCode: string = "UnknownError";
705
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
706
- switch (errorCode) {
707
- case "AccessDeniedException":
708
- case "com.amazonaws.lexruntimev2#AccessDeniedException":
709
- response = {
710
- ...(await deserializeAws_restJson1AccessDeniedExceptionResponse(parsedOutput, context)),
711
- name: errorCode,
712
- $metadata: deserializeMetadata(output),
713
- };
714
- break;
715
- case "BadGatewayException":
716
- case "com.amazonaws.lexruntimev2#BadGatewayException":
717
- response = {
718
- ...(await deserializeAws_restJson1BadGatewayExceptionResponse(parsedOutput, context)),
719
- name: errorCode,
720
- $metadata: deserializeMetadata(output),
721
- };
722
- break;
723
- case "ConflictException":
724
- case "com.amazonaws.lexruntimev2#ConflictException":
725
- response = {
726
- ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
727
- name: errorCode,
728
- $metadata: deserializeMetadata(output),
729
- };
730
- break;
731
- case "DependencyFailedException":
732
- case "com.amazonaws.lexruntimev2#DependencyFailedException":
733
- response = {
734
- ...(await deserializeAws_restJson1DependencyFailedExceptionResponse(parsedOutput, context)),
735
- name: errorCode,
736
- $metadata: deserializeMetadata(output),
737
- };
738
- break;
739
- case "InternalServerException":
740
- case "com.amazonaws.lexruntimev2#InternalServerException":
741
- response = {
742
- ...(await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context)),
743
- name: errorCode,
744
- $metadata: deserializeMetadata(output),
745
- };
746
- break;
747
- case "ResourceNotFoundException":
748
- case "com.amazonaws.lexruntimev2#ResourceNotFoundException":
749
- response = {
750
- ...(await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context)),
751
- name: errorCode,
752
- $metadata: deserializeMetadata(output),
753
- };
754
- break;
755
- case "ThrottlingException":
756
- case "com.amazonaws.lexruntimev2#ThrottlingException":
757
- response = {
758
- ...(await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context)),
759
- name: errorCode,
760
- $metadata: deserializeMetadata(output),
761
- };
762
- break;
763
- case "ValidationException":
764
- case "com.amazonaws.lexruntimev2#ValidationException":
765
- response = {
766
- ...(await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context)),
767
- name: errorCode,
768
- $metadata: deserializeMetadata(output),
769
- };
770
- break;
771
- default:
772
- const parsedBody = parsedOutput.body;
773
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
774
- response = {
775
- ...parsedBody,
776
- name: `${errorCode}`,
777
- message: parsedBody.message || parsedBody.Message || errorCode,
778
- $fault: "client",
779
- $metadata: deserializeMetadata(output),
780
- } as any;
781
- }
782
- const message = response.message || response.Message || errorCode;
783
- response.message = message;
784
- delete response.Message;
785
- return Promise.reject(Object.assign(new Error(message), response));
786
- };
787
-
788
- export const deserializeAws_restJson1RecognizeTextCommand = async (
789
- output: __HttpResponse,
790
- context: __SerdeContext
791
- ): Promise<RecognizeTextCommandOutput> => {
792
- if (output.statusCode !== 200 && output.statusCode >= 300) {
793
- return deserializeAws_restJson1RecognizeTextCommandError(output, context);
794
- }
795
- const contents: RecognizeTextCommandOutput = {
796
- $metadata: deserializeMetadata(output),
797
- interpretations: undefined,
798
- messages: undefined,
799
- requestAttributes: undefined,
800
- sessionId: undefined,
801
- sessionState: undefined,
802
- };
803
- const data: { [key: string]: any } = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
804
- if (data.interpretations !== undefined && data.interpretations !== null) {
805
- contents.interpretations = deserializeAws_restJson1Interpretations(data.interpretations, context);
806
- }
807
- if (data.messages !== undefined && data.messages !== null) {
808
- contents.messages = deserializeAws_restJson1Messages(data.messages, context);
809
- }
810
- if (data.requestAttributes !== undefined && data.requestAttributes !== null) {
811
- contents.requestAttributes = deserializeAws_restJson1StringMap(data.requestAttributes, context);
812
- }
813
- if (data.sessionId !== undefined && data.sessionId !== null) {
814
- contents.sessionId = __expectString(data.sessionId);
815
- }
816
- if (data.sessionState !== undefined && data.sessionState !== null) {
817
- contents.sessionState = deserializeAws_restJson1SessionState(data.sessionState, context);
818
- }
819
- return Promise.resolve(contents);
820
- };
821
-
822
- const deserializeAws_restJson1RecognizeTextCommandError = async (
823
- output: __HttpResponse,
824
- context: __SerdeContext
825
- ): Promise<RecognizeTextCommandOutput> => {
826
- const parsedOutput: any = {
827
- ...output,
828
- body: await parseBody(output.body, context),
829
- };
830
- let response: __SmithyException & __MetadataBearer & { [key: string]: any };
831
- let errorCode: string = "UnknownError";
832
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
833
- switch (errorCode) {
834
- case "AccessDeniedException":
835
- case "com.amazonaws.lexruntimev2#AccessDeniedException":
836
- response = {
837
- ...(await deserializeAws_restJson1AccessDeniedExceptionResponse(parsedOutput, context)),
838
- name: errorCode,
839
- $metadata: deserializeMetadata(output),
840
- };
841
- break;
842
- case "BadGatewayException":
843
- case "com.amazonaws.lexruntimev2#BadGatewayException":
844
- response = {
845
- ...(await deserializeAws_restJson1BadGatewayExceptionResponse(parsedOutput, context)),
846
- name: errorCode,
847
- $metadata: deserializeMetadata(output),
848
- };
849
- break;
850
- case "ConflictException":
851
- case "com.amazonaws.lexruntimev2#ConflictException":
852
- response = {
853
- ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
854
- name: errorCode,
855
- $metadata: deserializeMetadata(output),
856
- };
857
- break;
858
- case "DependencyFailedException":
859
- case "com.amazonaws.lexruntimev2#DependencyFailedException":
860
- response = {
861
- ...(await deserializeAws_restJson1DependencyFailedExceptionResponse(parsedOutput, context)),
862
- name: errorCode,
863
- $metadata: deserializeMetadata(output),
864
- };
865
- break;
866
- case "InternalServerException":
867
- case "com.amazonaws.lexruntimev2#InternalServerException":
868
- response = {
869
- ...(await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context)),
870
- name: errorCode,
871
- $metadata: deserializeMetadata(output),
872
- };
873
- break;
874
- case "ResourceNotFoundException":
875
- case "com.amazonaws.lexruntimev2#ResourceNotFoundException":
876
- response = {
877
- ...(await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context)),
878
- name: errorCode,
879
- $metadata: deserializeMetadata(output),
880
- };
881
- break;
882
- case "ThrottlingException":
883
- case "com.amazonaws.lexruntimev2#ThrottlingException":
884
- response = {
885
- ...(await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context)),
886
- name: errorCode,
887
- $metadata: deserializeMetadata(output),
888
- };
889
- break;
890
- case "ValidationException":
891
- case "com.amazonaws.lexruntimev2#ValidationException":
892
- response = {
893
- ...(await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context)),
894
- name: errorCode,
895
- $metadata: deserializeMetadata(output),
896
- };
897
- break;
898
- default:
899
- const parsedBody = parsedOutput.body;
900
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
901
- response = {
902
- ...parsedBody,
903
- name: `${errorCode}`,
904
- message: parsedBody.message || parsedBody.Message || errorCode,
905
- $fault: "client",
906
- $metadata: deserializeMetadata(output),
907
- } as any;
908
- }
909
- const message = response.message || response.Message || errorCode;
910
- response.message = message;
911
- delete response.Message;
912
- return Promise.reject(Object.assign(new Error(message), response));
913
- };
914
-
915
- export const deserializeAws_restJson1RecognizeUtteranceCommand = async (
916
- output: __HttpResponse,
917
- context: __SerdeContext
918
- ): Promise<RecognizeUtteranceCommandOutput> => {
919
- if (output.statusCode !== 200 && output.statusCode >= 300) {
920
- return deserializeAws_restJson1RecognizeUtteranceCommandError(output, context);
921
- }
922
- const contents: RecognizeUtteranceCommandOutput = {
923
- $metadata: deserializeMetadata(output),
924
- audioStream: undefined,
925
- contentType: undefined,
926
- inputMode: undefined,
927
- inputTranscript: undefined,
928
- interpretations: undefined,
929
- messages: undefined,
930
- requestAttributes: undefined,
931
- sessionId: undefined,
932
- sessionState: undefined,
933
- };
934
- if (output.headers["x-amz-lex-input-mode"] !== undefined) {
935
- contents.inputMode = output.headers["x-amz-lex-input-mode"];
936
- }
937
- if (output.headers["content-type"] !== undefined) {
938
- contents.contentType = output.headers["content-type"];
939
- }
940
- if (output.headers["x-amz-lex-messages"] !== undefined) {
941
- contents.messages = output.headers["x-amz-lex-messages"];
942
- }
943
- if (output.headers["x-amz-lex-interpretations"] !== undefined) {
944
- contents.interpretations = output.headers["x-amz-lex-interpretations"];
945
- }
946
- if (output.headers["x-amz-lex-session-state"] !== undefined) {
947
- contents.sessionState = output.headers["x-amz-lex-session-state"];
948
- }
949
- if (output.headers["x-amz-lex-request-attributes"] !== undefined) {
950
- contents.requestAttributes = output.headers["x-amz-lex-request-attributes"];
951
- }
952
- if (output.headers["x-amz-lex-session-id"] !== undefined) {
953
- contents.sessionId = output.headers["x-amz-lex-session-id"];
954
- }
955
- if (output.headers["x-amz-lex-input-transcript"] !== undefined) {
956
- contents.inputTranscript = output.headers["x-amz-lex-input-transcript"];
957
- }
958
- const data: any = output.body;
959
- contents.audioStream = data;
960
- return Promise.resolve(contents);
961
- };
962
-
963
- const deserializeAws_restJson1RecognizeUtteranceCommandError = async (
964
- output: __HttpResponse,
965
- context: __SerdeContext
966
- ): Promise<RecognizeUtteranceCommandOutput> => {
967
- const parsedOutput: any = {
968
- ...output,
969
- body: await parseBody(output.body, context),
970
- };
971
- let response: __SmithyException & __MetadataBearer & { [key: string]: any };
972
- let errorCode: string = "UnknownError";
973
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
974
- switch (errorCode) {
975
- case "AccessDeniedException":
976
- case "com.amazonaws.lexruntimev2#AccessDeniedException":
977
- response = {
978
- ...(await deserializeAws_restJson1AccessDeniedExceptionResponse(parsedOutput, context)),
979
- name: errorCode,
980
- $metadata: deserializeMetadata(output),
981
- };
982
- break;
983
- case "BadGatewayException":
984
- case "com.amazonaws.lexruntimev2#BadGatewayException":
985
- response = {
986
- ...(await deserializeAws_restJson1BadGatewayExceptionResponse(parsedOutput, context)),
987
- name: errorCode,
988
- $metadata: deserializeMetadata(output),
989
- };
990
- break;
991
- case "ConflictException":
992
- case "com.amazonaws.lexruntimev2#ConflictException":
993
- response = {
994
- ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
995
- name: errorCode,
996
- $metadata: deserializeMetadata(output),
997
- };
998
- break;
999
- case "DependencyFailedException":
1000
- case "com.amazonaws.lexruntimev2#DependencyFailedException":
1001
- response = {
1002
- ...(await deserializeAws_restJson1DependencyFailedExceptionResponse(parsedOutput, context)),
1003
- name: errorCode,
1004
- $metadata: deserializeMetadata(output),
1005
- };
1006
- break;
1007
- case "InternalServerException":
1008
- case "com.amazonaws.lexruntimev2#InternalServerException":
1009
- response = {
1010
- ...(await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context)),
1011
- name: errorCode,
1012
- $metadata: deserializeMetadata(output),
1013
- };
1014
- break;
1015
- case "ResourceNotFoundException":
1016
- case "com.amazonaws.lexruntimev2#ResourceNotFoundException":
1017
- response = {
1018
- ...(await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context)),
1019
- name: errorCode,
1020
- $metadata: deserializeMetadata(output),
1021
- };
1022
- break;
1023
- case "ThrottlingException":
1024
- case "com.amazonaws.lexruntimev2#ThrottlingException":
1025
- response = {
1026
- ...(await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context)),
1027
- name: errorCode,
1028
- $metadata: deserializeMetadata(output),
1029
- };
1030
- break;
1031
- case "ValidationException":
1032
- case "com.amazonaws.lexruntimev2#ValidationException":
1033
- response = {
1034
- ...(await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context)),
1035
- name: errorCode,
1036
- $metadata: deserializeMetadata(output),
1037
- };
1038
- break;
1039
- default:
1040
- const parsedBody = parsedOutput.body;
1041
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
1042
- response = {
1043
- ...parsedBody,
1044
- name: `${errorCode}`,
1045
- message: parsedBody.message || parsedBody.Message || errorCode,
1046
- $fault: "client",
1047
- $metadata: deserializeMetadata(output),
1048
- } as any;
1049
- }
1050
- const message = response.message || response.Message || errorCode;
1051
- response.message = message;
1052
- delete response.Message;
1053
- return Promise.reject(Object.assign(new Error(message), response));
1054
- };
1055
-
1056
- export const deserializeAws_restJson1StartConversationCommand = async (
1057
- output: __HttpResponse,
1058
- context: __SerdeContext & __EventStreamSerdeContext
1059
- ): Promise<StartConversationCommandOutput> => {
1060
- if (output.statusCode !== 200 && output.statusCode >= 300) {
1061
- return deserializeAws_restJson1StartConversationCommandError(output, context);
1062
- }
1063
- const contents: StartConversationCommandOutput = {
1064
- $metadata: deserializeMetadata(output),
1065
- responseEventStream: undefined,
1066
- };
1067
- const data: any = context.eventStreamMarshaller.deserialize(output.body, async (event) => {
1068
- const eventName = Object.keys(event)[0];
1069
- const eventHeaders = Object.entries(event[eventName].headers).reduce((accummulator, curr) => {
1070
- accummulator[curr[0]] = curr[1].value;
1071
- return accummulator;
1072
- }, {} as { [key: string]: any });
1073
- const eventMessage = {
1074
- headers: eventHeaders,
1075
- body: event[eventName].body,
1076
- };
1077
- const parsedEvent = {
1078
- [eventName]: eventMessage,
1079
- };
1080
- return await deserializeAws_restJson1StartConversationResponseEventStream_event(parsedEvent, context);
1081
- });
1082
- contents.responseEventStream = data;
1083
- return Promise.resolve(contents);
1084
- };
1085
-
1086
- const deserializeAws_restJson1StartConversationCommandError = async (
1087
- output: __HttpResponse,
1088
- context: __SerdeContext
1089
- ): Promise<StartConversationCommandOutput> => {
1090
- const parsedOutput: any = {
1091
- ...output,
1092
- body: await parseBody(output.body, context),
1093
- };
1094
- let response: __SmithyException & __MetadataBearer & { [key: string]: any };
1095
- let errorCode: string = "UnknownError";
1096
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
1097
- switch (errorCode) {
1098
- case "AccessDeniedException":
1099
- case "com.amazonaws.lexruntimev2#AccessDeniedException":
1100
- response = {
1101
- ...(await deserializeAws_restJson1AccessDeniedExceptionResponse(parsedOutput, context)),
1102
- name: errorCode,
1103
- $metadata: deserializeMetadata(output),
1104
- };
1105
- break;
1106
- case "InternalServerException":
1107
- case "com.amazonaws.lexruntimev2#InternalServerException":
1108
- response = {
1109
- ...(await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context)),
1110
- name: errorCode,
1111
- $metadata: deserializeMetadata(output),
1112
- };
1113
- break;
1114
- case "ThrottlingException":
1115
- case "com.amazonaws.lexruntimev2#ThrottlingException":
1116
- response = {
1117
- ...(await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context)),
1118
- name: errorCode,
1119
- $metadata: deserializeMetadata(output),
1120
- };
1121
- break;
1122
- case "ValidationException":
1123
- case "com.amazonaws.lexruntimev2#ValidationException":
1124
- response = {
1125
- ...(await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context)),
1126
- name: errorCode,
1127
- $metadata: deserializeMetadata(output),
1128
- };
1129
- break;
1130
- default:
1131
- const parsedBody = parsedOutput.body;
1132
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
1133
- response = {
1134
- ...parsedBody,
1135
- name: `${errorCode}`,
1136
- message: parsedBody.message || parsedBody.Message || errorCode,
1137
- $fault: "client",
1138
- $metadata: deserializeMetadata(output),
1139
- } as any;
1140
- }
1141
- const message = response.message || response.Message || errorCode;
1142
- response.message = message;
1143
- delete response.Message;
1144
- return Promise.reject(Object.assign(new Error(message), response));
1145
- };
1146
-
1147
- const serializeAws_restJson1StartConversationRequestEventStream_event = (
1148
- input: any,
1149
- context: __SerdeContext
1150
- ): __Message => {
1151
- return StartConversationRequestEventStream.visit(input, {
1152
- ConfigurationEvent: (value) => serializeAws_restJson1ConfigurationEvent_event(value, context),
1153
- AudioInputEvent: (value) => serializeAws_restJson1AudioInputEvent_event(value, context),
1154
- DTMFInputEvent: (value) => serializeAws_restJson1DTMFInputEvent_event(value, context),
1155
- TextInputEvent: (value) => serializeAws_restJson1TextInputEvent_event(value, context),
1156
- PlaybackCompletionEvent: (value) => serializeAws_restJson1PlaybackCompletionEvent_event(value, context),
1157
- DisconnectionEvent: (value) => serializeAws_restJson1DisconnectionEvent_event(value, context),
1158
- _: (value) => value as any,
1159
- });
1160
- };
1161
- const deserializeAws_restJson1StartConversationResponseEventStream_event = async (
1162
- output: any,
1163
- context: __SerdeContext
1164
- ): Promise<StartConversationResponseEventStream> => {
1165
- if (output["PlaybackInterruptionEvent"] !== undefined) {
1166
- return {
1167
- PlaybackInterruptionEvent: await deserializeAws_restJson1PlaybackInterruptionEvent_event(
1168
- output["PlaybackInterruptionEvent"],
1169
- context
1170
- ),
1171
- };
1172
- }
1173
- if (output["TranscriptEvent"] !== undefined) {
1174
- return {
1175
- TranscriptEvent: await deserializeAws_restJson1TranscriptEvent_event(output["TranscriptEvent"], context),
1176
- };
1177
- }
1178
- if (output["IntentResultEvent"] !== undefined) {
1179
- return {
1180
- IntentResultEvent: await deserializeAws_restJson1IntentResultEvent_event(output["IntentResultEvent"], context),
1181
- };
1182
- }
1183
- if (output["TextResponseEvent"] !== undefined) {
1184
- return {
1185
- TextResponseEvent: await deserializeAws_restJson1TextResponseEvent_event(output["TextResponseEvent"], context),
1186
- };
1187
- }
1188
- if (output["AudioResponseEvent"] !== undefined) {
1189
- return {
1190
- AudioResponseEvent: await deserializeAws_restJson1AudioResponseEvent_event(output["AudioResponseEvent"], context),
1191
- };
1192
- }
1193
- if (output["HeartbeatEvent"] !== undefined) {
1194
- return {
1195
- HeartbeatEvent: await deserializeAws_restJson1HeartbeatEvent_event(output["HeartbeatEvent"], context),
1196
- };
1197
- }
1198
- if (output["AccessDeniedException"] !== undefined) {
1199
- return {
1200
- AccessDeniedException: await deserializeAws_restJson1AccessDeniedException_event(
1201
- output["AccessDeniedException"],
1202
- context
1203
- ),
1204
- };
1205
- }
1206
- if (output["ResourceNotFoundException"] !== undefined) {
1207
- return {
1208
- ResourceNotFoundException: await deserializeAws_restJson1ResourceNotFoundException_event(
1209
- output["ResourceNotFoundException"],
1210
- context
1211
- ),
1212
- };
1213
- }
1214
- if (output["ValidationException"] !== undefined) {
1215
- return {
1216
- ValidationException: await deserializeAws_restJson1ValidationException_event(
1217
- output["ValidationException"],
1218
- context
1219
- ),
1220
- };
1221
- }
1222
- if (output["ThrottlingException"] !== undefined) {
1223
- return {
1224
- ThrottlingException: await deserializeAws_restJson1ThrottlingException_event(
1225
- output["ThrottlingException"],
1226
- context
1227
- ),
1228
- };
1229
- }
1230
- if (output["InternalServerException"] !== undefined) {
1231
- return {
1232
- InternalServerException: await deserializeAws_restJson1InternalServerException_event(
1233
- output["InternalServerException"],
1234
- context
1235
- ),
1236
- };
1237
- }
1238
- if (output["ConflictException"] !== undefined) {
1239
- return {
1240
- ConflictException: await deserializeAws_restJson1ConflictException_event(output["ConflictException"], context),
1241
- };
1242
- }
1243
- if (output["DependencyFailedException"] !== undefined) {
1244
- return {
1245
- DependencyFailedException: await deserializeAws_restJson1DependencyFailedException_event(
1246
- output["DependencyFailedException"],
1247
- context
1248
- ),
1249
- };
1250
- }
1251
- if (output["BadGatewayException"] !== undefined) {
1252
- return {
1253
- BadGatewayException: await deserializeAws_restJson1BadGatewayException_event(
1254
- output["BadGatewayException"],
1255
- context
1256
- ),
1257
- };
1258
- }
1259
- return { $unknown: output };
1260
- };
1261
- const serializeAws_restJson1AudioInputEvent_event = (input: AudioInputEvent, context: __SerdeContext): __Message => {
1262
- const message: __Message = {
1263
- headers: {
1264
- ":event-type": { type: "string", value: "AudioInputEvent" },
1265
- ":message-type": { type: "string", value: "event" },
1266
- },
1267
- body: new Uint8Array(),
1268
- };
1269
- message.body = serializeAws_restJson1AudioInputEvent(input, context);
1270
- return message;
1271
- };
1272
- const serializeAws_restJson1ConfigurationEvent_event = (
1273
- input: ConfigurationEvent,
1274
- context: __SerdeContext
1275
- ): __Message => {
1276
- const message: __Message = {
1277
- headers: {
1278
- ":event-type": { type: "string", value: "ConfigurationEvent" },
1279
- ":message-type": { type: "string", value: "event" },
1280
- },
1281
- body: new Uint8Array(),
1282
- };
1283
- message.body = serializeAws_restJson1ConfigurationEvent(input, context);
1284
- return message;
1285
- };
1286
- const serializeAws_restJson1DisconnectionEvent_event = (
1287
- input: DisconnectionEvent,
1288
- context: __SerdeContext
1289
- ): __Message => {
1290
- const message: __Message = {
1291
- headers: {
1292
- ":event-type": { type: "string", value: "DisconnectionEvent" },
1293
- ":message-type": { type: "string", value: "event" },
1294
- },
1295
- body: new Uint8Array(),
1296
- };
1297
- message.body = serializeAws_restJson1DisconnectionEvent(input, context);
1298
- return message;
1299
- };
1300
- const serializeAws_restJson1DTMFInputEvent_event = (input: DTMFInputEvent, context: __SerdeContext): __Message => {
1301
- const message: __Message = {
1302
- headers: {
1303
- ":event-type": { type: "string", value: "DTMFInputEvent" },
1304
- ":message-type": { type: "string", value: "event" },
1305
- },
1306
- body: new Uint8Array(),
1307
- };
1308
- message.body = serializeAws_restJson1DTMFInputEvent(input, context);
1309
- return message;
1310
- };
1311
- const serializeAws_restJson1PlaybackCompletionEvent_event = (
1312
- input: PlaybackCompletionEvent,
1313
- context: __SerdeContext
1314
- ): __Message => {
1315
- const message: __Message = {
1316
- headers: {
1317
- ":event-type": { type: "string", value: "PlaybackCompletionEvent" },
1318
- ":message-type": { type: "string", value: "event" },
1319
- },
1320
- body: new Uint8Array(),
1321
- };
1322
- message.body = serializeAws_restJson1PlaybackCompletionEvent(input, context);
1323
- return message;
1324
- };
1325
- const serializeAws_restJson1TextInputEvent_event = (input: TextInputEvent, context: __SerdeContext): __Message => {
1326
- const message: __Message = {
1327
- headers: {
1328
- ":event-type": { type: "string", value: "TextInputEvent" },
1329
- ":message-type": { type: "string", value: "event" },
1330
- },
1331
- body: new Uint8Array(),
1332
- };
1333
- message.body = serializeAws_restJson1TextInputEvent(input, context);
1334
- return message;
1335
- };
1336
- const deserializeAws_restJson1AccessDeniedException_event = async (
1337
- output: any,
1338
- context: __SerdeContext
1339
- ): Promise<AccessDeniedException> => {
1340
- const parsedOutput: any = {
1341
- ...output,
1342
- body: await parseBody(output.body, context),
1343
- };
1344
- return deserializeAws_restJson1AccessDeniedExceptionResponse(parsedOutput, context);
1345
- };
1346
- const deserializeAws_restJson1AudioResponseEvent_event = async (
1347
- output: any,
1348
- context: __SerdeContext
1349
- ): Promise<AudioResponseEvent> => {
1350
- let contents: AudioResponseEvent = {} as any;
1351
- const data: any = await parseBody(output.body, context);
1352
- contents = {
1353
- ...contents,
1354
- ...deserializeAws_restJson1AudioResponseEvent(data, context),
1355
- } as any;
1356
- return contents;
1357
- };
1358
- const deserializeAws_restJson1BadGatewayException_event = async (
1359
- output: any,
1360
- context: __SerdeContext
1361
- ): Promise<BadGatewayException> => {
1362
- const parsedOutput: any = {
1363
- ...output,
1364
- body: await parseBody(output.body, context),
1365
- };
1366
- return deserializeAws_restJson1BadGatewayExceptionResponse(parsedOutput, context);
1367
- };
1368
- const deserializeAws_restJson1ConflictException_event = async (
1369
- output: any,
1370
- context: __SerdeContext
1371
- ): Promise<ConflictException> => {
1372
- const parsedOutput: any = {
1373
- ...output,
1374
- body: await parseBody(output.body, context),
1375
- };
1376
- return deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context);
1377
- };
1378
- const deserializeAws_restJson1DependencyFailedException_event = async (
1379
- output: any,
1380
- context: __SerdeContext
1381
- ): Promise<DependencyFailedException> => {
1382
- const parsedOutput: any = {
1383
- ...output,
1384
- body: await parseBody(output.body, context),
1385
- };
1386
- return deserializeAws_restJson1DependencyFailedExceptionResponse(parsedOutput, context);
1387
- };
1388
- const deserializeAws_restJson1HeartbeatEvent_event = async (
1389
- output: any,
1390
- context: __SerdeContext
1391
- ): Promise<HeartbeatEvent> => {
1392
- let contents: HeartbeatEvent = {} as any;
1393
- const data: any = await parseBody(output.body, context);
1394
- contents = {
1395
- ...contents,
1396
- ...deserializeAws_restJson1HeartbeatEvent(data, context),
1397
- } as any;
1398
- return contents;
1399
- };
1400
- const deserializeAws_restJson1IntentResultEvent_event = async (
1401
- output: any,
1402
- context: __SerdeContext
1403
- ): Promise<IntentResultEvent> => {
1404
- let contents: IntentResultEvent = {} as any;
1405
- const data: any = await parseBody(output.body, context);
1406
- contents = {
1407
- ...contents,
1408
- ...deserializeAws_restJson1IntentResultEvent(data, context),
1409
- } as any;
1410
- return contents;
1411
- };
1412
- const deserializeAws_restJson1InternalServerException_event = async (
1413
- output: any,
1414
- context: __SerdeContext
1415
- ): Promise<InternalServerException> => {
1416
- const parsedOutput: any = {
1417
- ...output,
1418
- body: await parseBody(output.body, context),
1419
- };
1420
- return deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context);
1421
- };
1422
- const deserializeAws_restJson1PlaybackInterruptionEvent_event = async (
1423
- output: any,
1424
- context: __SerdeContext
1425
- ): Promise<PlaybackInterruptionEvent> => {
1426
- let contents: PlaybackInterruptionEvent = {} as any;
1427
- const data: any = await parseBody(output.body, context);
1428
- contents = {
1429
- ...contents,
1430
- ...deserializeAws_restJson1PlaybackInterruptionEvent(data, context),
1431
- } as any;
1432
- return contents;
1433
- };
1434
- const deserializeAws_restJson1ResourceNotFoundException_event = async (
1435
- output: any,
1436
- context: __SerdeContext
1437
- ): Promise<ResourceNotFoundException> => {
1438
- const parsedOutput: any = {
1439
- ...output,
1440
- body: await parseBody(output.body, context),
1441
- };
1442
- return deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context);
1443
- };
1444
- const deserializeAws_restJson1TextResponseEvent_event = async (
1445
- output: any,
1446
- context: __SerdeContext
1447
- ): Promise<TextResponseEvent> => {
1448
- let contents: TextResponseEvent = {} as any;
1449
- const data: any = await parseBody(output.body, context);
1450
- contents = {
1451
- ...contents,
1452
- ...deserializeAws_restJson1TextResponseEvent(data, context),
1453
- } as any;
1454
- return contents;
1455
- };
1456
- const deserializeAws_restJson1ThrottlingException_event = async (
1457
- output: any,
1458
- context: __SerdeContext
1459
- ): Promise<ThrottlingException> => {
1460
- const parsedOutput: any = {
1461
- ...output,
1462
- body: await parseBody(output.body, context),
1463
- };
1464
- return deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context);
1465
- };
1466
- const deserializeAws_restJson1TranscriptEvent_event = async (
1467
- output: any,
1468
- context: __SerdeContext
1469
- ): Promise<TranscriptEvent> => {
1470
- let contents: TranscriptEvent = {} as any;
1471
- const data: any = await parseBody(output.body, context);
1472
- contents = {
1473
- ...contents,
1474
- ...deserializeAws_restJson1TranscriptEvent(data, context),
1475
- } as any;
1476
- return contents;
1477
- };
1478
- const deserializeAws_restJson1ValidationException_event = async (
1479
- output: any,
1480
- context: __SerdeContext
1481
- ): Promise<ValidationException> => {
1482
- const parsedOutput: any = {
1483
- ...output,
1484
- body: await parseBody(output.body, context),
1485
- };
1486
- return deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context);
1487
- };
1488
- const deserializeAws_restJson1AccessDeniedExceptionResponse = async (
1489
- parsedOutput: any,
1490
- context: __SerdeContext
1491
- ): Promise<AccessDeniedException> => {
1492
- const contents: AccessDeniedException = {
1493
- name: "AccessDeniedException",
1494
- $fault: "client",
1495
- $metadata: deserializeMetadata(parsedOutput),
1496
- message: undefined,
1497
- };
1498
- const data: any = parsedOutput.body;
1499
- if (data.message !== undefined && data.message !== null) {
1500
- contents.message = __expectString(data.message);
1501
- }
1502
- return contents;
1503
- };
1504
-
1505
- const deserializeAws_restJson1BadGatewayExceptionResponse = async (
1506
- parsedOutput: any,
1507
- context: __SerdeContext
1508
- ): Promise<BadGatewayException> => {
1509
- const contents: BadGatewayException = {
1510
- name: "BadGatewayException",
1511
- $fault: "server",
1512
- $metadata: deserializeMetadata(parsedOutput),
1513
- message: undefined,
1514
- };
1515
- const data: any = parsedOutput.body;
1516
- if (data.message !== undefined && data.message !== null) {
1517
- contents.message = __expectString(data.message);
1518
- }
1519
- return contents;
1520
- };
1521
-
1522
- const deserializeAws_restJson1ConflictExceptionResponse = async (
1523
- parsedOutput: any,
1524
- context: __SerdeContext
1525
- ): Promise<ConflictException> => {
1526
- const contents: ConflictException = {
1527
- name: "ConflictException",
1528
- $fault: "client",
1529
- $metadata: deserializeMetadata(parsedOutput),
1530
- message: undefined,
1531
- };
1532
- const data: any = parsedOutput.body;
1533
- if (data.message !== undefined && data.message !== null) {
1534
- contents.message = __expectString(data.message);
1535
- }
1536
- return contents;
1537
- };
1538
-
1539
- const deserializeAws_restJson1DependencyFailedExceptionResponse = async (
1540
- parsedOutput: any,
1541
- context: __SerdeContext
1542
- ): Promise<DependencyFailedException> => {
1543
- const contents: DependencyFailedException = {
1544
- name: "DependencyFailedException",
1545
- $fault: "client",
1546
- $metadata: deserializeMetadata(parsedOutput),
1547
- message: undefined,
1548
- };
1549
- const data: any = parsedOutput.body;
1550
- if (data.message !== undefined && data.message !== null) {
1551
- contents.message = __expectString(data.message);
1552
- }
1553
- return contents;
1554
- };
1555
-
1556
- const deserializeAws_restJson1InternalServerExceptionResponse = async (
1557
- parsedOutput: any,
1558
- context: __SerdeContext
1559
- ): Promise<InternalServerException> => {
1560
- const contents: InternalServerException = {
1561
- name: "InternalServerException",
1562
- $fault: "server",
1563
- $metadata: deserializeMetadata(parsedOutput),
1564
- message: undefined,
1565
- };
1566
- const data: any = parsedOutput.body;
1567
- if (data.message !== undefined && data.message !== null) {
1568
- contents.message = __expectString(data.message);
1569
- }
1570
- return contents;
1571
- };
1572
-
1573
- const deserializeAws_restJson1ResourceNotFoundExceptionResponse = async (
1574
- parsedOutput: any,
1575
- context: __SerdeContext
1576
- ): Promise<ResourceNotFoundException> => {
1577
- const contents: ResourceNotFoundException = {
1578
- name: "ResourceNotFoundException",
1579
- $fault: "client",
1580
- $metadata: deserializeMetadata(parsedOutput),
1581
- message: undefined,
1582
- };
1583
- const data: any = parsedOutput.body;
1584
- if (data.message !== undefined && data.message !== null) {
1585
- contents.message = __expectString(data.message);
1586
- }
1587
- return contents;
1588
- };
1589
-
1590
- const deserializeAws_restJson1ThrottlingExceptionResponse = async (
1591
- parsedOutput: any,
1592
- context: __SerdeContext
1593
- ): Promise<ThrottlingException> => {
1594
- const contents: ThrottlingException = {
1595
- name: "ThrottlingException",
1596
- $fault: "client",
1597
- $metadata: deserializeMetadata(parsedOutput),
1598
- message: undefined,
1599
- };
1600
- const data: any = parsedOutput.body;
1601
- if (data.message !== undefined && data.message !== null) {
1602
- contents.message = __expectString(data.message);
1603
- }
1604
- return contents;
1605
- };
1606
-
1607
- const deserializeAws_restJson1ValidationExceptionResponse = async (
1608
- parsedOutput: any,
1609
- context: __SerdeContext
1610
- ): Promise<ValidationException> => {
1611
- const contents: ValidationException = {
1612
- name: "ValidationException",
1613
- $fault: "client",
1614
- $metadata: deserializeMetadata(parsedOutput),
1615
- message: undefined,
1616
- };
1617
- const data: any = parsedOutput.body;
1618
- if (data.message !== undefined && data.message !== null) {
1619
- contents.message = __expectString(data.message);
1620
- }
1621
- return contents;
1622
- };
1623
-
1624
- const serializeAws_restJson1ActiveContext = (input: ActiveContext, context: __SerdeContext): any => {
1625
- return {
1626
- ...(input.contextAttributes !== undefined &&
1627
- input.contextAttributes !== null && {
1628
- contextAttributes: serializeAws_restJson1ActiveContextParametersMap(input.contextAttributes, context),
1629
- }),
1630
- ...(input.name !== undefined && input.name !== null && { name: input.name }),
1631
- ...(input.timeToLive !== undefined &&
1632
- input.timeToLive !== null && {
1633
- timeToLive: serializeAws_restJson1ActiveContextTimeToLive(input.timeToLive, context),
1634
- }),
1635
- };
1636
- };
1637
-
1638
- const serializeAws_restJson1ActiveContextParametersMap = (
1639
- input: { [key: string]: string },
1640
- context: __SerdeContext
1641
- ): any => {
1642
- return Object.entries(input).reduce((acc: { [key: string]: any }, [key, value]: [string, any]) => {
1643
- if (value === null) {
1644
- return acc;
1645
- }
1646
- return {
1647
- ...acc,
1648
- [key]: value,
1649
- };
1650
- }, {});
1651
- };
1652
-
1653
- const serializeAws_restJson1ActiveContextsList = (input: ActiveContext[], context: __SerdeContext): any => {
1654
- return input
1655
- .filter((e: any) => e != null)
1656
- .map((entry) => {
1657
- if (entry === null) {
1658
- return null as any;
1659
- }
1660
- return serializeAws_restJson1ActiveContext(entry, context);
1661
- });
1662
- };
1663
-
1664
- const serializeAws_restJson1ActiveContextTimeToLive = (
1665
- input: ActiveContextTimeToLive,
1666
- context: __SerdeContext
1667
- ): any => {
1668
- return {
1669
- ...(input.timeToLiveInSeconds !== undefined &&
1670
- input.timeToLiveInSeconds !== null && { timeToLiveInSeconds: input.timeToLiveInSeconds }),
1671
- ...(input.turnsToLive !== undefined && input.turnsToLive !== null && { turnsToLive: input.turnsToLive }),
1672
- };
1673
- };
1674
-
1675
- const serializeAws_restJson1AudioInputEvent = (input: AudioInputEvent, context: __SerdeContext): any => {
1676
- return {
1677
- ...(input.audioChunk !== undefined &&
1678
- input.audioChunk !== null && { audioChunk: context.base64Encoder(input.audioChunk) }),
1679
- ...(input.clientTimestampMillis !== undefined &&
1680
- input.clientTimestampMillis !== null && { clientTimestampMillis: input.clientTimestampMillis }),
1681
- ...(input.contentType !== undefined && input.contentType !== null && { contentType: input.contentType }),
1682
- ...(input.eventId !== undefined && input.eventId !== null && { eventId: input.eventId }),
1683
- };
1684
- };
1685
-
1686
- const serializeAws_restJson1Button = (input: Button, context: __SerdeContext): any => {
1687
- return {
1688
- ...(input.text !== undefined && input.text !== null && { text: input.text }),
1689
- ...(input.value !== undefined && input.value !== null && { value: input.value }),
1690
- };
1691
- };
1692
-
1693
- const serializeAws_restJson1ButtonsList = (input: Button[], context: __SerdeContext): any => {
1694
- return input
1695
- .filter((e: any) => e != null)
1696
- .map((entry) => {
1697
- if (entry === null) {
1698
- return null as any;
1699
- }
1700
- return serializeAws_restJson1Button(entry, context);
1701
- });
1702
- };
1703
-
1704
- const serializeAws_restJson1ConfigurationEvent = (input: ConfigurationEvent, context: __SerdeContext): any => {
1705
- return {
1706
- ...(input.clientTimestampMillis !== undefined &&
1707
- input.clientTimestampMillis !== null && { clientTimestampMillis: input.clientTimestampMillis }),
1708
- ...(input.disablePlayback !== undefined &&
1709
- input.disablePlayback !== null && { disablePlayback: input.disablePlayback }),
1710
- ...(input.eventId !== undefined && input.eventId !== null && { eventId: input.eventId }),
1711
- ...(input.requestAttributes !== undefined &&
1712
- input.requestAttributes !== null && {
1713
- requestAttributes: serializeAws_restJson1StringMap(input.requestAttributes, context),
1714
- }),
1715
- ...(input.responseContentType !== undefined &&
1716
- input.responseContentType !== null && { responseContentType: input.responseContentType }),
1717
- ...(input.sessionState !== undefined &&
1718
- input.sessionState !== null && { sessionState: serializeAws_restJson1SessionState(input.sessionState, context) }),
1719
- ...(input.welcomeMessages !== undefined &&
1720
- input.welcomeMessages !== null && {
1721
- welcomeMessages: serializeAws_restJson1Messages(input.welcomeMessages, context),
1722
- }),
1723
- };
1724
- };
1725
-
1726
- const serializeAws_restJson1DialogAction = (input: DialogAction, context: __SerdeContext): any => {
1727
- return {
1728
- ...(input.slotToElicit !== undefined && input.slotToElicit !== null && { slotToElicit: input.slotToElicit }),
1729
- ...(input.type !== undefined && input.type !== null && { type: input.type }),
1730
- };
1731
- };
1732
-
1733
- const serializeAws_restJson1DisconnectionEvent = (input: DisconnectionEvent, context: __SerdeContext): any => {
1734
- return {
1735
- ...(input.clientTimestampMillis !== undefined &&
1736
- input.clientTimestampMillis !== null && { clientTimestampMillis: input.clientTimestampMillis }),
1737
- ...(input.eventId !== undefined && input.eventId !== null && { eventId: input.eventId }),
1738
- };
1739
- };
1740
-
1741
- const serializeAws_restJson1DTMFInputEvent = (input: DTMFInputEvent, context: __SerdeContext): any => {
1742
- return {
1743
- ...(input.clientTimestampMillis !== undefined &&
1744
- input.clientTimestampMillis !== null && { clientTimestampMillis: input.clientTimestampMillis }),
1745
- ...(input.eventId !== undefined && input.eventId !== null && { eventId: input.eventId }),
1746
- ...(input.inputCharacter !== undefined &&
1747
- input.inputCharacter !== null && { inputCharacter: input.inputCharacter }),
1748
- };
1749
- };
1750
-
1751
- const serializeAws_restJson1ImageResponseCard = (input: ImageResponseCard, context: __SerdeContext): any => {
1752
- return {
1753
- ...(input.buttons !== undefined &&
1754
- input.buttons !== null && { buttons: serializeAws_restJson1ButtonsList(input.buttons, context) }),
1755
- ...(input.imageUrl !== undefined && input.imageUrl !== null && { imageUrl: input.imageUrl }),
1756
- ...(input.subtitle !== undefined && input.subtitle !== null && { subtitle: input.subtitle }),
1757
- ...(input.title !== undefined && input.title !== null && { title: input.title }),
1758
- };
1759
- };
1760
-
1761
- const serializeAws_restJson1Intent = (input: Intent, context: __SerdeContext): any => {
1762
- return {
1763
- ...(input.confirmationState !== undefined &&
1764
- input.confirmationState !== null && { confirmationState: input.confirmationState }),
1765
- ...(input.name !== undefined && input.name !== null && { name: input.name }),
1766
- ...(input.slots !== undefined &&
1767
- input.slots !== null && { slots: serializeAws_restJson1Slots(input.slots, context) }),
1768
- ...(input.state !== undefined && input.state !== null && { state: input.state }),
1769
- };
1770
- };
1771
-
1772
- const serializeAws_restJson1Message = (input: Message, context: __SerdeContext): any => {
1773
- return {
1774
- ...(input.content !== undefined && input.content !== null && { content: input.content }),
1775
- ...(input.contentType !== undefined && input.contentType !== null && { contentType: input.contentType }),
1776
- ...(input.imageResponseCard !== undefined &&
1777
- input.imageResponseCard !== null && {
1778
- imageResponseCard: serializeAws_restJson1ImageResponseCard(input.imageResponseCard, context),
1779
- }),
1780
- };
1781
- };
1782
-
1783
- const serializeAws_restJson1Messages = (input: Message[], context: __SerdeContext): any => {
1784
- return input
1785
- .filter((e: any) => e != null)
1786
- .map((entry) => {
1787
- if (entry === null) {
1788
- return null as any;
1789
- }
1790
- return serializeAws_restJson1Message(entry, context);
1791
- });
1792
- };
1793
-
1794
- const serializeAws_restJson1PlaybackCompletionEvent = (
1795
- input: PlaybackCompletionEvent,
1796
- context: __SerdeContext
1797
- ): any => {
1798
- return {
1799
- ...(input.clientTimestampMillis !== undefined &&
1800
- input.clientTimestampMillis !== null && { clientTimestampMillis: input.clientTimestampMillis }),
1801
- ...(input.eventId !== undefined && input.eventId !== null && { eventId: input.eventId }),
1802
- };
1803
- };
1804
-
1805
- const serializeAws_restJson1SessionState = (input: SessionState, context: __SerdeContext): any => {
1806
- return {
1807
- ...(input.activeContexts !== undefined &&
1808
- input.activeContexts !== null && {
1809
- activeContexts: serializeAws_restJson1ActiveContextsList(input.activeContexts, context),
1810
- }),
1811
- ...(input.dialogAction !== undefined &&
1812
- input.dialogAction !== null && { dialogAction: serializeAws_restJson1DialogAction(input.dialogAction, context) }),
1813
- ...(input.intent !== undefined &&
1814
- input.intent !== null && { intent: serializeAws_restJson1Intent(input.intent, context) }),
1815
- ...(input.originatingRequestId !== undefined &&
1816
- input.originatingRequestId !== null && { originatingRequestId: input.originatingRequestId }),
1817
- ...(input.sessionAttributes !== undefined &&
1818
- input.sessionAttributes !== null && {
1819
- sessionAttributes: serializeAws_restJson1StringMap(input.sessionAttributes, context),
1820
- }),
1821
- };
1822
- };
1823
-
1824
- const serializeAws_restJson1Slot = (input: Slot, context: __SerdeContext): any => {
1825
- return {
1826
- ...(input.shape !== undefined && input.shape !== null && { shape: input.shape }),
1827
- ...(input.value !== undefined &&
1828
- input.value !== null && { value: serializeAws_restJson1Value(input.value, context) }),
1829
- ...(input.values !== undefined &&
1830
- input.values !== null && { values: serializeAws_restJson1Values(input.values, context) }),
1831
- };
1832
- };
1833
-
1834
- const serializeAws_restJson1Slots = (input: { [key: string]: Slot }, context: __SerdeContext): any => {
1835
- return Object.entries(input).reduce((acc: { [key: string]: any }, [key, value]: [string, any]) => {
1836
- if (value === null) {
1837
- return acc;
1838
- }
1839
- return {
1840
- ...acc,
1841
- [key]: serializeAws_restJson1Slot(value, context),
1842
- };
1843
- }, {});
1844
- };
1845
-
1846
- const serializeAws_restJson1StartConversationRequestEventStream = (
1847
- input: StartConversationRequestEventStream,
1848
- context: __SerdeContext
1849
- ): any => {
1850
- return StartConversationRequestEventStream.visit(input, {
1851
- AudioInputEvent: (value) => ({ AudioInputEvent: serializeAws_restJson1AudioInputEvent(value, context) }),
1852
- ConfigurationEvent: (value) => ({ ConfigurationEvent: serializeAws_restJson1ConfigurationEvent(value, context) }),
1853
- DTMFInputEvent: (value) => ({ DTMFInputEvent: serializeAws_restJson1DTMFInputEvent(value, context) }),
1854
- DisconnectionEvent: (value) => ({ DisconnectionEvent: serializeAws_restJson1DisconnectionEvent(value, context) }),
1855
- PlaybackCompletionEvent: (value) => ({
1856
- PlaybackCompletionEvent: serializeAws_restJson1PlaybackCompletionEvent(value, context),
1857
- }),
1858
- TextInputEvent: (value) => ({ TextInputEvent: serializeAws_restJson1TextInputEvent(value, context) }),
1859
- _: (name, value) => ({ name: value } as any),
1860
- });
1861
- };
1862
-
1863
- const serializeAws_restJson1StringList = (input: string[], context: __SerdeContext): any => {
1864
- return input
1865
- .filter((e: any) => e != null)
1866
- .map((entry) => {
1867
- if (entry === null) {
1868
- return null as any;
1869
- }
1870
- return entry;
1871
- });
1872
- };
1873
-
1874
- const serializeAws_restJson1StringMap = (input: { [key: string]: string }, context: __SerdeContext): any => {
1875
- return Object.entries(input).reduce((acc: { [key: string]: any }, [key, value]: [string, any]) => {
1876
- if (value === null) {
1877
- return acc;
1878
- }
1879
- return {
1880
- ...acc,
1881
- [key]: value,
1882
- };
1883
- }, {});
1884
- };
1885
-
1886
- const serializeAws_restJson1TextInputEvent = (input: TextInputEvent, context: __SerdeContext): any => {
1887
- return {
1888
- ...(input.clientTimestampMillis !== undefined &&
1889
- input.clientTimestampMillis !== null && { clientTimestampMillis: input.clientTimestampMillis }),
1890
- ...(input.eventId !== undefined && input.eventId !== null && { eventId: input.eventId }),
1891
- ...(input.text !== undefined && input.text !== null && { text: input.text }),
1892
- };
1893
- };
1894
-
1895
- const serializeAws_restJson1Value = (input: Value, context: __SerdeContext): any => {
1896
- return {
1897
- ...(input.interpretedValue !== undefined &&
1898
- input.interpretedValue !== null && { interpretedValue: input.interpretedValue }),
1899
- ...(input.originalValue !== undefined && input.originalValue !== null && { originalValue: input.originalValue }),
1900
- ...(input.resolvedValues !== undefined &&
1901
- input.resolvedValues !== null && {
1902
- resolvedValues: serializeAws_restJson1StringList(input.resolvedValues, context),
1903
- }),
1904
- };
1905
- };
1906
-
1907
- const serializeAws_restJson1Values = (input: Slot[], context: __SerdeContext): any => {
1908
- return input
1909
- .filter((e: any) => e != null)
1910
- .map((entry) => {
1911
- if (entry === null) {
1912
- return null as any;
1913
- }
1914
- return serializeAws_restJson1Slot(entry, context);
1915
- });
1916
- };
1917
-
1918
- const deserializeAws_restJson1AccessDeniedException = (output: any, context: __SerdeContext): AccessDeniedException => {
1919
- return {
1920
- message: __expectString(output.message),
1921
- } as any;
1922
- };
1923
-
1924
- const deserializeAws_restJson1ActiveContext = (output: any, context: __SerdeContext): ActiveContext => {
1925
- return {
1926
- contextAttributes:
1927
- output.contextAttributes !== undefined && output.contextAttributes !== null
1928
- ? deserializeAws_restJson1ActiveContextParametersMap(output.contextAttributes, context)
1929
- : undefined,
1930
- name: __expectString(output.name),
1931
- timeToLive:
1932
- output.timeToLive !== undefined && output.timeToLive !== null
1933
- ? deserializeAws_restJson1ActiveContextTimeToLive(output.timeToLive, context)
1934
- : undefined,
1935
- } as any;
1936
- };
1937
-
1938
- const deserializeAws_restJson1ActiveContextParametersMap = (
1939
- output: any,
1940
- context: __SerdeContext
1941
- ): { [key: string]: string } => {
1942
- return Object.entries(output).reduce((acc: { [key: string]: string }, [key, value]: [string, any]) => {
1943
- if (value === null) {
1944
- return acc;
1945
- }
1946
- return {
1947
- ...acc,
1948
- [key]: __expectString(value) as any,
1949
- };
1950
- }, {});
1951
- };
1952
-
1953
- const deserializeAws_restJson1ActiveContextsList = (output: any, context: __SerdeContext): ActiveContext[] => {
1954
- return (output || [])
1955
- .filter((e: any) => e != null)
1956
- .map((entry: any) => {
1957
- if (entry === null) {
1958
- return null as any;
1959
- }
1960
- return deserializeAws_restJson1ActiveContext(entry, context);
1961
- });
1962
- };
1963
-
1964
- const deserializeAws_restJson1ActiveContextTimeToLive = (
1965
- output: any,
1966
- context: __SerdeContext
1967
- ): ActiveContextTimeToLive => {
1968
- return {
1969
- timeToLiveInSeconds: __expectInt32(output.timeToLiveInSeconds),
1970
- turnsToLive: __expectInt32(output.turnsToLive),
1971
- } as any;
1972
- };
1973
-
1974
- const deserializeAws_restJson1AudioResponseEvent = (output: any, context: __SerdeContext): AudioResponseEvent => {
1975
- return {
1976
- audioChunk:
1977
- output.audioChunk !== undefined && output.audioChunk !== null
1978
- ? context.base64Decoder(output.audioChunk)
1979
- : undefined,
1980
- contentType: __expectString(output.contentType),
1981
- eventId: __expectString(output.eventId),
1982
- } as any;
1983
- };
1984
-
1985
- const deserializeAws_restJson1BadGatewayException = (output: any, context: __SerdeContext): BadGatewayException => {
1986
- return {
1987
- message: __expectString(output.message),
1988
- } as any;
1989
- };
1990
-
1991
- const deserializeAws_restJson1Button = (output: any, context: __SerdeContext): Button => {
1992
- return {
1993
- text: __expectString(output.text),
1994
- value: __expectString(output.value),
1995
- } as any;
1996
- };
1997
-
1998
- const deserializeAws_restJson1ButtonsList = (output: any, context: __SerdeContext): Button[] => {
1999
- return (output || [])
2000
- .filter((e: any) => e != null)
2001
- .map((entry: any) => {
2002
- if (entry === null) {
2003
- return null as any;
2004
- }
2005
- return deserializeAws_restJson1Button(entry, context);
2006
- });
2007
- };
2008
-
2009
- const deserializeAws_restJson1ConfidenceScore = (output: any, context: __SerdeContext): ConfidenceScore => {
2010
- return {
2011
- score: __limitedParseDouble(output.score),
2012
- } as any;
2013
- };
2014
-
2015
- const deserializeAws_restJson1ConflictException = (output: any, context: __SerdeContext): ConflictException => {
2016
- return {
2017
- message: __expectString(output.message),
2018
- } as any;
2019
- };
2020
-
2021
- const deserializeAws_restJson1DependencyFailedException = (
2022
- output: any,
2023
- context: __SerdeContext
2024
- ): DependencyFailedException => {
2025
- return {
2026
- message: __expectString(output.message),
2027
- } as any;
2028
- };
2029
-
2030
- const deserializeAws_restJson1DialogAction = (output: any, context: __SerdeContext): DialogAction => {
2031
- return {
2032
- slotToElicit: __expectString(output.slotToElicit),
2033
- type: __expectString(output.type),
2034
- } as any;
2035
- };
2036
-
2037
- const deserializeAws_restJson1HeartbeatEvent = (output: any, context: __SerdeContext): HeartbeatEvent => {
2038
- return {
2039
- eventId: __expectString(output.eventId),
2040
- } as any;
2041
- };
2042
-
2043
- const deserializeAws_restJson1ImageResponseCard = (output: any, context: __SerdeContext): ImageResponseCard => {
2044
- return {
2045
- buttons:
2046
- output.buttons !== undefined && output.buttons !== null
2047
- ? deserializeAws_restJson1ButtonsList(output.buttons, context)
2048
- : undefined,
2049
- imageUrl: __expectString(output.imageUrl),
2050
- subtitle: __expectString(output.subtitle),
2051
- title: __expectString(output.title),
2052
- } as any;
2053
- };
2054
-
2055
- const deserializeAws_restJson1Intent = (output: any, context: __SerdeContext): Intent => {
2056
- return {
2057
- confirmationState: __expectString(output.confirmationState),
2058
- name: __expectString(output.name),
2059
- slots:
2060
- output.slots !== undefined && output.slots !== null
2061
- ? deserializeAws_restJson1Slots(output.slots, context)
2062
- : undefined,
2063
- state: __expectString(output.state),
2064
- } as any;
2065
- };
2066
-
2067
- const deserializeAws_restJson1IntentResultEvent = (output: any, context: __SerdeContext): IntentResultEvent => {
2068
- return {
2069
- eventId: __expectString(output.eventId),
2070
- inputMode: __expectString(output.inputMode),
2071
- interpretations:
2072
- output.interpretations !== undefined && output.interpretations !== null
2073
- ? deserializeAws_restJson1Interpretations(output.interpretations, context)
2074
- : undefined,
2075
- requestAttributes:
2076
- output.requestAttributes !== undefined && output.requestAttributes !== null
2077
- ? deserializeAws_restJson1StringMap(output.requestAttributes, context)
2078
- : undefined,
2079
- sessionId: __expectString(output.sessionId),
2080
- sessionState:
2081
- output.sessionState !== undefined && output.sessionState !== null
2082
- ? deserializeAws_restJson1SessionState(output.sessionState, context)
2083
- : undefined,
2084
- } as any;
2085
- };
2086
-
2087
- const deserializeAws_restJson1InternalServerException = (
2088
- output: any,
2089
- context: __SerdeContext
2090
- ): InternalServerException => {
2091
- return {
2092
- message: __expectString(output.message),
2093
- } as any;
2094
- };
2095
-
2096
- const deserializeAws_restJson1Interpretation = (output: any, context: __SerdeContext): Interpretation => {
2097
- return {
2098
- intent:
2099
- output.intent !== undefined && output.intent !== null
2100
- ? deserializeAws_restJson1Intent(output.intent, context)
2101
- : undefined,
2102
- nluConfidence:
2103
- output.nluConfidence !== undefined && output.nluConfidence !== null
2104
- ? deserializeAws_restJson1ConfidenceScore(output.nluConfidence, context)
2105
- : undefined,
2106
- sentimentResponse:
2107
- output.sentimentResponse !== undefined && output.sentimentResponse !== null
2108
- ? deserializeAws_restJson1SentimentResponse(output.sentimentResponse, context)
2109
- : undefined,
2110
- } as any;
2111
- };
2112
-
2113
- const deserializeAws_restJson1Interpretations = (output: any, context: __SerdeContext): Interpretation[] => {
2114
- return (output || [])
2115
- .filter((e: any) => e != null)
2116
- .map((entry: any) => {
2117
- if (entry === null) {
2118
- return null as any;
2119
- }
2120
- return deserializeAws_restJson1Interpretation(entry, context);
2121
- });
2122
- };
2123
-
2124
- const deserializeAws_restJson1Message = (output: any, context: __SerdeContext): Message => {
2125
- return {
2126
- content: __expectString(output.content),
2127
- contentType: __expectString(output.contentType),
2128
- imageResponseCard:
2129
- output.imageResponseCard !== undefined && output.imageResponseCard !== null
2130
- ? deserializeAws_restJson1ImageResponseCard(output.imageResponseCard, context)
2131
- : undefined,
2132
- } as any;
2133
- };
2134
-
2135
- const deserializeAws_restJson1Messages = (output: any, context: __SerdeContext): Message[] => {
2136
- return (output || [])
2137
- .filter((e: any) => e != null)
2138
- .map((entry: any) => {
2139
- if (entry === null) {
2140
- return null as any;
2141
- }
2142
- return deserializeAws_restJson1Message(entry, context);
2143
- });
2144
- };
2145
-
2146
- const deserializeAws_restJson1PlaybackInterruptionEvent = (
2147
- output: any,
2148
- context: __SerdeContext
2149
- ): PlaybackInterruptionEvent => {
2150
- return {
2151
- causedByEventId: __expectString(output.causedByEventId),
2152
- eventId: __expectString(output.eventId),
2153
- eventReason: __expectString(output.eventReason),
2154
- } as any;
2155
- };
2156
-
2157
- const deserializeAws_restJson1ResourceNotFoundException = (
2158
- output: any,
2159
- context: __SerdeContext
2160
- ): ResourceNotFoundException => {
2161
- return {
2162
- message: __expectString(output.message),
2163
- } as any;
2164
- };
2165
-
2166
- const deserializeAws_restJson1SentimentResponse = (output: any, context: __SerdeContext): SentimentResponse => {
2167
- return {
2168
- sentiment: __expectString(output.sentiment),
2169
- sentimentScore:
2170
- output.sentimentScore !== undefined && output.sentimentScore !== null
2171
- ? deserializeAws_restJson1SentimentScore(output.sentimentScore, context)
2172
- : undefined,
2173
- } as any;
2174
- };
2175
-
2176
- const deserializeAws_restJson1SentimentScore = (output: any, context: __SerdeContext): SentimentScore => {
2177
- return {
2178
- mixed: __limitedParseDouble(output.mixed),
2179
- negative: __limitedParseDouble(output.negative),
2180
- neutral: __limitedParseDouble(output.neutral),
2181
- positive: __limitedParseDouble(output.positive),
2182
- } as any;
2183
- };
2184
-
2185
- const deserializeAws_restJson1SessionState = (output: any, context: __SerdeContext): SessionState => {
2186
- return {
2187
- activeContexts:
2188
- output.activeContexts !== undefined && output.activeContexts !== null
2189
- ? deserializeAws_restJson1ActiveContextsList(output.activeContexts, context)
2190
- : undefined,
2191
- dialogAction:
2192
- output.dialogAction !== undefined && output.dialogAction !== null
2193
- ? deserializeAws_restJson1DialogAction(output.dialogAction, context)
2194
- : undefined,
2195
- intent:
2196
- output.intent !== undefined && output.intent !== null
2197
- ? deserializeAws_restJson1Intent(output.intent, context)
2198
- : undefined,
2199
- originatingRequestId: __expectString(output.originatingRequestId),
2200
- sessionAttributes:
2201
- output.sessionAttributes !== undefined && output.sessionAttributes !== null
2202
- ? deserializeAws_restJson1StringMap(output.sessionAttributes, context)
2203
- : undefined,
2204
- } as any;
2205
- };
2206
-
2207
- const deserializeAws_restJson1Slot = (output: any, context: __SerdeContext): Slot => {
2208
- return {
2209
- shape: __expectString(output.shape),
2210
- value:
2211
- output.value !== undefined && output.value !== null
2212
- ? deserializeAws_restJson1Value(output.value, context)
2213
- : undefined,
2214
- values:
2215
- output.values !== undefined && output.values !== null
2216
- ? deserializeAws_restJson1Values(output.values, context)
2217
- : undefined,
2218
- } as any;
2219
- };
2220
-
2221
- const deserializeAws_restJson1Slots = (output: any, context: __SerdeContext): { [key: string]: Slot } => {
2222
- return Object.entries(output).reduce((acc: { [key: string]: Slot }, [key, value]: [string, any]) => {
2223
- if (value === null) {
2224
- return acc;
2225
- }
2226
- return {
2227
- ...acc,
2228
- [key]: deserializeAws_restJson1Slot(value, context),
2229
- };
2230
- }, {});
2231
- };
2232
-
2233
- const deserializeAws_restJson1StartConversationResponseEventStream = (
2234
- output: any,
2235
- context: __SerdeContext
2236
- ): StartConversationResponseEventStream => {
2237
- if (output.AccessDeniedException !== undefined && output.AccessDeniedException !== null) {
2238
- return {
2239
- AccessDeniedException: deserializeAws_restJson1AccessDeniedException(output.AccessDeniedException, context),
2240
- };
2241
- }
2242
- if (output.AudioResponseEvent !== undefined && output.AudioResponseEvent !== null) {
2243
- return {
2244
- AudioResponseEvent: deserializeAws_restJson1AudioResponseEvent(output.AudioResponseEvent, context),
2245
- };
2246
- }
2247
- if (output.BadGatewayException !== undefined && output.BadGatewayException !== null) {
2248
- return {
2249
- BadGatewayException: deserializeAws_restJson1BadGatewayException(output.BadGatewayException, context),
2250
- };
2251
- }
2252
- if (output.ConflictException !== undefined && output.ConflictException !== null) {
2253
- return {
2254
- ConflictException: deserializeAws_restJson1ConflictException(output.ConflictException, context),
2255
- };
2256
- }
2257
- if (output.DependencyFailedException !== undefined && output.DependencyFailedException !== null) {
2258
- return {
2259
- DependencyFailedException: deserializeAws_restJson1DependencyFailedException(
2260
- output.DependencyFailedException,
2261
- context
2262
- ),
2263
- };
2264
- }
2265
- if (output.HeartbeatEvent !== undefined && output.HeartbeatEvent !== null) {
2266
- return {
2267
- HeartbeatEvent: deserializeAws_restJson1HeartbeatEvent(output.HeartbeatEvent, context),
2268
- };
2269
- }
2270
- if (output.IntentResultEvent !== undefined && output.IntentResultEvent !== null) {
2271
- return {
2272
- IntentResultEvent: deserializeAws_restJson1IntentResultEvent(output.IntentResultEvent, context),
2273
- };
2274
- }
2275
- if (output.InternalServerException !== undefined && output.InternalServerException !== null) {
2276
- return {
2277
- InternalServerException: deserializeAws_restJson1InternalServerException(output.InternalServerException, context),
2278
- };
2279
- }
2280
- if (output.PlaybackInterruptionEvent !== undefined && output.PlaybackInterruptionEvent !== null) {
2281
- return {
2282
- PlaybackInterruptionEvent: deserializeAws_restJson1PlaybackInterruptionEvent(
2283
- output.PlaybackInterruptionEvent,
2284
- context
2285
- ),
2286
- };
2287
- }
2288
- if (output.ResourceNotFoundException !== undefined && output.ResourceNotFoundException !== null) {
2289
- return {
2290
- ResourceNotFoundException: deserializeAws_restJson1ResourceNotFoundException(
2291
- output.ResourceNotFoundException,
2292
- context
2293
- ),
2294
- };
2295
- }
2296
- if (output.TextResponseEvent !== undefined && output.TextResponseEvent !== null) {
2297
- return {
2298
- TextResponseEvent: deserializeAws_restJson1TextResponseEvent(output.TextResponseEvent, context),
2299
- };
2300
- }
2301
- if (output.ThrottlingException !== undefined && output.ThrottlingException !== null) {
2302
- return {
2303
- ThrottlingException: deserializeAws_restJson1ThrottlingException(output.ThrottlingException, context),
2304
- };
2305
- }
2306
- if (output.TranscriptEvent !== undefined && output.TranscriptEvent !== null) {
2307
- return {
2308
- TranscriptEvent: deserializeAws_restJson1TranscriptEvent(output.TranscriptEvent, context),
2309
- };
2310
- }
2311
- if (output.ValidationException !== undefined && output.ValidationException !== null) {
2312
- return {
2313
- ValidationException: deserializeAws_restJson1ValidationException(output.ValidationException, context),
2314
- };
2315
- }
2316
- return { $unknown: Object.entries(output)[0] };
2317
- };
2318
-
2319
- const deserializeAws_restJson1StringList = (output: any, context: __SerdeContext): string[] => {
2320
- return (output || [])
2321
- .filter((e: any) => e != null)
2322
- .map((entry: any) => {
2323
- if (entry === null) {
2324
- return null as any;
2325
- }
2326
- return __expectString(entry) as any;
2327
- });
2328
- };
2329
-
2330
- const deserializeAws_restJson1StringMap = (output: any, context: __SerdeContext): { [key: string]: string } => {
2331
- return Object.entries(output).reduce((acc: { [key: string]: string }, [key, value]: [string, any]) => {
2332
- if (value === null) {
2333
- return acc;
2334
- }
2335
- return {
2336
- ...acc,
2337
- [key]: __expectString(value) as any,
2338
- };
2339
- }, {});
2340
- };
2341
-
2342
- const deserializeAws_restJson1TextResponseEvent = (output: any, context: __SerdeContext): TextResponseEvent => {
2343
- return {
2344
- eventId: __expectString(output.eventId),
2345
- messages:
2346
- output.messages !== undefined && output.messages !== null
2347
- ? deserializeAws_restJson1Messages(output.messages, context)
2348
- : undefined,
2349
- } as any;
2350
- };
2351
-
2352
- const deserializeAws_restJson1ThrottlingException = (output: any, context: __SerdeContext): ThrottlingException => {
2353
- return {
2354
- message: __expectString(output.message),
2355
- } as any;
2356
- };
2357
-
2358
- const deserializeAws_restJson1TranscriptEvent = (output: any, context: __SerdeContext): TranscriptEvent => {
2359
- return {
2360
- eventId: __expectString(output.eventId),
2361
- transcript: __expectString(output.transcript),
2362
- } as any;
2363
- };
2364
-
2365
- const deserializeAws_restJson1ValidationException = (output: any, context: __SerdeContext): ValidationException => {
2366
- return {
2367
- message: __expectString(output.message),
2368
- } as any;
2369
- };
2370
-
2371
- const deserializeAws_restJson1Value = (output: any, context: __SerdeContext): Value => {
2372
- return {
2373
- interpretedValue: __expectString(output.interpretedValue),
2374
- originalValue: __expectString(output.originalValue),
2375
- resolvedValues:
2376
- output.resolvedValues !== undefined && output.resolvedValues !== null
2377
- ? deserializeAws_restJson1StringList(output.resolvedValues, context)
2378
- : undefined,
2379
- } as any;
2380
- };
2381
-
2382
- const deserializeAws_restJson1Values = (output: any, context: __SerdeContext): Slot[] => {
2383
- return (output || [])
2384
- .filter((e: any) => e != null)
2385
- .map((entry: any) => {
2386
- if (entry === null) {
2387
- return null as any;
2388
- }
2389
- return deserializeAws_restJson1Slot(entry, context);
2390
- });
2391
- };
2392
-
2393
- const deserializeMetadata = (output: __HttpResponse): __ResponseMetadata => ({
2394
- httpStatusCode: output.statusCode,
2395
- requestId: output.headers["x-amzn-requestid"] ?? output.headers["x-amzn-request-id"],
2396
- extendedRequestId: output.headers["x-amz-id-2"],
2397
- cfId: output.headers["x-amz-cf-id"],
2398
- });
2399
-
2400
- // Collect low-level response body stream to Uint8Array.
2401
- const collectBody = (streamBody: any = new Uint8Array(), context: __SerdeContext): Promise<Uint8Array> => {
2402
- if (streamBody instanceof Uint8Array) {
2403
- return Promise.resolve(streamBody);
2404
- }
2405
- return context.streamCollector(streamBody) || Promise.resolve(new Uint8Array());
2406
- };
2407
-
2408
- // Encode Uint8Array data into string with utf-8.
2409
- const collectBodyString = (streamBody: any, context: __SerdeContext): Promise<string> =>
2410
- collectBody(streamBody, context).then((body) => context.utf8Encoder(body));
2411
-
2412
- const isSerializableHeaderValue = (value: any): boolean =>
2413
- value !== undefined &&
2414
- value !== null &&
2415
- value !== "" &&
2416
- (!Object.getOwnPropertyNames(value).includes("length") || value.length != 0) &&
2417
- (!Object.getOwnPropertyNames(value).includes("size") || value.size != 0);
2418
-
2419
- const parseBody = (streamBody: any, context: __SerdeContext): any =>
2420
- collectBodyString(streamBody, context).then((encoded) => {
2421
- if (encoded.length) {
2422
- return JSON.parse(encoded);
2423
- }
2424
- return {};
2425
- });
2426
-
2427
- /**
2428
- * Load an error code for the aws.rest-json-1.1 protocol.
2429
- */
2430
- const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => {
2431
- const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase());
2432
-
2433
- const sanitizeErrorCode = (rawValue: string): string => {
2434
- let cleanValue = rawValue;
2435
- if (cleanValue.indexOf(":") >= 0) {
2436
- cleanValue = cleanValue.split(":")[0];
2437
- }
2438
- if (cleanValue.indexOf("#") >= 0) {
2439
- cleanValue = cleanValue.split("#")[1];
2440
- }
2441
- return cleanValue;
2442
- };
2443
-
2444
- const headerKey = findKey(output.headers, "x-amzn-errortype");
2445
- if (headerKey !== undefined) {
2446
- return sanitizeErrorCode(output.headers[headerKey]);
2447
- }
2448
-
2449
- if (data.code !== undefined) {
2450
- return sanitizeErrorCode(data.code);
2451
- }
2452
-
2453
- if (data["__type"] !== undefined) {
2454
- return sanitizeErrorCode(data["__type"]);
2455
- }
2456
-
2457
- return "";
2458
- };