@aws-sdk/client-personalize-events 3.185.0 → 3.188.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,374 +1,296 @@
1
- import { __assign, __awaiter, __generator } from "tslib";
2
1
  import { HttpRequest as __HttpRequest } from "@aws-sdk/protocol-http";
3
2
  import { decorateServiceException as __decorateServiceException, expectString as __expectString, LazyJsonString as __LazyJsonString, map as __map, serializeFloat as __serializeFloat, throwDefaultError, } from "@aws-sdk/smithy-client";
4
3
  import { InvalidInputException, ResourceInUseException, ResourceNotFoundException, } from "../models/models_0";
5
4
  import { PersonalizeEventsServiceException as __BaseException } from "../models/PersonalizeEventsServiceException";
6
- export var serializeAws_restJson1PutEventsCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
7
- var _a, hostname, _b, protocol, port, basePath, headers, resolvedPath, body;
8
- return __generator(this, function (_c) {
9
- switch (_c.label) {
10
- case 0: return [4, context.endpoint()];
11
- case 1:
12
- _a = _c.sent(), hostname = _a.hostname, _b = _a.protocol, protocol = _b === void 0 ? "https" : _b, port = _a.port, basePath = _a.path;
13
- headers = {
14
- "content-type": "application/json",
15
- };
16
- resolvedPath = "".concat((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || "") + "/events";
17
- body = JSON.stringify(__assign(__assign(__assign(__assign({}, (input.eventList != null && { eventList: serializeAws_restJson1EventList(input.eventList, context) })), (input.sessionId != null && { sessionId: input.sessionId })), (input.trackingId != null && { trackingId: input.trackingId })), (input.userId != null && { userId: input.userId })));
18
- return [2, new __HttpRequest({
19
- protocol: protocol,
20
- hostname: hostname,
21
- port: port,
22
- method: "POST",
23
- headers: headers,
24
- path: resolvedPath,
25
- body: body,
26
- })];
27
- }
5
+ export const serializeAws_restJson1PutEventsCommand = async (input, context) => {
6
+ const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
7
+ const headers = {
8
+ "content-type": "application/json",
9
+ };
10
+ const resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/events";
11
+ let body;
12
+ body = JSON.stringify({
13
+ ...(input.eventList != null && { eventList: serializeAws_restJson1EventList(input.eventList, context) }),
14
+ ...(input.sessionId != null && { sessionId: input.sessionId }),
15
+ ...(input.trackingId != null && { trackingId: input.trackingId }),
16
+ ...(input.userId != null && { userId: input.userId }),
28
17
  });
29
- }); };
30
- export var serializeAws_restJson1PutItemsCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
31
- var _a, hostname, _b, protocol, port, basePath, headers, resolvedPath, body;
32
- return __generator(this, function (_c) {
33
- switch (_c.label) {
34
- case 0: return [4, context.endpoint()];
35
- case 1:
36
- _a = _c.sent(), hostname = _a.hostname, _b = _a.protocol, protocol = _b === void 0 ? "https" : _b, port = _a.port, basePath = _a.path;
37
- headers = {
38
- "content-type": "application/json",
39
- };
40
- resolvedPath = "".concat((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || "") + "/items";
41
- body = JSON.stringify(__assign(__assign({}, (input.datasetArn != null && { datasetArn: input.datasetArn })), (input.items != null && { items: serializeAws_restJson1ItemList(input.items, context) })));
42
- return [2, new __HttpRequest({
43
- protocol: protocol,
44
- hostname: hostname,
45
- port: port,
46
- method: "POST",
47
- headers: headers,
48
- path: resolvedPath,
49
- body: body,
50
- })];
51
- }
18
+ return new __HttpRequest({
19
+ protocol,
20
+ hostname,
21
+ port,
22
+ method: "POST",
23
+ headers,
24
+ path: resolvedPath,
25
+ body,
52
26
  });
53
- }); };
54
- export var serializeAws_restJson1PutUsersCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
55
- var _a, hostname, _b, protocol, port, basePath, headers, resolvedPath, body;
56
- return __generator(this, function (_c) {
57
- switch (_c.label) {
58
- case 0: return [4, context.endpoint()];
59
- case 1:
60
- _a = _c.sent(), hostname = _a.hostname, _b = _a.protocol, protocol = _b === void 0 ? "https" : _b, port = _a.port, basePath = _a.path;
61
- headers = {
62
- "content-type": "application/json",
63
- };
64
- resolvedPath = "".concat((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || "") + "/users";
65
- body = JSON.stringify(__assign(__assign({}, (input.datasetArn != null && { datasetArn: input.datasetArn })), (input.users != null && { users: serializeAws_restJson1UserList(input.users, context) })));
66
- return [2, new __HttpRequest({
67
- protocol: protocol,
68
- hostname: hostname,
69
- port: port,
70
- method: "POST",
71
- headers: headers,
72
- path: resolvedPath,
73
- body: body,
74
- })];
75
- }
27
+ };
28
+ export const serializeAws_restJson1PutItemsCommand = async (input, context) => {
29
+ const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
30
+ const headers = {
31
+ "content-type": "application/json",
32
+ };
33
+ const resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/items";
34
+ let body;
35
+ body = JSON.stringify({
36
+ ...(input.datasetArn != null && { datasetArn: input.datasetArn }),
37
+ ...(input.items != null && { items: serializeAws_restJson1ItemList(input.items, context) }),
76
38
  });
77
- }); };
78
- export var deserializeAws_restJson1PutEventsCommand = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
79
- var contents;
80
- return __generator(this, function (_a) {
81
- switch (_a.label) {
82
- case 0:
83
- if (output.statusCode !== 200 && output.statusCode >= 300) {
84
- return [2, deserializeAws_restJson1PutEventsCommandError(output, context)];
85
- }
86
- contents = map({
87
- $metadata: deserializeMetadata(output),
88
- });
89
- return [4, collectBody(output.body, context)];
90
- case 1:
91
- _a.sent();
92
- return [2, contents];
93
- }
39
+ return new __HttpRequest({
40
+ protocol,
41
+ hostname,
42
+ port,
43
+ method: "POST",
44
+ headers,
45
+ path: resolvedPath,
46
+ body,
94
47
  });
95
- }); };
96
- var deserializeAws_restJson1PutEventsCommandError = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
97
- var parsedOutput, _a, errorCode, _b, parsedBody;
98
- var _c;
99
- return __generator(this, function (_d) {
100
- switch (_d.label) {
101
- case 0:
102
- _a = [__assign({}, output)];
103
- _c = {};
104
- return [4, parseErrorBody(output.body, context)];
105
- case 1:
106
- parsedOutput = __assign.apply(void 0, _a.concat([(_c.body = _d.sent(), _c)]));
107
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
108
- _b = errorCode;
109
- switch (_b) {
110
- case "InvalidInputException": return [3, 2];
111
- case "com.amazonaws.personalizeevents#InvalidInputException": return [3, 2];
112
- }
113
- return [3, 4];
114
- case 2: return [4, deserializeAws_restJson1InvalidInputExceptionResponse(parsedOutput, context)];
115
- case 3: throw _d.sent();
116
- case 4:
117
- parsedBody = parsedOutput.body;
118
- throwDefaultError({
119
- output: output,
120
- parsedBody: parsedBody,
121
- exceptionCtor: __BaseException,
122
- errorCode: errorCode,
123
- });
124
- _d.label = 5;
125
- case 5: return [2];
126
- }
48
+ };
49
+ export const serializeAws_restJson1PutUsersCommand = async (input, context) => {
50
+ const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
51
+ const headers = {
52
+ "content-type": "application/json",
53
+ };
54
+ const resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/users";
55
+ let body;
56
+ body = JSON.stringify({
57
+ ...(input.datasetArn != null && { datasetArn: input.datasetArn }),
58
+ ...(input.users != null && { users: serializeAws_restJson1UserList(input.users, context) }),
127
59
  });
128
- }); };
129
- export var deserializeAws_restJson1PutItemsCommand = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
130
- var contents;
131
- return __generator(this, function (_a) {
132
- switch (_a.label) {
133
- case 0:
134
- if (output.statusCode !== 200 && output.statusCode >= 300) {
135
- return [2, deserializeAws_restJson1PutItemsCommandError(output, context)];
136
- }
137
- contents = map({
138
- $metadata: deserializeMetadata(output),
139
- });
140
- return [4, collectBody(output.body, context)];
141
- case 1:
142
- _a.sent();
143
- return [2, contents];
144
- }
60
+ return new __HttpRequest({
61
+ protocol,
62
+ hostname,
63
+ port,
64
+ method: "POST",
65
+ headers,
66
+ path: resolvedPath,
67
+ body,
145
68
  });
146
- }); };
147
- var deserializeAws_restJson1PutItemsCommandError = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
148
- var parsedOutput, _a, errorCode, _b, parsedBody;
149
- var _c;
150
- return __generator(this, function (_d) {
151
- switch (_d.label) {
152
- case 0:
153
- _a = [__assign({}, output)];
154
- _c = {};
155
- return [4, parseErrorBody(output.body, context)];
156
- case 1:
157
- parsedOutput = __assign.apply(void 0, _a.concat([(_c.body = _d.sent(), _c)]));
158
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
159
- _b = errorCode;
160
- switch (_b) {
161
- case "InvalidInputException": return [3, 2];
162
- case "com.amazonaws.personalizeevents#InvalidInputException": return [3, 2];
163
- case "ResourceInUseException": return [3, 4];
164
- case "com.amazonaws.personalizeevents#ResourceInUseException": return [3, 4];
165
- case "ResourceNotFoundException": return [3, 6];
166
- case "com.amazonaws.personalizeevents#ResourceNotFoundException": return [3, 6];
167
- }
168
- return [3, 8];
169
- case 2: return [4, deserializeAws_restJson1InvalidInputExceptionResponse(parsedOutput, context)];
170
- case 3: throw _d.sent();
171
- case 4: return [4, deserializeAws_restJson1ResourceInUseExceptionResponse(parsedOutput, context)];
172
- case 5: throw _d.sent();
173
- case 6: return [4, deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context)];
174
- case 7: throw _d.sent();
175
- case 8:
176
- parsedBody = parsedOutput.body;
177
- throwDefaultError({
178
- output: output,
179
- parsedBody: parsedBody,
180
- exceptionCtor: __BaseException,
181
- errorCode: errorCode,
182
- });
183
- _d.label = 9;
184
- case 9: return [2];
185
- }
69
+ };
70
+ export const deserializeAws_restJson1PutEventsCommand = async (output, context) => {
71
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
72
+ return deserializeAws_restJson1PutEventsCommandError(output, context);
73
+ }
74
+ const contents = map({
75
+ $metadata: deserializeMetadata(output),
186
76
  });
187
- }); };
188
- export var deserializeAws_restJson1PutUsersCommand = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
189
- var contents;
190
- return __generator(this, function (_a) {
191
- switch (_a.label) {
192
- case 0:
193
- if (output.statusCode !== 200 && output.statusCode >= 300) {
194
- return [2, deserializeAws_restJson1PutUsersCommandError(output, context)];
195
- }
196
- contents = map({
197
- $metadata: deserializeMetadata(output),
198
- });
199
- return [4, collectBody(output.body, context)];
200
- case 1:
201
- _a.sent();
202
- return [2, contents];
203
- }
77
+ await collectBody(output.body, context);
78
+ return contents;
79
+ };
80
+ const deserializeAws_restJson1PutEventsCommandError = async (output, context) => {
81
+ const parsedOutput = {
82
+ ...output,
83
+ body: await parseErrorBody(output.body, context),
84
+ };
85
+ const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
86
+ switch (errorCode) {
87
+ case "InvalidInputException":
88
+ case "com.amazonaws.personalizeevents#InvalidInputException":
89
+ throw await deserializeAws_restJson1InvalidInputExceptionResponse(parsedOutput, context);
90
+ default:
91
+ const parsedBody = parsedOutput.body;
92
+ throwDefaultError({
93
+ output,
94
+ parsedBody,
95
+ exceptionCtor: __BaseException,
96
+ errorCode,
97
+ });
98
+ }
99
+ };
100
+ export const deserializeAws_restJson1PutItemsCommand = async (output, context) => {
101
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
102
+ return deserializeAws_restJson1PutItemsCommandError(output, context);
103
+ }
104
+ const contents = map({
105
+ $metadata: deserializeMetadata(output),
204
106
  });
205
- }); };
206
- var deserializeAws_restJson1PutUsersCommandError = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
207
- var parsedOutput, _a, errorCode, _b, parsedBody;
208
- var _c;
209
- return __generator(this, function (_d) {
210
- switch (_d.label) {
211
- case 0:
212
- _a = [__assign({}, output)];
213
- _c = {};
214
- return [4, parseErrorBody(output.body, context)];
215
- case 1:
216
- parsedOutput = __assign.apply(void 0, _a.concat([(_c.body = _d.sent(), _c)]));
217
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
218
- _b = errorCode;
219
- switch (_b) {
220
- case "InvalidInputException": return [3, 2];
221
- case "com.amazonaws.personalizeevents#InvalidInputException": return [3, 2];
222
- case "ResourceInUseException": return [3, 4];
223
- case "com.amazonaws.personalizeevents#ResourceInUseException": return [3, 4];
224
- case "ResourceNotFoundException": return [3, 6];
225
- case "com.amazonaws.personalizeevents#ResourceNotFoundException": return [3, 6];
226
- }
227
- return [3, 8];
228
- case 2: return [4, deserializeAws_restJson1InvalidInputExceptionResponse(parsedOutput, context)];
229
- case 3: throw _d.sent();
230
- case 4: return [4, deserializeAws_restJson1ResourceInUseExceptionResponse(parsedOutput, context)];
231
- case 5: throw _d.sent();
232
- case 6: return [4, deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context)];
233
- case 7: throw _d.sent();
234
- case 8:
235
- parsedBody = parsedOutput.body;
236
- throwDefaultError({
237
- output: output,
238
- parsedBody: parsedBody,
239
- exceptionCtor: __BaseException,
240
- errorCode: errorCode,
241
- });
242
- _d.label = 9;
243
- case 9: return [2];
244
- }
107
+ await collectBody(output.body, context);
108
+ return contents;
109
+ };
110
+ const deserializeAws_restJson1PutItemsCommandError = async (output, context) => {
111
+ const parsedOutput = {
112
+ ...output,
113
+ body: await parseErrorBody(output.body, context),
114
+ };
115
+ const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
116
+ switch (errorCode) {
117
+ case "InvalidInputException":
118
+ case "com.amazonaws.personalizeevents#InvalidInputException":
119
+ throw await deserializeAws_restJson1InvalidInputExceptionResponse(parsedOutput, context);
120
+ case "ResourceInUseException":
121
+ case "com.amazonaws.personalizeevents#ResourceInUseException":
122
+ throw await deserializeAws_restJson1ResourceInUseExceptionResponse(parsedOutput, context);
123
+ case "ResourceNotFoundException":
124
+ case "com.amazonaws.personalizeevents#ResourceNotFoundException":
125
+ throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context);
126
+ default:
127
+ const parsedBody = parsedOutput.body;
128
+ throwDefaultError({
129
+ output,
130
+ parsedBody,
131
+ exceptionCtor: __BaseException,
132
+ errorCode,
133
+ });
134
+ }
135
+ };
136
+ export const deserializeAws_restJson1PutUsersCommand = async (output, context) => {
137
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
138
+ return deserializeAws_restJson1PutUsersCommandError(output, context);
139
+ }
140
+ const contents = map({
141
+ $metadata: deserializeMetadata(output),
245
142
  });
246
- }); };
247
- var map = __map;
248
- var deserializeAws_restJson1InvalidInputExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
249
- var contents, data, exception;
250
- return __generator(this, function (_a) {
251
- contents = map({});
252
- data = parsedOutput.body;
253
- if (data.message != null) {
254
- contents.message = __expectString(data.message);
255
- }
256
- exception = new InvalidInputException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
257
- return [2, __decorateServiceException(exception, parsedOutput.body)];
143
+ await collectBody(output.body, context);
144
+ return contents;
145
+ };
146
+ const deserializeAws_restJson1PutUsersCommandError = async (output, context) => {
147
+ const parsedOutput = {
148
+ ...output,
149
+ body: await parseErrorBody(output.body, context),
150
+ };
151
+ const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
152
+ switch (errorCode) {
153
+ case "InvalidInputException":
154
+ case "com.amazonaws.personalizeevents#InvalidInputException":
155
+ throw await deserializeAws_restJson1InvalidInputExceptionResponse(parsedOutput, context);
156
+ case "ResourceInUseException":
157
+ case "com.amazonaws.personalizeevents#ResourceInUseException":
158
+ throw await deserializeAws_restJson1ResourceInUseExceptionResponse(parsedOutput, context);
159
+ case "ResourceNotFoundException":
160
+ case "com.amazonaws.personalizeevents#ResourceNotFoundException":
161
+ throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context);
162
+ default:
163
+ const parsedBody = parsedOutput.body;
164
+ throwDefaultError({
165
+ output,
166
+ parsedBody,
167
+ exceptionCtor: __BaseException,
168
+ errorCode,
169
+ });
170
+ }
171
+ };
172
+ const map = __map;
173
+ const deserializeAws_restJson1InvalidInputExceptionResponse = async (parsedOutput, context) => {
174
+ const contents = map({});
175
+ const data = parsedOutput.body;
176
+ if (data.message != null) {
177
+ contents.message = __expectString(data.message);
178
+ }
179
+ const exception = new InvalidInputException({
180
+ $metadata: deserializeMetadata(parsedOutput),
181
+ ...contents,
258
182
  });
259
- }); };
260
- var deserializeAws_restJson1ResourceInUseExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
261
- var contents, data, exception;
262
- return __generator(this, function (_a) {
263
- contents = map({});
264
- data = parsedOutput.body;
265
- if (data.message != null) {
266
- contents.message = __expectString(data.message);
267
- }
268
- exception = new ResourceInUseException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
269
- return [2, __decorateServiceException(exception, parsedOutput.body)];
183
+ return __decorateServiceException(exception, parsedOutput.body);
184
+ };
185
+ const deserializeAws_restJson1ResourceInUseExceptionResponse = async (parsedOutput, context) => {
186
+ const contents = map({});
187
+ const data = parsedOutput.body;
188
+ if (data.message != null) {
189
+ contents.message = __expectString(data.message);
190
+ }
191
+ const exception = new ResourceInUseException({
192
+ $metadata: deserializeMetadata(parsedOutput),
193
+ ...contents,
270
194
  });
271
- }); };
272
- var deserializeAws_restJson1ResourceNotFoundExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
273
- var contents, data, exception;
274
- return __generator(this, function (_a) {
275
- contents = map({});
276
- data = parsedOutput.body;
277
- if (data.message != null) {
278
- contents.message = __expectString(data.message);
279
- }
280
- exception = new ResourceNotFoundException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
281
- return [2, __decorateServiceException(exception, parsedOutput.body)];
195
+ return __decorateServiceException(exception, parsedOutput.body);
196
+ };
197
+ const deserializeAws_restJson1ResourceNotFoundExceptionResponse = async (parsedOutput, context) => {
198
+ const contents = map({});
199
+ const data = parsedOutput.body;
200
+ if (data.message != null) {
201
+ contents.message = __expectString(data.message);
202
+ }
203
+ const exception = new ResourceNotFoundException({
204
+ $metadata: deserializeMetadata(parsedOutput),
205
+ ...contents,
282
206
  });
283
- }); };
284
- var serializeAws_restJson1Event = function (input, context) {
285
- return __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, (input.eventId != null && { eventId: input.eventId })), (input.eventType != null && { eventType: input.eventType })), (input.eventValue != null && { eventValue: __serializeFloat(input.eventValue) })), (input.impression != null && { impression: serializeAws_restJson1Impression(input.impression, context) })), (input.itemId != null && { itemId: input.itemId })), (input.properties != null && { properties: __LazyJsonString.fromObject(input.properties) })), (input.recommendationId != null && { recommendationId: input.recommendationId })), (input.sentAt != null && { sentAt: Math.round(input.sentAt.getTime() / 1000) }));
207
+ return __decorateServiceException(exception, parsedOutput.body);
286
208
  };
287
- var serializeAws_restJson1EventList = function (input, context) {
209
+ const serializeAws_restJson1Event = (input, context) => {
210
+ return {
211
+ ...(input.eventId != null && { eventId: input.eventId }),
212
+ ...(input.eventType != null && { eventType: input.eventType }),
213
+ ...(input.eventValue != null && { eventValue: __serializeFloat(input.eventValue) }),
214
+ ...(input.impression != null && { impression: serializeAws_restJson1Impression(input.impression, context) }),
215
+ ...(input.itemId != null && { itemId: input.itemId }),
216
+ ...(input.properties != null && { properties: __LazyJsonString.fromObject(input.properties) }),
217
+ ...(input.recommendationId != null && { recommendationId: input.recommendationId }),
218
+ ...(input.sentAt != null && { sentAt: Math.round(input.sentAt.getTime() / 1000) }),
219
+ };
220
+ };
221
+ const serializeAws_restJson1EventList = (input, context) => {
288
222
  return input
289
- .filter(function (e) { return e != null; })
290
- .map(function (entry) {
223
+ .filter((e) => e != null)
224
+ .map((entry) => {
291
225
  return serializeAws_restJson1Event(entry, context);
292
226
  });
293
227
  };
294
- var serializeAws_restJson1Impression = function (input, context) {
228
+ const serializeAws_restJson1Impression = (input, context) => {
295
229
  return input
296
- .filter(function (e) { return e != null; })
297
- .map(function (entry) {
230
+ .filter((e) => e != null)
231
+ .map((entry) => {
298
232
  return entry;
299
233
  });
300
234
  };
301
- var serializeAws_restJson1Item = function (input, context) {
302
- return __assign(__assign({}, (input.itemId != null && { itemId: input.itemId })), (input.properties != null && { properties: __LazyJsonString.fromObject(input.properties) }));
235
+ const serializeAws_restJson1Item = (input, context) => {
236
+ return {
237
+ ...(input.itemId != null && { itemId: input.itemId }),
238
+ ...(input.properties != null && { properties: __LazyJsonString.fromObject(input.properties) }),
239
+ };
303
240
  };
304
- var serializeAws_restJson1ItemList = function (input, context) {
241
+ const serializeAws_restJson1ItemList = (input, context) => {
305
242
  return input
306
- .filter(function (e) { return e != null; })
307
- .map(function (entry) {
243
+ .filter((e) => e != null)
244
+ .map((entry) => {
308
245
  return serializeAws_restJson1Item(entry, context);
309
246
  });
310
247
  };
311
- var serializeAws_restJson1User = function (input, context) {
312
- return __assign(__assign({}, (input.properties != null && { properties: __LazyJsonString.fromObject(input.properties) })), (input.userId != null && { userId: input.userId }));
248
+ const serializeAws_restJson1User = (input, context) => {
249
+ return {
250
+ ...(input.properties != null && { properties: __LazyJsonString.fromObject(input.properties) }),
251
+ ...(input.userId != null && { userId: input.userId }),
252
+ };
313
253
  };
314
- var serializeAws_restJson1UserList = function (input, context) {
254
+ const serializeAws_restJson1UserList = (input, context) => {
315
255
  return input
316
- .filter(function (e) { return e != null; })
317
- .map(function (entry) {
256
+ .filter((e) => e != null)
257
+ .map((entry) => {
318
258
  return serializeAws_restJson1User(entry, context);
319
259
  });
320
260
  };
321
- var deserializeMetadata = function (output) {
322
- var _a, _b;
323
- return ({
324
- httpStatusCode: output.statusCode,
325
- requestId: (_b = (_a = output.headers["x-amzn-requestid"]) !== null && _a !== void 0 ? _a : output.headers["x-amzn-request-id"]) !== null && _b !== void 0 ? _b : output.headers["x-amz-request-id"],
326
- extendedRequestId: output.headers["x-amz-id-2"],
327
- cfId: output.headers["x-amz-cf-id"],
328
- });
329
- };
330
- var collectBody = function (streamBody, context) {
331
- if (streamBody === void 0) { streamBody = new Uint8Array(); }
261
+ const deserializeMetadata = (output) => ({
262
+ httpStatusCode: output.statusCode,
263
+ requestId: output.headers["x-amzn-requestid"] ?? output.headers["x-amzn-request-id"] ?? output.headers["x-amz-request-id"],
264
+ extendedRequestId: output.headers["x-amz-id-2"],
265
+ cfId: output.headers["x-amz-cf-id"],
266
+ });
267
+ const collectBody = (streamBody = new Uint8Array(), context) => {
332
268
  if (streamBody instanceof Uint8Array) {
333
269
  return Promise.resolve(streamBody);
334
270
  }
335
271
  return context.streamCollector(streamBody) || Promise.resolve(new Uint8Array());
336
272
  };
337
- var collectBodyString = function (streamBody, context) {
338
- return collectBody(streamBody, context).then(function (body) { return context.utf8Encoder(body); });
339
- };
340
- var isSerializableHeaderValue = function (value) {
341
- return value !== undefined &&
342
- value !== null &&
343
- value !== "" &&
344
- (!Object.getOwnPropertyNames(value).includes("length") || value.length != 0) &&
345
- (!Object.getOwnPropertyNames(value).includes("size") || value.size != 0);
346
- };
347
- var parseBody = function (streamBody, context) {
348
- return collectBodyString(streamBody, context).then(function (encoded) {
349
- if (encoded.length) {
350
- return JSON.parse(encoded);
351
- }
352
- return {};
353
- });
273
+ const collectBodyString = (streamBody, context) => collectBody(streamBody, context).then((body) => context.utf8Encoder(body));
274
+ const isSerializableHeaderValue = (value) => value !== undefined &&
275
+ value !== null &&
276
+ value !== "" &&
277
+ (!Object.getOwnPropertyNames(value).includes("length") || value.length != 0) &&
278
+ (!Object.getOwnPropertyNames(value).includes("size") || value.size != 0);
279
+ const parseBody = (streamBody, context) => collectBodyString(streamBody, context).then((encoded) => {
280
+ if (encoded.length) {
281
+ return JSON.parse(encoded);
282
+ }
283
+ return {};
284
+ });
285
+ const parseErrorBody = async (errorBody, context) => {
286
+ const value = await parseBody(errorBody, context);
287
+ value.message = value.message ?? value.Message;
288
+ return value;
354
289
  };
355
- var parseErrorBody = function (errorBody, context) { return __awaiter(void 0, void 0, void 0, function () {
356
- var value;
357
- var _a;
358
- return __generator(this, function (_b) {
359
- switch (_b.label) {
360
- case 0: return [4, parseBody(errorBody, context)];
361
- case 1:
362
- value = _b.sent();
363
- value.message = (_a = value.message) !== null && _a !== void 0 ? _a : value.Message;
364
- return [2, value];
365
- }
366
- });
367
- }); };
368
- var loadRestJsonErrorCode = function (output, data) {
369
- var findKey = function (object, key) { return Object.keys(object).find(function (k) { return k.toLowerCase() === key.toLowerCase(); }); };
370
- var sanitizeErrorCode = function (rawValue) {
371
- var cleanValue = rawValue;
290
+ const loadRestJsonErrorCode = (output, data) => {
291
+ const findKey = (object, key) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase());
292
+ const sanitizeErrorCode = (rawValue) => {
293
+ let cleanValue = rawValue;
372
294
  if (typeof cleanValue === "number") {
373
295
  cleanValue = cleanValue.toString();
374
296
  }
@@ -383,7 +305,7 @@ var loadRestJsonErrorCode = function (output, data) {
383
305
  }
384
306
  return cleanValue;
385
307
  };
386
- var headerKey = findKey(output.headers, "x-amzn-errortype");
308
+ const headerKey = findKey(output.headers, "x-amzn-errortype");
387
309
  if (headerKey !== undefined) {
388
310
  return sanitizeErrorCode(output.headers[headerKey]);
389
311
  }