@aws-sdk/client-lex-runtime-service 3.490.0 → 3.495.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,695 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.de_PutSessionCommand = exports.de_PostTextCommand = exports.de_PostContentCommand = exports.de_GetSessionCommand = exports.de_DeleteSessionCommand = exports.se_PutSessionCommand = exports.se_PostTextCommand = exports.se_PostContentCommand = exports.se_GetSessionCommand = exports.se_DeleteSessionCommand = void 0;
4
- const core_1 = require("@smithy/core");
5
- const smithy_client_1 = require("@smithy/smithy-client");
6
- const LexRuntimeServiceServiceException_1 = require("../models/LexRuntimeServiceServiceException");
7
- const models_0_1 = require("../models/models_0");
8
- const se_DeleteSessionCommand = async (input, context) => {
9
- const b = (0, core_1.requestBuilder)(input, context);
10
- const headers = {};
11
- b.bp("/bot/{botName}/alias/{botAlias}/user/{userId}/session");
12
- b.p("botName", () => input.botName, "{botName}", false);
13
- b.p("botAlias", () => input.botAlias, "{botAlias}", false);
14
- b.p("userId", () => input.userId, "{userId}", false);
15
- let body;
16
- b.m("DELETE").h(headers).b(body);
17
- return b.build();
18
- };
19
- exports.se_DeleteSessionCommand = se_DeleteSessionCommand;
20
- const se_GetSessionCommand = async (input, context) => {
21
- const b = (0, core_1.requestBuilder)(input, context);
22
- const headers = {};
23
- b.bp("/bot/{botName}/alias/{botAlias}/user/{userId}/session");
24
- b.p("botName", () => input.botName, "{botName}", false);
25
- b.p("botAlias", () => input.botAlias, "{botAlias}", false);
26
- b.p("userId", () => input.userId, "{userId}", false);
27
- const query = (0, smithy_client_1.map)({
28
- [_cLF]: [, input[_cLF]],
29
- });
30
- let body;
31
- b.m("GET").h(headers).q(query).b(body);
32
- return b.build();
33
- };
34
- exports.se_GetSessionCommand = se_GetSessionCommand;
35
- const se_PostContentCommand = async (input, context) => {
36
- const b = (0, core_1.requestBuilder)(input, context);
37
- const headers = (0, smithy_client_1.map)({}, isSerializableHeaderValue, {
38
- "x-amz-content-sha256": "UNSIGNED-PAYLOAD",
39
- [_ct]: input[_cT] || "application/octet-stream",
40
- [_xalsa]: [
41
- () => isSerializableHeaderValue(input[_sA]),
42
- () => context.base64Encoder(Buffer.from(smithy_client_1.LazyJsonString.fromObject(input[_sA]))),
43
- ],
44
- [_xalra]: [
45
- () => isSerializableHeaderValue(input[_rA]),
46
- () => context.base64Encoder(Buffer.from(smithy_client_1.LazyJsonString.fromObject(input[_rA]))),
47
- ],
48
- [_a]: input[_a],
49
- [_xalac]: [
50
- () => isSerializableHeaderValue(input[_aC]),
51
- () => context.base64Encoder(Buffer.from(smithy_client_1.LazyJsonString.fromObject(input[_aC]))),
52
- ],
53
- });
54
- b.bp("/bot/{botName}/alias/{botAlias}/user/{userId}/content");
55
- b.p("botName", () => input.botName, "{botName}", false);
56
- b.p("botAlias", () => input.botAlias, "{botAlias}", false);
57
- b.p("userId", () => input.userId, "{userId}", false);
58
- let body;
59
- if (input.inputStream !== undefined) {
60
- body = input.inputStream;
61
- }
62
- b.m("POST").h(headers).b(body);
63
- return b.build();
64
- };
65
- exports.se_PostContentCommand = se_PostContentCommand;
66
- const se_PostTextCommand = async (input, context) => {
67
- const b = (0, core_1.requestBuilder)(input, context);
68
- const headers = {
69
- "content-type": "application/json",
70
- };
71
- b.bp("/bot/{botName}/alias/{botAlias}/user/{userId}/text");
72
- b.p("botName", () => input.botName, "{botName}", false);
73
- b.p("botAlias", () => input.botAlias, "{botAlias}", false);
74
- b.p("userId", () => input.userId, "{userId}", false);
75
- let body;
76
- body = JSON.stringify((0, smithy_client_1.take)(input, {
77
- activeContexts: (_) => (0, smithy_client_1._json)(_),
78
- inputText: [],
79
- requestAttributes: (_) => (0, smithy_client_1._json)(_),
80
- sessionAttributes: (_) => (0, smithy_client_1._json)(_),
81
- }));
82
- b.m("POST").h(headers).b(body);
83
- return b.build();
84
- };
85
- exports.se_PostTextCommand = se_PostTextCommand;
86
- const se_PutSessionCommand = async (input, context) => {
87
- const b = (0, core_1.requestBuilder)(input, context);
88
- const headers = (0, smithy_client_1.map)({}, isSerializableHeaderValue, {
89
- "content-type": "application/json",
90
- [_a]: input[_a],
91
- });
92
- b.bp("/bot/{botName}/alias/{botAlias}/user/{userId}/session");
93
- b.p("botName", () => input.botName, "{botName}", false);
94
- b.p("botAlias", () => input.botAlias, "{botAlias}", false);
95
- b.p("userId", () => input.userId, "{userId}", false);
96
- let body;
97
- body = JSON.stringify((0, smithy_client_1.take)(input, {
98
- activeContexts: (_) => (0, smithy_client_1._json)(_),
99
- dialogAction: (_) => (0, smithy_client_1._json)(_),
100
- recentIntentSummaryView: (_) => (0, smithy_client_1._json)(_),
101
- sessionAttributes: (_) => (0, smithy_client_1._json)(_),
102
- }));
103
- b.m("POST").h(headers).b(body);
104
- return b.build();
105
- };
106
- exports.se_PutSessionCommand = se_PutSessionCommand;
107
- const de_DeleteSessionCommand = async (output, context) => {
108
- if (output.statusCode !== 200 && output.statusCode >= 300) {
109
- return de_DeleteSessionCommandError(output, context);
110
- }
111
- const contents = (0, smithy_client_1.map)({
112
- $metadata: deserializeMetadata(output),
113
- });
114
- const data = (0, smithy_client_1.expectNonNull)((0, smithy_client_1.expectObject)(await parseBody(output.body, context)), "body");
115
- const doc = (0, smithy_client_1.take)(data, {
116
- botAlias: smithy_client_1.expectString,
117
- botName: smithy_client_1.expectString,
118
- sessionId: smithy_client_1.expectString,
119
- userId: smithy_client_1.expectString,
120
- });
121
- Object.assign(contents, doc);
122
- return contents;
123
- };
124
- exports.de_DeleteSessionCommand = de_DeleteSessionCommand;
125
- const de_DeleteSessionCommandError = async (output, context) => {
126
- const parsedOutput = {
127
- ...output,
128
- body: await parseErrorBody(output.body, context),
129
- };
130
- const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
131
- switch (errorCode) {
132
- case "BadRequestException":
133
- case "com.amazonaws.lexruntimeservice#BadRequestException":
134
- throw await de_BadRequestExceptionRes(parsedOutput, context);
135
- case "ConflictException":
136
- case "com.amazonaws.lexruntimeservice#ConflictException":
137
- throw await de_ConflictExceptionRes(parsedOutput, context);
138
- case "InternalFailureException":
139
- case "com.amazonaws.lexruntimeservice#InternalFailureException":
140
- throw await de_InternalFailureExceptionRes(parsedOutput, context);
141
- case "LimitExceededException":
142
- case "com.amazonaws.lexruntimeservice#LimitExceededException":
143
- throw await de_LimitExceededExceptionRes(parsedOutput, context);
144
- case "NotFoundException":
145
- case "com.amazonaws.lexruntimeservice#NotFoundException":
146
- throw await de_NotFoundExceptionRes(parsedOutput, context);
147
- default:
148
- const parsedBody = parsedOutput.body;
149
- return throwDefaultError({
150
- output,
151
- parsedBody,
152
- errorCode,
153
- });
154
- }
155
- };
156
- const de_GetSessionCommand = async (output, context) => {
157
- if (output.statusCode !== 200 && output.statusCode >= 300) {
158
- return de_GetSessionCommandError(output, context);
159
- }
160
- const contents = (0, smithy_client_1.map)({
161
- $metadata: deserializeMetadata(output),
162
- });
163
- const data = (0, smithy_client_1.expectNonNull)((0, smithy_client_1.expectObject)(await parseBody(output.body, context)), "body");
164
- const doc = (0, smithy_client_1.take)(data, {
165
- activeContexts: smithy_client_1._json,
166
- dialogAction: smithy_client_1._json,
167
- recentIntentSummaryView: smithy_client_1._json,
168
- sessionAttributes: smithy_client_1._json,
169
- sessionId: smithy_client_1.expectString,
170
- });
171
- Object.assign(contents, doc);
172
- return contents;
173
- };
174
- exports.de_GetSessionCommand = de_GetSessionCommand;
175
- const de_GetSessionCommandError = async (output, context) => {
176
- const parsedOutput = {
177
- ...output,
178
- body: await parseErrorBody(output.body, context),
179
- };
180
- const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
181
- switch (errorCode) {
182
- case "BadRequestException":
183
- case "com.amazonaws.lexruntimeservice#BadRequestException":
184
- throw await de_BadRequestExceptionRes(parsedOutput, context);
185
- case "InternalFailureException":
186
- case "com.amazonaws.lexruntimeservice#InternalFailureException":
187
- throw await de_InternalFailureExceptionRes(parsedOutput, context);
188
- case "LimitExceededException":
189
- case "com.amazonaws.lexruntimeservice#LimitExceededException":
190
- throw await de_LimitExceededExceptionRes(parsedOutput, context);
191
- case "NotFoundException":
192
- case "com.amazonaws.lexruntimeservice#NotFoundException":
193
- throw await de_NotFoundExceptionRes(parsedOutput, context);
194
- default:
195
- const parsedBody = parsedOutput.body;
196
- return throwDefaultError({
197
- output,
198
- parsedBody,
199
- errorCode,
200
- });
201
- }
202
- };
203
- const de_PostContentCommand = async (output, context) => {
204
- if (output.statusCode !== 200 && output.statusCode >= 300) {
205
- return de_PostContentCommandError(output, context);
206
- }
207
- const contents = (0, smithy_client_1.map)({
208
- $metadata: deserializeMetadata(output),
209
- [_cT]: [, output.headers[_ct]],
210
- [_iN]: [, output.headers[_xalin]],
211
- [_nIC]: [
212
- () => void 0 !== output.headers[_xalnic],
213
- () => new smithy_client_1.LazyJsonString(Buffer.from(context.base64Decoder(output.headers[_xalnic])).toString("utf8")),
214
- ],
215
- [_aI]: [
216
- () => void 0 !== output.headers[_xalai],
217
- () => new smithy_client_1.LazyJsonString(Buffer.from(context.base64Decoder(output.headers[_xalai])).toString("utf8")),
218
- ],
219
- [_s]: [
220
- () => void 0 !== output.headers[_xals],
221
- () => new smithy_client_1.LazyJsonString(Buffer.from(context.base64Decoder(output.headers[_xals])).toString("utf8")),
222
- ],
223
- [_sA]: [
224
- () => void 0 !== output.headers[_xalsa],
225
- () => new smithy_client_1.LazyJsonString(Buffer.from(context.base64Decoder(output.headers[_xalsa])).toString("utf8")),
226
- ],
227
- [_sR]: [, output.headers[_xals_]],
228
- [_m]: [, output.headers[_xalm]],
229
- [_eM]: [, output.headers[_xalem]],
230
- [_mF]: [, output.headers[_xalmf]],
231
- [_dS]: [, output.headers[_xalds]],
232
- [_sTE]: [, output.headers[_xalste]],
233
- [_iT]: [, output.headers[_xalit]],
234
- [_eIT]: [, output.headers[_xaleit]],
235
- [_bV]: [, output.headers[_xalbv]],
236
- [_sI]: [, output.headers[_xalsi]],
237
- [_aC]: [
238
- () => void 0 !== output.headers[_xalac],
239
- () => new smithy_client_1.LazyJsonString(Buffer.from(context.base64Decoder(output.headers[_xalac])).toString("utf8")),
240
- ],
241
- });
242
- const data = output.body;
243
- context.sdkStreamMixin(data);
244
- contents.audioStream = data;
245
- return contents;
246
- };
247
- exports.de_PostContentCommand = de_PostContentCommand;
248
- const de_PostContentCommandError = async (output, context) => {
249
- const parsedOutput = {
250
- ...output,
251
- body: await parseErrorBody(output.body, context),
252
- };
253
- const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
254
- switch (errorCode) {
255
- case "BadGatewayException":
256
- case "com.amazonaws.lexruntimeservice#BadGatewayException":
257
- throw await de_BadGatewayExceptionRes(parsedOutput, context);
258
- case "BadRequestException":
259
- case "com.amazonaws.lexruntimeservice#BadRequestException":
260
- throw await de_BadRequestExceptionRes(parsedOutput, context);
261
- case "ConflictException":
262
- case "com.amazonaws.lexruntimeservice#ConflictException":
263
- throw await de_ConflictExceptionRes(parsedOutput, context);
264
- case "DependencyFailedException":
265
- case "com.amazonaws.lexruntimeservice#DependencyFailedException":
266
- throw await de_DependencyFailedExceptionRes(parsedOutput, context);
267
- case "InternalFailureException":
268
- case "com.amazonaws.lexruntimeservice#InternalFailureException":
269
- throw await de_InternalFailureExceptionRes(parsedOutput, context);
270
- case "LimitExceededException":
271
- case "com.amazonaws.lexruntimeservice#LimitExceededException":
272
- throw await de_LimitExceededExceptionRes(parsedOutput, context);
273
- case "LoopDetectedException":
274
- case "com.amazonaws.lexruntimeservice#LoopDetectedException":
275
- throw await de_LoopDetectedExceptionRes(parsedOutput, context);
276
- case "NotAcceptableException":
277
- case "com.amazonaws.lexruntimeservice#NotAcceptableException":
278
- throw await de_NotAcceptableExceptionRes(parsedOutput, context);
279
- case "NotFoundException":
280
- case "com.amazonaws.lexruntimeservice#NotFoundException":
281
- throw await de_NotFoundExceptionRes(parsedOutput, context);
282
- case "RequestTimeoutException":
283
- case "com.amazonaws.lexruntimeservice#RequestTimeoutException":
284
- throw await de_RequestTimeoutExceptionRes(parsedOutput, context);
285
- case "UnsupportedMediaTypeException":
286
- case "com.amazonaws.lexruntimeservice#UnsupportedMediaTypeException":
287
- throw await de_UnsupportedMediaTypeExceptionRes(parsedOutput, context);
288
- default:
289
- const parsedBody = parsedOutput.body;
290
- return throwDefaultError({
291
- output,
292
- parsedBody,
293
- errorCode,
294
- });
295
- }
296
- };
297
- const de_PostTextCommand = async (output, context) => {
298
- if (output.statusCode !== 200 && output.statusCode >= 300) {
299
- return de_PostTextCommandError(output, context);
300
- }
301
- const contents = (0, smithy_client_1.map)({
302
- $metadata: deserializeMetadata(output),
303
- });
304
- const data = (0, smithy_client_1.expectNonNull)((0, smithy_client_1.expectObject)(await parseBody(output.body, context)), "body");
305
- const doc = (0, smithy_client_1.take)(data, {
306
- activeContexts: smithy_client_1._json,
307
- alternativeIntents: (_) => de_IntentList(_, context),
308
- botVersion: smithy_client_1.expectString,
309
- dialogState: smithy_client_1.expectString,
310
- intentName: smithy_client_1.expectString,
311
- message: smithy_client_1.expectString,
312
- messageFormat: smithy_client_1.expectString,
313
- nluIntentConfidence: (_) => de_IntentConfidence(_, context),
314
- responseCard: smithy_client_1._json,
315
- sentimentResponse: smithy_client_1._json,
316
- sessionAttributes: smithy_client_1._json,
317
- sessionId: smithy_client_1.expectString,
318
- slotToElicit: smithy_client_1.expectString,
319
- slots: smithy_client_1._json,
320
- });
321
- Object.assign(contents, doc);
322
- return contents;
323
- };
324
- exports.de_PostTextCommand = de_PostTextCommand;
325
- const de_PostTextCommandError = async (output, context) => {
326
- const parsedOutput = {
327
- ...output,
328
- body: await parseErrorBody(output.body, context),
329
- };
330
- const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
331
- switch (errorCode) {
332
- case "BadGatewayException":
333
- case "com.amazonaws.lexruntimeservice#BadGatewayException":
334
- throw await de_BadGatewayExceptionRes(parsedOutput, context);
335
- case "BadRequestException":
336
- case "com.amazonaws.lexruntimeservice#BadRequestException":
337
- throw await de_BadRequestExceptionRes(parsedOutput, context);
338
- case "ConflictException":
339
- case "com.amazonaws.lexruntimeservice#ConflictException":
340
- throw await de_ConflictExceptionRes(parsedOutput, context);
341
- case "DependencyFailedException":
342
- case "com.amazonaws.lexruntimeservice#DependencyFailedException":
343
- throw await de_DependencyFailedExceptionRes(parsedOutput, context);
344
- case "InternalFailureException":
345
- case "com.amazonaws.lexruntimeservice#InternalFailureException":
346
- throw await de_InternalFailureExceptionRes(parsedOutput, context);
347
- case "LimitExceededException":
348
- case "com.amazonaws.lexruntimeservice#LimitExceededException":
349
- throw await de_LimitExceededExceptionRes(parsedOutput, context);
350
- case "LoopDetectedException":
351
- case "com.amazonaws.lexruntimeservice#LoopDetectedException":
352
- throw await de_LoopDetectedExceptionRes(parsedOutput, context);
353
- case "NotFoundException":
354
- case "com.amazonaws.lexruntimeservice#NotFoundException":
355
- throw await de_NotFoundExceptionRes(parsedOutput, context);
356
- default:
357
- const parsedBody = parsedOutput.body;
358
- return throwDefaultError({
359
- output,
360
- parsedBody,
361
- errorCode,
362
- });
363
- }
364
- };
365
- const de_PutSessionCommand = async (output, context) => {
366
- if (output.statusCode !== 200 && output.statusCode >= 300) {
367
- return de_PutSessionCommandError(output, context);
368
- }
369
- const contents = (0, smithy_client_1.map)({
370
- $metadata: deserializeMetadata(output),
371
- [_cT]: [, output.headers[_ct]],
372
- [_iN]: [, output.headers[_xalin]],
373
- [_s]: [
374
- () => void 0 !== output.headers[_xals],
375
- () => new smithy_client_1.LazyJsonString(Buffer.from(context.base64Decoder(output.headers[_xals])).toString("utf8")),
376
- ],
377
- [_sA]: [
378
- () => void 0 !== output.headers[_xalsa],
379
- () => new smithy_client_1.LazyJsonString(Buffer.from(context.base64Decoder(output.headers[_xalsa])).toString("utf8")),
380
- ],
381
- [_m]: [, output.headers[_xalm]],
382
- [_eM]: [, output.headers[_xalem]],
383
- [_mF]: [, output.headers[_xalmf]],
384
- [_dS]: [, output.headers[_xalds]],
385
- [_sTE]: [, output.headers[_xalste]],
386
- [_sI]: [, output.headers[_xalsi]],
387
- [_aC]: [
388
- () => void 0 !== output.headers[_xalac],
389
- () => new smithy_client_1.LazyJsonString(Buffer.from(context.base64Decoder(output.headers[_xalac])).toString("utf8")),
390
- ],
391
- });
392
- const data = output.body;
393
- context.sdkStreamMixin(data);
394
- contents.audioStream = data;
395
- return contents;
396
- };
397
- exports.de_PutSessionCommand = de_PutSessionCommand;
398
- const de_PutSessionCommandError = async (output, context) => {
399
- const parsedOutput = {
400
- ...output,
401
- body: await parseErrorBody(output.body, context),
402
- };
403
- const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
404
- switch (errorCode) {
405
- case "BadGatewayException":
406
- case "com.amazonaws.lexruntimeservice#BadGatewayException":
407
- throw await de_BadGatewayExceptionRes(parsedOutput, context);
408
- case "BadRequestException":
409
- case "com.amazonaws.lexruntimeservice#BadRequestException":
410
- throw await de_BadRequestExceptionRes(parsedOutput, context);
411
- case "ConflictException":
412
- case "com.amazonaws.lexruntimeservice#ConflictException":
413
- throw await de_ConflictExceptionRes(parsedOutput, context);
414
- case "DependencyFailedException":
415
- case "com.amazonaws.lexruntimeservice#DependencyFailedException":
416
- throw await de_DependencyFailedExceptionRes(parsedOutput, context);
417
- case "InternalFailureException":
418
- case "com.amazonaws.lexruntimeservice#InternalFailureException":
419
- throw await de_InternalFailureExceptionRes(parsedOutput, context);
420
- case "LimitExceededException":
421
- case "com.amazonaws.lexruntimeservice#LimitExceededException":
422
- throw await de_LimitExceededExceptionRes(parsedOutput, context);
423
- case "NotAcceptableException":
424
- case "com.amazonaws.lexruntimeservice#NotAcceptableException":
425
- throw await de_NotAcceptableExceptionRes(parsedOutput, context);
426
- case "NotFoundException":
427
- case "com.amazonaws.lexruntimeservice#NotFoundException":
428
- throw await de_NotFoundExceptionRes(parsedOutput, context);
429
- default:
430
- const parsedBody = parsedOutput.body;
431
- return throwDefaultError({
432
- output,
433
- parsedBody,
434
- errorCode,
435
- });
436
- }
437
- };
438
- const throwDefaultError = (0, smithy_client_1.withBaseException)(LexRuntimeServiceServiceException_1.LexRuntimeServiceServiceException);
439
- const de_BadGatewayExceptionRes = async (parsedOutput, context) => {
440
- const contents = (0, smithy_client_1.map)({});
441
- const data = parsedOutput.body;
442
- const doc = (0, smithy_client_1.take)(data, {
443
- Message: smithy_client_1.expectString,
444
- });
445
- Object.assign(contents, doc);
446
- const exception = new models_0_1.BadGatewayException({
447
- $metadata: deserializeMetadata(parsedOutput),
448
- ...contents,
449
- });
450
- return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
451
- };
452
- const de_BadRequestExceptionRes = async (parsedOutput, context) => {
453
- const contents = (0, smithy_client_1.map)({});
454
- const data = parsedOutput.body;
455
- const doc = (0, smithy_client_1.take)(data, {
456
- message: smithy_client_1.expectString,
457
- });
458
- Object.assign(contents, doc);
459
- const exception = new models_0_1.BadRequestException({
460
- $metadata: deserializeMetadata(parsedOutput),
461
- ...contents,
462
- });
463
- return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
464
- };
465
- const de_ConflictExceptionRes = async (parsedOutput, context) => {
466
- const contents = (0, smithy_client_1.map)({});
467
- const data = parsedOutput.body;
468
- const doc = (0, smithy_client_1.take)(data, {
469
- message: smithy_client_1.expectString,
470
- });
471
- Object.assign(contents, doc);
472
- const exception = new models_0_1.ConflictException({
473
- $metadata: deserializeMetadata(parsedOutput),
474
- ...contents,
475
- });
476
- return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
477
- };
478
- const de_DependencyFailedExceptionRes = async (parsedOutput, context) => {
479
- const contents = (0, smithy_client_1.map)({});
480
- const data = parsedOutput.body;
481
- const doc = (0, smithy_client_1.take)(data, {
482
- Message: smithy_client_1.expectString,
483
- });
484
- Object.assign(contents, doc);
485
- const exception = new models_0_1.DependencyFailedException({
486
- $metadata: deserializeMetadata(parsedOutput),
487
- ...contents,
488
- });
489
- return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
490
- };
491
- const de_InternalFailureExceptionRes = async (parsedOutput, context) => {
492
- const contents = (0, smithy_client_1.map)({});
493
- const data = parsedOutput.body;
494
- const doc = (0, smithy_client_1.take)(data, {
495
- message: smithy_client_1.expectString,
496
- });
497
- Object.assign(contents, doc);
498
- const exception = new models_0_1.InternalFailureException({
499
- $metadata: deserializeMetadata(parsedOutput),
500
- ...contents,
501
- });
502
- return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
503
- };
504
- const de_LimitExceededExceptionRes = async (parsedOutput, context) => {
505
- const contents = (0, smithy_client_1.map)({
506
- [_rAS]: [, parsedOutput.headers[_ra]],
507
- });
508
- const data = parsedOutput.body;
509
- const doc = (0, smithy_client_1.take)(data, {
510
- message: smithy_client_1.expectString,
511
- });
512
- Object.assign(contents, doc);
513
- const exception = new models_0_1.LimitExceededException({
514
- $metadata: deserializeMetadata(parsedOutput),
515
- ...contents,
516
- });
517
- return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
518
- };
519
- const de_LoopDetectedExceptionRes = async (parsedOutput, context) => {
520
- const contents = (0, smithy_client_1.map)({});
521
- const data = parsedOutput.body;
522
- const doc = (0, smithy_client_1.take)(data, {
523
- Message: smithy_client_1.expectString,
524
- });
525
- Object.assign(contents, doc);
526
- const exception = new models_0_1.LoopDetectedException({
527
- $metadata: deserializeMetadata(parsedOutput),
528
- ...contents,
529
- });
530
- return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
531
- };
532
- const de_NotAcceptableExceptionRes = async (parsedOutput, context) => {
533
- const contents = (0, smithy_client_1.map)({});
534
- const data = parsedOutput.body;
535
- const doc = (0, smithy_client_1.take)(data, {
536
- message: smithy_client_1.expectString,
537
- });
538
- Object.assign(contents, doc);
539
- const exception = new models_0_1.NotAcceptableException({
540
- $metadata: deserializeMetadata(parsedOutput),
541
- ...contents,
542
- });
543
- return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
544
- };
545
- const de_NotFoundExceptionRes = async (parsedOutput, context) => {
546
- const contents = (0, smithy_client_1.map)({});
547
- const data = parsedOutput.body;
548
- const doc = (0, smithy_client_1.take)(data, {
549
- message: smithy_client_1.expectString,
550
- });
551
- Object.assign(contents, doc);
552
- const exception = new models_0_1.NotFoundException({
553
- $metadata: deserializeMetadata(parsedOutput),
554
- ...contents,
555
- });
556
- return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
557
- };
558
- const de_RequestTimeoutExceptionRes = async (parsedOutput, context) => {
559
- const contents = (0, smithy_client_1.map)({});
560
- const data = parsedOutput.body;
561
- const doc = (0, smithy_client_1.take)(data, {
562
- message: smithy_client_1.expectString,
563
- });
564
- Object.assign(contents, doc);
565
- const exception = new models_0_1.RequestTimeoutException({
566
- $metadata: deserializeMetadata(parsedOutput),
567
- ...contents,
568
- });
569
- return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
570
- };
571
- const de_UnsupportedMediaTypeExceptionRes = async (parsedOutput, context) => {
572
- const contents = (0, smithy_client_1.map)({});
573
- const data = parsedOutput.body;
574
- const doc = (0, smithy_client_1.take)(data, {
575
- message: smithy_client_1.expectString,
576
- });
577
- Object.assign(contents, doc);
578
- const exception = new models_0_1.UnsupportedMediaTypeException({
579
- $metadata: deserializeMetadata(parsedOutput),
580
- ...contents,
581
- });
582
- return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
583
- };
584
- const de_IntentConfidence = (output, context) => {
585
- return (0, smithy_client_1.take)(output, {
586
- score: smithy_client_1.limitedParseDouble,
587
- });
588
- };
589
- const de_IntentList = (output, context) => {
590
- const retVal = (output || [])
591
- .filter((e) => e != null)
592
- .map((entry) => {
593
- return de_PredictedIntent(entry, context);
594
- });
595
- return retVal;
596
- };
597
- const de_PredictedIntent = (output, context) => {
598
- return (0, smithy_client_1.take)(output, {
599
- intentName: smithy_client_1.expectString,
600
- nluIntentConfidence: (_) => de_IntentConfidence(_, context),
601
- slots: smithy_client_1._json,
602
- });
603
- };
604
- const deserializeMetadata = (output) => ({
605
- httpStatusCode: output.statusCode,
606
- requestId: output.headers["x-amzn-requestid"] ?? output.headers["x-amzn-request-id"] ?? output.headers["x-amz-request-id"],
607
- extendedRequestId: output.headers["x-amz-id-2"],
608
- cfId: output.headers["x-amz-cf-id"],
609
- });
610
- const collectBodyString = (streamBody, context) => (0, smithy_client_1.collectBody)(streamBody, context).then((body) => context.utf8Encoder(body));
611
- const isSerializableHeaderValue = (value) => value !== undefined &&
612
- value !== null &&
613
- value !== "" &&
614
- (!Object.getOwnPropertyNames(value).includes("length") || value.length != 0) &&
615
- (!Object.getOwnPropertyNames(value).includes("size") || value.size != 0);
616
- const _a = "accept";
617
- const _aC = "activeContexts";
618
- const _aI = "alternativeIntents";
619
- const _bV = "botVersion";
620
- const _cLF = "checkpointLabelFilter";
621
- const _cT = "contentType";
622
- const _ct = "content-type";
623
- const _dS = "dialogState";
624
- const _eIT = "encodedInputTranscript";
625
- const _eM = "encodedMessage";
626
- const _iN = "intentName";
627
- const _iT = "inputTranscript";
628
- const _m = "message";
629
- const _mF = "messageFormat";
630
- const _nIC = "nluIntentConfidence";
631
- const _rA = "requestAttributes";
632
- const _rAS = "retryAfterSeconds";
633
- const _ra = "retry-after";
634
- const _s = "slots";
635
- const _sA = "sessionAttributes";
636
- const _sI = "sessionId";
637
- const _sR = "sentimentResponse";
638
- const _sTE = "slotToElicit";
639
- const _xalac = "x-amz-lex-active-contexts";
640
- const _xalai = "x-amz-lex-alternative-intents";
641
- const _xalbv = "x-amz-lex-bot-version";
642
- const _xalds = "x-amz-lex-dialog-state";
643
- const _xaleit = "x-amz-lex-encoded-input-transcript";
644
- const _xalem = "x-amz-lex-encoded-message";
645
- const _xalin = "x-amz-lex-intent-name";
646
- const _xalit = "x-amz-lex-input-transcript";
647
- const _xalm = "x-amz-lex-message";
648
- const _xalmf = "x-amz-lex-message-format";
649
- const _xalnic = "x-amz-lex-nlu-intent-confidence";
650
- const _xalra = "x-amz-lex-request-attributes";
651
- const _xals = "x-amz-lex-slots";
652
- const _xals_ = "x-amz-lex-sentiment";
653
- const _xalsa = "x-amz-lex-session-attributes";
654
- const _xalsi = "x-amz-lex-session-id";
655
- const _xalste = "x-amz-lex-slot-to-elicit";
656
- const parseBody = (streamBody, context) => collectBodyString(streamBody, context).then((encoded) => {
657
- if (encoded.length) {
658
- return JSON.parse(encoded);
659
- }
660
- return {};
661
- });
662
- const parseErrorBody = async (errorBody, context) => {
663
- const value = await parseBody(errorBody, context);
664
- value.message = value.message ?? value.Message;
665
- return value;
666
- };
667
- const loadRestJsonErrorCode = (output, data) => {
668
- const findKey = (object, key) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase());
669
- const sanitizeErrorCode = (rawValue) => {
670
- let cleanValue = rawValue;
671
- if (typeof cleanValue === "number") {
672
- cleanValue = cleanValue.toString();
673
- }
674
- if (cleanValue.indexOf(",") >= 0) {
675
- cleanValue = cleanValue.split(",")[0];
676
- }
677
- if (cleanValue.indexOf(":") >= 0) {
678
- cleanValue = cleanValue.split(":")[0];
679
- }
680
- if (cleanValue.indexOf("#") >= 0) {
681
- cleanValue = cleanValue.split("#")[1];
682
- }
683
- return cleanValue;
684
- };
685
- const headerKey = findKey(output.headers, "x-amzn-errortype");
686
- if (headerKey !== undefined) {
687
- return sanitizeErrorCode(output.headers[headerKey]);
688
- }
689
- if (data.code !== undefined) {
690
- return sanitizeErrorCode(data.code);
691
- }
692
- if (data["__type"] !== undefined) {
693
- return sanitizeErrorCode(data["__type"]);
694
- }
695
- };
1
+ module.exports = require("../index.js");