@rivet-gg/chat 0.0.2 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist-cjs/ChatService.js +112 -0
  2. package/dist-cjs/ChatServiceClient.js +47 -0
  3. package/dist-cjs/commands/GetDirectThreadCommand.js +36 -0
  4. package/dist-cjs/commands/GetThreadHistoryCommand.js +36 -0
  5. package/dist-cjs/commands/GetThreadTopicCommand.js +36 -0
  6. package/dist-cjs/commands/SendChatMessageCommand.js +36 -0
  7. package/dist-cjs/commands/SetThreadReadCommand.js +36 -0
  8. package/dist-cjs/commands/SetTypingStatusCommand.js +36 -0
  9. package/dist-cjs/commands/WatchThreadCommand.js +36 -0
  10. package/dist-cjs/commands/index.js +10 -0
  11. package/dist-cjs/index.js +11 -0
  12. package/dist-cjs/models/ChatServiceServiceException.js +11 -0
  13. package/dist-cjs/models/index.js +4 -0
  14. package/dist-cjs/models/models_0.js +600 -0
  15. package/dist-cjs/protocols/Aws_restJson1.js +1055 -0
  16. package/dist-cjs/runtimeConfig.browser.js +42 -0
  17. package/dist-cjs/runtimeConfig.js +45 -0
  18. package/dist-cjs/runtimeConfig.native.js +16 -0
  19. package/dist-cjs/runtimeConfig.shared.js +14 -0
  20. package/dist-es/ChatService.js +115 -0
  21. package/dist-es/ChatServiceClient.js +49 -0
  22. package/dist-es/commands/GetDirectThreadCommand.js +39 -0
  23. package/dist-es/commands/GetThreadHistoryCommand.js +39 -0
  24. package/dist-es/commands/GetThreadTopicCommand.js +39 -0
  25. package/dist-es/commands/SendChatMessageCommand.js +39 -0
  26. package/dist-es/commands/SetThreadReadCommand.js +39 -0
  27. package/dist-es/commands/SetTypingStatusCommand.js +39 -0
  28. package/dist-es/commands/WatchThreadCommand.js +39 -0
  29. package/dist-es/commands/index.js +7 -0
  30. package/dist-es/index.js +6 -0
  31. package/dist-es/models/ChatServiceServiceException.js +12 -0
  32. package/dist-es/models/index.js +1 -0
  33. package/dist-es/models/models_0.js +492 -0
  34. package/dist-es/protocols/Aws_restJson1.js +1238 -0
  35. package/dist-es/runtimeConfig.browser.js +25 -0
  36. package/dist-es/runtimeConfig.js +28 -0
  37. package/dist-es/runtimeConfig.native.js +8 -0
  38. package/dist-es/runtimeConfig.shared.js +10 -0
  39. package/dist-types/models/models_0.d.ts +1 -1
  40. package/package.json +1 -1
@@ -0,0 +1,1238 @@
1
+ import { __assign, __awaiter, __generator } from "tslib";
2
+ import { ChatServiceServiceException as __BaseException } from "../models/ChatServiceServiceException";
3
+ import { BadRequestError, ChatTypingStatus, ForbiddenError, InternalError, NotFoundError, RateLimitError, SendChatTopic, SendMessageBody, UnauthorizedError, } from "../models/models_0";
4
+ import { HttpRequest as __HttpRequest, } from "@aws-sdk/protocol-http";
5
+ import { decorateServiceException as __decorateServiceException, expectBoolean as __expectBoolean, expectInt32 as __expectInt32, expectNonNull as __expectNonNull, expectObject as __expectObject, expectString as __expectString, expectUnion as __expectUnion, extendedEncodeURIComponent as __extendedEncodeURIComponent, parseRfc3339DateTime as __parseRfc3339DateTime, } from "@aws-sdk/smithy-client";
6
+ export var serializeAws_restJson1GetDirectThreadCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
7
+ var _a, hostname, _b, protocol, port, basePath, headers, resolvedPath, labelValue, 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 || '')) + "/identities/{identity_id}/thread";
15
+ if (input.identityId !== undefined) {
16
+ labelValue = input.identityId;
17
+ if (labelValue.length <= 0) {
18
+ throw new Error('Empty value provided for input HTTP label: identityId.');
19
+ }
20
+ resolvedPath = resolvedPath.replace("{identity_id}", __extendedEncodeURIComponent(labelValue));
21
+ }
22
+ else {
23
+ throw new Error('No value provided for input HTTP label: identityId.');
24
+ }
25
+ return [2, new __HttpRequest({
26
+ protocol: protocol,
27
+ hostname: hostname,
28
+ port: port,
29
+ method: "GET",
30
+ headers: headers,
31
+ path: resolvedPath,
32
+ body: body,
33
+ })];
34
+ }
35
+ });
36
+ }); };
37
+ export var serializeAws_restJson1GetThreadHistoryCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
38
+ var _a, hostname, _b, protocol, port, basePath, headers, resolvedPath, labelValue, query, body;
39
+ return __generator(this, function (_c) {
40
+ switch (_c.label) {
41
+ case 0: return [4, context.endpoint()];
42
+ case 1:
43
+ _a = _c.sent(), hostname = _a.hostname, _b = _a.protocol, protocol = _b === void 0 ? "https" : _b, port = _a.port, basePath = _a.path;
44
+ headers = {};
45
+ resolvedPath = "".concat((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith('/')) ? basePath.slice(0, -1) : (basePath || '')) + "/threads/{thread_id}/history";
46
+ if (input.threadId !== undefined) {
47
+ labelValue = input.threadId;
48
+ if (labelValue.length <= 0) {
49
+ throw new Error('Empty value provided for input HTTP label: threadId.');
50
+ }
51
+ resolvedPath = resolvedPath.replace("{thread_id}", __extendedEncodeURIComponent(labelValue));
52
+ }
53
+ else {
54
+ throw new Error('No value provided for input HTTP label: threadId.');
55
+ }
56
+ query = __assign(__assign(__assign({}, (input.ts !== undefined && { "ts": input.ts.toISOString().toString() })), (input.count !== undefined && { "count": input.count.toString() })), (input.queryDirection !== undefined && { "query_direction": input.queryDirection }));
57
+ return [2, new __HttpRequest({
58
+ protocol: protocol,
59
+ hostname: hostname,
60
+ port: port,
61
+ method: "GET",
62
+ headers: headers,
63
+ path: resolvedPath,
64
+ query: query,
65
+ body: body,
66
+ })];
67
+ }
68
+ });
69
+ }); };
70
+ export var serializeAws_restJson1GetThreadTopicCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
71
+ var _a, hostname, _b, protocol, port, basePath, headers, resolvedPath, labelValue, body;
72
+ return __generator(this, function (_c) {
73
+ switch (_c.label) {
74
+ case 0: return [4, context.endpoint()];
75
+ case 1:
76
+ _a = _c.sent(), hostname = _a.hostname, _b = _a.protocol, protocol = _b === void 0 ? "https" : _b, port = _a.port, basePath = _a.path;
77
+ headers = {};
78
+ resolvedPath = "".concat((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith('/')) ? basePath.slice(0, -1) : (basePath || '')) + "/threads/{thread_id}/topic";
79
+ if (input.threadId !== undefined) {
80
+ labelValue = input.threadId;
81
+ if (labelValue.length <= 0) {
82
+ throw new Error('Empty value provided for input HTTP label: threadId.');
83
+ }
84
+ resolvedPath = resolvedPath.replace("{thread_id}", __extendedEncodeURIComponent(labelValue));
85
+ }
86
+ else {
87
+ throw new Error('No value provided for input HTTP label: threadId.');
88
+ }
89
+ return [2, new __HttpRequest({
90
+ protocol: protocol,
91
+ hostname: hostname,
92
+ port: port,
93
+ method: "GET",
94
+ headers: headers,
95
+ path: resolvedPath,
96
+ body: body,
97
+ })];
98
+ }
99
+ });
100
+ }); };
101
+ export var serializeAws_restJson1SendChatMessageCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
102
+ var _a, hostname, _b, protocol, port, basePath, headers, resolvedPath, body;
103
+ return __generator(this, function (_c) {
104
+ switch (_c.label) {
105
+ case 0: return [4, context.endpoint()];
106
+ case 1:
107
+ _a = _c.sent(), hostname = _a.hostname, _b = _a.protocol, protocol = _b === void 0 ? "https" : _b, port = _a.port, basePath = _a.path;
108
+ headers = {
109
+ 'content-type': "application/json",
110
+ };
111
+ resolvedPath = "".concat((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith('/')) ? basePath.slice(0, -1) : (basePath || '')) + "/messages";
112
+ body = JSON.stringify(__assign(__assign({}, (input.messageBody !== undefined && input.messageBody !== null && { "message_body": serializeAws_restJson1SendMessageBody(input.messageBody, context) })), (input.topic !== undefined && input.topic !== null && { "topic": serializeAws_restJson1SendChatTopic(input.topic, context) })));
113
+ return [2, new __HttpRequest({
114
+ protocol: protocol,
115
+ hostname: hostname,
116
+ port: port,
117
+ method: "POST",
118
+ headers: headers,
119
+ path: resolvedPath,
120
+ body: body,
121
+ })];
122
+ }
123
+ });
124
+ }); };
125
+ export var serializeAws_restJson1SetThreadReadCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
126
+ var _a, hostname, _b, protocol, port, basePath, headers, resolvedPath, labelValue, body;
127
+ return __generator(this, function (_c) {
128
+ switch (_c.label) {
129
+ case 0: return [4, context.endpoint()];
130
+ case 1:
131
+ _a = _c.sent(), hostname = _a.hostname, _b = _a.protocol, protocol = _b === void 0 ? "https" : _b, port = _a.port, basePath = _a.path;
132
+ headers = {
133
+ 'content-type': "application/json",
134
+ };
135
+ resolvedPath = "".concat((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith('/')) ? basePath.slice(0, -1) : (basePath || '')) + "/threads/{thread_id}/read";
136
+ if (input.threadId !== undefined) {
137
+ labelValue = input.threadId;
138
+ if (labelValue.length <= 0) {
139
+ throw new Error('Empty value provided for input HTTP label: threadId.');
140
+ }
141
+ resolvedPath = resolvedPath.replace("{thread_id}", __extendedEncodeURIComponent(labelValue));
142
+ }
143
+ else {
144
+ throw new Error('No value provided for input HTTP label: threadId.');
145
+ }
146
+ body = JSON.stringify(__assign({}, (input.lastReadTs !== undefined && input.lastReadTs !== null && { "last_read_ts": input.lastReadTs.toISOString() })));
147
+ return [2, new __HttpRequest({
148
+ protocol: protocol,
149
+ hostname: hostname,
150
+ port: port,
151
+ method: "POST",
152
+ headers: headers,
153
+ path: resolvedPath,
154
+ body: body,
155
+ })];
156
+ }
157
+ });
158
+ }); };
159
+ export var serializeAws_restJson1SetTypingStatusCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
160
+ var _a, hostname, _b, protocol, port, basePath, headers, resolvedPath, labelValue, body;
161
+ return __generator(this, function (_c) {
162
+ switch (_c.label) {
163
+ case 0: return [4, context.endpoint()];
164
+ case 1:
165
+ _a = _c.sent(), hostname = _a.hostname, _b = _a.protocol, protocol = _b === void 0 ? "https" : _b, port = _a.port, basePath = _a.path;
166
+ headers = {
167
+ 'content-type': "application/json",
168
+ };
169
+ resolvedPath = "".concat((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith('/')) ? basePath.slice(0, -1) : (basePath || '')) + "/threads/{thread_id}/typing-status";
170
+ if (input.threadId !== undefined) {
171
+ labelValue = input.threadId;
172
+ if (labelValue.length <= 0) {
173
+ throw new Error('Empty value provided for input HTTP label: threadId.');
174
+ }
175
+ resolvedPath = resolvedPath.replace("{thread_id}", __extendedEncodeURIComponent(labelValue));
176
+ }
177
+ else {
178
+ throw new Error('No value provided for input HTTP label: threadId.');
179
+ }
180
+ body = JSON.stringify(__assign({}, (input.status !== undefined && input.status !== null && { "status": serializeAws_restJson1ChatTypingStatus(input.status, context) })));
181
+ return [2, new __HttpRequest({
182
+ protocol: protocol,
183
+ hostname: hostname,
184
+ port: port,
185
+ method: "PUT",
186
+ headers: headers,
187
+ path: resolvedPath,
188
+ body: body,
189
+ })];
190
+ }
191
+ });
192
+ }); };
193
+ export var serializeAws_restJson1WatchThreadCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
194
+ var _a, hostname, _b, protocol, port, basePath, headers, resolvedPath, labelValue, query, body;
195
+ return __generator(this, function (_c) {
196
+ switch (_c.label) {
197
+ case 0: return [4, context.endpoint()];
198
+ case 1:
199
+ _a = _c.sent(), hostname = _a.hostname, _b = _a.protocol, protocol = _b === void 0 ? "https" : _b, port = _a.port, basePath = _a.path;
200
+ headers = {};
201
+ resolvedPath = "".concat((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith('/')) ? basePath.slice(0, -1) : (basePath || '')) + "/threads/{thread_id}/live";
202
+ if (input.threadId !== undefined) {
203
+ labelValue = input.threadId;
204
+ if (labelValue.length <= 0) {
205
+ throw new Error('Empty value provided for input HTTP label: threadId.');
206
+ }
207
+ resolvedPath = resolvedPath.replace("{thread_id}", __extendedEncodeURIComponent(labelValue));
208
+ }
209
+ else {
210
+ throw new Error('No value provided for input HTTP label: threadId.');
211
+ }
212
+ query = __assign({}, (input.watchIndex !== undefined && { "watch_index": input.watchIndex }));
213
+ return [2, new __HttpRequest({
214
+ protocol: protocol,
215
+ hostname: hostname,
216
+ port: port,
217
+ method: "GET",
218
+ headers: headers,
219
+ path: resolvedPath,
220
+ query: query,
221
+ body: body,
222
+ })];
223
+ }
224
+ });
225
+ }); };
226
+ export var deserializeAws_restJson1GetDirectThreadCommand = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
227
+ var contents, data, _a, _b;
228
+ return __generator(this, function (_c) {
229
+ switch (_c.label) {
230
+ case 0:
231
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
232
+ return [2, deserializeAws_restJson1GetDirectThreadCommandError(output, context)];
233
+ }
234
+ contents = {
235
+ $metadata: deserializeMetadata(output),
236
+ identity: undefined,
237
+ threadId: undefined,
238
+ };
239
+ _a = __expectNonNull;
240
+ _b = __expectObject;
241
+ return [4, parseBody(output.body, context)];
242
+ case 1:
243
+ data = _a.apply(void 0, [(_b.apply(void 0, [_c.sent()])), "body"]);
244
+ if (data.identity !== undefined && data.identity !== null) {
245
+ contents.identity = deserializeAws_restJson1IdentityHandle(data.identity, context);
246
+ }
247
+ if (data.thread_id !== undefined && data.thread_id !== null) {
248
+ contents.threadId = __expectString(data.thread_id);
249
+ }
250
+ return [2, Promise.resolve(contents)];
251
+ }
252
+ });
253
+ }); };
254
+ var deserializeAws_restJson1GetDirectThreadCommandError = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
255
+ var parsedOutput, _a, response, errorCode, _b, parsedBody;
256
+ var _c;
257
+ return __generator(this, function (_d) {
258
+ switch (_d.label) {
259
+ case 0:
260
+ _a = [__assign({}, output)];
261
+ _c = {};
262
+ return [4, parseBody(output.body, context)];
263
+ case 1:
264
+ parsedOutput = __assign.apply(void 0, _a.concat([(_c.body = _d.sent(), _c)]));
265
+ errorCode = "UnknownError";
266
+ errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
267
+ _b = errorCode;
268
+ switch (_b) {
269
+ case "BadRequestError": return [3, 2];
270
+ case "rivet.error#BadRequestError": return [3, 2];
271
+ case "ForbiddenError": return [3, 4];
272
+ case "rivet.error#ForbiddenError": return [3, 4];
273
+ case "InternalError": return [3, 6];
274
+ case "rivet.error#InternalError": return [3, 6];
275
+ case "NotFoundError": return [3, 8];
276
+ case "rivet.error#NotFoundError": return [3, 8];
277
+ case "RateLimitError": return [3, 10];
278
+ case "rivet.error#RateLimitError": return [3, 10];
279
+ case "UnauthorizedError": return [3, 12];
280
+ case "rivet.error#UnauthorizedError": return [3, 12];
281
+ }
282
+ return [3, 14];
283
+ case 2: return [4, deserializeAws_restJson1BadRequestErrorResponse(parsedOutput, context)];
284
+ case 3: throw _d.sent();
285
+ case 4: return [4, deserializeAws_restJson1ForbiddenErrorResponse(parsedOutput, context)];
286
+ case 5: throw _d.sent();
287
+ case 6: return [4, deserializeAws_restJson1InternalErrorResponse(parsedOutput, context)];
288
+ case 7: throw _d.sent();
289
+ case 8: return [4, deserializeAws_restJson1NotFoundErrorResponse(parsedOutput, context)];
290
+ case 9: throw _d.sent();
291
+ case 10: return [4, deserializeAws_restJson1RateLimitErrorResponse(parsedOutput, context)];
292
+ case 11: throw _d.sent();
293
+ case 12: return [4, deserializeAws_restJson1UnauthorizedErrorResponse(parsedOutput, context)];
294
+ case 13: throw _d.sent();
295
+ case 14:
296
+ parsedBody = parsedOutput.body;
297
+ response = new __BaseException({
298
+ name: parsedBody.code || parsedBody.Code || errorCode,
299
+ $fault: "client",
300
+ $metadata: deserializeMetadata(output)
301
+ });
302
+ throw __decorateServiceException(response, parsedBody);
303
+ }
304
+ });
305
+ }); };
306
+ export var deserializeAws_restJson1GetThreadHistoryCommand = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
307
+ var contents, data, _a, _b;
308
+ return __generator(this, function (_c) {
309
+ switch (_c.label) {
310
+ case 0:
311
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
312
+ return [2, deserializeAws_restJson1GetThreadHistoryCommandError(output, context)];
313
+ }
314
+ contents = {
315
+ $metadata: deserializeMetadata(output),
316
+ chatMessages: undefined,
317
+ };
318
+ _a = __expectNonNull;
319
+ _b = __expectObject;
320
+ return [4, parseBody(output.body, context)];
321
+ case 1:
322
+ data = _a.apply(void 0, [(_b.apply(void 0, [_c.sent()])), "body"]);
323
+ if (data.chat_messages !== undefined && data.chat_messages !== null) {
324
+ contents.chatMessages = deserializeAws_restJson1ChatMessages(data.chat_messages, context);
325
+ }
326
+ return [2, Promise.resolve(contents)];
327
+ }
328
+ });
329
+ }); };
330
+ var deserializeAws_restJson1GetThreadHistoryCommandError = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
331
+ var parsedOutput, _a, response, errorCode, _b, parsedBody;
332
+ var _c;
333
+ return __generator(this, function (_d) {
334
+ switch (_d.label) {
335
+ case 0:
336
+ _a = [__assign({}, output)];
337
+ _c = {};
338
+ return [4, parseBody(output.body, context)];
339
+ case 1:
340
+ parsedOutput = __assign.apply(void 0, _a.concat([(_c.body = _d.sent(), _c)]));
341
+ errorCode = "UnknownError";
342
+ errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
343
+ _b = errorCode;
344
+ switch (_b) {
345
+ case "BadRequestError": return [3, 2];
346
+ case "rivet.error#BadRequestError": return [3, 2];
347
+ case "ForbiddenError": return [3, 4];
348
+ case "rivet.error#ForbiddenError": return [3, 4];
349
+ case "InternalError": return [3, 6];
350
+ case "rivet.error#InternalError": return [3, 6];
351
+ case "NotFoundError": return [3, 8];
352
+ case "rivet.error#NotFoundError": return [3, 8];
353
+ case "RateLimitError": return [3, 10];
354
+ case "rivet.error#RateLimitError": return [3, 10];
355
+ case "UnauthorizedError": return [3, 12];
356
+ case "rivet.error#UnauthorizedError": return [3, 12];
357
+ }
358
+ return [3, 14];
359
+ case 2: return [4, deserializeAws_restJson1BadRequestErrorResponse(parsedOutput, context)];
360
+ case 3: throw _d.sent();
361
+ case 4: return [4, deserializeAws_restJson1ForbiddenErrorResponse(parsedOutput, context)];
362
+ case 5: throw _d.sent();
363
+ case 6: return [4, deserializeAws_restJson1InternalErrorResponse(parsedOutput, context)];
364
+ case 7: throw _d.sent();
365
+ case 8: return [4, deserializeAws_restJson1NotFoundErrorResponse(parsedOutput, context)];
366
+ case 9: throw _d.sent();
367
+ case 10: return [4, deserializeAws_restJson1RateLimitErrorResponse(parsedOutput, context)];
368
+ case 11: throw _d.sent();
369
+ case 12: return [4, deserializeAws_restJson1UnauthorizedErrorResponse(parsedOutput, context)];
370
+ case 13: throw _d.sent();
371
+ case 14:
372
+ parsedBody = parsedOutput.body;
373
+ response = new __BaseException({
374
+ name: parsedBody.code || parsedBody.Code || errorCode,
375
+ $fault: "client",
376
+ $metadata: deserializeMetadata(output)
377
+ });
378
+ throw __decorateServiceException(response, parsedBody);
379
+ }
380
+ });
381
+ }); };
382
+ export var deserializeAws_restJson1GetThreadTopicCommand = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
383
+ var contents, data, _a, _b;
384
+ return __generator(this, function (_c) {
385
+ switch (_c.label) {
386
+ case 0:
387
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
388
+ return [2, deserializeAws_restJson1GetThreadTopicCommandError(output, context)];
389
+ }
390
+ contents = {
391
+ $metadata: deserializeMetadata(output),
392
+ topic: undefined,
393
+ };
394
+ _a = __expectNonNull;
395
+ _b = __expectObject;
396
+ return [4, parseBody(output.body, context)];
397
+ case 1:
398
+ data = _a.apply(void 0, [(_b.apply(void 0, [_c.sent()])), "body"]);
399
+ if (data.topic !== undefined && data.topic !== null) {
400
+ contents.topic = deserializeAws_restJson1ChatSimpleTopic(__expectUnion(data.topic), context);
401
+ }
402
+ return [2, Promise.resolve(contents)];
403
+ }
404
+ });
405
+ }); };
406
+ var deserializeAws_restJson1GetThreadTopicCommandError = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
407
+ var parsedOutput, _a, response, errorCode, _b, parsedBody;
408
+ var _c;
409
+ return __generator(this, function (_d) {
410
+ switch (_d.label) {
411
+ case 0:
412
+ _a = [__assign({}, output)];
413
+ _c = {};
414
+ return [4, parseBody(output.body, context)];
415
+ case 1:
416
+ parsedOutput = __assign.apply(void 0, _a.concat([(_c.body = _d.sent(), _c)]));
417
+ errorCode = "UnknownError";
418
+ errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
419
+ _b = errorCode;
420
+ switch (_b) {
421
+ case "BadRequestError": return [3, 2];
422
+ case "rivet.error#BadRequestError": return [3, 2];
423
+ case "ForbiddenError": return [3, 4];
424
+ case "rivet.error#ForbiddenError": return [3, 4];
425
+ case "InternalError": return [3, 6];
426
+ case "rivet.error#InternalError": return [3, 6];
427
+ case "NotFoundError": return [3, 8];
428
+ case "rivet.error#NotFoundError": return [3, 8];
429
+ case "RateLimitError": return [3, 10];
430
+ case "rivet.error#RateLimitError": return [3, 10];
431
+ case "UnauthorizedError": return [3, 12];
432
+ case "rivet.error#UnauthorizedError": return [3, 12];
433
+ }
434
+ return [3, 14];
435
+ case 2: return [4, deserializeAws_restJson1BadRequestErrorResponse(parsedOutput, context)];
436
+ case 3: throw _d.sent();
437
+ case 4: return [4, deserializeAws_restJson1ForbiddenErrorResponse(parsedOutput, context)];
438
+ case 5: throw _d.sent();
439
+ case 6: return [4, deserializeAws_restJson1InternalErrorResponse(parsedOutput, context)];
440
+ case 7: throw _d.sent();
441
+ case 8: return [4, deserializeAws_restJson1NotFoundErrorResponse(parsedOutput, context)];
442
+ case 9: throw _d.sent();
443
+ case 10: return [4, deserializeAws_restJson1RateLimitErrorResponse(parsedOutput, context)];
444
+ case 11: throw _d.sent();
445
+ case 12: return [4, deserializeAws_restJson1UnauthorizedErrorResponse(parsedOutput, context)];
446
+ case 13: throw _d.sent();
447
+ case 14:
448
+ parsedBody = parsedOutput.body;
449
+ response = new __BaseException({
450
+ name: parsedBody.code || parsedBody.Code || errorCode,
451
+ $fault: "client",
452
+ $metadata: deserializeMetadata(output)
453
+ });
454
+ throw __decorateServiceException(response, parsedBody);
455
+ }
456
+ });
457
+ }); };
458
+ export var deserializeAws_restJson1SendChatMessageCommand = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
459
+ var contents, data, _a, _b;
460
+ return __generator(this, function (_c) {
461
+ switch (_c.label) {
462
+ case 0:
463
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
464
+ return [2, deserializeAws_restJson1SendChatMessageCommandError(output, context)];
465
+ }
466
+ contents = {
467
+ $metadata: deserializeMetadata(output),
468
+ chatMessageId: undefined,
469
+ };
470
+ _a = __expectNonNull;
471
+ _b = __expectObject;
472
+ return [4, parseBody(output.body, context)];
473
+ case 1:
474
+ data = _a.apply(void 0, [(_b.apply(void 0, [_c.sent()])), "body"]);
475
+ if (data.chat_message_id !== undefined && data.chat_message_id !== null) {
476
+ contents.chatMessageId = __expectString(data.chat_message_id);
477
+ }
478
+ return [2, Promise.resolve(contents)];
479
+ }
480
+ });
481
+ }); };
482
+ var deserializeAws_restJson1SendChatMessageCommandError = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
483
+ var parsedOutput, _a, response, errorCode, _b, parsedBody;
484
+ var _c;
485
+ return __generator(this, function (_d) {
486
+ switch (_d.label) {
487
+ case 0:
488
+ _a = [__assign({}, output)];
489
+ _c = {};
490
+ return [4, parseBody(output.body, context)];
491
+ case 1:
492
+ parsedOutput = __assign.apply(void 0, _a.concat([(_c.body = _d.sent(), _c)]));
493
+ errorCode = "UnknownError";
494
+ errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
495
+ _b = errorCode;
496
+ switch (_b) {
497
+ case "BadRequestError": return [3, 2];
498
+ case "rivet.error#BadRequestError": return [3, 2];
499
+ case "ForbiddenError": return [3, 4];
500
+ case "rivet.error#ForbiddenError": return [3, 4];
501
+ case "InternalError": return [3, 6];
502
+ case "rivet.error#InternalError": return [3, 6];
503
+ case "NotFoundError": return [3, 8];
504
+ case "rivet.error#NotFoundError": return [3, 8];
505
+ case "RateLimitError": return [3, 10];
506
+ case "rivet.error#RateLimitError": return [3, 10];
507
+ case "UnauthorizedError": return [3, 12];
508
+ case "rivet.error#UnauthorizedError": return [3, 12];
509
+ }
510
+ return [3, 14];
511
+ case 2: return [4, deserializeAws_restJson1BadRequestErrorResponse(parsedOutput, context)];
512
+ case 3: throw _d.sent();
513
+ case 4: return [4, deserializeAws_restJson1ForbiddenErrorResponse(parsedOutput, context)];
514
+ case 5: throw _d.sent();
515
+ case 6: return [4, deserializeAws_restJson1InternalErrorResponse(parsedOutput, context)];
516
+ case 7: throw _d.sent();
517
+ case 8: return [4, deserializeAws_restJson1NotFoundErrorResponse(parsedOutput, context)];
518
+ case 9: throw _d.sent();
519
+ case 10: return [4, deserializeAws_restJson1RateLimitErrorResponse(parsedOutput, context)];
520
+ case 11: throw _d.sent();
521
+ case 12: return [4, deserializeAws_restJson1UnauthorizedErrorResponse(parsedOutput, context)];
522
+ case 13: throw _d.sent();
523
+ case 14:
524
+ parsedBody = parsedOutput.body;
525
+ response = new __BaseException({
526
+ name: parsedBody.code || parsedBody.Code || errorCode,
527
+ $fault: "client",
528
+ $metadata: deserializeMetadata(output)
529
+ });
530
+ throw __decorateServiceException(response, parsedBody);
531
+ }
532
+ });
533
+ }); };
534
+ export var deserializeAws_restJson1SetThreadReadCommand = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
535
+ var contents;
536
+ return __generator(this, function (_a) {
537
+ switch (_a.label) {
538
+ case 0:
539
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
540
+ return [2, deserializeAws_restJson1SetThreadReadCommandError(output, context)];
541
+ }
542
+ contents = {
543
+ $metadata: deserializeMetadata(output),
544
+ };
545
+ return [4, collectBody(output.body, context)];
546
+ case 1:
547
+ _a.sent();
548
+ return [2, Promise.resolve(contents)];
549
+ }
550
+ });
551
+ }); };
552
+ var deserializeAws_restJson1SetThreadReadCommandError = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
553
+ var parsedOutput, _a, response, errorCode, _b, parsedBody;
554
+ var _c;
555
+ return __generator(this, function (_d) {
556
+ switch (_d.label) {
557
+ case 0:
558
+ _a = [__assign({}, output)];
559
+ _c = {};
560
+ return [4, parseBody(output.body, context)];
561
+ case 1:
562
+ parsedOutput = __assign.apply(void 0, _a.concat([(_c.body = _d.sent(), _c)]));
563
+ errorCode = "UnknownError";
564
+ errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
565
+ _b = errorCode;
566
+ switch (_b) {
567
+ case "BadRequestError": return [3, 2];
568
+ case "rivet.error#BadRequestError": return [3, 2];
569
+ case "ForbiddenError": return [3, 4];
570
+ case "rivet.error#ForbiddenError": return [3, 4];
571
+ case "InternalError": return [3, 6];
572
+ case "rivet.error#InternalError": return [3, 6];
573
+ case "NotFoundError": return [3, 8];
574
+ case "rivet.error#NotFoundError": return [3, 8];
575
+ case "RateLimitError": return [3, 10];
576
+ case "rivet.error#RateLimitError": return [3, 10];
577
+ case "UnauthorizedError": return [3, 12];
578
+ case "rivet.error#UnauthorizedError": return [3, 12];
579
+ }
580
+ return [3, 14];
581
+ case 2: return [4, deserializeAws_restJson1BadRequestErrorResponse(parsedOutput, context)];
582
+ case 3: throw _d.sent();
583
+ case 4: return [4, deserializeAws_restJson1ForbiddenErrorResponse(parsedOutput, context)];
584
+ case 5: throw _d.sent();
585
+ case 6: return [4, deserializeAws_restJson1InternalErrorResponse(parsedOutput, context)];
586
+ case 7: throw _d.sent();
587
+ case 8: return [4, deserializeAws_restJson1NotFoundErrorResponse(parsedOutput, context)];
588
+ case 9: throw _d.sent();
589
+ case 10: return [4, deserializeAws_restJson1RateLimitErrorResponse(parsedOutput, context)];
590
+ case 11: throw _d.sent();
591
+ case 12: return [4, deserializeAws_restJson1UnauthorizedErrorResponse(parsedOutput, context)];
592
+ case 13: throw _d.sent();
593
+ case 14:
594
+ parsedBody = parsedOutput.body;
595
+ response = new __BaseException({
596
+ name: parsedBody.code || parsedBody.Code || errorCode,
597
+ $fault: "client",
598
+ $metadata: deserializeMetadata(output)
599
+ });
600
+ throw __decorateServiceException(response, parsedBody);
601
+ }
602
+ });
603
+ }); };
604
+ export var deserializeAws_restJson1SetTypingStatusCommand = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
605
+ var contents;
606
+ return __generator(this, function (_a) {
607
+ switch (_a.label) {
608
+ case 0:
609
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
610
+ return [2, deserializeAws_restJson1SetTypingStatusCommandError(output, context)];
611
+ }
612
+ contents = {
613
+ $metadata: deserializeMetadata(output),
614
+ };
615
+ return [4, collectBody(output.body, context)];
616
+ case 1:
617
+ _a.sent();
618
+ return [2, Promise.resolve(contents)];
619
+ }
620
+ });
621
+ }); };
622
+ var deserializeAws_restJson1SetTypingStatusCommandError = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
623
+ var parsedOutput, _a, response, errorCode, _b, parsedBody;
624
+ var _c;
625
+ return __generator(this, function (_d) {
626
+ switch (_d.label) {
627
+ case 0:
628
+ _a = [__assign({}, output)];
629
+ _c = {};
630
+ return [4, parseBody(output.body, context)];
631
+ case 1:
632
+ parsedOutput = __assign.apply(void 0, _a.concat([(_c.body = _d.sent(), _c)]));
633
+ errorCode = "UnknownError";
634
+ errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
635
+ _b = errorCode;
636
+ switch (_b) {
637
+ case "BadRequestError": return [3, 2];
638
+ case "rivet.error#BadRequestError": return [3, 2];
639
+ case "ForbiddenError": return [3, 4];
640
+ case "rivet.error#ForbiddenError": return [3, 4];
641
+ case "InternalError": return [3, 6];
642
+ case "rivet.error#InternalError": return [3, 6];
643
+ case "NotFoundError": return [3, 8];
644
+ case "rivet.error#NotFoundError": return [3, 8];
645
+ case "RateLimitError": return [3, 10];
646
+ case "rivet.error#RateLimitError": return [3, 10];
647
+ case "UnauthorizedError": return [3, 12];
648
+ case "rivet.error#UnauthorizedError": return [3, 12];
649
+ }
650
+ return [3, 14];
651
+ case 2: return [4, deserializeAws_restJson1BadRequestErrorResponse(parsedOutput, context)];
652
+ case 3: throw _d.sent();
653
+ case 4: return [4, deserializeAws_restJson1ForbiddenErrorResponse(parsedOutput, context)];
654
+ case 5: throw _d.sent();
655
+ case 6: return [4, deserializeAws_restJson1InternalErrorResponse(parsedOutput, context)];
656
+ case 7: throw _d.sent();
657
+ case 8: return [4, deserializeAws_restJson1NotFoundErrorResponse(parsedOutput, context)];
658
+ case 9: throw _d.sent();
659
+ case 10: return [4, deserializeAws_restJson1RateLimitErrorResponse(parsedOutput, context)];
660
+ case 11: throw _d.sent();
661
+ case 12: return [4, deserializeAws_restJson1UnauthorizedErrorResponse(parsedOutput, context)];
662
+ case 13: throw _d.sent();
663
+ case 14:
664
+ parsedBody = parsedOutput.body;
665
+ response = new __BaseException({
666
+ name: parsedBody.code || parsedBody.Code || errorCode,
667
+ $fault: "client",
668
+ $metadata: deserializeMetadata(output)
669
+ });
670
+ throw __decorateServiceException(response, parsedBody);
671
+ }
672
+ });
673
+ }); };
674
+ export var deserializeAws_restJson1WatchThreadCommand = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
675
+ var contents, data, _a, _b;
676
+ return __generator(this, function (_c) {
677
+ switch (_c.label) {
678
+ case 0:
679
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
680
+ return [2, deserializeAws_restJson1WatchThreadCommandError(output, context)];
681
+ }
682
+ contents = {
683
+ $metadata: deserializeMetadata(output),
684
+ chatMessages: undefined,
685
+ typingStatuses: undefined,
686
+ watch: undefined,
687
+ };
688
+ _a = __expectNonNull;
689
+ _b = __expectObject;
690
+ return [4, parseBody(output.body, context)];
691
+ case 1:
692
+ data = _a.apply(void 0, [(_b.apply(void 0, [_c.sent()])), "body"]);
693
+ if (data.chat_messages !== undefined && data.chat_messages !== null) {
694
+ contents.chatMessages = deserializeAws_restJson1ChatMessages(data.chat_messages, context);
695
+ }
696
+ if (data.typing_statuses !== undefined && data.typing_statuses !== null) {
697
+ contents.typingStatuses = deserializeAws_restJson1ChatIdentityTypingStatuses(data.typing_statuses, context);
698
+ }
699
+ if (data.watch !== undefined && data.watch !== null) {
700
+ contents.watch = deserializeAws_restJson1WatchResponse(data.watch, context);
701
+ }
702
+ return [2, Promise.resolve(contents)];
703
+ }
704
+ });
705
+ }); };
706
+ var deserializeAws_restJson1WatchThreadCommandError = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
707
+ var parsedOutput, _a, response, errorCode, _b, parsedBody;
708
+ var _c;
709
+ return __generator(this, function (_d) {
710
+ switch (_d.label) {
711
+ case 0:
712
+ _a = [__assign({}, output)];
713
+ _c = {};
714
+ return [4, parseBody(output.body, context)];
715
+ case 1:
716
+ parsedOutput = __assign.apply(void 0, _a.concat([(_c.body = _d.sent(), _c)]));
717
+ errorCode = "UnknownError";
718
+ errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
719
+ _b = errorCode;
720
+ switch (_b) {
721
+ case "BadRequestError": return [3, 2];
722
+ case "rivet.error#BadRequestError": return [3, 2];
723
+ case "ForbiddenError": return [3, 4];
724
+ case "rivet.error#ForbiddenError": return [3, 4];
725
+ case "InternalError": return [3, 6];
726
+ case "rivet.error#InternalError": return [3, 6];
727
+ case "NotFoundError": return [3, 8];
728
+ case "rivet.error#NotFoundError": return [3, 8];
729
+ case "RateLimitError": return [3, 10];
730
+ case "rivet.error#RateLimitError": return [3, 10];
731
+ case "UnauthorizedError": return [3, 12];
732
+ case "rivet.error#UnauthorizedError": return [3, 12];
733
+ }
734
+ return [3, 14];
735
+ case 2: return [4, deserializeAws_restJson1BadRequestErrorResponse(parsedOutput, context)];
736
+ case 3: throw _d.sent();
737
+ case 4: return [4, deserializeAws_restJson1ForbiddenErrorResponse(parsedOutput, context)];
738
+ case 5: throw _d.sent();
739
+ case 6: return [4, deserializeAws_restJson1InternalErrorResponse(parsedOutput, context)];
740
+ case 7: throw _d.sent();
741
+ case 8: return [4, deserializeAws_restJson1NotFoundErrorResponse(parsedOutput, context)];
742
+ case 9: throw _d.sent();
743
+ case 10: return [4, deserializeAws_restJson1RateLimitErrorResponse(parsedOutput, context)];
744
+ case 11: throw _d.sent();
745
+ case 12: return [4, deserializeAws_restJson1UnauthorizedErrorResponse(parsedOutput, context)];
746
+ case 13: throw _d.sent();
747
+ case 14:
748
+ parsedBody = parsedOutput.body;
749
+ response = new __BaseException({
750
+ name: parsedBody.code || parsedBody.Code || errorCode,
751
+ $fault: "client",
752
+ $metadata: deserializeMetadata(output)
753
+ });
754
+ throw __decorateServiceException(response, parsedBody);
755
+ }
756
+ });
757
+ }); };
758
+ var deserializeAws_restJson1BadRequestErrorResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
759
+ var contents, data, exception;
760
+ return __generator(this, function (_a) {
761
+ contents = {};
762
+ data = parsedOutput.body;
763
+ if (data.code !== undefined && data.code !== null) {
764
+ contents.code = __expectString(data.code);
765
+ }
766
+ if (data.message !== undefined && data.message !== null) {
767
+ contents.message = __expectString(data.message);
768
+ }
769
+ if (data.metadata !== undefined && data.metadata !== null) {
770
+ contents.metadata = deserializeAws_restJson1ErrorMetadata(data.metadata, context);
771
+ }
772
+ exception = new BadRequestError(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
773
+ return [2, __decorateServiceException(exception, parsedOutput.body)];
774
+ });
775
+ }); };
776
+ var deserializeAws_restJson1ForbiddenErrorResponse = 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 = {};
780
+ data = parsedOutput.body;
781
+ if (data.code !== undefined && data.code !== null) {
782
+ contents.code = __expectString(data.code);
783
+ }
784
+ if (data.message !== undefined && data.message !== null) {
785
+ contents.message = __expectString(data.message);
786
+ }
787
+ if (data.metadata !== undefined && data.metadata !== null) {
788
+ contents.metadata = deserializeAws_restJson1ErrorMetadata(data.metadata, context);
789
+ }
790
+ exception = new ForbiddenError(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
791
+ return [2, __decorateServiceException(exception, parsedOutput.body)];
792
+ });
793
+ }); };
794
+ var deserializeAws_restJson1InternalErrorResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
795
+ var contents, data, exception;
796
+ return __generator(this, function (_a) {
797
+ contents = {};
798
+ data = parsedOutput.body;
799
+ if (data.code !== undefined && data.code !== null) {
800
+ contents.code = __expectString(data.code);
801
+ }
802
+ if (data.message !== undefined && data.message !== null) {
803
+ contents.message = __expectString(data.message);
804
+ }
805
+ if (data.metadata !== undefined && data.metadata !== null) {
806
+ contents.metadata = deserializeAws_restJson1ErrorMetadata(data.metadata, context);
807
+ }
808
+ exception = new InternalError(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
809
+ return [2, __decorateServiceException(exception, parsedOutput.body)];
810
+ });
811
+ }); };
812
+ var deserializeAws_restJson1NotFoundErrorResponse = 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 = {};
816
+ data = parsedOutput.body;
817
+ if (data.code !== undefined && data.code !== null) {
818
+ contents.code = __expectString(data.code);
819
+ }
820
+ if (data.message !== undefined && data.message !== null) {
821
+ contents.message = __expectString(data.message);
822
+ }
823
+ if (data.metadata !== undefined && data.metadata !== null) {
824
+ contents.metadata = deserializeAws_restJson1ErrorMetadata(data.metadata, context);
825
+ }
826
+ exception = new NotFoundError(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
827
+ return [2, __decorateServiceException(exception, parsedOutput.body)];
828
+ });
829
+ }); };
830
+ var deserializeAws_restJson1RateLimitErrorResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
831
+ var contents, data, exception;
832
+ return __generator(this, function (_a) {
833
+ contents = {};
834
+ data = parsedOutput.body;
835
+ if (data.code !== undefined && data.code !== null) {
836
+ contents.code = __expectString(data.code);
837
+ }
838
+ if (data.message !== undefined && data.message !== null) {
839
+ contents.message = __expectString(data.message);
840
+ }
841
+ if (data.metadata !== undefined && data.metadata !== null) {
842
+ contents.metadata = deserializeAws_restJson1ErrorMetadata(data.metadata, context);
843
+ }
844
+ exception = new RateLimitError(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
845
+ return [2, __decorateServiceException(exception, parsedOutput.body)];
846
+ });
847
+ }); };
848
+ var deserializeAws_restJson1UnauthorizedErrorResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
849
+ var contents, data, exception;
850
+ return __generator(this, function (_a) {
851
+ contents = {};
852
+ data = parsedOutput.body;
853
+ if (data.code !== undefined && data.code !== null) {
854
+ contents.code = __expectString(data.code);
855
+ }
856
+ if (data.message !== undefined && data.message !== null) {
857
+ contents.message = __expectString(data.message);
858
+ }
859
+ if (data.metadata !== undefined && data.metadata !== null) {
860
+ contents.metadata = deserializeAws_restJson1ErrorMetadata(data.metadata, context);
861
+ }
862
+ exception = new UnauthorizedError(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
863
+ return [2, __decorateServiceException(exception, parsedOutput.body)];
864
+ });
865
+ }); };
866
+ var serializeAws_restJson1SendChatTopic = function (input, context) {
867
+ return SendChatTopic.visit(input, {
868
+ groupId: function (value) { return ({ "group_id": value }); },
869
+ identityId: function (value) { return ({ "identity_id": value }); },
870
+ partyId: function (value) { return ({ "party_id": value }); },
871
+ threadId: function (value) { return ({ "thread_id": value }); },
872
+ _: function (name, value) { return ({ name: value }); }
873
+ });
874
+ };
875
+ var serializeAws_restJson1SendMessageBody = function (input, context) {
876
+ return SendMessageBody.visit(input, {
877
+ partyInvite: function (value) { return ({ "party_invite": serializeAws_restJson1SendMessageBodyPartyInvite(value, context) }); },
878
+ text: function (value) { return ({ "text": serializeAws_restJson1SendMessageBodyText(value, context) }); },
879
+ _: function (name, value) { return ({ name: value }); }
880
+ });
881
+ };
882
+ var serializeAws_restJson1SendMessageBodyPartyInvite = function (input, context) {
883
+ return __assign({}, (input.token !== undefined && input.token !== null && { "token": input.token }));
884
+ };
885
+ var serializeAws_restJson1SendMessageBodyText = function (input, context) {
886
+ return __assign({}, (input.body !== undefined && input.body !== null && { "body": input.body }));
887
+ };
888
+ var serializeAws_restJson1ChatTypingStatus = function (input, context) {
889
+ return ChatTypingStatus.visit(input, {
890
+ idle: function (value) { return ({ "idle": serializeAws_restJson1Unit(value, context) }); },
891
+ typing: function (value) { return ({ "typing": serializeAws_restJson1Unit(value, context) }); },
892
+ _: function (name, value) { return ({ name: value }); }
893
+ });
894
+ };
895
+ var serializeAws_restJson1Unit = function (input, context) {
896
+ return {};
897
+ };
898
+ var deserializeAws_restJson1ChatIdentityTypingStatus = function (output, context) {
899
+ return {
900
+ identity: (output.identity !== undefined && output.identity !== null) ? deserializeAws_restJson1IdentityHandle(output.identity, context) : undefined,
901
+ status: (output.status !== undefined && output.status !== null) ? deserializeAws_restJson1ChatTypingStatus(__expectUnion(output.status), context) : undefined,
902
+ };
903
+ };
904
+ var deserializeAws_restJson1ChatIdentityTypingStatuses = function (output, context) {
905
+ var retVal = (output || []).filter(function (e) { return e != null; }).map(function (entry) {
906
+ if (entry === null) {
907
+ return null;
908
+ }
909
+ return deserializeAws_restJson1ChatIdentityTypingStatus(entry, context);
910
+ });
911
+ return retVal;
912
+ };
913
+ var deserializeAws_restJson1ChatMessage = function (output, context) {
914
+ return {
915
+ body: (output.body !== undefined && output.body !== null) ? deserializeAws_restJson1ChatMessageBody(__expectUnion(output.body), context) : undefined,
916
+ chatMessageId: __expectString(output.chat_message_id),
917
+ sendTs: (output.send_ts !== undefined && output.send_ts !== null) ? __expectNonNull(__parseRfc3339DateTime(output.send_ts)) : undefined,
918
+ threadId: __expectString(output.thread_id),
919
+ };
920
+ };
921
+ var deserializeAws_restJson1ChatMessageBody = function (output, context) {
922
+ if (output.chat_create !== undefined && output.chat_create !== null) {
923
+ return {
924
+ chatCreate: deserializeAws_restJson1ChatMessageBodyChatCreate(output.chat_create, context)
925
+ };
926
+ }
927
+ if (output.group_join !== undefined && output.group_join !== null) {
928
+ return {
929
+ groupJoin: deserializeAws_restJson1ChatMessageBodyGroupJoin(output.group_join, context)
930
+ };
931
+ }
932
+ if (output.group_leave !== undefined && output.group_leave !== null) {
933
+ return {
934
+ groupLeave: deserializeAws_restJson1ChatMessageBodyGroupLeave(output.group_leave, context)
935
+ };
936
+ }
937
+ if (output.identity_follow !== undefined && output.identity_follow !== null) {
938
+ return {
939
+ identityFollow: deserializeAws_restJson1ChatMessageBodyIdentityFollow(output.identity_follow, context)
940
+ };
941
+ }
942
+ if (output.party_activity_change !== undefined && output.party_activity_change !== null) {
943
+ return {
944
+ partyActivityChange: deserializeAws_restJson1ChatMessageBodyPartyActivityChange(output.party_activity_change, context)
945
+ };
946
+ }
947
+ if (output.party_invite !== undefined && output.party_invite !== null) {
948
+ return {
949
+ partyInvite: deserializeAws_restJson1ChatMessageBodyPartyInvite(output.party_invite, context)
950
+ };
951
+ }
952
+ if (output.party_join !== undefined && output.party_join !== null) {
953
+ return {
954
+ partyJoin: deserializeAws_restJson1ChatMessageBodyPartyJoin(output.party_join, context)
955
+ };
956
+ }
957
+ if (output.party_join_request !== undefined && output.party_join_request !== null) {
958
+ return {
959
+ partyJoinRequest: deserializeAws_restJson1ChatMessageBodyPartyJoinRequest(output.party_join_request, context)
960
+ };
961
+ }
962
+ if (output.party_leave !== undefined && output.party_leave !== null) {
963
+ return {
964
+ partyLeave: deserializeAws_restJson1ChatMessageBodyPartyLeave(output.party_leave, context)
965
+ };
966
+ }
967
+ if (output.text !== undefined && output.text !== null) {
968
+ return {
969
+ text: deserializeAws_restJson1ChatMessageBodyText(output.text, context)
970
+ };
971
+ }
972
+ return { $unknown: Object.entries(output)[0] };
973
+ };
974
+ var deserializeAws_restJson1ChatMessageBodyChatCreate = function (output, context) {
975
+ return {};
976
+ };
977
+ var deserializeAws_restJson1ChatMessageBodyGroupJoin = function (output, context) {
978
+ return {
979
+ identity: (output.identity !== undefined && output.identity !== null) ? deserializeAws_restJson1IdentityHandle(output.identity, context) : undefined,
980
+ };
981
+ };
982
+ var deserializeAws_restJson1ChatMessageBodyGroupLeave = function (output, context) {
983
+ return {
984
+ identity: (output.identity !== undefined && output.identity !== null) ? deserializeAws_restJson1IdentityHandle(output.identity, context) : undefined,
985
+ };
986
+ };
987
+ var deserializeAws_restJson1ChatMessageBodyIdentityFollow = function (output, context) {
988
+ return {};
989
+ };
990
+ var deserializeAws_restJson1ChatMessageBodyPartyActivityChange = function (output, context) {
991
+ return {};
992
+ };
993
+ var deserializeAws_restJson1ChatMessageBodyPartyInvite = function (output, context) {
994
+ return {
995
+ inviteToken: __expectString(output.invite_token),
996
+ party: (output.party !== undefined && output.party !== null) ? deserializeAws_restJson1PartyHandle(output.party, context) : undefined,
997
+ sender: (output.sender !== undefined && output.sender !== null) ? deserializeAws_restJson1IdentityHandle(output.sender, context) : undefined,
998
+ };
999
+ };
1000
+ var deserializeAws_restJson1ChatMessageBodyPartyJoin = function (output, context) {
1001
+ return {
1002
+ identity: (output.identity !== undefined && output.identity !== null) ? deserializeAws_restJson1IdentityHandle(output.identity, context) : undefined,
1003
+ };
1004
+ };
1005
+ var deserializeAws_restJson1ChatMessageBodyPartyJoinRequest = function (output, context) {
1006
+ return {
1007
+ sender: (output.sender !== undefined && output.sender !== null) ? deserializeAws_restJson1IdentityHandle(output.sender, context) : undefined,
1008
+ };
1009
+ };
1010
+ var deserializeAws_restJson1ChatMessageBodyPartyLeave = function (output, context) {
1011
+ return {
1012
+ identity: (output.identity !== undefined && output.identity !== null) ? deserializeAws_restJson1IdentityHandle(output.identity, context) : undefined,
1013
+ };
1014
+ };
1015
+ var deserializeAws_restJson1ChatMessageBodyText = function (output, context) {
1016
+ return {
1017
+ body: __expectString(output.body),
1018
+ sender: (output.sender !== undefined && output.sender !== null) ? deserializeAws_restJson1IdentityHandle(output.sender, context) : undefined,
1019
+ };
1020
+ };
1021
+ var deserializeAws_restJson1ChatMessages = function (output, context) {
1022
+ var retVal = (output || []).filter(function (e) { return e != null; }).map(function (entry) {
1023
+ if (entry === null) {
1024
+ return null;
1025
+ }
1026
+ return deserializeAws_restJson1ChatMessage(entry, context);
1027
+ });
1028
+ return retVal;
1029
+ };
1030
+ var deserializeAws_restJson1ChatSimpleTopic = function (output, context) {
1031
+ if (output.direct !== undefined && output.direct !== null) {
1032
+ return {
1033
+ direct: deserializeAws_restJson1ChatSimpleTopicDirect(output.direct, context)
1034
+ };
1035
+ }
1036
+ if (output.group !== undefined && output.group !== null) {
1037
+ return {
1038
+ group: deserializeAws_restJson1ChatSimpleTopicGroup(output.group, context)
1039
+ };
1040
+ }
1041
+ if (output.party !== undefined && output.party !== null) {
1042
+ return {
1043
+ party: deserializeAws_restJson1ChatSimpleTopicParty(output.party, context)
1044
+ };
1045
+ }
1046
+ return { $unknown: Object.entries(output)[0] };
1047
+ };
1048
+ var deserializeAws_restJson1ChatSimpleTopicDirect = function (output, context) {
1049
+ return {
1050
+ identityAId: __expectString(output.identity_a_id),
1051
+ identityBId: __expectString(output.identity_b_id),
1052
+ };
1053
+ };
1054
+ var deserializeAws_restJson1ChatSimpleTopicGroup = function (output, context) {
1055
+ return {
1056
+ groupId: __expectString(output.group_id),
1057
+ };
1058
+ };
1059
+ var deserializeAws_restJson1ChatSimpleTopicParty = function (output, context) {
1060
+ return {
1061
+ partyId: __expectString(output.party_id),
1062
+ };
1063
+ };
1064
+ var deserializeAws_restJson1ChatTypingStatus = function (output, context) {
1065
+ if (output.idle !== undefined && output.idle !== null) {
1066
+ return {
1067
+ idle: deserializeAws_restJson1Unit(output.idle, context)
1068
+ };
1069
+ }
1070
+ if (output.typing !== undefined && output.typing !== null) {
1071
+ return {
1072
+ typing: deserializeAws_restJson1Unit(output.typing, context)
1073
+ };
1074
+ }
1075
+ return { $unknown: Object.entries(output)[0] };
1076
+ };
1077
+ var deserializeAws_restJson1WatchResponse = function (output, context) {
1078
+ return {
1079
+ index: __expectString(output.index),
1080
+ };
1081
+ };
1082
+ var deserializeAws_restJson1ErrorMetadata = function (output, context) {
1083
+ return output;
1084
+ };
1085
+ var deserializeAws_restJson1GameHandle = function (output, context) {
1086
+ return {
1087
+ bannerUrl: __expectString(output.banner_url),
1088
+ displayName: __expectString(output.display_name),
1089
+ gameId: __expectString(output.game_id),
1090
+ logoUrl: __expectString(output.logo_url),
1091
+ nameId: __expectString(output.name_id),
1092
+ };
1093
+ };
1094
+ var deserializeAws_restJson1IdentityExternalLinks = function (output, context) {
1095
+ return {
1096
+ chat: __expectString(output.chat),
1097
+ profile: __expectString(output.profile),
1098
+ settings: __expectString(output.settings),
1099
+ };
1100
+ };
1101
+ var deserializeAws_restJson1IdentityGameActivity = function (output, context) {
1102
+ return {
1103
+ friendMetadata: (output.friend_metadata !== undefined && output.friend_metadata !== null) ? deserializeAws_restJson1Document(output.friend_metadata, context) : undefined,
1104
+ game: (output.game !== undefined && output.game !== null) ? deserializeAws_restJson1GameHandle(output.game, context) : undefined,
1105
+ message: __expectString(output.message),
1106
+ publicMetadata: (output.public_metadata !== undefined && output.public_metadata !== null) ? deserializeAws_restJson1Document(output.public_metadata, context) : undefined,
1107
+ };
1108
+ };
1109
+ var deserializeAws_restJson1IdentityHandle = function (output, context) {
1110
+ return {
1111
+ accountNumber: __expectInt32(output.account_number),
1112
+ avatarUrl: __expectString(output.avatar_url),
1113
+ displayName: __expectString(output.display_name),
1114
+ external: (output.external !== undefined && output.external !== null) ? deserializeAws_restJson1IdentityExternalLinks(output.external, context) : undefined,
1115
+ identityId: __expectString(output.identity_id),
1116
+ isRegistered: __expectBoolean(output.is_registered),
1117
+ party: (output.party !== undefined && output.party !== null) ? deserializeAws_restJson1PartyHandle(output.party, context) : undefined,
1118
+ presence: (output.presence !== undefined && output.presence !== null) ? deserializeAws_restJson1IdentityPresence(output.presence, context) : undefined,
1119
+ };
1120
+ };
1121
+ var deserializeAws_restJson1IdentityPresence = function (output, context) {
1122
+ return {
1123
+ gameActivity: (output.game_activity !== undefined && output.game_activity !== null) ? deserializeAws_restJson1IdentityGameActivity(output.game_activity, context) : undefined,
1124
+ status: __expectString(output.status),
1125
+ updateTs: (output.update_ts !== undefined && output.update_ts !== null) ? __expectNonNull(__parseRfc3339DateTime(output.update_ts)) : undefined,
1126
+ };
1127
+ };
1128
+ var deserializeAws_restJson1PartyActivity = function (output, context) {
1129
+ if (output.idle !== undefined && output.idle !== null) {
1130
+ return {
1131
+ idle: deserializeAws_restJson1PartyActivityIdle(output.idle, context)
1132
+ };
1133
+ }
1134
+ if (output.matchmaker_finding_lobby !== undefined && output.matchmaker_finding_lobby !== null) {
1135
+ return {
1136
+ matchmakerFindingLobby: deserializeAws_restJson1PartyActivityMatchmakerFindingLobby(output.matchmaker_finding_lobby, context)
1137
+ };
1138
+ }
1139
+ if (output.matchmaker_lobby !== undefined && output.matchmaker_lobby !== null) {
1140
+ return {
1141
+ matchmakerLobby: deserializeAws_restJson1PartyActivityMatchmakerLobby(output.matchmaker_lobby, context)
1142
+ };
1143
+ }
1144
+ return { $unknown: Object.entries(output)[0] };
1145
+ };
1146
+ var deserializeAws_restJson1PartyActivityIdle = function (output, context) {
1147
+ return {};
1148
+ };
1149
+ var deserializeAws_restJson1PartyActivityMatchmakerFindingLobby = function (output, context) {
1150
+ return {
1151
+ game: (output.game !== undefined && output.game !== null) ? deserializeAws_restJson1GameHandle(output.game, context) : undefined,
1152
+ };
1153
+ };
1154
+ var deserializeAws_restJson1PartyActivityMatchmakerLobby = function (output, context) {
1155
+ return {
1156
+ game: (output.game !== undefined && output.game !== null) ? deserializeAws_restJson1GameHandle(output.game, context) : undefined,
1157
+ lobby: (output.lobby !== undefined && output.lobby !== null) ? deserializeAws_restJson1PartyMatchmakerLobby(output.lobby, context) : undefined,
1158
+ };
1159
+ };
1160
+ var deserializeAws_restJson1PartyExternalLinks = function (output, context) {
1161
+ return {
1162
+ chat: __expectString(output.chat),
1163
+ };
1164
+ };
1165
+ var deserializeAws_restJson1PartyHandle = function (output, context) {
1166
+ return {
1167
+ activity: (output.activity !== undefined && output.activity !== null) ? deserializeAws_restJson1PartyActivity(__expectUnion(output.activity), context) : undefined,
1168
+ createTs: (output.create_ts !== undefined && output.create_ts !== null) ? __expectNonNull(__parseRfc3339DateTime(output.create_ts)) : undefined,
1169
+ external: (output.external !== undefined && output.external !== null) ? deserializeAws_restJson1PartyExternalLinks(output.external, context) : undefined,
1170
+ partyId: __expectString(output.party_id),
1171
+ };
1172
+ };
1173
+ var deserializeAws_restJson1PartyMatchmakerLobby = function (output, context) {
1174
+ return {
1175
+ lobbyId: __expectString(output.lobby_id),
1176
+ };
1177
+ };
1178
+ var deserializeAws_restJson1Document = function (output, context) {
1179
+ return output;
1180
+ };
1181
+ var deserializeAws_restJson1Unit = function (output, context) {
1182
+ return {};
1183
+ };
1184
+ var deserializeMetadata = function (output) {
1185
+ var _a;
1186
+ return ({
1187
+ httpStatusCode: output.statusCode,
1188
+ requestId: (_a = output.headers["x-amzn-requestid"]) !== null && _a !== void 0 ? _a : output.headers["x-amzn-request-id"],
1189
+ extendedRequestId: output.headers["x-amz-id-2"],
1190
+ cfId: output.headers["x-amz-cf-id"],
1191
+ });
1192
+ };
1193
+ var collectBody = function (streamBody, context) {
1194
+ if (streamBody === void 0) { streamBody = new Uint8Array(); }
1195
+ if (streamBody instanceof Uint8Array) {
1196
+ return Promise.resolve(streamBody);
1197
+ }
1198
+ return context.streamCollector(streamBody) || Promise.resolve(new Uint8Array());
1199
+ };
1200
+ var collectBodyString = function (streamBody, context) { return collectBody(streamBody, context).then(function (body) { return context.utf8Encoder(body); }); };
1201
+ var isSerializableHeaderValue = function (value) {
1202
+ return value !== undefined &&
1203
+ value !== null &&
1204
+ value !== "" &&
1205
+ (!Object.getOwnPropertyNames(value).includes("length") ||
1206
+ value.length != 0) &&
1207
+ (!Object.getOwnPropertyNames(value).includes("size") || value.size != 0);
1208
+ };
1209
+ var parseBody = function (streamBody, context) { return collectBodyString(streamBody, context).then(function (encoded) {
1210
+ if (encoded.length) {
1211
+ return JSON.parse(encoded);
1212
+ }
1213
+ return {};
1214
+ }); };
1215
+ var loadRestJsonErrorCode = function (output, data) {
1216
+ var findKey = function (object, key) { return Object.keys(object).find(function (k) { return k.toLowerCase() === key.toLowerCase(); }); };
1217
+ var sanitizeErrorCode = function (rawValue) {
1218
+ var cleanValue = rawValue;
1219
+ if (cleanValue.indexOf(":") >= 0) {
1220
+ cleanValue = cleanValue.split(":")[0];
1221
+ }
1222
+ if (cleanValue.indexOf("#") >= 0) {
1223
+ cleanValue = cleanValue.split("#")[1];
1224
+ }
1225
+ return cleanValue;
1226
+ };
1227
+ var headerKey = findKey(output.headers, "x-amzn-errortype");
1228
+ if (headerKey !== undefined) {
1229
+ return sanitizeErrorCode(output.headers[headerKey]);
1230
+ }
1231
+ if (data.code !== undefined) {
1232
+ return sanitizeErrorCode(data.code);
1233
+ }
1234
+ if (data["__type"] !== undefined) {
1235
+ return sanitizeErrorCode(data["__type"]);
1236
+ }
1237
+ return "";
1238
+ };