@aws-sdk/client-lex-runtime-service 3.181.0 → 3.183.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.
@@ -1,877 +1,733 @@
1
- import { __assign, __awaiter, __generator, __read } from "tslib";
2
1
  import { HttpRequest as __HttpRequest } from "@aws-sdk/protocol-http";
3
2
  import { decorateServiceException as __decorateServiceException, expectInt32 as __expectInt32, expectNonNull as __expectNonNull, expectObject as __expectObject, expectString as __expectString, LazyJsonString as __LazyJsonString, limitedParseDouble as __limitedParseDouble, map as __map, resolvedPath as __resolvedPath, throwDefaultError, } from "@aws-sdk/smithy-client";
4
3
  import { LexRuntimeServiceServiceException as __BaseException } from "../models/LexRuntimeServiceServiceException";
5
4
  import { BadGatewayException, BadRequestException, ConflictException, DependencyFailedException, InternalFailureException, LimitExceededException, LoopDetectedException, NotAcceptableException, NotFoundException, RequestTimeoutException, UnsupportedMediaTypeException, } from "../models/models_0";
6
- export var serializeAws_restJson1DeleteSessionCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
7
- var _a, hostname, _b, protocol, port, basePath, headers, resolvedPath, body;
8
- return __generator(this, function (_c) {
9
- switch (_c.label) {
10
- case 0: return [4, context.endpoint()];
11
- case 1:
12
- _a = _c.sent(), hostname = _a.hostname, _b = _a.protocol, protocol = _b === void 0 ? "https" : _b, port = _a.port, basePath = _a.path;
13
- headers = {};
14
- resolvedPath = "".concat((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || "") +
15
- "/bot/{botName}/alias/{botAlias}/user/{userId}/session";
16
- resolvedPath = __resolvedPath(resolvedPath, input, "botName", function () { return input.botName; }, "{botName}", false);
17
- resolvedPath = __resolvedPath(resolvedPath, input, "botAlias", function () { return input.botAlias; }, "{botAlias}", false);
18
- resolvedPath = __resolvedPath(resolvedPath, input, "userId", function () { return input.userId; }, "{userId}", false);
19
- return [2, new __HttpRequest({
20
- protocol: protocol,
21
- hostname: hostname,
22
- port: port,
23
- method: "DELETE",
24
- headers: headers,
25
- path: resolvedPath,
26
- body: body,
27
- })];
28
- }
29
- });
30
- }); };
31
- export var serializeAws_restJson1GetSessionCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
32
- var _a, hostname, _b, protocol, port, basePath, headers, resolvedPath, query, body;
33
- return __generator(this, function (_c) {
34
- switch (_c.label) {
35
- case 0: return [4, context.endpoint()];
36
- case 1:
37
- _a = _c.sent(), hostname = _a.hostname, _b = _a.protocol, protocol = _b === void 0 ? "https" : _b, port = _a.port, basePath = _a.path;
38
- headers = {};
39
- resolvedPath = "".concat((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || "") +
40
- "/bot/{botName}/alias/{botAlias}/user/{userId}/session";
41
- resolvedPath = __resolvedPath(resolvedPath, input, "botName", function () { return input.botName; }, "{botName}", false);
42
- resolvedPath = __resolvedPath(resolvedPath, input, "botAlias", function () { return input.botAlias; }, "{botAlias}", false);
43
- resolvedPath = __resolvedPath(resolvedPath, input, "userId", function () { return input.userId; }, "{userId}", false);
44
- query = map({
45
- checkpointLabelFilter: [, input.checkpointLabelFilter],
46
- });
47
- return [2, new __HttpRequest({
48
- protocol: protocol,
49
- hostname: hostname,
50
- port: port,
51
- method: "GET",
52
- headers: headers,
53
- path: resolvedPath,
54
- query: query,
55
- body: body,
56
- })];
57
- }
58
- });
59
- }); };
60
- export var serializeAws_restJson1PostContentCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
61
- var _a, hostname, _b, protocol, port, basePath, headers, resolvedPath, body;
62
- return __generator(this, function (_c) {
63
- switch (_c.label) {
64
- case 0: return [4, context.endpoint()];
65
- case 1:
66
- _a = _c.sent(), hostname = _a.hostname, _b = _a.protocol, protocol = _b === void 0 ? "https" : _b, port = _a.port, basePath = _a.path;
67
- headers = map({}, isSerializableHeaderValue, {
68
- "x-amz-content-sha256": "UNSIGNED-PAYLOAD",
69
- "content-type": input.contentType || "application/octet-stream",
70
- "x-amz-lex-session-attributes": [
71
- function () { return isSerializableHeaderValue(input.sessionAttributes); },
72
- function () { return context.base64Encoder(Buffer.from(__LazyJsonString.fromObject(input.sessionAttributes))); },
73
- ],
74
- "x-amz-lex-request-attributes": [
75
- function () { return isSerializableHeaderValue(input.requestAttributes); },
76
- function () { return context.base64Encoder(Buffer.from(__LazyJsonString.fromObject(input.requestAttributes))); },
77
- ],
78
- accept: input.accept,
79
- "x-amz-lex-active-contexts": [
80
- function () { return isSerializableHeaderValue(input.activeContexts); },
81
- function () { return context.base64Encoder(Buffer.from(__LazyJsonString.fromObject(input.activeContexts))); },
82
- ],
83
- });
84
- resolvedPath = "".concat((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || "") +
85
- "/bot/{botName}/alias/{botAlias}/user/{userId}/content";
86
- resolvedPath = __resolvedPath(resolvedPath, input, "botName", function () { return input.botName; }, "{botName}", false);
87
- resolvedPath = __resolvedPath(resolvedPath, input, "botAlias", function () { return input.botAlias; }, "{botAlias}", false);
88
- resolvedPath = __resolvedPath(resolvedPath, input, "userId", function () { return input.userId; }, "{userId}", false);
89
- if (input.inputStream !== undefined) {
90
- body = input.inputStream;
91
- }
92
- return [2, new __HttpRequest({
93
- protocol: protocol,
94
- hostname: hostname,
95
- port: port,
96
- method: "POST",
97
- headers: headers,
98
- path: resolvedPath,
99
- body: body,
100
- })];
101
- }
102
- });
103
- }); };
104
- export var serializeAws_restJson1PostTextCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
105
- var _a, hostname, _b, protocol, port, basePath, headers, resolvedPath, body;
106
- return __generator(this, function (_c) {
107
- switch (_c.label) {
108
- case 0: return [4, context.endpoint()];
109
- case 1:
110
- _a = _c.sent(), hostname = _a.hostname, _b = _a.protocol, protocol = _b === void 0 ? "https" : _b, port = _a.port, basePath = _a.path;
111
- headers = {
112
- "content-type": "application/json",
113
- };
114
- resolvedPath = "".concat((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || "") +
115
- "/bot/{botName}/alias/{botAlias}/user/{userId}/text";
116
- resolvedPath = __resolvedPath(resolvedPath, input, "botName", function () { return input.botName; }, "{botName}", false);
117
- resolvedPath = __resolvedPath(resolvedPath, input, "botAlias", function () { return input.botAlias; }, "{botAlias}", false);
118
- resolvedPath = __resolvedPath(resolvedPath, input, "userId", function () { return input.userId; }, "{userId}", false);
119
- body = JSON.stringify(__assign(__assign(__assign(__assign({}, (input.activeContexts != null && {
120
- activeContexts: serializeAws_restJson1ActiveContextsList(input.activeContexts, context),
121
- })), (input.inputText != null && { inputText: input.inputText })), (input.requestAttributes != null && {
122
- requestAttributes: serializeAws_restJson1StringMap(input.requestAttributes, context),
123
- })), (input.sessionAttributes != null && {
124
- sessionAttributes: serializeAws_restJson1StringMap(input.sessionAttributes, context),
125
- })));
126
- return [2, new __HttpRequest({
127
- protocol: protocol,
128
- hostname: hostname,
129
- port: port,
130
- method: "POST",
131
- headers: headers,
132
- path: resolvedPath,
133
- body: body,
134
- })];
135
- }
136
- });
137
- }); };
138
- export var serializeAws_restJson1PutSessionCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
139
- var _a, hostname, _b, protocol, port, basePath, headers, resolvedPath, body;
140
- return __generator(this, function (_c) {
141
- switch (_c.label) {
142
- case 0: return [4, context.endpoint()];
143
- case 1:
144
- _a = _c.sent(), hostname = _a.hostname, _b = _a.protocol, protocol = _b === void 0 ? "https" : _b, port = _a.port, basePath = _a.path;
145
- headers = map({}, isSerializableHeaderValue, {
146
- "content-type": "application/json",
147
- accept: input.accept,
148
- });
149
- resolvedPath = "".concat((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || "") +
150
- "/bot/{botName}/alias/{botAlias}/user/{userId}/session";
151
- resolvedPath = __resolvedPath(resolvedPath, input, "botName", function () { return input.botName; }, "{botName}", false);
152
- resolvedPath = __resolvedPath(resolvedPath, input, "botAlias", function () { return input.botAlias; }, "{botAlias}", false);
153
- resolvedPath = __resolvedPath(resolvedPath, input, "userId", function () { return input.userId; }, "{userId}", false);
154
- body = JSON.stringify(__assign(__assign(__assign(__assign({}, (input.activeContexts != null && {
155
- activeContexts: serializeAws_restJson1ActiveContextsList(input.activeContexts, context),
156
- })), (input.dialogAction != null && {
157
- dialogAction: serializeAws_restJson1DialogAction(input.dialogAction, context),
158
- })), (input.recentIntentSummaryView != null && {
159
- recentIntentSummaryView: serializeAws_restJson1IntentSummaryList(input.recentIntentSummaryView, context),
160
- })), (input.sessionAttributes != null && {
161
- sessionAttributes: serializeAws_restJson1StringMap(input.sessionAttributes, context),
162
- })));
163
- return [2, new __HttpRequest({
164
- protocol: protocol,
165
- hostname: hostname,
166
- port: port,
167
- method: "POST",
168
- headers: headers,
169
- path: resolvedPath,
170
- body: body,
171
- })];
172
- }
173
- });
174
- }); };
175
- export var deserializeAws_restJson1DeleteSessionCommand = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
176
- var contents, data, _a, _b;
177
- return __generator(this, function (_c) {
178
- switch (_c.label) {
179
- case 0:
180
- if (output.statusCode !== 200 && output.statusCode >= 300) {
181
- return [2, deserializeAws_restJson1DeleteSessionCommandError(output, context)];
182
- }
183
- contents = map({
184
- $metadata: deserializeMetadata(output),
185
- });
186
- _a = __expectNonNull;
187
- _b = __expectObject;
188
- return [4, parseBody(output.body, context)];
189
- case 1:
190
- data = _a.apply(void 0, [_b.apply(void 0, [_c.sent()]), "body"]);
191
- if (data.botAlias != null) {
192
- contents.botAlias = __expectString(data.botAlias);
193
- }
194
- if (data.botName != null) {
195
- contents.botName = __expectString(data.botName);
196
- }
197
- if (data.sessionId != null) {
198
- contents.sessionId = __expectString(data.sessionId);
199
- }
200
- if (data.userId != null) {
201
- contents.userId = __expectString(data.userId);
202
- }
203
- return [2, contents];
204
- }
205
- });
206
- }); };
207
- var deserializeAws_restJson1DeleteSessionCommandError = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
208
- var parsedOutput, _a, errorCode, _b, parsedBody;
209
- var _c;
210
- return __generator(this, function (_d) {
211
- switch (_d.label) {
212
- case 0:
213
- _a = [__assign({}, output)];
214
- _c = {};
215
- return [4, parseErrorBody(output.body, context)];
216
- case 1:
217
- parsedOutput = __assign.apply(void 0, _a.concat([(_c.body = _d.sent(), _c)]));
218
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
219
- _b = errorCode;
220
- switch (_b) {
221
- case "BadRequestException": return [3, 2];
222
- case "com.amazonaws.lexruntimeservice#BadRequestException": return [3, 2];
223
- case "ConflictException": return [3, 4];
224
- case "com.amazonaws.lexruntimeservice#ConflictException": return [3, 4];
225
- case "InternalFailureException": return [3, 6];
226
- case "com.amazonaws.lexruntimeservice#InternalFailureException": return [3, 6];
227
- case "LimitExceededException": return [3, 8];
228
- case "com.amazonaws.lexruntimeservice#LimitExceededException": return [3, 8];
229
- case "NotFoundException": return [3, 10];
230
- case "com.amazonaws.lexruntimeservice#NotFoundException": return [3, 10];
231
- }
232
- return [3, 12];
233
- case 2: return [4, deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)];
234
- case 3: throw _d.sent();
235
- case 4: return [4, deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)];
236
- case 5: throw _d.sent();
237
- case 6: return [4, deserializeAws_restJson1InternalFailureExceptionResponse(parsedOutput, context)];
238
- case 7: throw _d.sent();
239
- case 8: return [4, deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)];
240
- case 9: throw _d.sent();
241
- case 10: return [4, deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)];
242
- case 11: throw _d.sent();
243
- case 12:
244
- parsedBody = parsedOutput.body;
245
- throwDefaultError({
246
- output: output,
247
- parsedBody: parsedBody,
248
- exceptionCtor: __BaseException,
249
- errorCode: errorCode,
250
- });
251
- _d.label = 13;
252
- case 13: return [2];
253
- }
5
+ export const serializeAws_restJson1DeleteSessionCommand = async (input, context) => {
6
+ const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
7
+ const headers = {};
8
+ let resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` +
9
+ "/bot/{botName}/alias/{botAlias}/user/{userId}/session";
10
+ resolvedPath = __resolvedPath(resolvedPath, input, "botName", () => input.botName, "{botName}", false);
11
+ resolvedPath = __resolvedPath(resolvedPath, input, "botAlias", () => input.botAlias, "{botAlias}", false);
12
+ resolvedPath = __resolvedPath(resolvedPath, input, "userId", () => input.userId, "{userId}", false);
13
+ let body;
14
+ return new __HttpRequest({
15
+ protocol,
16
+ hostname,
17
+ port,
18
+ method: "DELETE",
19
+ headers,
20
+ path: resolvedPath,
21
+ body,
254
22
  });
255
- }); };
256
- export var deserializeAws_restJson1GetSessionCommand = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
257
- var contents, data, _a, _b;
258
- return __generator(this, function (_c) {
259
- switch (_c.label) {
260
- case 0:
261
- if (output.statusCode !== 200 && output.statusCode >= 300) {
262
- return [2, deserializeAws_restJson1GetSessionCommandError(output, context)];
263
- }
264
- contents = map({
265
- $metadata: deserializeMetadata(output),
266
- });
267
- _a = __expectNonNull;
268
- _b = __expectObject;
269
- return [4, parseBody(output.body, context)];
270
- case 1:
271
- data = _a.apply(void 0, [_b.apply(void 0, [_c.sent()]), "body"]);
272
- if (data.activeContexts != null) {
273
- contents.activeContexts = deserializeAws_restJson1ActiveContextsList(data.activeContexts, context);
274
- }
275
- if (data.dialogAction != null) {
276
- contents.dialogAction = deserializeAws_restJson1DialogAction(data.dialogAction, context);
277
- }
278
- if (data.recentIntentSummaryView != null) {
279
- contents.recentIntentSummaryView = deserializeAws_restJson1IntentSummaryList(data.recentIntentSummaryView, context);
280
- }
281
- if (data.sessionAttributes != null) {
282
- contents.sessionAttributes = deserializeAws_restJson1StringMap(data.sessionAttributes, context);
283
- }
284
- if (data.sessionId != null) {
285
- contents.sessionId = __expectString(data.sessionId);
286
- }
287
- return [2, contents];
288
- }
23
+ };
24
+ export const serializeAws_restJson1GetSessionCommand = async (input, context) => {
25
+ const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
26
+ const headers = {};
27
+ let resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` +
28
+ "/bot/{botName}/alias/{botAlias}/user/{userId}/session";
29
+ resolvedPath = __resolvedPath(resolvedPath, input, "botName", () => input.botName, "{botName}", false);
30
+ resolvedPath = __resolvedPath(resolvedPath, input, "botAlias", () => input.botAlias, "{botAlias}", false);
31
+ resolvedPath = __resolvedPath(resolvedPath, input, "userId", () => input.userId, "{userId}", false);
32
+ const query = map({
33
+ checkpointLabelFilter: [, input.checkpointLabelFilter],
34
+ });
35
+ let body;
36
+ return new __HttpRequest({
37
+ protocol,
38
+ hostname,
39
+ port,
40
+ method: "GET",
41
+ headers,
42
+ path: resolvedPath,
43
+ query,
44
+ body,
289
45
  });
290
- }); };
291
- var deserializeAws_restJson1GetSessionCommandError = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
292
- var parsedOutput, _a, errorCode, _b, parsedBody;
293
- var _c;
294
- return __generator(this, function (_d) {
295
- switch (_d.label) {
296
- case 0:
297
- _a = [__assign({}, output)];
298
- _c = {};
299
- return [4, parseErrorBody(output.body, context)];
300
- case 1:
301
- parsedOutput = __assign.apply(void 0, _a.concat([(_c.body = _d.sent(), _c)]));
302
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
303
- _b = errorCode;
304
- switch (_b) {
305
- case "BadRequestException": return [3, 2];
306
- case "com.amazonaws.lexruntimeservice#BadRequestException": return [3, 2];
307
- case "InternalFailureException": return [3, 4];
308
- case "com.amazonaws.lexruntimeservice#InternalFailureException": return [3, 4];
309
- case "LimitExceededException": return [3, 6];
310
- case "com.amazonaws.lexruntimeservice#LimitExceededException": return [3, 6];
311
- case "NotFoundException": return [3, 8];
312
- case "com.amazonaws.lexruntimeservice#NotFoundException": return [3, 8];
313
- }
314
- return [3, 10];
315
- case 2: return [4, deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)];
316
- case 3: throw _d.sent();
317
- case 4: return [4, deserializeAws_restJson1InternalFailureExceptionResponse(parsedOutput, context)];
318
- case 5: throw _d.sent();
319
- case 6: return [4, deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)];
320
- case 7: throw _d.sent();
321
- case 8: return [4, deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)];
322
- case 9: throw _d.sent();
323
- case 10:
324
- parsedBody = parsedOutput.body;
325
- throwDefaultError({
326
- output: output,
327
- parsedBody: parsedBody,
328
- exceptionCtor: __BaseException,
329
- errorCode: errorCode,
330
- });
331
- _d.label = 11;
332
- case 11: return [2];
333
- }
46
+ };
47
+ export const serializeAws_restJson1PostContentCommand = async (input, context) => {
48
+ const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
49
+ const headers = map({}, isSerializableHeaderValue, {
50
+ "x-amz-content-sha256": "UNSIGNED-PAYLOAD",
51
+ "content-type": input.contentType || "application/octet-stream",
52
+ "x-amz-lex-session-attributes": [
53
+ () => isSerializableHeaderValue(input.sessionAttributes),
54
+ () => context.base64Encoder(Buffer.from(__LazyJsonString.fromObject(input.sessionAttributes))),
55
+ ],
56
+ "x-amz-lex-request-attributes": [
57
+ () => isSerializableHeaderValue(input.requestAttributes),
58
+ () => context.base64Encoder(Buffer.from(__LazyJsonString.fromObject(input.requestAttributes))),
59
+ ],
60
+ accept: input.accept,
61
+ "x-amz-lex-active-contexts": [
62
+ () => isSerializableHeaderValue(input.activeContexts),
63
+ () => context.base64Encoder(Buffer.from(__LazyJsonString.fromObject(input.activeContexts))),
64
+ ],
65
+ });
66
+ let resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` +
67
+ "/bot/{botName}/alias/{botAlias}/user/{userId}/content";
68
+ resolvedPath = __resolvedPath(resolvedPath, input, "botName", () => input.botName, "{botName}", false);
69
+ resolvedPath = __resolvedPath(resolvedPath, input, "botAlias", () => input.botAlias, "{botAlias}", false);
70
+ resolvedPath = __resolvedPath(resolvedPath, input, "userId", () => input.userId, "{userId}", false);
71
+ let body;
72
+ if (input.inputStream !== undefined) {
73
+ body = input.inputStream;
74
+ }
75
+ return new __HttpRequest({
76
+ protocol,
77
+ hostname,
78
+ port,
79
+ method: "POST",
80
+ headers,
81
+ path: resolvedPath,
82
+ body,
334
83
  });
335
- }); };
336
- export var deserializeAws_restJson1PostContentCommand = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
337
- var contents, data;
338
- return __generator(this, function (_a) {
339
- if (output.statusCode !== 200 && output.statusCode >= 300) {
340
- return [2, deserializeAws_restJson1PostContentCommandError(output, context)];
341
- }
342
- contents = map({
343
- $metadata: deserializeMetadata(output),
344
- contentType: [, output.headers["content-type"]],
345
- intentName: [, output.headers["x-amz-lex-intent-name"]],
346
- nluIntentConfidence: [
347
- function () { return void 0 !== output.headers["x-amz-lex-nlu-intent-confidence"]; },
348
- function () {
349
- return new __LazyJsonString(Buffer.from(context.base64Decoder(output.headers["x-amz-lex-nlu-intent-confidence"])).toString("utf8"));
350
- },
351
- ],
352
- alternativeIntents: [
353
- function () { return void 0 !== output.headers["x-amz-lex-alternative-intents"]; },
354
- function () {
355
- return new __LazyJsonString(Buffer.from(context.base64Decoder(output.headers["x-amz-lex-alternative-intents"])).toString("utf8"));
356
- },
357
- ],
358
- slots: [
359
- function () { return void 0 !== output.headers["x-amz-lex-slots"]; },
360
- function () {
361
- return new __LazyJsonString(Buffer.from(context.base64Decoder(output.headers["x-amz-lex-slots"])).toString("utf8"));
362
- },
363
- ],
364
- sessionAttributes: [
365
- function () { return void 0 !== output.headers["x-amz-lex-session-attributes"]; },
366
- function () {
367
- return new __LazyJsonString(Buffer.from(context.base64Decoder(output.headers["x-amz-lex-session-attributes"])).toString("utf8"));
368
- },
369
- ],
370
- sentimentResponse: [, output.headers["x-amz-lex-sentiment"]],
371
- message: [, output.headers["x-amz-lex-message"]],
372
- encodedMessage: [, output.headers["x-amz-lex-encoded-message"]],
373
- messageFormat: [, output.headers["x-amz-lex-message-format"]],
374
- dialogState: [, output.headers["x-amz-lex-dialog-state"]],
375
- slotToElicit: [, output.headers["x-amz-lex-slot-to-elicit"]],
376
- inputTranscript: [, output.headers["x-amz-lex-input-transcript"]],
377
- encodedInputTranscript: [, output.headers["x-amz-lex-encoded-input-transcript"]],
378
- botVersion: [, output.headers["x-amz-lex-bot-version"]],
379
- sessionId: [, output.headers["x-amz-lex-session-id"]],
380
- activeContexts: [
381
- function () { return void 0 !== output.headers["x-amz-lex-active-contexts"]; },
382
- function () {
383
- return new __LazyJsonString(Buffer.from(context.base64Decoder(output.headers["x-amz-lex-active-contexts"])).toString("utf8"));
384
- },
385
- ],
386
- });
387
- data = output.body;
388
- contents.audioStream = data;
389
- return [2, contents];
84
+ };
85
+ export const serializeAws_restJson1PostTextCommand = async (input, context) => {
86
+ const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
87
+ const headers = {
88
+ "content-type": "application/json",
89
+ };
90
+ let resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` +
91
+ "/bot/{botName}/alias/{botAlias}/user/{userId}/text";
92
+ resolvedPath = __resolvedPath(resolvedPath, input, "botName", () => input.botName, "{botName}", false);
93
+ resolvedPath = __resolvedPath(resolvedPath, input, "botAlias", () => input.botAlias, "{botAlias}", false);
94
+ resolvedPath = __resolvedPath(resolvedPath, input, "userId", () => input.userId, "{userId}", false);
95
+ let body;
96
+ body = JSON.stringify({
97
+ ...(input.activeContexts != null && {
98
+ activeContexts: serializeAws_restJson1ActiveContextsList(input.activeContexts, context),
99
+ }),
100
+ ...(input.inputText != null && { inputText: input.inputText }),
101
+ ...(input.requestAttributes != null && {
102
+ requestAttributes: serializeAws_restJson1StringMap(input.requestAttributes, context),
103
+ }),
104
+ ...(input.sessionAttributes != null && {
105
+ sessionAttributes: serializeAws_restJson1StringMap(input.sessionAttributes, context),
106
+ }),
107
+ });
108
+ return new __HttpRequest({
109
+ protocol,
110
+ hostname,
111
+ port,
112
+ method: "POST",
113
+ headers,
114
+ path: resolvedPath,
115
+ body,
390
116
  });
391
- }); };
392
- var deserializeAws_restJson1PostContentCommandError = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
393
- var parsedOutput, _a, errorCode, _b, parsedBody;
394
- var _c;
395
- return __generator(this, function (_d) {
396
- switch (_d.label) {
397
- case 0:
398
- _a = [__assign({}, output)];
399
- _c = {};
400
- return [4, parseErrorBody(output.body, context)];
401
- case 1:
402
- parsedOutput = __assign.apply(void 0, _a.concat([(_c.body = _d.sent(), _c)]));
403
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
404
- _b = errorCode;
405
- switch (_b) {
406
- case "BadGatewayException": return [3, 2];
407
- case "com.amazonaws.lexruntimeservice#BadGatewayException": return [3, 2];
408
- case "BadRequestException": return [3, 4];
409
- case "com.amazonaws.lexruntimeservice#BadRequestException": return [3, 4];
410
- case "ConflictException": return [3, 6];
411
- case "com.amazonaws.lexruntimeservice#ConflictException": return [3, 6];
412
- case "DependencyFailedException": return [3, 8];
413
- case "com.amazonaws.lexruntimeservice#DependencyFailedException": return [3, 8];
414
- case "InternalFailureException": return [3, 10];
415
- case "com.amazonaws.lexruntimeservice#InternalFailureException": return [3, 10];
416
- case "LimitExceededException": return [3, 12];
417
- case "com.amazonaws.lexruntimeservice#LimitExceededException": return [3, 12];
418
- case "LoopDetectedException": return [3, 14];
419
- case "com.amazonaws.lexruntimeservice#LoopDetectedException": return [3, 14];
420
- case "NotAcceptableException": return [3, 16];
421
- case "com.amazonaws.lexruntimeservice#NotAcceptableException": return [3, 16];
422
- case "NotFoundException": return [3, 18];
423
- case "com.amazonaws.lexruntimeservice#NotFoundException": return [3, 18];
424
- case "RequestTimeoutException": return [3, 20];
425
- case "com.amazonaws.lexruntimeservice#RequestTimeoutException": return [3, 20];
426
- case "UnsupportedMediaTypeException": return [3, 22];
427
- case "com.amazonaws.lexruntimeservice#UnsupportedMediaTypeException": return [3, 22];
428
- }
429
- return [3, 24];
430
- case 2: return [4, deserializeAws_restJson1BadGatewayExceptionResponse(parsedOutput, context)];
431
- case 3: throw _d.sent();
432
- case 4: return [4, deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)];
433
- case 5: throw _d.sent();
434
- case 6: return [4, deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)];
435
- case 7: throw _d.sent();
436
- case 8: return [4, deserializeAws_restJson1DependencyFailedExceptionResponse(parsedOutput, context)];
437
- case 9: throw _d.sent();
438
- case 10: return [4, deserializeAws_restJson1InternalFailureExceptionResponse(parsedOutput, context)];
439
- case 11: throw _d.sent();
440
- case 12: return [4, deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)];
441
- case 13: throw _d.sent();
442
- case 14: return [4, deserializeAws_restJson1LoopDetectedExceptionResponse(parsedOutput, context)];
443
- case 15: throw _d.sent();
444
- case 16: return [4, deserializeAws_restJson1NotAcceptableExceptionResponse(parsedOutput, context)];
445
- case 17: throw _d.sent();
446
- case 18: return [4, deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)];
447
- case 19: throw _d.sent();
448
- case 20: return [4, deserializeAws_restJson1RequestTimeoutExceptionResponse(parsedOutput, context)];
449
- case 21: throw _d.sent();
450
- case 22: return [4, deserializeAws_restJson1UnsupportedMediaTypeExceptionResponse(parsedOutput, context)];
451
- case 23: throw _d.sent();
452
- case 24:
453
- parsedBody = parsedOutput.body;
454
- throwDefaultError({
455
- output: output,
456
- parsedBody: parsedBody,
457
- exceptionCtor: __BaseException,
458
- errorCode: errorCode,
459
- });
460
- _d.label = 25;
461
- case 25: return [2];
462
- }
117
+ };
118
+ export const serializeAws_restJson1PutSessionCommand = async (input, context) => {
119
+ const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
120
+ const headers = map({}, isSerializableHeaderValue, {
121
+ "content-type": "application/json",
122
+ accept: input.accept,
123
+ });
124
+ let resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` +
125
+ "/bot/{botName}/alias/{botAlias}/user/{userId}/session";
126
+ resolvedPath = __resolvedPath(resolvedPath, input, "botName", () => input.botName, "{botName}", false);
127
+ resolvedPath = __resolvedPath(resolvedPath, input, "botAlias", () => input.botAlias, "{botAlias}", false);
128
+ resolvedPath = __resolvedPath(resolvedPath, input, "userId", () => input.userId, "{userId}", false);
129
+ let body;
130
+ body = JSON.stringify({
131
+ ...(input.activeContexts != null && {
132
+ activeContexts: serializeAws_restJson1ActiveContextsList(input.activeContexts, context),
133
+ }),
134
+ ...(input.dialogAction != null && {
135
+ dialogAction: serializeAws_restJson1DialogAction(input.dialogAction, context),
136
+ }),
137
+ ...(input.recentIntentSummaryView != null && {
138
+ recentIntentSummaryView: serializeAws_restJson1IntentSummaryList(input.recentIntentSummaryView, context),
139
+ }),
140
+ ...(input.sessionAttributes != null && {
141
+ sessionAttributes: serializeAws_restJson1StringMap(input.sessionAttributes, context),
142
+ }),
143
+ });
144
+ return new __HttpRequest({
145
+ protocol,
146
+ hostname,
147
+ port,
148
+ method: "POST",
149
+ headers,
150
+ path: resolvedPath,
151
+ body,
463
152
  });
464
- }); };
465
- export var deserializeAws_restJson1PostTextCommand = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
466
- var contents, data, _a, _b;
467
- return __generator(this, function (_c) {
468
- switch (_c.label) {
469
- case 0:
470
- if (output.statusCode !== 200 && output.statusCode >= 300) {
471
- return [2, deserializeAws_restJson1PostTextCommandError(output, context)];
472
- }
473
- contents = map({
474
- $metadata: deserializeMetadata(output),
475
- });
476
- _a = __expectNonNull;
477
- _b = __expectObject;
478
- return [4, parseBody(output.body, context)];
479
- case 1:
480
- data = _a.apply(void 0, [_b.apply(void 0, [_c.sent()]), "body"]);
481
- if (data.activeContexts != null) {
482
- contents.activeContexts = deserializeAws_restJson1ActiveContextsList(data.activeContexts, context);
483
- }
484
- if (data.alternativeIntents != null) {
485
- contents.alternativeIntents = deserializeAws_restJson1IntentList(data.alternativeIntents, context);
486
- }
487
- if (data.botVersion != null) {
488
- contents.botVersion = __expectString(data.botVersion);
489
- }
490
- if (data.dialogState != null) {
491
- contents.dialogState = __expectString(data.dialogState);
492
- }
493
- if (data.intentName != null) {
494
- contents.intentName = __expectString(data.intentName);
495
- }
496
- if (data.message != null) {
497
- contents.message = __expectString(data.message);
498
- }
499
- if (data.messageFormat != null) {
500
- contents.messageFormat = __expectString(data.messageFormat);
501
- }
502
- if (data.nluIntentConfidence != null) {
503
- contents.nluIntentConfidence = deserializeAws_restJson1IntentConfidence(data.nluIntentConfidence, context);
504
- }
505
- if (data.responseCard != null) {
506
- contents.responseCard = deserializeAws_restJson1ResponseCard(data.responseCard, context);
507
- }
508
- if (data.sentimentResponse != null) {
509
- contents.sentimentResponse = deserializeAws_restJson1SentimentResponse(data.sentimentResponse, context);
510
- }
511
- if (data.sessionAttributes != null) {
512
- contents.sessionAttributes = deserializeAws_restJson1StringMap(data.sessionAttributes, context);
513
- }
514
- if (data.sessionId != null) {
515
- contents.sessionId = __expectString(data.sessionId);
516
- }
517
- if (data.slotToElicit != null) {
518
- contents.slotToElicit = __expectString(data.slotToElicit);
519
- }
520
- if (data.slots != null) {
521
- contents.slots = deserializeAws_restJson1StringMap(data.slots, context);
522
- }
523
- return [2, contents];
524
- }
153
+ };
154
+ export const deserializeAws_restJson1DeleteSessionCommand = async (output, context) => {
155
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
156
+ return deserializeAws_restJson1DeleteSessionCommandError(output, context);
157
+ }
158
+ const contents = map({
159
+ $metadata: deserializeMetadata(output),
525
160
  });
526
- }); };
527
- var deserializeAws_restJson1PostTextCommandError = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
528
- var parsedOutput, _a, errorCode, _b, parsedBody;
529
- var _c;
530
- return __generator(this, function (_d) {
531
- switch (_d.label) {
532
- case 0:
533
- _a = [__assign({}, output)];
534
- _c = {};
535
- return [4, parseErrorBody(output.body, context)];
536
- case 1:
537
- parsedOutput = __assign.apply(void 0, _a.concat([(_c.body = _d.sent(), _c)]));
538
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
539
- _b = errorCode;
540
- switch (_b) {
541
- case "BadGatewayException": return [3, 2];
542
- case "com.amazonaws.lexruntimeservice#BadGatewayException": return [3, 2];
543
- case "BadRequestException": return [3, 4];
544
- case "com.amazonaws.lexruntimeservice#BadRequestException": return [3, 4];
545
- case "ConflictException": return [3, 6];
546
- case "com.amazonaws.lexruntimeservice#ConflictException": return [3, 6];
547
- case "DependencyFailedException": return [3, 8];
548
- case "com.amazonaws.lexruntimeservice#DependencyFailedException": return [3, 8];
549
- case "InternalFailureException": return [3, 10];
550
- case "com.amazonaws.lexruntimeservice#InternalFailureException": return [3, 10];
551
- case "LimitExceededException": return [3, 12];
552
- case "com.amazonaws.lexruntimeservice#LimitExceededException": return [3, 12];
553
- case "LoopDetectedException": return [3, 14];
554
- case "com.amazonaws.lexruntimeservice#LoopDetectedException": return [3, 14];
555
- case "NotFoundException": return [3, 16];
556
- case "com.amazonaws.lexruntimeservice#NotFoundException": return [3, 16];
557
- }
558
- return [3, 18];
559
- case 2: return [4, deserializeAws_restJson1BadGatewayExceptionResponse(parsedOutput, context)];
560
- case 3: throw _d.sent();
561
- case 4: return [4, deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)];
562
- case 5: throw _d.sent();
563
- case 6: return [4, deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)];
564
- case 7: throw _d.sent();
565
- case 8: return [4, deserializeAws_restJson1DependencyFailedExceptionResponse(parsedOutput, context)];
566
- case 9: throw _d.sent();
567
- case 10: return [4, deserializeAws_restJson1InternalFailureExceptionResponse(parsedOutput, context)];
568
- case 11: throw _d.sent();
569
- case 12: return [4, deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)];
570
- case 13: throw _d.sent();
571
- case 14: return [4, deserializeAws_restJson1LoopDetectedExceptionResponse(parsedOutput, context)];
572
- case 15: throw _d.sent();
573
- case 16: return [4, deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)];
574
- case 17: throw _d.sent();
575
- case 18:
576
- parsedBody = parsedOutput.body;
577
- throwDefaultError({
578
- output: output,
579
- parsedBody: parsedBody,
580
- exceptionCtor: __BaseException,
581
- errorCode: errorCode,
582
- });
583
- _d.label = 19;
584
- case 19: return [2];
585
- }
161
+ const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
162
+ if (data.botAlias != null) {
163
+ contents.botAlias = __expectString(data.botAlias);
164
+ }
165
+ if (data.botName != null) {
166
+ contents.botName = __expectString(data.botName);
167
+ }
168
+ if (data.sessionId != null) {
169
+ contents.sessionId = __expectString(data.sessionId);
170
+ }
171
+ if (data.userId != null) {
172
+ contents.userId = __expectString(data.userId);
173
+ }
174
+ return contents;
175
+ };
176
+ const deserializeAws_restJson1DeleteSessionCommandError = async (output, context) => {
177
+ const parsedOutput = {
178
+ ...output,
179
+ body: await parseErrorBody(output.body, context),
180
+ };
181
+ const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
182
+ switch (errorCode) {
183
+ case "BadRequestException":
184
+ case "com.amazonaws.lexruntimeservice#BadRequestException":
185
+ throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context);
186
+ case "ConflictException":
187
+ case "com.amazonaws.lexruntimeservice#ConflictException":
188
+ throw await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context);
189
+ case "InternalFailureException":
190
+ case "com.amazonaws.lexruntimeservice#InternalFailureException":
191
+ throw await deserializeAws_restJson1InternalFailureExceptionResponse(parsedOutput, context);
192
+ case "LimitExceededException":
193
+ case "com.amazonaws.lexruntimeservice#LimitExceededException":
194
+ throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context);
195
+ case "NotFoundException":
196
+ case "com.amazonaws.lexruntimeservice#NotFoundException":
197
+ throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context);
198
+ default:
199
+ const parsedBody = parsedOutput.body;
200
+ throwDefaultError({
201
+ output,
202
+ parsedBody,
203
+ exceptionCtor: __BaseException,
204
+ errorCode,
205
+ });
206
+ }
207
+ };
208
+ export const deserializeAws_restJson1GetSessionCommand = async (output, context) => {
209
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
210
+ return deserializeAws_restJson1GetSessionCommandError(output, context);
211
+ }
212
+ const contents = map({
213
+ $metadata: deserializeMetadata(output),
586
214
  });
587
- }); };
588
- export var deserializeAws_restJson1PutSessionCommand = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
589
- var contents, data;
590
- return __generator(this, function (_a) {
591
- if (output.statusCode !== 200 && output.statusCode >= 300) {
592
- return [2, deserializeAws_restJson1PutSessionCommandError(output, context)];
593
- }
594
- contents = map({
595
- $metadata: deserializeMetadata(output),
596
- contentType: [, output.headers["content-type"]],
597
- intentName: [, output.headers["x-amz-lex-intent-name"]],
598
- slots: [
599
- function () { return void 0 !== output.headers["x-amz-lex-slots"]; },
600
- function () {
601
- return new __LazyJsonString(Buffer.from(context.base64Decoder(output.headers["x-amz-lex-slots"])).toString("utf8"));
602
- },
603
- ],
604
- sessionAttributes: [
605
- function () { return void 0 !== output.headers["x-amz-lex-session-attributes"]; },
606
- function () {
607
- return new __LazyJsonString(Buffer.from(context.base64Decoder(output.headers["x-amz-lex-session-attributes"])).toString("utf8"));
608
- },
609
- ],
610
- message: [, output.headers["x-amz-lex-message"]],
611
- encodedMessage: [, output.headers["x-amz-lex-encoded-message"]],
612
- messageFormat: [, output.headers["x-amz-lex-message-format"]],
613
- dialogState: [, output.headers["x-amz-lex-dialog-state"]],
614
- slotToElicit: [, output.headers["x-amz-lex-slot-to-elicit"]],
615
- sessionId: [, output.headers["x-amz-lex-session-id"]],
616
- activeContexts: [
617
- function () { return void 0 !== output.headers["x-amz-lex-active-contexts"]; },
618
- function () {
619
- return new __LazyJsonString(Buffer.from(context.base64Decoder(output.headers["x-amz-lex-active-contexts"])).toString("utf8"));
620
- },
621
- ],
622
- });
623
- data = output.body;
624
- contents.audioStream = data;
625
- return [2, contents];
215
+ const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
216
+ if (data.activeContexts != null) {
217
+ contents.activeContexts = deserializeAws_restJson1ActiveContextsList(data.activeContexts, context);
218
+ }
219
+ if (data.dialogAction != null) {
220
+ contents.dialogAction = deserializeAws_restJson1DialogAction(data.dialogAction, context);
221
+ }
222
+ if (data.recentIntentSummaryView != null) {
223
+ contents.recentIntentSummaryView = deserializeAws_restJson1IntentSummaryList(data.recentIntentSummaryView, context);
224
+ }
225
+ if (data.sessionAttributes != null) {
226
+ contents.sessionAttributes = deserializeAws_restJson1StringMap(data.sessionAttributes, context);
227
+ }
228
+ if (data.sessionId != null) {
229
+ contents.sessionId = __expectString(data.sessionId);
230
+ }
231
+ return contents;
232
+ };
233
+ const deserializeAws_restJson1GetSessionCommandError = async (output, context) => {
234
+ const parsedOutput = {
235
+ ...output,
236
+ body: await parseErrorBody(output.body, context),
237
+ };
238
+ const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
239
+ switch (errorCode) {
240
+ case "BadRequestException":
241
+ case "com.amazonaws.lexruntimeservice#BadRequestException":
242
+ throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context);
243
+ case "InternalFailureException":
244
+ case "com.amazonaws.lexruntimeservice#InternalFailureException":
245
+ throw await deserializeAws_restJson1InternalFailureExceptionResponse(parsedOutput, context);
246
+ case "LimitExceededException":
247
+ case "com.amazonaws.lexruntimeservice#LimitExceededException":
248
+ throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context);
249
+ case "NotFoundException":
250
+ case "com.amazonaws.lexruntimeservice#NotFoundException":
251
+ throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context);
252
+ default:
253
+ const parsedBody = parsedOutput.body;
254
+ throwDefaultError({
255
+ output,
256
+ parsedBody,
257
+ exceptionCtor: __BaseException,
258
+ errorCode,
259
+ });
260
+ }
261
+ };
262
+ export const deserializeAws_restJson1PostContentCommand = async (output, context) => {
263
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
264
+ return deserializeAws_restJson1PostContentCommandError(output, context);
265
+ }
266
+ const contents = map({
267
+ $metadata: deserializeMetadata(output),
268
+ contentType: [, output.headers["content-type"]],
269
+ intentName: [, output.headers["x-amz-lex-intent-name"]],
270
+ nluIntentConfidence: [
271
+ () => void 0 !== output.headers["x-amz-lex-nlu-intent-confidence"],
272
+ () => new __LazyJsonString(Buffer.from(context.base64Decoder(output.headers["x-amz-lex-nlu-intent-confidence"])).toString("utf8")),
273
+ ],
274
+ alternativeIntents: [
275
+ () => void 0 !== output.headers["x-amz-lex-alternative-intents"],
276
+ () => new __LazyJsonString(Buffer.from(context.base64Decoder(output.headers["x-amz-lex-alternative-intents"])).toString("utf8")),
277
+ ],
278
+ slots: [
279
+ () => void 0 !== output.headers["x-amz-lex-slots"],
280
+ () => new __LazyJsonString(Buffer.from(context.base64Decoder(output.headers["x-amz-lex-slots"])).toString("utf8")),
281
+ ],
282
+ sessionAttributes: [
283
+ () => void 0 !== output.headers["x-amz-lex-session-attributes"],
284
+ () => new __LazyJsonString(Buffer.from(context.base64Decoder(output.headers["x-amz-lex-session-attributes"])).toString("utf8")),
285
+ ],
286
+ sentimentResponse: [, output.headers["x-amz-lex-sentiment"]],
287
+ message: [, output.headers["x-amz-lex-message"]],
288
+ encodedMessage: [, output.headers["x-amz-lex-encoded-message"]],
289
+ messageFormat: [, output.headers["x-amz-lex-message-format"]],
290
+ dialogState: [, output.headers["x-amz-lex-dialog-state"]],
291
+ slotToElicit: [, output.headers["x-amz-lex-slot-to-elicit"]],
292
+ inputTranscript: [, output.headers["x-amz-lex-input-transcript"]],
293
+ encodedInputTranscript: [, output.headers["x-amz-lex-encoded-input-transcript"]],
294
+ botVersion: [, output.headers["x-amz-lex-bot-version"]],
295
+ sessionId: [, output.headers["x-amz-lex-session-id"]],
296
+ activeContexts: [
297
+ () => void 0 !== output.headers["x-amz-lex-active-contexts"],
298
+ () => new __LazyJsonString(Buffer.from(context.base64Decoder(output.headers["x-amz-lex-active-contexts"])).toString("utf8")),
299
+ ],
300
+ });
301
+ const data = output.body;
302
+ contents.audioStream = data;
303
+ return contents;
304
+ };
305
+ const deserializeAws_restJson1PostContentCommandError = async (output, context) => {
306
+ const parsedOutput = {
307
+ ...output,
308
+ body: await parseErrorBody(output.body, context),
309
+ };
310
+ const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
311
+ switch (errorCode) {
312
+ case "BadGatewayException":
313
+ case "com.amazonaws.lexruntimeservice#BadGatewayException":
314
+ throw await deserializeAws_restJson1BadGatewayExceptionResponse(parsedOutput, context);
315
+ case "BadRequestException":
316
+ case "com.amazonaws.lexruntimeservice#BadRequestException":
317
+ throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context);
318
+ case "ConflictException":
319
+ case "com.amazonaws.lexruntimeservice#ConflictException":
320
+ throw await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context);
321
+ case "DependencyFailedException":
322
+ case "com.amazonaws.lexruntimeservice#DependencyFailedException":
323
+ throw await deserializeAws_restJson1DependencyFailedExceptionResponse(parsedOutput, context);
324
+ case "InternalFailureException":
325
+ case "com.amazonaws.lexruntimeservice#InternalFailureException":
326
+ throw await deserializeAws_restJson1InternalFailureExceptionResponse(parsedOutput, context);
327
+ case "LimitExceededException":
328
+ case "com.amazonaws.lexruntimeservice#LimitExceededException":
329
+ throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context);
330
+ case "LoopDetectedException":
331
+ case "com.amazonaws.lexruntimeservice#LoopDetectedException":
332
+ throw await deserializeAws_restJson1LoopDetectedExceptionResponse(parsedOutput, context);
333
+ case "NotAcceptableException":
334
+ case "com.amazonaws.lexruntimeservice#NotAcceptableException":
335
+ throw await deserializeAws_restJson1NotAcceptableExceptionResponse(parsedOutput, context);
336
+ case "NotFoundException":
337
+ case "com.amazonaws.lexruntimeservice#NotFoundException":
338
+ throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context);
339
+ case "RequestTimeoutException":
340
+ case "com.amazonaws.lexruntimeservice#RequestTimeoutException":
341
+ throw await deserializeAws_restJson1RequestTimeoutExceptionResponse(parsedOutput, context);
342
+ case "UnsupportedMediaTypeException":
343
+ case "com.amazonaws.lexruntimeservice#UnsupportedMediaTypeException":
344
+ throw await deserializeAws_restJson1UnsupportedMediaTypeExceptionResponse(parsedOutput, context);
345
+ default:
346
+ const parsedBody = parsedOutput.body;
347
+ throwDefaultError({
348
+ output,
349
+ parsedBody,
350
+ exceptionCtor: __BaseException,
351
+ errorCode,
352
+ });
353
+ }
354
+ };
355
+ export const deserializeAws_restJson1PostTextCommand = async (output, context) => {
356
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
357
+ return deserializeAws_restJson1PostTextCommandError(output, context);
358
+ }
359
+ const contents = map({
360
+ $metadata: deserializeMetadata(output),
626
361
  });
627
- }); };
628
- var deserializeAws_restJson1PutSessionCommandError = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
629
- var parsedOutput, _a, errorCode, _b, parsedBody;
630
- var _c;
631
- return __generator(this, function (_d) {
632
- switch (_d.label) {
633
- case 0:
634
- _a = [__assign({}, output)];
635
- _c = {};
636
- return [4, parseErrorBody(output.body, context)];
637
- case 1:
638
- parsedOutput = __assign.apply(void 0, _a.concat([(_c.body = _d.sent(), _c)]));
639
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
640
- _b = errorCode;
641
- switch (_b) {
642
- case "BadGatewayException": return [3, 2];
643
- case "com.amazonaws.lexruntimeservice#BadGatewayException": return [3, 2];
644
- case "BadRequestException": return [3, 4];
645
- case "com.amazonaws.lexruntimeservice#BadRequestException": return [3, 4];
646
- case "ConflictException": return [3, 6];
647
- case "com.amazonaws.lexruntimeservice#ConflictException": return [3, 6];
648
- case "DependencyFailedException": return [3, 8];
649
- case "com.amazonaws.lexruntimeservice#DependencyFailedException": return [3, 8];
650
- case "InternalFailureException": return [3, 10];
651
- case "com.amazonaws.lexruntimeservice#InternalFailureException": return [3, 10];
652
- case "LimitExceededException": return [3, 12];
653
- case "com.amazonaws.lexruntimeservice#LimitExceededException": return [3, 12];
654
- case "NotAcceptableException": return [3, 14];
655
- case "com.amazonaws.lexruntimeservice#NotAcceptableException": return [3, 14];
656
- case "NotFoundException": return [3, 16];
657
- case "com.amazonaws.lexruntimeservice#NotFoundException": return [3, 16];
658
- }
659
- return [3, 18];
660
- case 2: return [4, deserializeAws_restJson1BadGatewayExceptionResponse(parsedOutput, context)];
661
- case 3: throw _d.sent();
662
- case 4: return [4, deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)];
663
- case 5: throw _d.sent();
664
- case 6: return [4, deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)];
665
- case 7: throw _d.sent();
666
- case 8: return [4, deserializeAws_restJson1DependencyFailedExceptionResponse(parsedOutput, context)];
667
- case 9: throw _d.sent();
668
- case 10: return [4, deserializeAws_restJson1InternalFailureExceptionResponse(parsedOutput, context)];
669
- case 11: throw _d.sent();
670
- case 12: return [4, deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)];
671
- case 13: throw _d.sent();
672
- case 14: return [4, deserializeAws_restJson1NotAcceptableExceptionResponse(parsedOutput, context)];
673
- case 15: throw _d.sent();
674
- case 16: return [4, deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)];
675
- case 17: throw _d.sent();
676
- case 18:
677
- parsedBody = parsedOutput.body;
678
- throwDefaultError({
679
- output: output,
680
- parsedBody: parsedBody,
681
- exceptionCtor: __BaseException,
682
- errorCode: errorCode,
683
- });
684
- _d.label = 19;
685
- case 19: return [2];
686
- }
362
+ const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
363
+ if (data.activeContexts != null) {
364
+ contents.activeContexts = deserializeAws_restJson1ActiveContextsList(data.activeContexts, context);
365
+ }
366
+ if (data.alternativeIntents != null) {
367
+ contents.alternativeIntents = deserializeAws_restJson1IntentList(data.alternativeIntents, context);
368
+ }
369
+ if (data.botVersion != null) {
370
+ contents.botVersion = __expectString(data.botVersion);
371
+ }
372
+ if (data.dialogState != null) {
373
+ contents.dialogState = __expectString(data.dialogState);
374
+ }
375
+ if (data.intentName != null) {
376
+ contents.intentName = __expectString(data.intentName);
377
+ }
378
+ if (data.message != null) {
379
+ contents.message = __expectString(data.message);
380
+ }
381
+ if (data.messageFormat != null) {
382
+ contents.messageFormat = __expectString(data.messageFormat);
383
+ }
384
+ if (data.nluIntentConfidence != null) {
385
+ contents.nluIntentConfidence = deserializeAws_restJson1IntentConfidence(data.nluIntentConfidence, context);
386
+ }
387
+ if (data.responseCard != null) {
388
+ contents.responseCard = deserializeAws_restJson1ResponseCard(data.responseCard, context);
389
+ }
390
+ if (data.sentimentResponse != null) {
391
+ contents.sentimentResponse = deserializeAws_restJson1SentimentResponse(data.sentimentResponse, context);
392
+ }
393
+ if (data.sessionAttributes != null) {
394
+ contents.sessionAttributes = deserializeAws_restJson1StringMap(data.sessionAttributes, context);
395
+ }
396
+ if (data.sessionId != null) {
397
+ contents.sessionId = __expectString(data.sessionId);
398
+ }
399
+ if (data.slotToElicit != null) {
400
+ contents.slotToElicit = __expectString(data.slotToElicit);
401
+ }
402
+ if (data.slots != null) {
403
+ contents.slots = deserializeAws_restJson1StringMap(data.slots, context);
404
+ }
405
+ return contents;
406
+ };
407
+ const deserializeAws_restJson1PostTextCommandError = async (output, context) => {
408
+ const parsedOutput = {
409
+ ...output,
410
+ body: await parseErrorBody(output.body, context),
411
+ };
412
+ const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
413
+ switch (errorCode) {
414
+ case "BadGatewayException":
415
+ case "com.amazonaws.lexruntimeservice#BadGatewayException":
416
+ throw await deserializeAws_restJson1BadGatewayExceptionResponse(parsedOutput, context);
417
+ case "BadRequestException":
418
+ case "com.amazonaws.lexruntimeservice#BadRequestException":
419
+ throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context);
420
+ case "ConflictException":
421
+ case "com.amazonaws.lexruntimeservice#ConflictException":
422
+ throw await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context);
423
+ case "DependencyFailedException":
424
+ case "com.amazonaws.lexruntimeservice#DependencyFailedException":
425
+ throw await deserializeAws_restJson1DependencyFailedExceptionResponse(parsedOutput, context);
426
+ case "InternalFailureException":
427
+ case "com.amazonaws.lexruntimeservice#InternalFailureException":
428
+ throw await deserializeAws_restJson1InternalFailureExceptionResponse(parsedOutput, context);
429
+ case "LimitExceededException":
430
+ case "com.amazonaws.lexruntimeservice#LimitExceededException":
431
+ throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context);
432
+ case "LoopDetectedException":
433
+ case "com.amazonaws.lexruntimeservice#LoopDetectedException":
434
+ throw await deserializeAws_restJson1LoopDetectedExceptionResponse(parsedOutput, context);
435
+ case "NotFoundException":
436
+ case "com.amazonaws.lexruntimeservice#NotFoundException":
437
+ throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context);
438
+ default:
439
+ const parsedBody = parsedOutput.body;
440
+ throwDefaultError({
441
+ output,
442
+ parsedBody,
443
+ exceptionCtor: __BaseException,
444
+ errorCode,
445
+ });
446
+ }
447
+ };
448
+ export const deserializeAws_restJson1PutSessionCommand = async (output, context) => {
449
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
450
+ return deserializeAws_restJson1PutSessionCommandError(output, context);
451
+ }
452
+ const contents = map({
453
+ $metadata: deserializeMetadata(output),
454
+ contentType: [, output.headers["content-type"]],
455
+ intentName: [, output.headers["x-amz-lex-intent-name"]],
456
+ slots: [
457
+ () => void 0 !== output.headers["x-amz-lex-slots"],
458
+ () => new __LazyJsonString(Buffer.from(context.base64Decoder(output.headers["x-amz-lex-slots"])).toString("utf8")),
459
+ ],
460
+ sessionAttributes: [
461
+ () => void 0 !== output.headers["x-amz-lex-session-attributes"],
462
+ () => new __LazyJsonString(Buffer.from(context.base64Decoder(output.headers["x-amz-lex-session-attributes"])).toString("utf8")),
463
+ ],
464
+ message: [, output.headers["x-amz-lex-message"]],
465
+ encodedMessage: [, output.headers["x-amz-lex-encoded-message"]],
466
+ messageFormat: [, output.headers["x-amz-lex-message-format"]],
467
+ dialogState: [, output.headers["x-amz-lex-dialog-state"]],
468
+ slotToElicit: [, output.headers["x-amz-lex-slot-to-elicit"]],
469
+ sessionId: [, output.headers["x-amz-lex-session-id"]],
470
+ activeContexts: [
471
+ () => void 0 !== output.headers["x-amz-lex-active-contexts"],
472
+ () => new __LazyJsonString(Buffer.from(context.base64Decoder(output.headers["x-amz-lex-active-contexts"])).toString("utf8")),
473
+ ],
474
+ });
475
+ const data = output.body;
476
+ contents.audioStream = data;
477
+ return contents;
478
+ };
479
+ const deserializeAws_restJson1PutSessionCommandError = async (output, context) => {
480
+ const parsedOutput = {
481
+ ...output,
482
+ body: await parseErrorBody(output.body, context),
483
+ };
484
+ const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
485
+ switch (errorCode) {
486
+ case "BadGatewayException":
487
+ case "com.amazonaws.lexruntimeservice#BadGatewayException":
488
+ throw await deserializeAws_restJson1BadGatewayExceptionResponse(parsedOutput, context);
489
+ case "BadRequestException":
490
+ case "com.amazonaws.lexruntimeservice#BadRequestException":
491
+ throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context);
492
+ case "ConflictException":
493
+ case "com.amazonaws.lexruntimeservice#ConflictException":
494
+ throw await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context);
495
+ case "DependencyFailedException":
496
+ case "com.amazonaws.lexruntimeservice#DependencyFailedException":
497
+ throw await deserializeAws_restJson1DependencyFailedExceptionResponse(parsedOutput, context);
498
+ case "InternalFailureException":
499
+ case "com.amazonaws.lexruntimeservice#InternalFailureException":
500
+ throw await deserializeAws_restJson1InternalFailureExceptionResponse(parsedOutput, context);
501
+ case "LimitExceededException":
502
+ case "com.amazonaws.lexruntimeservice#LimitExceededException":
503
+ throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context);
504
+ case "NotAcceptableException":
505
+ case "com.amazonaws.lexruntimeservice#NotAcceptableException":
506
+ throw await deserializeAws_restJson1NotAcceptableExceptionResponse(parsedOutput, context);
507
+ case "NotFoundException":
508
+ case "com.amazonaws.lexruntimeservice#NotFoundException":
509
+ throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context);
510
+ default:
511
+ const parsedBody = parsedOutput.body;
512
+ throwDefaultError({
513
+ output,
514
+ parsedBody,
515
+ exceptionCtor: __BaseException,
516
+ errorCode,
517
+ });
518
+ }
519
+ };
520
+ const map = __map;
521
+ const deserializeAws_restJson1BadGatewayExceptionResponse = async (parsedOutput, context) => {
522
+ const contents = map({});
523
+ const data = parsedOutput.body;
524
+ if (data.Message != null) {
525
+ contents.Message = __expectString(data.Message);
526
+ }
527
+ const exception = new BadGatewayException({
528
+ $metadata: deserializeMetadata(parsedOutput),
529
+ ...contents,
687
530
  });
688
- }); };
689
- var map = __map;
690
- var deserializeAws_restJson1BadGatewayExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
691
- var contents, data, exception;
692
- return __generator(this, function (_a) {
693
- contents = map({});
694
- data = parsedOutput.body;
695
- if (data.Message != null) {
696
- contents.Message = __expectString(data.Message);
697
- }
698
- exception = new BadGatewayException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
699
- return [2, __decorateServiceException(exception, parsedOutput.body)];
531
+ return __decorateServiceException(exception, parsedOutput.body);
532
+ };
533
+ const deserializeAws_restJson1BadRequestExceptionResponse = async (parsedOutput, context) => {
534
+ const contents = map({});
535
+ const data = parsedOutput.body;
536
+ if (data.message != null) {
537
+ contents.message = __expectString(data.message);
538
+ }
539
+ const exception = new BadRequestException({
540
+ $metadata: deserializeMetadata(parsedOutput),
541
+ ...contents,
700
542
  });
701
- }); };
702
- var deserializeAws_restJson1BadRequestExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
703
- var contents, data, exception;
704
- return __generator(this, function (_a) {
705
- contents = map({});
706
- data = parsedOutput.body;
707
- if (data.message != null) {
708
- contents.message = __expectString(data.message);
709
- }
710
- exception = new BadRequestException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
711
- return [2, __decorateServiceException(exception, parsedOutput.body)];
543
+ return __decorateServiceException(exception, parsedOutput.body);
544
+ };
545
+ const deserializeAws_restJson1ConflictExceptionResponse = async (parsedOutput, context) => {
546
+ const contents = map({});
547
+ const data = parsedOutput.body;
548
+ if (data.message != null) {
549
+ contents.message = __expectString(data.message);
550
+ }
551
+ const exception = new ConflictException({
552
+ $metadata: deserializeMetadata(parsedOutput),
553
+ ...contents,
712
554
  });
713
- }); };
714
- var deserializeAws_restJson1ConflictExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
715
- var contents, data, exception;
716
- return __generator(this, function (_a) {
717
- contents = map({});
718
- data = parsedOutput.body;
719
- if (data.message != null) {
720
- contents.message = __expectString(data.message);
721
- }
722
- exception = new ConflictException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
723
- return [2, __decorateServiceException(exception, parsedOutput.body)];
555
+ return __decorateServiceException(exception, parsedOutput.body);
556
+ };
557
+ const deserializeAws_restJson1DependencyFailedExceptionResponse = async (parsedOutput, context) => {
558
+ const contents = map({});
559
+ const data = parsedOutput.body;
560
+ if (data.Message != null) {
561
+ contents.Message = __expectString(data.Message);
562
+ }
563
+ const exception = new DependencyFailedException({
564
+ $metadata: deserializeMetadata(parsedOutput),
565
+ ...contents,
724
566
  });
725
- }); };
726
- var deserializeAws_restJson1DependencyFailedExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
727
- var contents, data, exception;
728
- return __generator(this, function (_a) {
729
- contents = map({});
730
- data = parsedOutput.body;
731
- if (data.Message != null) {
732
- contents.Message = __expectString(data.Message);
733
- }
734
- exception = new DependencyFailedException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
735
- return [2, __decorateServiceException(exception, parsedOutput.body)];
567
+ return __decorateServiceException(exception, parsedOutput.body);
568
+ };
569
+ const deserializeAws_restJson1InternalFailureExceptionResponse = async (parsedOutput, context) => {
570
+ const contents = map({});
571
+ const data = parsedOutput.body;
572
+ if (data.message != null) {
573
+ contents.message = __expectString(data.message);
574
+ }
575
+ const exception = new InternalFailureException({
576
+ $metadata: deserializeMetadata(parsedOutput),
577
+ ...contents,
736
578
  });
737
- }); };
738
- var deserializeAws_restJson1InternalFailureExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
739
- var contents, data, exception;
740
- return __generator(this, function (_a) {
741
- contents = map({});
742
- data = parsedOutput.body;
743
- if (data.message != null) {
744
- contents.message = __expectString(data.message);
745
- }
746
- exception = new InternalFailureException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
747
- return [2, __decorateServiceException(exception, parsedOutput.body)];
579
+ return __decorateServiceException(exception, parsedOutput.body);
580
+ };
581
+ const deserializeAws_restJson1LimitExceededExceptionResponse = async (parsedOutput, context) => {
582
+ const contents = map({
583
+ retryAfterSeconds: [, parsedOutput.headers["retry-after"]],
748
584
  });
749
- }); };
750
- var deserializeAws_restJson1LimitExceededExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
751
- var contents, data, exception;
752
- return __generator(this, function (_a) {
753
- contents = map({
754
- retryAfterSeconds: [, parsedOutput.headers["retry-after"]],
755
- });
756
- data = parsedOutput.body;
757
- if (data.message != null) {
758
- contents.message = __expectString(data.message);
759
- }
760
- exception = new LimitExceededException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
761
- return [2, __decorateServiceException(exception, parsedOutput.body)];
585
+ const data = parsedOutput.body;
586
+ if (data.message != null) {
587
+ contents.message = __expectString(data.message);
588
+ }
589
+ const exception = new LimitExceededException({
590
+ $metadata: deserializeMetadata(parsedOutput),
591
+ ...contents,
762
592
  });
763
- }); };
764
- var deserializeAws_restJson1LoopDetectedExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
765
- var contents, data, exception;
766
- return __generator(this, function (_a) {
767
- contents = map({});
768
- data = parsedOutput.body;
769
- if (data.Message != null) {
770
- contents.Message = __expectString(data.Message);
771
- }
772
- exception = new LoopDetectedException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
773
- return [2, __decorateServiceException(exception, parsedOutput.body)];
593
+ return __decorateServiceException(exception, parsedOutput.body);
594
+ };
595
+ const deserializeAws_restJson1LoopDetectedExceptionResponse = async (parsedOutput, context) => {
596
+ const contents = map({});
597
+ const data = parsedOutput.body;
598
+ if (data.Message != null) {
599
+ contents.Message = __expectString(data.Message);
600
+ }
601
+ const exception = new LoopDetectedException({
602
+ $metadata: deserializeMetadata(parsedOutput),
603
+ ...contents,
774
604
  });
775
- }); };
776
- var deserializeAws_restJson1NotAcceptableExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
777
- var contents, data, exception;
778
- return __generator(this, function (_a) {
779
- contents = map({});
780
- data = parsedOutput.body;
781
- if (data.message != null) {
782
- contents.message = __expectString(data.message);
783
- }
784
- exception = new NotAcceptableException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
785
- return [2, __decorateServiceException(exception, parsedOutput.body)];
605
+ return __decorateServiceException(exception, parsedOutput.body);
606
+ };
607
+ const deserializeAws_restJson1NotAcceptableExceptionResponse = async (parsedOutput, context) => {
608
+ const contents = map({});
609
+ const data = parsedOutput.body;
610
+ if (data.message != null) {
611
+ contents.message = __expectString(data.message);
612
+ }
613
+ const exception = new NotAcceptableException({
614
+ $metadata: deserializeMetadata(parsedOutput),
615
+ ...contents,
786
616
  });
787
- }); };
788
- var deserializeAws_restJson1NotFoundExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
789
- var contents, data, exception;
790
- return __generator(this, function (_a) {
791
- contents = map({});
792
- data = parsedOutput.body;
793
- if (data.message != null) {
794
- contents.message = __expectString(data.message);
795
- }
796
- exception = new NotFoundException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
797
- return [2, __decorateServiceException(exception, parsedOutput.body)];
617
+ return __decorateServiceException(exception, parsedOutput.body);
618
+ };
619
+ const deserializeAws_restJson1NotFoundExceptionResponse = async (parsedOutput, context) => {
620
+ const contents = map({});
621
+ const data = parsedOutput.body;
622
+ if (data.message != null) {
623
+ contents.message = __expectString(data.message);
624
+ }
625
+ const exception = new NotFoundException({
626
+ $metadata: deserializeMetadata(parsedOutput),
627
+ ...contents,
798
628
  });
799
- }); };
800
- var deserializeAws_restJson1RequestTimeoutExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
801
- var contents, data, exception;
802
- return __generator(this, function (_a) {
803
- contents = map({});
804
- data = parsedOutput.body;
805
- if (data.message != null) {
806
- contents.message = __expectString(data.message);
807
- }
808
- exception = new RequestTimeoutException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
809
- return [2, __decorateServiceException(exception, parsedOutput.body)];
629
+ return __decorateServiceException(exception, parsedOutput.body);
630
+ };
631
+ const deserializeAws_restJson1RequestTimeoutExceptionResponse = async (parsedOutput, context) => {
632
+ const contents = map({});
633
+ const data = parsedOutput.body;
634
+ if (data.message != null) {
635
+ contents.message = __expectString(data.message);
636
+ }
637
+ const exception = new RequestTimeoutException({
638
+ $metadata: deserializeMetadata(parsedOutput),
639
+ ...contents,
810
640
  });
811
- }); };
812
- var deserializeAws_restJson1UnsupportedMediaTypeExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
813
- var contents, data, exception;
814
- return __generator(this, function (_a) {
815
- contents = map({});
816
- data = parsedOutput.body;
817
- if (data.message != null) {
818
- contents.message = __expectString(data.message);
819
- }
820
- exception = new UnsupportedMediaTypeException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
821
- return [2, __decorateServiceException(exception, parsedOutput.body)];
641
+ return __decorateServiceException(exception, parsedOutput.body);
642
+ };
643
+ const deserializeAws_restJson1UnsupportedMediaTypeExceptionResponse = async (parsedOutput, context) => {
644
+ const contents = map({});
645
+ const data = parsedOutput.body;
646
+ if (data.message != null) {
647
+ contents.message = __expectString(data.message);
648
+ }
649
+ const exception = new UnsupportedMediaTypeException({
650
+ $metadata: deserializeMetadata(parsedOutput),
651
+ ...contents,
822
652
  });
823
- }); };
824
- var serializeAws_restJson1ActiveContext = function (input, context) {
825
- return __assign(__assign(__assign({}, (input.name != null && { name: input.name })), (input.parameters != null && {
826
- parameters: serializeAws_restJson1ActiveContextParametersMap(input.parameters, context),
827
- })), (input.timeToLive != null && {
828
- timeToLive: serializeAws_restJson1ActiveContextTimeToLive(input.timeToLive, context),
829
- }));
653
+ return __decorateServiceException(exception, parsedOutput.body);
654
+ };
655
+ const serializeAws_restJson1ActiveContext = (input, context) => {
656
+ return {
657
+ ...(input.name != null && { name: input.name }),
658
+ ...(input.parameters != null && {
659
+ parameters: serializeAws_restJson1ActiveContextParametersMap(input.parameters, context),
660
+ }),
661
+ ...(input.timeToLive != null && {
662
+ timeToLive: serializeAws_restJson1ActiveContextTimeToLive(input.timeToLive, context),
663
+ }),
664
+ };
830
665
  };
831
- var serializeAws_restJson1ActiveContextParametersMap = function (input, context) {
832
- return Object.entries(input).reduce(function (acc, _a) {
833
- var _b;
834
- var _c = __read(_a, 2), key = _c[0], value = _c[1];
666
+ const serializeAws_restJson1ActiveContextParametersMap = (input, context) => {
667
+ return Object.entries(input).reduce((acc, [key, value]) => {
835
668
  if (value === null) {
836
669
  return acc;
837
670
  }
838
- return __assign(__assign({}, acc), (_b = {}, _b[key] = value, _b));
671
+ return {
672
+ ...acc,
673
+ [key]: value,
674
+ };
839
675
  }, {});
840
676
  };
841
- var serializeAws_restJson1ActiveContextsList = function (input, context) {
677
+ const serializeAws_restJson1ActiveContextsList = (input, context) => {
842
678
  return input
843
- .filter(function (e) { return e != null; })
844
- .map(function (entry) {
679
+ .filter((e) => e != null)
680
+ .map((entry) => {
845
681
  return serializeAws_restJson1ActiveContext(entry, context);
846
682
  });
847
683
  };
848
- var serializeAws_restJson1ActiveContextTimeToLive = function (input, context) {
849
- return __assign(__assign({}, (input.timeToLiveInSeconds != null && { timeToLiveInSeconds: input.timeToLiveInSeconds })), (input.turnsToLive != null && { turnsToLive: input.turnsToLive }));
684
+ const serializeAws_restJson1ActiveContextTimeToLive = (input, context) => {
685
+ return {
686
+ ...(input.timeToLiveInSeconds != null && { timeToLiveInSeconds: input.timeToLiveInSeconds }),
687
+ ...(input.turnsToLive != null && { turnsToLive: input.turnsToLive }),
688
+ };
850
689
  };
851
- var serializeAws_restJson1DialogAction = function (input, context) {
852
- return __assign(__assign(__assign(__assign(__assign(__assign(__assign({}, (input.fulfillmentState != null && { fulfillmentState: input.fulfillmentState })), (input.intentName != null && { intentName: input.intentName })), (input.message != null && { message: input.message })), (input.messageFormat != null && { messageFormat: input.messageFormat })), (input.slotToElicit != null && { slotToElicit: input.slotToElicit })), (input.slots != null && { slots: serializeAws_restJson1StringMap(input.slots, context) })), (input.type != null && { type: input.type }));
690
+ const serializeAws_restJson1DialogAction = (input, context) => {
691
+ return {
692
+ ...(input.fulfillmentState != null && { fulfillmentState: input.fulfillmentState }),
693
+ ...(input.intentName != null && { intentName: input.intentName }),
694
+ ...(input.message != null && { message: input.message }),
695
+ ...(input.messageFormat != null && { messageFormat: input.messageFormat }),
696
+ ...(input.slotToElicit != null && { slotToElicit: input.slotToElicit }),
697
+ ...(input.slots != null && { slots: serializeAws_restJson1StringMap(input.slots, context) }),
698
+ ...(input.type != null && { type: input.type }),
699
+ };
853
700
  };
854
- var serializeAws_restJson1IntentSummary = function (input, context) {
855
- return __assign(__assign(__assign(__assign(__assign(__assign(__assign({}, (input.checkpointLabel != null && { checkpointLabel: input.checkpointLabel })), (input.confirmationStatus != null && { confirmationStatus: input.confirmationStatus })), (input.dialogActionType != null && { dialogActionType: input.dialogActionType })), (input.fulfillmentState != null && { fulfillmentState: input.fulfillmentState })), (input.intentName != null && { intentName: input.intentName })), (input.slotToElicit != null && { slotToElicit: input.slotToElicit })), (input.slots != null && { slots: serializeAws_restJson1StringMap(input.slots, context) }));
701
+ const serializeAws_restJson1IntentSummary = (input, context) => {
702
+ return {
703
+ ...(input.checkpointLabel != null && { checkpointLabel: input.checkpointLabel }),
704
+ ...(input.confirmationStatus != null && { confirmationStatus: input.confirmationStatus }),
705
+ ...(input.dialogActionType != null && { dialogActionType: input.dialogActionType }),
706
+ ...(input.fulfillmentState != null && { fulfillmentState: input.fulfillmentState }),
707
+ ...(input.intentName != null && { intentName: input.intentName }),
708
+ ...(input.slotToElicit != null && { slotToElicit: input.slotToElicit }),
709
+ ...(input.slots != null && { slots: serializeAws_restJson1StringMap(input.slots, context) }),
710
+ };
856
711
  };
857
- var serializeAws_restJson1IntentSummaryList = function (input, context) {
712
+ const serializeAws_restJson1IntentSummaryList = (input, context) => {
858
713
  return input
859
- .filter(function (e) { return e != null; })
860
- .map(function (entry) {
714
+ .filter((e) => e != null)
715
+ .map((entry) => {
861
716
  return serializeAws_restJson1IntentSummary(entry, context);
862
717
  });
863
718
  };
864
- var serializeAws_restJson1StringMap = function (input, context) {
865
- return Object.entries(input).reduce(function (acc, _a) {
866
- var _b;
867
- var _c = __read(_a, 2), key = _c[0], value = _c[1];
719
+ const serializeAws_restJson1StringMap = (input, context) => {
720
+ return Object.entries(input).reduce((acc, [key, value]) => {
868
721
  if (value === null) {
869
722
  return acc;
870
723
  }
871
- return __assign(__assign({}, acc), (_b = {}, _b[key] = value, _b));
724
+ return {
725
+ ...acc,
726
+ [key]: value,
727
+ };
872
728
  }, {});
873
729
  };
874
- var deserializeAws_restJson1ActiveContext = function (output, context) {
730
+ const deserializeAws_restJson1ActiveContext = (output, context) => {
875
731
  return {
876
732
  name: __expectString(output.name),
877
733
  parameters: output.parameters != null
@@ -882,20 +738,21 @@ var deserializeAws_restJson1ActiveContext = function (output, context) {
882
738
  : undefined,
883
739
  };
884
740
  };
885
- var deserializeAws_restJson1ActiveContextParametersMap = function (output, context) {
886
- return Object.entries(output).reduce(function (acc, _a) {
887
- var _b;
888
- var _c = __read(_a, 2), key = _c[0], value = _c[1];
741
+ const deserializeAws_restJson1ActiveContextParametersMap = (output, context) => {
742
+ return Object.entries(output).reduce((acc, [key, value]) => {
889
743
  if (value === null) {
890
744
  return acc;
891
745
  }
892
- return __assign(__assign({}, acc), (_b = {}, _b[key] = __expectString(value), _b));
746
+ return {
747
+ ...acc,
748
+ [key]: __expectString(value),
749
+ };
893
750
  }, {});
894
751
  };
895
- var deserializeAws_restJson1ActiveContextsList = function (output, context) {
896
- var retVal = (output || [])
897
- .filter(function (e) { return e != null; })
898
- .map(function (entry) {
752
+ const deserializeAws_restJson1ActiveContextsList = (output, context) => {
753
+ const retVal = (output || [])
754
+ .filter((e) => e != null)
755
+ .map((entry) => {
899
756
  if (entry === null) {
900
757
  return null;
901
758
  }
@@ -903,19 +760,19 @@ var deserializeAws_restJson1ActiveContextsList = function (output, context) {
903
760
  });
904
761
  return retVal;
905
762
  };
906
- var deserializeAws_restJson1ActiveContextTimeToLive = function (output, context) {
763
+ const deserializeAws_restJson1ActiveContextTimeToLive = (output, context) => {
907
764
  return {
908
765
  timeToLiveInSeconds: __expectInt32(output.timeToLiveInSeconds),
909
766
  turnsToLive: __expectInt32(output.turnsToLive),
910
767
  };
911
768
  };
912
- var deserializeAws_restJson1Button = function (output, context) {
769
+ const deserializeAws_restJson1Button = (output, context) => {
913
770
  return {
914
771
  text: __expectString(output.text),
915
772
  value: __expectString(output.value),
916
773
  };
917
774
  };
918
- var deserializeAws_restJson1DialogAction = function (output, context) {
775
+ const deserializeAws_restJson1DialogAction = (output, context) => {
919
776
  return {
920
777
  fulfillmentState: __expectString(output.fulfillmentState),
921
778
  intentName: __expectString(output.intentName),
@@ -926,7 +783,7 @@ var deserializeAws_restJson1DialogAction = function (output, context) {
926
783
  type: __expectString(output.type),
927
784
  };
928
785
  };
929
- var deserializeAws_restJson1GenericAttachment = function (output, context) {
786
+ const deserializeAws_restJson1GenericAttachment = (output, context) => {
930
787
  return {
931
788
  attachmentLinkUrl: __expectString(output.attachmentLinkUrl),
932
789
  buttons: output.buttons != null ? deserializeAws_restJson1listOfButtons(output.buttons, context) : undefined,
@@ -935,10 +792,10 @@ var deserializeAws_restJson1GenericAttachment = function (output, context) {
935
792
  title: __expectString(output.title),
936
793
  };
937
794
  };
938
- var deserializeAws_restJson1genericAttachmentList = function (output, context) {
939
- var retVal = (output || [])
940
- .filter(function (e) { return e != null; })
941
- .map(function (entry) {
795
+ const deserializeAws_restJson1genericAttachmentList = (output, context) => {
796
+ const retVal = (output || [])
797
+ .filter((e) => e != null)
798
+ .map((entry) => {
942
799
  if (entry === null) {
943
800
  return null;
944
801
  }
@@ -946,15 +803,15 @@ var deserializeAws_restJson1genericAttachmentList = function (output, context) {
946
803
  });
947
804
  return retVal;
948
805
  };
949
- var deserializeAws_restJson1IntentConfidence = function (output, context) {
806
+ const deserializeAws_restJson1IntentConfidence = (output, context) => {
950
807
  return {
951
808
  score: __limitedParseDouble(output.score),
952
809
  };
953
810
  };
954
- var deserializeAws_restJson1IntentList = function (output, context) {
955
- var retVal = (output || [])
956
- .filter(function (e) { return e != null; })
957
- .map(function (entry) {
811
+ const deserializeAws_restJson1IntentList = (output, context) => {
812
+ const retVal = (output || [])
813
+ .filter((e) => e != null)
814
+ .map((entry) => {
958
815
  if (entry === null) {
959
816
  return null;
960
817
  }
@@ -962,7 +819,7 @@ var deserializeAws_restJson1IntentList = function (output, context) {
962
819
  });
963
820
  return retVal;
964
821
  };
965
- var deserializeAws_restJson1IntentSummary = function (output, context) {
822
+ const deserializeAws_restJson1IntentSummary = (output, context) => {
966
823
  return {
967
824
  checkpointLabel: __expectString(output.checkpointLabel),
968
825
  confirmationStatus: __expectString(output.confirmationStatus),
@@ -973,10 +830,10 @@ var deserializeAws_restJson1IntentSummary = function (output, context) {
973
830
  slots: output.slots != null ? deserializeAws_restJson1StringMap(output.slots, context) : undefined,
974
831
  };
975
832
  };
976
- var deserializeAws_restJson1IntentSummaryList = function (output, context) {
977
- var retVal = (output || [])
978
- .filter(function (e) { return e != null; })
979
- .map(function (entry) {
833
+ const deserializeAws_restJson1IntentSummaryList = (output, context) => {
834
+ const retVal = (output || [])
835
+ .filter((e) => e != null)
836
+ .map((entry) => {
980
837
  if (entry === null) {
981
838
  return null;
982
839
  }
@@ -984,10 +841,10 @@ var deserializeAws_restJson1IntentSummaryList = function (output, context) {
984
841
  });
985
842
  return retVal;
986
843
  };
987
- var deserializeAws_restJson1listOfButtons = function (output, context) {
988
- var retVal = (output || [])
989
- .filter(function (e) { return e != null; })
990
- .map(function (entry) {
844
+ const deserializeAws_restJson1listOfButtons = (output, context) => {
845
+ const retVal = (output || [])
846
+ .filter((e) => e != null)
847
+ .map((entry) => {
991
848
  if (entry === null) {
992
849
  return null;
993
850
  }
@@ -995,7 +852,7 @@ var deserializeAws_restJson1listOfButtons = function (output, context) {
995
852
  });
996
853
  return retVal;
997
854
  };
998
- var deserializeAws_restJson1PredictedIntent = function (output, context) {
855
+ const deserializeAws_restJson1PredictedIntent = (output, context) => {
999
856
  return {
1000
857
  intentName: __expectString(output.intentName),
1001
858
  nluIntentConfidence: output.nluIntentConfidence != null
@@ -1004,7 +861,7 @@ var deserializeAws_restJson1PredictedIntent = function (output, context) {
1004
861
  slots: output.slots != null ? deserializeAws_restJson1StringMap(output.slots, context) : undefined,
1005
862
  };
1006
863
  };
1007
- var deserializeAws_restJson1ResponseCard = function (output, context) {
864
+ const deserializeAws_restJson1ResponseCard = (output, context) => {
1008
865
  return {
1009
866
  contentType: __expectString(output.contentType),
1010
867
  genericAttachments: output.genericAttachments != null
@@ -1013,73 +870,56 @@ var deserializeAws_restJson1ResponseCard = function (output, context) {
1013
870
  version: __expectString(output.version),
1014
871
  };
1015
872
  };
1016
- var deserializeAws_restJson1SentimentResponse = function (output, context) {
873
+ const deserializeAws_restJson1SentimentResponse = (output, context) => {
1017
874
  return {
1018
875
  sentimentLabel: __expectString(output.sentimentLabel),
1019
876
  sentimentScore: __expectString(output.sentimentScore),
1020
877
  };
1021
878
  };
1022
- var deserializeAws_restJson1StringMap = function (output, context) {
1023
- return Object.entries(output).reduce(function (acc, _a) {
1024
- var _b;
1025
- var _c = __read(_a, 2), key = _c[0], value = _c[1];
879
+ const deserializeAws_restJson1StringMap = (output, context) => {
880
+ return Object.entries(output).reduce((acc, [key, value]) => {
1026
881
  if (value === null) {
1027
882
  return acc;
1028
883
  }
1029
- return __assign(__assign({}, acc), (_b = {}, _b[key] = __expectString(value), _b));
884
+ return {
885
+ ...acc,
886
+ [key]: __expectString(value),
887
+ };
1030
888
  }, {});
1031
889
  };
1032
- var deserializeMetadata = function (output) {
1033
- var _a;
1034
- return ({
1035
- httpStatusCode: output.statusCode,
1036
- requestId: (_a = output.headers["x-amzn-requestid"]) !== null && _a !== void 0 ? _a : output.headers["x-amzn-request-id"],
1037
- extendedRequestId: output.headers["x-amz-id-2"],
1038
- cfId: output.headers["x-amz-cf-id"],
1039
- });
1040
- };
1041
- var collectBody = function (streamBody, context) {
1042
- if (streamBody === void 0) { streamBody = new Uint8Array(); }
890
+ const deserializeMetadata = (output) => ({
891
+ httpStatusCode: output.statusCode,
892
+ requestId: output.headers["x-amzn-requestid"] ?? output.headers["x-amzn-request-id"],
893
+ extendedRequestId: output.headers["x-amz-id-2"],
894
+ cfId: output.headers["x-amz-cf-id"],
895
+ });
896
+ const collectBody = (streamBody = new Uint8Array(), context) => {
1043
897
  if (streamBody instanceof Uint8Array) {
1044
898
  return Promise.resolve(streamBody);
1045
899
  }
1046
900
  return context.streamCollector(streamBody) || Promise.resolve(new Uint8Array());
1047
901
  };
1048
- var collectBodyString = function (streamBody, context) {
1049
- return collectBody(streamBody, context).then(function (body) { return context.utf8Encoder(body); });
1050
- };
1051
- var isSerializableHeaderValue = function (value) {
1052
- return value !== undefined &&
1053
- value !== null &&
1054
- value !== "" &&
1055
- (!Object.getOwnPropertyNames(value).includes("length") || value.length != 0) &&
1056
- (!Object.getOwnPropertyNames(value).includes("size") || value.size != 0);
1057
- };
1058
- var parseBody = function (streamBody, context) {
1059
- return collectBodyString(streamBody, context).then(function (encoded) {
1060
- if (encoded.length) {
1061
- return JSON.parse(encoded);
1062
- }
1063
- return {};
1064
- });
902
+ const collectBodyString = (streamBody, context) => collectBody(streamBody, context).then((body) => context.utf8Encoder(body));
903
+ const isSerializableHeaderValue = (value) => value !== undefined &&
904
+ value !== null &&
905
+ value !== "" &&
906
+ (!Object.getOwnPropertyNames(value).includes("length") || value.length != 0) &&
907
+ (!Object.getOwnPropertyNames(value).includes("size") || value.size != 0);
908
+ const parseBody = (streamBody, context) => collectBodyString(streamBody, context).then((encoded) => {
909
+ if (encoded.length) {
910
+ return JSON.parse(encoded);
911
+ }
912
+ return {};
913
+ });
914
+ const parseErrorBody = async (errorBody, context) => {
915
+ const value = await parseBody(errorBody, context);
916
+ value.message = value.message ?? value.Message;
917
+ return value;
1065
918
  };
1066
- var parseErrorBody = function (errorBody, context) { return __awaiter(void 0, void 0, void 0, function () {
1067
- var value;
1068
- var _a;
1069
- return __generator(this, function (_b) {
1070
- switch (_b.label) {
1071
- case 0: return [4, parseBody(errorBody, context)];
1072
- case 1:
1073
- value = _b.sent();
1074
- value.message = (_a = value.message) !== null && _a !== void 0 ? _a : value.Message;
1075
- return [2, value];
1076
- }
1077
- });
1078
- }); };
1079
- var loadRestJsonErrorCode = function (output, data) {
1080
- var findKey = function (object, key) { return Object.keys(object).find(function (k) { return k.toLowerCase() === key.toLowerCase(); }); };
1081
- var sanitizeErrorCode = function (rawValue) {
1082
- var cleanValue = rawValue;
919
+ const loadRestJsonErrorCode = (output, data) => {
920
+ const findKey = (object, key) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase());
921
+ const sanitizeErrorCode = (rawValue) => {
922
+ let cleanValue = rawValue;
1083
923
  if (typeof cleanValue === "number") {
1084
924
  cleanValue = cleanValue.toString();
1085
925
  }
@@ -1094,7 +934,7 @@ var loadRestJsonErrorCode = function (output, data) {
1094
934
  }
1095
935
  return cleanValue;
1096
936
  };
1097
- var headerKey = findKey(output.headers, "x-amzn-errortype");
937
+ const headerKey = findKey(output.headers, "x-amzn-errortype");
1098
938
  if (headerKey !== undefined) {
1099
939
  return sanitizeErrorCode(output.headers[headerKey]);
1100
940
  }