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