@aws-sdk/client-textract 3.33.0 → 3.36.1

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 (155) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/{dist/cjs → dist-cjs}/Textract.js +1 -7
  3. package/{dist/cjs → dist-cjs}/TextractClient.js +8 -19
  4. package/dist-cjs/commands/AnalyzeDocumentCommand.js +36 -0
  5. package/dist-cjs/commands/AnalyzeExpenseCommand.js +36 -0
  6. package/dist-cjs/commands/DetectDocumentTextCommand.js +36 -0
  7. package/dist-cjs/commands/GetDocumentAnalysisCommand.js +36 -0
  8. package/dist-cjs/commands/GetDocumentTextDetectionCommand.js +36 -0
  9. package/dist-cjs/commands/StartDocumentAnalysisCommand.js +36 -0
  10. package/dist-cjs/commands/StartDocumentTextDetectionCommand.js +36 -0
  11. package/{dist/cjs → dist-cjs}/endpoints.js +0 -1
  12. package/{dist/cjs → dist-cjs}/index.js +0 -1
  13. package/{dist/cjs → dist-cjs}/models/index.js +0 -1
  14. package/{dist/cjs → dist-cjs}/models/models_0.js +0 -148
  15. package/{dist/cjs → dist-cjs}/protocols/Aws_json1_1.js +0 -6
  16. package/{dist/cjs → dist-cjs}/runtimeConfig.browser.js +1 -5
  17. package/{dist/cjs → dist-cjs}/runtimeConfig.js +1 -5
  18. package/{dist/cjs → dist-cjs}/runtimeConfig.native.js +0 -4
  19. package/{dist/cjs → dist-cjs}/runtimeConfig.shared.js +1 -5
  20. package/{dist/es → dist-es}/Textract.js +2 -8
  21. package/{dist/es → dist-es}/TextractClient.js +2 -13
  22. package/dist-es/commands/AnalyzeDocumentCommand.js +39 -0
  23. package/{dist/es → dist-es}/commands/AnalyzeExpenseCommand.js +4 -43
  24. package/dist-es/commands/DetectDocumentTextCommand.js +39 -0
  25. package/dist-es/commands/GetDocumentAnalysisCommand.js +39 -0
  26. package/dist-es/commands/GetDocumentTextDetectionCommand.js +39 -0
  27. package/dist-es/commands/StartDocumentAnalysisCommand.js +39 -0
  28. package/dist-es/commands/StartDocumentTextDetectionCommand.js +39 -0
  29. package/{dist/es → dist-es}/endpoints.js +1 -2
  30. package/{dist/types/index.d.ts → dist-es/index.js} +0 -0
  31. package/{dist/types/models/index.d.ts → dist-es/models/index.js} +0 -0
  32. package/{dist/es → dist-es}/models/models_0.js +0 -148
  33. package/{dist/es → dist-es}/protocols/Aws_json1_1.js +338 -344
  34. package/{dist/es → dist-es}/runtimeConfig.browser.js +1 -5
  35. package/{dist/es → dist-es}/runtimeConfig.js +1 -5
  36. package/{dist/es → dist-es}/runtimeConfig.native.js +0 -4
  37. package/{dist/es → dist-es}/runtimeConfig.shared.js +1 -5
  38. package/{dist/types → dist-types}/Textract.d.ts +2 -2
  39. package/{dist/types → dist-types}/TextractClient.d.ts +8 -8
  40. package/{dist/types → dist-types}/commands/AnalyzeDocumentCommand.d.ts +3 -3
  41. package/{dist/types → dist-types}/commands/AnalyzeExpenseCommand.d.ts +3 -3
  42. package/{dist/types → dist-types}/commands/DetectDocumentTextCommand.d.ts +3 -3
  43. package/{dist/types → dist-types}/commands/GetDocumentAnalysisCommand.d.ts +3 -3
  44. package/{dist/types → dist-types}/commands/GetDocumentTextDetectionCommand.d.ts +3 -3
  45. package/{dist/types → dist-types}/commands/StartDocumentAnalysisCommand.d.ts +3 -3
  46. package/{dist/types → dist-types}/commands/StartDocumentTextDetectionCommand.d.ts +3 -3
  47. package/{dist/types → dist-types}/endpoints.d.ts +0 -0
  48. package/{index.ts → dist-types/index.d.ts} +0 -0
  49. package/{models/index.ts → dist-types/models/index.d.ts} +0 -0
  50. package/{dist/types → dist-types}/models/models_0.d.ts +0 -0
  51. package/{dist/types → dist-types}/protocols/Aws_json1_1.d.ts +2 -2
  52. package/{dist/types → dist-types}/runtimeConfig.browser.d.ts +0 -0
  53. package/{dist/types → dist-types}/runtimeConfig.d.ts +1 -1
  54. package/{dist/types → dist-types}/runtimeConfig.native.d.ts +0 -0
  55. package/{dist/types → dist-types}/runtimeConfig.shared.d.ts +0 -0
  56. package/dist-types/ts3.4/Textract.d.ts +40 -0
  57. package/{dist/types → dist-types}/ts3.4/TextractClient.d.ts +32 -99
  58. package/dist-types/ts3.4/commands/AnalyzeDocumentCommand.d.ts +17 -0
  59. package/dist-types/ts3.4/commands/AnalyzeExpenseCommand.d.ts +17 -0
  60. package/dist-types/ts3.4/commands/DetectDocumentTextCommand.d.ts +17 -0
  61. package/dist-types/ts3.4/commands/GetDocumentAnalysisCommand.d.ts +17 -0
  62. package/dist-types/ts3.4/commands/GetDocumentTextDetectionCommand.d.ts +17 -0
  63. package/dist-types/ts3.4/commands/StartDocumentAnalysisCommand.d.ts +17 -0
  64. package/dist-types/ts3.4/commands/StartDocumentTextDetectionCommand.d.ts +17 -0
  65. package/{dist/types → dist-types}/ts3.4/endpoints.d.ts +0 -0
  66. package/{dist/types → dist-types}/ts3.4/index.d.ts +0 -0
  67. package/{dist/types → dist-types}/ts3.4/models/index.d.ts +0 -0
  68. package/dist-types/ts3.4/models/models_0.d.ts +649 -0
  69. package/{dist/types → dist-types}/ts3.4/protocols/Aws_json1_1.d.ts +2 -2
  70. package/{dist/types → dist-types}/ts3.4/runtimeConfig.browser.d.ts +1 -3
  71. package/{dist/types → dist-types}/ts3.4/runtimeConfig.d.ts +2 -4
  72. package/{dist/types → dist-types}/ts3.4/runtimeConfig.native.d.ts +1 -3
  73. package/{dist/types → dist-types}/ts3.4/runtimeConfig.shared.d.ts +1 -3
  74. package/package.json +52 -49
  75. package/Textract.ts +0 -422
  76. package/TextractClient.ts +0 -270
  77. package/commands/AnalyzeDocumentCommand.ts +0 -124
  78. package/commands/AnalyzeExpenseCommand.ts +0 -107
  79. package/commands/DetectDocumentTextCommand.ts +0 -104
  80. package/commands/GetDocumentAnalysisCommand.ts +0 -138
  81. package/commands/GetDocumentTextDetectionCommand.ts +0 -118
  82. package/commands/StartDocumentAnalysisCommand.ts +0 -111
  83. package/commands/StartDocumentTextDetectionCommand.ts +0 -113
  84. package/dist/cjs/Textract.js.map +0 -1
  85. package/dist/cjs/TextractClient.js.map +0 -1
  86. package/dist/cjs/commands/AnalyzeDocumentCommand.js +0 -91
  87. package/dist/cjs/commands/AnalyzeDocumentCommand.js.map +0 -1
  88. package/dist/cjs/commands/AnalyzeExpenseCommand.js +0 -74
  89. package/dist/cjs/commands/AnalyzeExpenseCommand.js.map +0 -1
  90. package/dist/cjs/commands/DetectDocumentTextCommand.js +0 -71
  91. package/dist/cjs/commands/DetectDocumentTextCommand.js.map +0 -1
  92. package/dist/cjs/commands/GetDocumentAnalysisCommand.js +0 -105
  93. package/dist/cjs/commands/GetDocumentAnalysisCommand.js.map +0 -1
  94. package/dist/cjs/commands/GetDocumentTextDetectionCommand.js +0 -85
  95. package/dist/cjs/commands/GetDocumentTextDetectionCommand.js.map +0 -1
  96. package/dist/cjs/commands/StartDocumentAnalysisCommand.js +0 -78
  97. package/dist/cjs/commands/StartDocumentAnalysisCommand.js.map +0 -1
  98. package/dist/cjs/commands/StartDocumentTextDetectionCommand.js +0 -77
  99. package/dist/cjs/commands/StartDocumentTextDetectionCommand.js.map +0 -1
  100. package/dist/cjs/endpoints.js.map +0 -1
  101. package/dist/cjs/index.js.map +0 -1
  102. package/dist/cjs/models/index.js.map +0 -1
  103. package/dist/cjs/models/models_0.js.map +0 -1
  104. package/dist/cjs/package.json +0 -91
  105. package/dist/cjs/protocols/Aws_json1_1.js.map +0 -1
  106. package/dist/cjs/runtimeConfig.browser.js.map +0 -1
  107. package/dist/cjs/runtimeConfig.js.map +0 -1
  108. package/dist/cjs/runtimeConfig.native.js.map +0 -1
  109. package/dist/cjs/runtimeConfig.shared.js.map +0 -1
  110. package/dist/es/Textract.js.map +0 -1
  111. package/dist/es/TextractClient.js.map +0 -1
  112. package/dist/es/commands/AnalyzeDocumentCommand.js +0 -95
  113. package/dist/es/commands/AnalyzeDocumentCommand.js.map +0 -1
  114. package/dist/es/commands/AnalyzeExpenseCommand.js.map +0 -1
  115. package/dist/es/commands/DetectDocumentTextCommand.js +0 -75
  116. package/dist/es/commands/DetectDocumentTextCommand.js.map +0 -1
  117. package/dist/es/commands/GetDocumentAnalysisCommand.js +0 -109
  118. package/dist/es/commands/GetDocumentAnalysisCommand.js.map +0 -1
  119. package/dist/es/commands/GetDocumentTextDetectionCommand.js +0 -89
  120. package/dist/es/commands/GetDocumentTextDetectionCommand.js.map +0 -1
  121. package/dist/es/commands/StartDocumentAnalysisCommand.js +0 -82
  122. package/dist/es/commands/StartDocumentAnalysisCommand.js.map +0 -1
  123. package/dist/es/commands/StartDocumentTextDetectionCommand.js +0 -81
  124. package/dist/es/commands/StartDocumentTextDetectionCommand.js.map +0 -1
  125. package/dist/es/endpoints.js.map +0 -1
  126. package/dist/es/index.js +0 -11
  127. package/dist/es/index.js.map +0 -1
  128. package/dist/es/models/index.js +0 -2
  129. package/dist/es/models/index.js.map +0 -1
  130. package/dist/es/models/models_0.js.map +0 -1
  131. package/dist/es/package.json +0 -91
  132. package/dist/es/protocols/Aws_json1_1.js.map +0 -1
  133. package/dist/es/runtimeConfig.browser.js.map +0 -1
  134. package/dist/es/runtimeConfig.js.map +0 -1
  135. package/dist/es/runtimeConfig.native.js.map +0 -1
  136. package/dist/es/runtimeConfig.shared.js.map +0 -1
  137. package/dist/types/ts3.4/Textract.d.ts +0 -212
  138. package/dist/types/ts3.4/commands/AnalyzeDocumentCommand.d.ts +0 -65
  139. package/dist/types/ts3.4/commands/AnalyzeExpenseCommand.d.ts +0 -48
  140. package/dist/types/ts3.4/commands/DetectDocumentTextCommand.d.ts +0 -45
  141. package/dist/types/ts3.4/commands/GetDocumentAnalysisCommand.d.ts +0 -79
  142. package/dist/types/ts3.4/commands/GetDocumentTextDetectionCommand.d.ts +0 -59
  143. package/dist/types/ts3.4/commands/StartDocumentAnalysisCommand.d.ts +0 -52
  144. package/dist/types/ts3.4/commands/StartDocumentTextDetectionCommand.d.ts +0 -51
  145. package/dist/types/ts3.4/models/models_0.d.ts +0 -1347
  146. package/endpoints.ts +0 -57
  147. package/jest.config.js +0 -4
  148. package/models/models_0.ts +0 -1627
  149. package/protocols/Aws_json1_1.ts +0 -2060
  150. package/runtimeConfig.browser.ts +0 -40
  151. package/runtimeConfig.native.ts +0 -16
  152. package/runtimeConfig.shared.ts +0 -16
  153. package/runtimeConfig.ts +0 -45
  154. package/tsconfig.es.json +0 -12
  155. package/tsconfig.json +0 -32
@@ -1,2060 +0,0 @@
1
- import { AnalyzeDocumentCommandInput, AnalyzeDocumentCommandOutput } from "../commands/AnalyzeDocumentCommand";
2
- import { AnalyzeExpenseCommandInput, AnalyzeExpenseCommandOutput } from "../commands/AnalyzeExpenseCommand";
3
- import { DetectDocumentTextCommandInput, DetectDocumentTextCommandOutput } from "../commands/DetectDocumentTextCommand";
4
- import {
5
- GetDocumentAnalysisCommandInput,
6
- GetDocumentAnalysisCommandOutput,
7
- } from "../commands/GetDocumentAnalysisCommand";
8
- import {
9
- GetDocumentTextDetectionCommandInput,
10
- GetDocumentTextDetectionCommandOutput,
11
- } from "../commands/GetDocumentTextDetectionCommand";
12
- import {
13
- StartDocumentAnalysisCommandInput,
14
- StartDocumentAnalysisCommandOutput,
15
- } from "../commands/StartDocumentAnalysisCommand";
16
- import {
17
- StartDocumentTextDetectionCommandInput,
18
- StartDocumentTextDetectionCommandOutput,
19
- } from "../commands/StartDocumentTextDetectionCommand";
20
- import {
21
- AccessDeniedException,
22
- AnalyzeDocumentRequest,
23
- AnalyzeDocumentResponse,
24
- AnalyzeExpenseRequest,
25
- AnalyzeExpenseResponse,
26
- BadDocumentException,
27
- Block,
28
- BoundingBox,
29
- ContentClassifier,
30
- DetectDocumentTextRequest,
31
- DetectDocumentTextResponse,
32
- Document,
33
- DocumentLocation,
34
- DocumentMetadata,
35
- DocumentTooLargeException,
36
- EntityType,
37
- ExpenseDetection,
38
- ExpenseDocument,
39
- ExpenseField,
40
- ExpenseType,
41
- FeatureType,
42
- Geometry,
43
- GetDocumentAnalysisRequest,
44
- GetDocumentAnalysisResponse,
45
- GetDocumentTextDetectionRequest,
46
- GetDocumentTextDetectionResponse,
47
- HumanLoopActivationOutput,
48
- HumanLoopConfig,
49
- HumanLoopDataAttributes,
50
- HumanLoopQuotaExceededException,
51
- IdempotentParameterMismatchException,
52
- InternalServerError,
53
- InvalidJobIdException,
54
- InvalidKMSKeyException,
55
- InvalidParameterException,
56
- InvalidS3ObjectException,
57
- LimitExceededException,
58
- LineItemFields,
59
- LineItemGroup,
60
- NotificationChannel,
61
- OutputConfig,
62
- Point,
63
- ProvisionedThroughputExceededException,
64
- Relationship,
65
- S3Object,
66
- StartDocumentAnalysisRequest,
67
- StartDocumentAnalysisResponse,
68
- StartDocumentTextDetectionRequest,
69
- StartDocumentTextDetectionResponse,
70
- ThrottlingException,
71
- UnsupportedDocumentException,
72
- Warning,
73
- } from "../models/models_0";
74
- import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
75
- import {
76
- LazyJsonString as __LazyJsonString,
77
- expectInt32 as __expectInt32,
78
- expectString as __expectString,
79
- limitedParseFloat32 as __limitedParseFloat32,
80
- } from "@aws-sdk/smithy-client";
81
- import {
82
- Endpoint as __Endpoint,
83
- HeaderBag as __HeaderBag,
84
- MetadataBearer as __MetadataBearer,
85
- ResponseMetadata as __ResponseMetadata,
86
- SerdeContext as __SerdeContext,
87
- SmithyException as __SmithyException,
88
- } from "@aws-sdk/types";
89
-
90
- export const serializeAws_json1_1AnalyzeDocumentCommand = async (
91
- input: AnalyzeDocumentCommandInput,
92
- context: __SerdeContext
93
- ): Promise<__HttpRequest> => {
94
- const headers: __HeaderBag = {
95
- "content-type": "application/x-amz-json-1.1",
96
- "x-amz-target": "Textract.AnalyzeDocument",
97
- };
98
- let body: any;
99
- body = JSON.stringify(serializeAws_json1_1AnalyzeDocumentRequest(input, context));
100
- return buildHttpRpcRequest(context, headers, "/", undefined, body);
101
- };
102
-
103
- export const serializeAws_json1_1AnalyzeExpenseCommand = async (
104
- input: AnalyzeExpenseCommandInput,
105
- context: __SerdeContext
106
- ): Promise<__HttpRequest> => {
107
- const headers: __HeaderBag = {
108
- "content-type": "application/x-amz-json-1.1",
109
- "x-amz-target": "Textract.AnalyzeExpense",
110
- };
111
- let body: any;
112
- body = JSON.stringify(serializeAws_json1_1AnalyzeExpenseRequest(input, context));
113
- return buildHttpRpcRequest(context, headers, "/", undefined, body);
114
- };
115
-
116
- export const serializeAws_json1_1DetectDocumentTextCommand = async (
117
- input: DetectDocumentTextCommandInput,
118
- context: __SerdeContext
119
- ): Promise<__HttpRequest> => {
120
- const headers: __HeaderBag = {
121
- "content-type": "application/x-amz-json-1.1",
122
- "x-amz-target": "Textract.DetectDocumentText",
123
- };
124
- let body: any;
125
- body = JSON.stringify(serializeAws_json1_1DetectDocumentTextRequest(input, context));
126
- return buildHttpRpcRequest(context, headers, "/", undefined, body);
127
- };
128
-
129
- export const serializeAws_json1_1GetDocumentAnalysisCommand = async (
130
- input: GetDocumentAnalysisCommandInput,
131
- context: __SerdeContext
132
- ): Promise<__HttpRequest> => {
133
- const headers: __HeaderBag = {
134
- "content-type": "application/x-amz-json-1.1",
135
- "x-amz-target": "Textract.GetDocumentAnalysis",
136
- };
137
- let body: any;
138
- body = JSON.stringify(serializeAws_json1_1GetDocumentAnalysisRequest(input, context));
139
- return buildHttpRpcRequest(context, headers, "/", undefined, body);
140
- };
141
-
142
- export const serializeAws_json1_1GetDocumentTextDetectionCommand = async (
143
- input: GetDocumentTextDetectionCommandInput,
144
- context: __SerdeContext
145
- ): Promise<__HttpRequest> => {
146
- const headers: __HeaderBag = {
147
- "content-type": "application/x-amz-json-1.1",
148
- "x-amz-target": "Textract.GetDocumentTextDetection",
149
- };
150
- let body: any;
151
- body = JSON.stringify(serializeAws_json1_1GetDocumentTextDetectionRequest(input, context));
152
- return buildHttpRpcRequest(context, headers, "/", undefined, body);
153
- };
154
-
155
- export const serializeAws_json1_1StartDocumentAnalysisCommand = async (
156
- input: StartDocumentAnalysisCommandInput,
157
- context: __SerdeContext
158
- ): Promise<__HttpRequest> => {
159
- const headers: __HeaderBag = {
160
- "content-type": "application/x-amz-json-1.1",
161
- "x-amz-target": "Textract.StartDocumentAnalysis",
162
- };
163
- let body: any;
164
- body = JSON.stringify(serializeAws_json1_1StartDocumentAnalysisRequest(input, context));
165
- return buildHttpRpcRequest(context, headers, "/", undefined, body);
166
- };
167
-
168
- export const serializeAws_json1_1StartDocumentTextDetectionCommand = async (
169
- input: StartDocumentTextDetectionCommandInput,
170
- context: __SerdeContext
171
- ): Promise<__HttpRequest> => {
172
- const headers: __HeaderBag = {
173
- "content-type": "application/x-amz-json-1.1",
174
- "x-amz-target": "Textract.StartDocumentTextDetection",
175
- };
176
- let body: any;
177
- body = JSON.stringify(serializeAws_json1_1StartDocumentTextDetectionRequest(input, context));
178
- return buildHttpRpcRequest(context, headers, "/", undefined, body);
179
- };
180
-
181
- export const deserializeAws_json1_1AnalyzeDocumentCommand = async (
182
- output: __HttpResponse,
183
- context: __SerdeContext
184
- ): Promise<AnalyzeDocumentCommandOutput> => {
185
- if (output.statusCode >= 300) {
186
- return deserializeAws_json1_1AnalyzeDocumentCommandError(output, context);
187
- }
188
- const data: any = await parseBody(output.body, context);
189
- let contents: any = {};
190
- contents = deserializeAws_json1_1AnalyzeDocumentResponse(data, context);
191
- const response: AnalyzeDocumentCommandOutput = {
192
- $metadata: deserializeMetadata(output),
193
- ...contents,
194
- };
195
- return Promise.resolve(response);
196
- };
197
-
198
- const deserializeAws_json1_1AnalyzeDocumentCommandError = async (
199
- output: __HttpResponse,
200
- context: __SerdeContext
201
- ): Promise<AnalyzeDocumentCommandOutput> => {
202
- const parsedOutput: any = {
203
- ...output,
204
- body: await parseBody(output.body, context),
205
- };
206
- let response: __SmithyException & __MetadataBearer & { [key: string]: any };
207
- let errorCode: string = "UnknownError";
208
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
209
- switch (errorCode) {
210
- case "AccessDeniedException":
211
- case "com.amazonaws.textract#AccessDeniedException":
212
- response = {
213
- ...(await deserializeAws_json1_1AccessDeniedExceptionResponse(parsedOutput, context)),
214
- name: errorCode,
215
- $metadata: deserializeMetadata(output),
216
- };
217
- break;
218
- case "BadDocumentException":
219
- case "com.amazonaws.textract#BadDocumentException":
220
- response = {
221
- ...(await deserializeAws_json1_1BadDocumentExceptionResponse(parsedOutput, context)),
222
- name: errorCode,
223
- $metadata: deserializeMetadata(output),
224
- };
225
- break;
226
- case "DocumentTooLargeException":
227
- case "com.amazonaws.textract#DocumentTooLargeException":
228
- response = {
229
- ...(await deserializeAws_json1_1DocumentTooLargeExceptionResponse(parsedOutput, context)),
230
- name: errorCode,
231
- $metadata: deserializeMetadata(output),
232
- };
233
- break;
234
- case "HumanLoopQuotaExceededException":
235
- case "com.amazonaws.textract#HumanLoopQuotaExceededException":
236
- response = {
237
- ...(await deserializeAws_json1_1HumanLoopQuotaExceededExceptionResponse(parsedOutput, context)),
238
- name: errorCode,
239
- $metadata: deserializeMetadata(output),
240
- };
241
- break;
242
- case "InternalServerError":
243
- case "com.amazonaws.textract#InternalServerError":
244
- response = {
245
- ...(await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context)),
246
- name: errorCode,
247
- $metadata: deserializeMetadata(output),
248
- };
249
- break;
250
- case "InvalidParameterException":
251
- case "com.amazonaws.textract#InvalidParameterException":
252
- response = {
253
- ...(await deserializeAws_json1_1InvalidParameterExceptionResponse(parsedOutput, context)),
254
- name: errorCode,
255
- $metadata: deserializeMetadata(output),
256
- };
257
- break;
258
- case "InvalidS3ObjectException":
259
- case "com.amazonaws.textract#InvalidS3ObjectException":
260
- response = {
261
- ...(await deserializeAws_json1_1InvalidS3ObjectExceptionResponse(parsedOutput, context)),
262
- name: errorCode,
263
- $metadata: deserializeMetadata(output),
264
- };
265
- break;
266
- case "ProvisionedThroughputExceededException":
267
- case "com.amazonaws.textract#ProvisionedThroughputExceededException":
268
- response = {
269
- ...(await deserializeAws_json1_1ProvisionedThroughputExceededExceptionResponse(parsedOutput, context)),
270
- name: errorCode,
271
- $metadata: deserializeMetadata(output),
272
- };
273
- break;
274
- case "ThrottlingException":
275
- case "com.amazonaws.textract#ThrottlingException":
276
- response = {
277
- ...(await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context)),
278
- name: errorCode,
279
- $metadata: deserializeMetadata(output),
280
- };
281
- break;
282
- case "UnsupportedDocumentException":
283
- case "com.amazonaws.textract#UnsupportedDocumentException":
284
- response = {
285
- ...(await deserializeAws_json1_1UnsupportedDocumentExceptionResponse(parsedOutput, context)),
286
- name: errorCode,
287
- $metadata: deserializeMetadata(output),
288
- };
289
- break;
290
- default:
291
- const parsedBody = parsedOutput.body;
292
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
293
- response = {
294
- ...parsedBody,
295
- name: `${errorCode}`,
296
- message: parsedBody.message || parsedBody.Message || errorCode,
297
- $fault: "client",
298
- $metadata: deserializeMetadata(output),
299
- } as any;
300
- }
301
- const message = response.message || response.Message || errorCode;
302
- response.message = message;
303
- delete response.Message;
304
- return Promise.reject(Object.assign(new Error(message), response));
305
- };
306
-
307
- export const deserializeAws_json1_1AnalyzeExpenseCommand = async (
308
- output: __HttpResponse,
309
- context: __SerdeContext
310
- ): Promise<AnalyzeExpenseCommandOutput> => {
311
- if (output.statusCode >= 300) {
312
- return deserializeAws_json1_1AnalyzeExpenseCommandError(output, context);
313
- }
314
- const data: any = await parseBody(output.body, context);
315
- let contents: any = {};
316
- contents = deserializeAws_json1_1AnalyzeExpenseResponse(data, context);
317
- const response: AnalyzeExpenseCommandOutput = {
318
- $metadata: deserializeMetadata(output),
319
- ...contents,
320
- };
321
- return Promise.resolve(response);
322
- };
323
-
324
- const deserializeAws_json1_1AnalyzeExpenseCommandError = async (
325
- output: __HttpResponse,
326
- context: __SerdeContext
327
- ): Promise<AnalyzeExpenseCommandOutput> => {
328
- const parsedOutput: any = {
329
- ...output,
330
- body: await parseBody(output.body, context),
331
- };
332
- let response: __SmithyException & __MetadataBearer & { [key: string]: any };
333
- let errorCode: string = "UnknownError";
334
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
335
- switch (errorCode) {
336
- case "AccessDeniedException":
337
- case "com.amazonaws.textract#AccessDeniedException":
338
- response = {
339
- ...(await deserializeAws_json1_1AccessDeniedExceptionResponse(parsedOutput, context)),
340
- name: errorCode,
341
- $metadata: deserializeMetadata(output),
342
- };
343
- break;
344
- case "BadDocumentException":
345
- case "com.amazonaws.textract#BadDocumentException":
346
- response = {
347
- ...(await deserializeAws_json1_1BadDocumentExceptionResponse(parsedOutput, context)),
348
- name: errorCode,
349
- $metadata: deserializeMetadata(output),
350
- };
351
- break;
352
- case "DocumentTooLargeException":
353
- case "com.amazonaws.textract#DocumentTooLargeException":
354
- response = {
355
- ...(await deserializeAws_json1_1DocumentTooLargeExceptionResponse(parsedOutput, context)),
356
- name: errorCode,
357
- $metadata: deserializeMetadata(output),
358
- };
359
- break;
360
- case "InternalServerError":
361
- case "com.amazonaws.textract#InternalServerError":
362
- response = {
363
- ...(await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context)),
364
- name: errorCode,
365
- $metadata: deserializeMetadata(output),
366
- };
367
- break;
368
- case "InvalidParameterException":
369
- case "com.amazonaws.textract#InvalidParameterException":
370
- response = {
371
- ...(await deserializeAws_json1_1InvalidParameterExceptionResponse(parsedOutput, context)),
372
- name: errorCode,
373
- $metadata: deserializeMetadata(output),
374
- };
375
- break;
376
- case "InvalidS3ObjectException":
377
- case "com.amazonaws.textract#InvalidS3ObjectException":
378
- response = {
379
- ...(await deserializeAws_json1_1InvalidS3ObjectExceptionResponse(parsedOutput, context)),
380
- name: errorCode,
381
- $metadata: deserializeMetadata(output),
382
- };
383
- break;
384
- case "ProvisionedThroughputExceededException":
385
- case "com.amazonaws.textract#ProvisionedThroughputExceededException":
386
- response = {
387
- ...(await deserializeAws_json1_1ProvisionedThroughputExceededExceptionResponse(parsedOutput, context)),
388
- name: errorCode,
389
- $metadata: deserializeMetadata(output),
390
- };
391
- break;
392
- case "ThrottlingException":
393
- case "com.amazonaws.textract#ThrottlingException":
394
- response = {
395
- ...(await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context)),
396
- name: errorCode,
397
- $metadata: deserializeMetadata(output),
398
- };
399
- break;
400
- case "UnsupportedDocumentException":
401
- case "com.amazonaws.textract#UnsupportedDocumentException":
402
- response = {
403
- ...(await deserializeAws_json1_1UnsupportedDocumentExceptionResponse(parsedOutput, context)),
404
- name: errorCode,
405
- $metadata: deserializeMetadata(output),
406
- };
407
- break;
408
- default:
409
- const parsedBody = parsedOutput.body;
410
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
411
- response = {
412
- ...parsedBody,
413
- name: `${errorCode}`,
414
- message: parsedBody.message || parsedBody.Message || errorCode,
415
- $fault: "client",
416
- $metadata: deserializeMetadata(output),
417
- } as any;
418
- }
419
- const message = response.message || response.Message || errorCode;
420
- response.message = message;
421
- delete response.Message;
422
- return Promise.reject(Object.assign(new Error(message), response));
423
- };
424
-
425
- export const deserializeAws_json1_1DetectDocumentTextCommand = async (
426
- output: __HttpResponse,
427
- context: __SerdeContext
428
- ): Promise<DetectDocumentTextCommandOutput> => {
429
- if (output.statusCode >= 300) {
430
- return deserializeAws_json1_1DetectDocumentTextCommandError(output, context);
431
- }
432
- const data: any = await parseBody(output.body, context);
433
- let contents: any = {};
434
- contents = deserializeAws_json1_1DetectDocumentTextResponse(data, context);
435
- const response: DetectDocumentTextCommandOutput = {
436
- $metadata: deserializeMetadata(output),
437
- ...contents,
438
- };
439
- return Promise.resolve(response);
440
- };
441
-
442
- const deserializeAws_json1_1DetectDocumentTextCommandError = async (
443
- output: __HttpResponse,
444
- context: __SerdeContext
445
- ): Promise<DetectDocumentTextCommandOutput> => {
446
- const parsedOutput: any = {
447
- ...output,
448
- body: await parseBody(output.body, context),
449
- };
450
- let response: __SmithyException & __MetadataBearer & { [key: string]: any };
451
- let errorCode: string = "UnknownError";
452
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
453
- switch (errorCode) {
454
- case "AccessDeniedException":
455
- case "com.amazonaws.textract#AccessDeniedException":
456
- response = {
457
- ...(await deserializeAws_json1_1AccessDeniedExceptionResponse(parsedOutput, context)),
458
- name: errorCode,
459
- $metadata: deserializeMetadata(output),
460
- };
461
- break;
462
- case "BadDocumentException":
463
- case "com.amazonaws.textract#BadDocumentException":
464
- response = {
465
- ...(await deserializeAws_json1_1BadDocumentExceptionResponse(parsedOutput, context)),
466
- name: errorCode,
467
- $metadata: deserializeMetadata(output),
468
- };
469
- break;
470
- case "DocumentTooLargeException":
471
- case "com.amazonaws.textract#DocumentTooLargeException":
472
- response = {
473
- ...(await deserializeAws_json1_1DocumentTooLargeExceptionResponse(parsedOutput, context)),
474
- name: errorCode,
475
- $metadata: deserializeMetadata(output),
476
- };
477
- break;
478
- case "InternalServerError":
479
- case "com.amazonaws.textract#InternalServerError":
480
- response = {
481
- ...(await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context)),
482
- name: errorCode,
483
- $metadata: deserializeMetadata(output),
484
- };
485
- break;
486
- case "InvalidParameterException":
487
- case "com.amazonaws.textract#InvalidParameterException":
488
- response = {
489
- ...(await deserializeAws_json1_1InvalidParameterExceptionResponse(parsedOutput, context)),
490
- name: errorCode,
491
- $metadata: deserializeMetadata(output),
492
- };
493
- break;
494
- case "InvalidS3ObjectException":
495
- case "com.amazonaws.textract#InvalidS3ObjectException":
496
- response = {
497
- ...(await deserializeAws_json1_1InvalidS3ObjectExceptionResponse(parsedOutput, context)),
498
- name: errorCode,
499
- $metadata: deserializeMetadata(output),
500
- };
501
- break;
502
- case "ProvisionedThroughputExceededException":
503
- case "com.amazonaws.textract#ProvisionedThroughputExceededException":
504
- response = {
505
- ...(await deserializeAws_json1_1ProvisionedThroughputExceededExceptionResponse(parsedOutput, context)),
506
- name: errorCode,
507
- $metadata: deserializeMetadata(output),
508
- };
509
- break;
510
- case "ThrottlingException":
511
- case "com.amazonaws.textract#ThrottlingException":
512
- response = {
513
- ...(await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context)),
514
- name: errorCode,
515
- $metadata: deserializeMetadata(output),
516
- };
517
- break;
518
- case "UnsupportedDocumentException":
519
- case "com.amazonaws.textract#UnsupportedDocumentException":
520
- response = {
521
- ...(await deserializeAws_json1_1UnsupportedDocumentExceptionResponse(parsedOutput, context)),
522
- name: errorCode,
523
- $metadata: deserializeMetadata(output),
524
- };
525
- break;
526
- default:
527
- const parsedBody = parsedOutput.body;
528
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
529
- response = {
530
- ...parsedBody,
531
- name: `${errorCode}`,
532
- message: parsedBody.message || parsedBody.Message || errorCode,
533
- $fault: "client",
534
- $metadata: deserializeMetadata(output),
535
- } as any;
536
- }
537
- const message = response.message || response.Message || errorCode;
538
- response.message = message;
539
- delete response.Message;
540
- return Promise.reject(Object.assign(new Error(message), response));
541
- };
542
-
543
- export const deserializeAws_json1_1GetDocumentAnalysisCommand = async (
544
- output: __HttpResponse,
545
- context: __SerdeContext
546
- ): Promise<GetDocumentAnalysisCommandOutput> => {
547
- if (output.statusCode >= 300) {
548
- return deserializeAws_json1_1GetDocumentAnalysisCommandError(output, context);
549
- }
550
- const data: any = await parseBody(output.body, context);
551
- let contents: any = {};
552
- contents = deserializeAws_json1_1GetDocumentAnalysisResponse(data, context);
553
- const response: GetDocumentAnalysisCommandOutput = {
554
- $metadata: deserializeMetadata(output),
555
- ...contents,
556
- };
557
- return Promise.resolve(response);
558
- };
559
-
560
- const deserializeAws_json1_1GetDocumentAnalysisCommandError = async (
561
- output: __HttpResponse,
562
- context: __SerdeContext
563
- ): Promise<GetDocumentAnalysisCommandOutput> => {
564
- const parsedOutput: any = {
565
- ...output,
566
- body: await parseBody(output.body, context),
567
- };
568
- let response: __SmithyException & __MetadataBearer & { [key: string]: any };
569
- let errorCode: string = "UnknownError";
570
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
571
- switch (errorCode) {
572
- case "AccessDeniedException":
573
- case "com.amazonaws.textract#AccessDeniedException":
574
- response = {
575
- ...(await deserializeAws_json1_1AccessDeniedExceptionResponse(parsedOutput, context)),
576
- name: errorCode,
577
- $metadata: deserializeMetadata(output),
578
- };
579
- break;
580
- case "InternalServerError":
581
- case "com.amazonaws.textract#InternalServerError":
582
- response = {
583
- ...(await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context)),
584
- name: errorCode,
585
- $metadata: deserializeMetadata(output),
586
- };
587
- break;
588
- case "InvalidJobIdException":
589
- case "com.amazonaws.textract#InvalidJobIdException":
590
- response = {
591
- ...(await deserializeAws_json1_1InvalidJobIdExceptionResponse(parsedOutput, context)),
592
- name: errorCode,
593
- $metadata: deserializeMetadata(output),
594
- };
595
- break;
596
- case "InvalidKMSKeyException":
597
- case "com.amazonaws.textract#InvalidKMSKeyException":
598
- response = {
599
- ...(await deserializeAws_json1_1InvalidKMSKeyExceptionResponse(parsedOutput, context)),
600
- name: errorCode,
601
- $metadata: deserializeMetadata(output),
602
- };
603
- break;
604
- case "InvalidParameterException":
605
- case "com.amazonaws.textract#InvalidParameterException":
606
- response = {
607
- ...(await deserializeAws_json1_1InvalidParameterExceptionResponse(parsedOutput, context)),
608
- name: errorCode,
609
- $metadata: deserializeMetadata(output),
610
- };
611
- break;
612
- case "InvalidS3ObjectException":
613
- case "com.amazonaws.textract#InvalidS3ObjectException":
614
- response = {
615
- ...(await deserializeAws_json1_1InvalidS3ObjectExceptionResponse(parsedOutput, context)),
616
- name: errorCode,
617
- $metadata: deserializeMetadata(output),
618
- };
619
- break;
620
- case "ProvisionedThroughputExceededException":
621
- case "com.amazonaws.textract#ProvisionedThroughputExceededException":
622
- response = {
623
- ...(await deserializeAws_json1_1ProvisionedThroughputExceededExceptionResponse(parsedOutput, context)),
624
- name: errorCode,
625
- $metadata: deserializeMetadata(output),
626
- };
627
- break;
628
- case "ThrottlingException":
629
- case "com.amazonaws.textract#ThrottlingException":
630
- response = {
631
- ...(await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context)),
632
- name: errorCode,
633
- $metadata: deserializeMetadata(output),
634
- };
635
- break;
636
- default:
637
- const parsedBody = parsedOutput.body;
638
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
639
- response = {
640
- ...parsedBody,
641
- name: `${errorCode}`,
642
- message: parsedBody.message || parsedBody.Message || errorCode,
643
- $fault: "client",
644
- $metadata: deserializeMetadata(output),
645
- } as any;
646
- }
647
- const message = response.message || response.Message || errorCode;
648
- response.message = message;
649
- delete response.Message;
650
- return Promise.reject(Object.assign(new Error(message), response));
651
- };
652
-
653
- export const deserializeAws_json1_1GetDocumentTextDetectionCommand = async (
654
- output: __HttpResponse,
655
- context: __SerdeContext
656
- ): Promise<GetDocumentTextDetectionCommandOutput> => {
657
- if (output.statusCode >= 300) {
658
- return deserializeAws_json1_1GetDocumentTextDetectionCommandError(output, context);
659
- }
660
- const data: any = await parseBody(output.body, context);
661
- let contents: any = {};
662
- contents = deserializeAws_json1_1GetDocumentTextDetectionResponse(data, context);
663
- const response: GetDocumentTextDetectionCommandOutput = {
664
- $metadata: deserializeMetadata(output),
665
- ...contents,
666
- };
667
- return Promise.resolve(response);
668
- };
669
-
670
- const deserializeAws_json1_1GetDocumentTextDetectionCommandError = async (
671
- output: __HttpResponse,
672
- context: __SerdeContext
673
- ): Promise<GetDocumentTextDetectionCommandOutput> => {
674
- const parsedOutput: any = {
675
- ...output,
676
- body: await parseBody(output.body, context),
677
- };
678
- let response: __SmithyException & __MetadataBearer & { [key: string]: any };
679
- let errorCode: string = "UnknownError";
680
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
681
- switch (errorCode) {
682
- case "AccessDeniedException":
683
- case "com.amazonaws.textract#AccessDeniedException":
684
- response = {
685
- ...(await deserializeAws_json1_1AccessDeniedExceptionResponse(parsedOutput, context)),
686
- name: errorCode,
687
- $metadata: deserializeMetadata(output),
688
- };
689
- break;
690
- case "InternalServerError":
691
- case "com.amazonaws.textract#InternalServerError":
692
- response = {
693
- ...(await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context)),
694
- name: errorCode,
695
- $metadata: deserializeMetadata(output),
696
- };
697
- break;
698
- case "InvalidJobIdException":
699
- case "com.amazonaws.textract#InvalidJobIdException":
700
- response = {
701
- ...(await deserializeAws_json1_1InvalidJobIdExceptionResponse(parsedOutput, context)),
702
- name: errorCode,
703
- $metadata: deserializeMetadata(output),
704
- };
705
- break;
706
- case "InvalidKMSKeyException":
707
- case "com.amazonaws.textract#InvalidKMSKeyException":
708
- response = {
709
- ...(await deserializeAws_json1_1InvalidKMSKeyExceptionResponse(parsedOutput, context)),
710
- name: errorCode,
711
- $metadata: deserializeMetadata(output),
712
- };
713
- break;
714
- case "InvalidParameterException":
715
- case "com.amazonaws.textract#InvalidParameterException":
716
- response = {
717
- ...(await deserializeAws_json1_1InvalidParameterExceptionResponse(parsedOutput, context)),
718
- name: errorCode,
719
- $metadata: deserializeMetadata(output),
720
- };
721
- break;
722
- case "InvalidS3ObjectException":
723
- case "com.amazonaws.textract#InvalidS3ObjectException":
724
- response = {
725
- ...(await deserializeAws_json1_1InvalidS3ObjectExceptionResponse(parsedOutput, context)),
726
- name: errorCode,
727
- $metadata: deserializeMetadata(output),
728
- };
729
- break;
730
- case "ProvisionedThroughputExceededException":
731
- case "com.amazonaws.textract#ProvisionedThroughputExceededException":
732
- response = {
733
- ...(await deserializeAws_json1_1ProvisionedThroughputExceededExceptionResponse(parsedOutput, context)),
734
- name: errorCode,
735
- $metadata: deserializeMetadata(output),
736
- };
737
- break;
738
- case "ThrottlingException":
739
- case "com.amazonaws.textract#ThrottlingException":
740
- response = {
741
- ...(await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context)),
742
- name: errorCode,
743
- $metadata: deserializeMetadata(output),
744
- };
745
- break;
746
- default:
747
- const parsedBody = parsedOutput.body;
748
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
749
- response = {
750
- ...parsedBody,
751
- name: `${errorCode}`,
752
- message: parsedBody.message || parsedBody.Message || errorCode,
753
- $fault: "client",
754
- $metadata: deserializeMetadata(output),
755
- } as any;
756
- }
757
- const message = response.message || response.Message || errorCode;
758
- response.message = message;
759
- delete response.Message;
760
- return Promise.reject(Object.assign(new Error(message), response));
761
- };
762
-
763
- export const deserializeAws_json1_1StartDocumentAnalysisCommand = async (
764
- output: __HttpResponse,
765
- context: __SerdeContext
766
- ): Promise<StartDocumentAnalysisCommandOutput> => {
767
- if (output.statusCode >= 300) {
768
- return deserializeAws_json1_1StartDocumentAnalysisCommandError(output, context);
769
- }
770
- const data: any = await parseBody(output.body, context);
771
- let contents: any = {};
772
- contents = deserializeAws_json1_1StartDocumentAnalysisResponse(data, context);
773
- const response: StartDocumentAnalysisCommandOutput = {
774
- $metadata: deserializeMetadata(output),
775
- ...contents,
776
- };
777
- return Promise.resolve(response);
778
- };
779
-
780
- const deserializeAws_json1_1StartDocumentAnalysisCommandError = async (
781
- output: __HttpResponse,
782
- context: __SerdeContext
783
- ): Promise<StartDocumentAnalysisCommandOutput> => {
784
- const parsedOutput: any = {
785
- ...output,
786
- body: await parseBody(output.body, context),
787
- };
788
- let response: __SmithyException & __MetadataBearer & { [key: string]: any };
789
- let errorCode: string = "UnknownError";
790
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
791
- switch (errorCode) {
792
- case "AccessDeniedException":
793
- case "com.amazonaws.textract#AccessDeniedException":
794
- response = {
795
- ...(await deserializeAws_json1_1AccessDeniedExceptionResponse(parsedOutput, context)),
796
- name: errorCode,
797
- $metadata: deserializeMetadata(output),
798
- };
799
- break;
800
- case "BadDocumentException":
801
- case "com.amazonaws.textract#BadDocumentException":
802
- response = {
803
- ...(await deserializeAws_json1_1BadDocumentExceptionResponse(parsedOutput, context)),
804
- name: errorCode,
805
- $metadata: deserializeMetadata(output),
806
- };
807
- break;
808
- case "DocumentTooLargeException":
809
- case "com.amazonaws.textract#DocumentTooLargeException":
810
- response = {
811
- ...(await deserializeAws_json1_1DocumentTooLargeExceptionResponse(parsedOutput, context)),
812
- name: errorCode,
813
- $metadata: deserializeMetadata(output),
814
- };
815
- break;
816
- case "IdempotentParameterMismatchException":
817
- case "com.amazonaws.textract#IdempotentParameterMismatchException":
818
- response = {
819
- ...(await deserializeAws_json1_1IdempotentParameterMismatchExceptionResponse(parsedOutput, context)),
820
- name: errorCode,
821
- $metadata: deserializeMetadata(output),
822
- };
823
- break;
824
- case "InternalServerError":
825
- case "com.amazonaws.textract#InternalServerError":
826
- response = {
827
- ...(await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context)),
828
- name: errorCode,
829
- $metadata: deserializeMetadata(output),
830
- };
831
- break;
832
- case "InvalidKMSKeyException":
833
- case "com.amazonaws.textract#InvalidKMSKeyException":
834
- response = {
835
- ...(await deserializeAws_json1_1InvalidKMSKeyExceptionResponse(parsedOutput, context)),
836
- name: errorCode,
837
- $metadata: deserializeMetadata(output),
838
- };
839
- break;
840
- case "InvalidParameterException":
841
- case "com.amazonaws.textract#InvalidParameterException":
842
- response = {
843
- ...(await deserializeAws_json1_1InvalidParameterExceptionResponse(parsedOutput, context)),
844
- name: errorCode,
845
- $metadata: deserializeMetadata(output),
846
- };
847
- break;
848
- case "InvalidS3ObjectException":
849
- case "com.amazonaws.textract#InvalidS3ObjectException":
850
- response = {
851
- ...(await deserializeAws_json1_1InvalidS3ObjectExceptionResponse(parsedOutput, context)),
852
- name: errorCode,
853
- $metadata: deserializeMetadata(output),
854
- };
855
- break;
856
- case "LimitExceededException":
857
- case "com.amazonaws.textract#LimitExceededException":
858
- response = {
859
- ...(await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context)),
860
- name: errorCode,
861
- $metadata: deserializeMetadata(output),
862
- };
863
- break;
864
- case "ProvisionedThroughputExceededException":
865
- case "com.amazonaws.textract#ProvisionedThroughputExceededException":
866
- response = {
867
- ...(await deserializeAws_json1_1ProvisionedThroughputExceededExceptionResponse(parsedOutput, context)),
868
- name: errorCode,
869
- $metadata: deserializeMetadata(output),
870
- };
871
- break;
872
- case "ThrottlingException":
873
- case "com.amazonaws.textract#ThrottlingException":
874
- response = {
875
- ...(await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context)),
876
- name: errorCode,
877
- $metadata: deserializeMetadata(output),
878
- };
879
- break;
880
- case "UnsupportedDocumentException":
881
- case "com.amazonaws.textract#UnsupportedDocumentException":
882
- response = {
883
- ...(await deserializeAws_json1_1UnsupportedDocumentExceptionResponse(parsedOutput, context)),
884
- name: errorCode,
885
- $metadata: deserializeMetadata(output),
886
- };
887
- break;
888
- default:
889
- const parsedBody = parsedOutput.body;
890
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
891
- response = {
892
- ...parsedBody,
893
- name: `${errorCode}`,
894
- message: parsedBody.message || parsedBody.Message || errorCode,
895
- $fault: "client",
896
- $metadata: deserializeMetadata(output),
897
- } as any;
898
- }
899
- const message = response.message || response.Message || errorCode;
900
- response.message = message;
901
- delete response.Message;
902
- return Promise.reject(Object.assign(new Error(message), response));
903
- };
904
-
905
- export const deserializeAws_json1_1StartDocumentTextDetectionCommand = async (
906
- output: __HttpResponse,
907
- context: __SerdeContext
908
- ): Promise<StartDocumentTextDetectionCommandOutput> => {
909
- if (output.statusCode >= 300) {
910
- return deserializeAws_json1_1StartDocumentTextDetectionCommandError(output, context);
911
- }
912
- const data: any = await parseBody(output.body, context);
913
- let contents: any = {};
914
- contents = deserializeAws_json1_1StartDocumentTextDetectionResponse(data, context);
915
- const response: StartDocumentTextDetectionCommandOutput = {
916
- $metadata: deserializeMetadata(output),
917
- ...contents,
918
- };
919
- return Promise.resolve(response);
920
- };
921
-
922
- const deserializeAws_json1_1StartDocumentTextDetectionCommandError = async (
923
- output: __HttpResponse,
924
- context: __SerdeContext
925
- ): Promise<StartDocumentTextDetectionCommandOutput> => {
926
- const parsedOutput: any = {
927
- ...output,
928
- body: await parseBody(output.body, context),
929
- };
930
- let response: __SmithyException & __MetadataBearer & { [key: string]: any };
931
- let errorCode: string = "UnknownError";
932
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
933
- switch (errorCode) {
934
- case "AccessDeniedException":
935
- case "com.amazonaws.textract#AccessDeniedException":
936
- response = {
937
- ...(await deserializeAws_json1_1AccessDeniedExceptionResponse(parsedOutput, context)),
938
- name: errorCode,
939
- $metadata: deserializeMetadata(output),
940
- };
941
- break;
942
- case "BadDocumentException":
943
- case "com.amazonaws.textract#BadDocumentException":
944
- response = {
945
- ...(await deserializeAws_json1_1BadDocumentExceptionResponse(parsedOutput, context)),
946
- name: errorCode,
947
- $metadata: deserializeMetadata(output),
948
- };
949
- break;
950
- case "DocumentTooLargeException":
951
- case "com.amazonaws.textract#DocumentTooLargeException":
952
- response = {
953
- ...(await deserializeAws_json1_1DocumentTooLargeExceptionResponse(parsedOutput, context)),
954
- name: errorCode,
955
- $metadata: deserializeMetadata(output),
956
- };
957
- break;
958
- case "IdempotentParameterMismatchException":
959
- case "com.amazonaws.textract#IdempotentParameterMismatchException":
960
- response = {
961
- ...(await deserializeAws_json1_1IdempotentParameterMismatchExceptionResponse(parsedOutput, context)),
962
- name: errorCode,
963
- $metadata: deserializeMetadata(output),
964
- };
965
- break;
966
- case "InternalServerError":
967
- case "com.amazonaws.textract#InternalServerError":
968
- response = {
969
- ...(await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context)),
970
- name: errorCode,
971
- $metadata: deserializeMetadata(output),
972
- };
973
- break;
974
- case "InvalidKMSKeyException":
975
- case "com.amazonaws.textract#InvalidKMSKeyException":
976
- response = {
977
- ...(await deserializeAws_json1_1InvalidKMSKeyExceptionResponse(parsedOutput, context)),
978
- name: errorCode,
979
- $metadata: deserializeMetadata(output),
980
- };
981
- break;
982
- case "InvalidParameterException":
983
- case "com.amazonaws.textract#InvalidParameterException":
984
- response = {
985
- ...(await deserializeAws_json1_1InvalidParameterExceptionResponse(parsedOutput, context)),
986
- name: errorCode,
987
- $metadata: deserializeMetadata(output),
988
- };
989
- break;
990
- case "InvalidS3ObjectException":
991
- case "com.amazonaws.textract#InvalidS3ObjectException":
992
- response = {
993
- ...(await deserializeAws_json1_1InvalidS3ObjectExceptionResponse(parsedOutput, context)),
994
- name: errorCode,
995
- $metadata: deserializeMetadata(output),
996
- };
997
- break;
998
- case "LimitExceededException":
999
- case "com.amazonaws.textract#LimitExceededException":
1000
- response = {
1001
- ...(await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context)),
1002
- name: errorCode,
1003
- $metadata: deserializeMetadata(output),
1004
- };
1005
- break;
1006
- case "ProvisionedThroughputExceededException":
1007
- case "com.amazonaws.textract#ProvisionedThroughputExceededException":
1008
- response = {
1009
- ...(await deserializeAws_json1_1ProvisionedThroughputExceededExceptionResponse(parsedOutput, context)),
1010
- name: errorCode,
1011
- $metadata: deserializeMetadata(output),
1012
- };
1013
- break;
1014
- case "ThrottlingException":
1015
- case "com.amazonaws.textract#ThrottlingException":
1016
- response = {
1017
- ...(await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context)),
1018
- name: errorCode,
1019
- $metadata: deserializeMetadata(output),
1020
- };
1021
- break;
1022
- case "UnsupportedDocumentException":
1023
- case "com.amazonaws.textract#UnsupportedDocumentException":
1024
- response = {
1025
- ...(await deserializeAws_json1_1UnsupportedDocumentExceptionResponse(parsedOutput, context)),
1026
- name: errorCode,
1027
- $metadata: deserializeMetadata(output),
1028
- };
1029
- break;
1030
- default:
1031
- const parsedBody = parsedOutput.body;
1032
- errorCode = parsedBody.code || parsedBody.Code || errorCode;
1033
- response = {
1034
- ...parsedBody,
1035
- name: `${errorCode}`,
1036
- message: parsedBody.message || parsedBody.Message || errorCode,
1037
- $fault: "client",
1038
- $metadata: deserializeMetadata(output),
1039
- } as any;
1040
- }
1041
- const message = response.message || response.Message || errorCode;
1042
- response.message = message;
1043
- delete response.Message;
1044
- return Promise.reject(Object.assign(new Error(message), response));
1045
- };
1046
-
1047
- const deserializeAws_json1_1AccessDeniedExceptionResponse = async (
1048
- parsedOutput: any,
1049
- context: __SerdeContext
1050
- ): Promise<AccessDeniedException> => {
1051
- const body = parsedOutput.body;
1052
- const deserialized: any = deserializeAws_json1_1AccessDeniedException(body, context);
1053
- const contents: AccessDeniedException = {
1054
- name: "AccessDeniedException",
1055
- $fault: "client",
1056
- $metadata: deserializeMetadata(parsedOutput),
1057
- ...deserialized,
1058
- };
1059
- return contents;
1060
- };
1061
-
1062
- const deserializeAws_json1_1BadDocumentExceptionResponse = async (
1063
- parsedOutput: any,
1064
- context: __SerdeContext
1065
- ): Promise<BadDocumentException> => {
1066
- const body = parsedOutput.body;
1067
- const deserialized: any = deserializeAws_json1_1BadDocumentException(body, context);
1068
- const contents: BadDocumentException = {
1069
- name: "BadDocumentException",
1070
- $fault: "client",
1071
- $metadata: deserializeMetadata(parsedOutput),
1072
- ...deserialized,
1073
- };
1074
- return contents;
1075
- };
1076
-
1077
- const deserializeAws_json1_1DocumentTooLargeExceptionResponse = async (
1078
- parsedOutput: any,
1079
- context: __SerdeContext
1080
- ): Promise<DocumentTooLargeException> => {
1081
- const body = parsedOutput.body;
1082
- const deserialized: any = deserializeAws_json1_1DocumentTooLargeException(body, context);
1083
- const contents: DocumentTooLargeException = {
1084
- name: "DocumentTooLargeException",
1085
- $fault: "client",
1086
- $metadata: deserializeMetadata(parsedOutput),
1087
- ...deserialized,
1088
- };
1089
- return contents;
1090
- };
1091
-
1092
- const deserializeAws_json1_1HumanLoopQuotaExceededExceptionResponse = async (
1093
- parsedOutput: any,
1094
- context: __SerdeContext
1095
- ): Promise<HumanLoopQuotaExceededException> => {
1096
- const body = parsedOutput.body;
1097
- const deserialized: any = deserializeAws_json1_1HumanLoopQuotaExceededException(body, context);
1098
- const contents: HumanLoopQuotaExceededException = {
1099
- name: "HumanLoopQuotaExceededException",
1100
- $fault: "client",
1101
- $metadata: deserializeMetadata(parsedOutput),
1102
- ...deserialized,
1103
- };
1104
- return contents;
1105
- };
1106
-
1107
- const deserializeAws_json1_1IdempotentParameterMismatchExceptionResponse = async (
1108
- parsedOutput: any,
1109
- context: __SerdeContext
1110
- ): Promise<IdempotentParameterMismatchException> => {
1111
- const body = parsedOutput.body;
1112
- const deserialized: any = deserializeAws_json1_1IdempotentParameterMismatchException(body, context);
1113
- const contents: IdempotentParameterMismatchException = {
1114
- name: "IdempotentParameterMismatchException",
1115
- $fault: "client",
1116
- $metadata: deserializeMetadata(parsedOutput),
1117
- ...deserialized,
1118
- };
1119
- return contents;
1120
- };
1121
-
1122
- const deserializeAws_json1_1InternalServerErrorResponse = async (
1123
- parsedOutput: any,
1124
- context: __SerdeContext
1125
- ): Promise<InternalServerError> => {
1126
- const body = parsedOutput.body;
1127
- const deserialized: any = deserializeAws_json1_1InternalServerError(body, context);
1128
- const contents: InternalServerError = {
1129
- name: "InternalServerError",
1130
- $fault: "server",
1131
- $metadata: deserializeMetadata(parsedOutput),
1132
- ...deserialized,
1133
- };
1134
- return contents;
1135
- };
1136
-
1137
- const deserializeAws_json1_1InvalidJobIdExceptionResponse = async (
1138
- parsedOutput: any,
1139
- context: __SerdeContext
1140
- ): Promise<InvalidJobIdException> => {
1141
- const body = parsedOutput.body;
1142
- const deserialized: any = deserializeAws_json1_1InvalidJobIdException(body, context);
1143
- const contents: InvalidJobIdException = {
1144
- name: "InvalidJobIdException",
1145
- $fault: "client",
1146
- $metadata: deserializeMetadata(parsedOutput),
1147
- ...deserialized,
1148
- };
1149
- return contents;
1150
- };
1151
-
1152
- const deserializeAws_json1_1InvalidKMSKeyExceptionResponse = async (
1153
- parsedOutput: any,
1154
- context: __SerdeContext
1155
- ): Promise<InvalidKMSKeyException> => {
1156
- const body = parsedOutput.body;
1157
- const deserialized: any = deserializeAws_json1_1InvalidKMSKeyException(body, context);
1158
- const contents: InvalidKMSKeyException = {
1159
- name: "InvalidKMSKeyException",
1160
- $fault: "client",
1161
- $metadata: deserializeMetadata(parsedOutput),
1162
- ...deserialized,
1163
- };
1164
- return contents;
1165
- };
1166
-
1167
- const deserializeAws_json1_1InvalidParameterExceptionResponse = async (
1168
- parsedOutput: any,
1169
- context: __SerdeContext
1170
- ): Promise<InvalidParameterException> => {
1171
- const body = parsedOutput.body;
1172
- const deserialized: any = deserializeAws_json1_1InvalidParameterException(body, context);
1173
- const contents: InvalidParameterException = {
1174
- name: "InvalidParameterException",
1175
- $fault: "client",
1176
- $metadata: deserializeMetadata(parsedOutput),
1177
- ...deserialized,
1178
- };
1179
- return contents;
1180
- };
1181
-
1182
- const deserializeAws_json1_1InvalidS3ObjectExceptionResponse = async (
1183
- parsedOutput: any,
1184
- context: __SerdeContext
1185
- ): Promise<InvalidS3ObjectException> => {
1186
- const body = parsedOutput.body;
1187
- const deserialized: any = deserializeAws_json1_1InvalidS3ObjectException(body, context);
1188
- const contents: InvalidS3ObjectException = {
1189
- name: "InvalidS3ObjectException",
1190
- $fault: "client",
1191
- $metadata: deserializeMetadata(parsedOutput),
1192
- ...deserialized,
1193
- };
1194
- return contents;
1195
- };
1196
-
1197
- const deserializeAws_json1_1LimitExceededExceptionResponse = async (
1198
- parsedOutput: any,
1199
- context: __SerdeContext
1200
- ): Promise<LimitExceededException> => {
1201
- const body = parsedOutput.body;
1202
- const deserialized: any = deserializeAws_json1_1LimitExceededException(body, context);
1203
- const contents: LimitExceededException = {
1204
- name: "LimitExceededException",
1205
- $fault: "client",
1206
- $metadata: deserializeMetadata(parsedOutput),
1207
- ...deserialized,
1208
- };
1209
- return contents;
1210
- };
1211
-
1212
- const deserializeAws_json1_1ProvisionedThroughputExceededExceptionResponse = async (
1213
- parsedOutput: any,
1214
- context: __SerdeContext
1215
- ): Promise<ProvisionedThroughputExceededException> => {
1216
- const body = parsedOutput.body;
1217
- const deserialized: any = deserializeAws_json1_1ProvisionedThroughputExceededException(body, context);
1218
- const contents: ProvisionedThroughputExceededException = {
1219
- name: "ProvisionedThroughputExceededException",
1220
- $fault: "client",
1221
- $metadata: deserializeMetadata(parsedOutput),
1222
- ...deserialized,
1223
- };
1224
- return contents;
1225
- };
1226
-
1227
- const deserializeAws_json1_1ThrottlingExceptionResponse = async (
1228
- parsedOutput: any,
1229
- context: __SerdeContext
1230
- ): Promise<ThrottlingException> => {
1231
- const body = parsedOutput.body;
1232
- const deserialized: any = deserializeAws_json1_1ThrottlingException(body, context);
1233
- const contents: ThrottlingException = {
1234
- name: "ThrottlingException",
1235
- $fault: "server",
1236
- $metadata: deserializeMetadata(parsedOutput),
1237
- ...deserialized,
1238
- };
1239
- return contents;
1240
- };
1241
-
1242
- const deserializeAws_json1_1UnsupportedDocumentExceptionResponse = async (
1243
- parsedOutput: any,
1244
- context: __SerdeContext
1245
- ): Promise<UnsupportedDocumentException> => {
1246
- const body = parsedOutput.body;
1247
- const deserialized: any = deserializeAws_json1_1UnsupportedDocumentException(body, context);
1248
- const contents: UnsupportedDocumentException = {
1249
- name: "UnsupportedDocumentException",
1250
- $fault: "client",
1251
- $metadata: deserializeMetadata(parsedOutput),
1252
- ...deserialized,
1253
- };
1254
- return contents;
1255
- };
1256
-
1257
- const serializeAws_json1_1AnalyzeDocumentRequest = (input: AnalyzeDocumentRequest, context: __SerdeContext): any => {
1258
- return {
1259
- ...(input.Document !== undefined &&
1260
- input.Document !== null && { Document: serializeAws_json1_1Document(input.Document, context) }),
1261
- ...(input.FeatureTypes !== undefined &&
1262
- input.FeatureTypes !== null && { FeatureTypes: serializeAws_json1_1FeatureTypes(input.FeatureTypes, context) }),
1263
- ...(input.HumanLoopConfig !== undefined &&
1264
- input.HumanLoopConfig !== null && {
1265
- HumanLoopConfig: serializeAws_json1_1HumanLoopConfig(input.HumanLoopConfig, context),
1266
- }),
1267
- };
1268
- };
1269
-
1270
- const serializeAws_json1_1AnalyzeExpenseRequest = (input: AnalyzeExpenseRequest, context: __SerdeContext): any => {
1271
- return {
1272
- ...(input.Document !== undefined &&
1273
- input.Document !== null && { Document: serializeAws_json1_1Document(input.Document, context) }),
1274
- };
1275
- };
1276
-
1277
- const serializeAws_json1_1ContentClassifiers = (
1278
- input: (ContentClassifier | string)[],
1279
- context: __SerdeContext
1280
- ): any => {
1281
- return input
1282
- .filter((e: any) => e != null)
1283
- .map((entry) => {
1284
- if (entry === null) {
1285
- return null as any;
1286
- }
1287
- return entry;
1288
- });
1289
- };
1290
-
1291
- const serializeAws_json1_1DetectDocumentTextRequest = (
1292
- input: DetectDocumentTextRequest,
1293
- context: __SerdeContext
1294
- ): any => {
1295
- return {
1296
- ...(input.Document !== undefined &&
1297
- input.Document !== null && { Document: serializeAws_json1_1Document(input.Document, context) }),
1298
- };
1299
- };
1300
-
1301
- const serializeAws_json1_1Document = (input: Document, context: __SerdeContext): any => {
1302
- return {
1303
- ...(input.Bytes !== undefined && input.Bytes !== null && { Bytes: context.base64Encoder(input.Bytes) }),
1304
- ...(input.S3Object !== undefined &&
1305
- input.S3Object !== null && { S3Object: serializeAws_json1_1S3Object(input.S3Object, context) }),
1306
- };
1307
- };
1308
-
1309
- const serializeAws_json1_1DocumentLocation = (input: DocumentLocation, context: __SerdeContext): any => {
1310
- return {
1311
- ...(input.S3Object !== undefined &&
1312
- input.S3Object !== null && { S3Object: serializeAws_json1_1S3Object(input.S3Object, context) }),
1313
- };
1314
- };
1315
-
1316
- const serializeAws_json1_1FeatureTypes = (input: (FeatureType | string)[], context: __SerdeContext): any => {
1317
- return input
1318
- .filter((e: any) => e != null)
1319
- .map((entry) => {
1320
- if (entry === null) {
1321
- return null as any;
1322
- }
1323
- return entry;
1324
- });
1325
- };
1326
-
1327
- const serializeAws_json1_1GetDocumentAnalysisRequest = (
1328
- input: GetDocumentAnalysisRequest,
1329
- context: __SerdeContext
1330
- ): any => {
1331
- return {
1332
- ...(input.JobId !== undefined && input.JobId !== null && { JobId: input.JobId }),
1333
- ...(input.MaxResults !== undefined && input.MaxResults !== null && { MaxResults: input.MaxResults }),
1334
- ...(input.NextToken !== undefined && input.NextToken !== null && { NextToken: input.NextToken }),
1335
- };
1336
- };
1337
-
1338
- const serializeAws_json1_1GetDocumentTextDetectionRequest = (
1339
- input: GetDocumentTextDetectionRequest,
1340
- context: __SerdeContext
1341
- ): any => {
1342
- return {
1343
- ...(input.JobId !== undefined && input.JobId !== null && { JobId: input.JobId }),
1344
- ...(input.MaxResults !== undefined && input.MaxResults !== null && { MaxResults: input.MaxResults }),
1345
- ...(input.NextToken !== undefined && input.NextToken !== null && { NextToken: input.NextToken }),
1346
- };
1347
- };
1348
-
1349
- const serializeAws_json1_1HumanLoopConfig = (input: HumanLoopConfig, context: __SerdeContext): any => {
1350
- return {
1351
- ...(input.DataAttributes !== undefined &&
1352
- input.DataAttributes !== null && {
1353
- DataAttributes: serializeAws_json1_1HumanLoopDataAttributes(input.DataAttributes, context),
1354
- }),
1355
- ...(input.FlowDefinitionArn !== undefined &&
1356
- input.FlowDefinitionArn !== null && { FlowDefinitionArn: input.FlowDefinitionArn }),
1357
- ...(input.HumanLoopName !== undefined && input.HumanLoopName !== null && { HumanLoopName: input.HumanLoopName }),
1358
- };
1359
- };
1360
-
1361
- const serializeAws_json1_1HumanLoopDataAttributes = (input: HumanLoopDataAttributes, context: __SerdeContext): any => {
1362
- return {
1363
- ...(input.ContentClassifiers !== undefined &&
1364
- input.ContentClassifiers !== null && {
1365
- ContentClassifiers: serializeAws_json1_1ContentClassifiers(input.ContentClassifiers, context),
1366
- }),
1367
- };
1368
- };
1369
-
1370
- const serializeAws_json1_1NotificationChannel = (input: NotificationChannel, context: __SerdeContext): any => {
1371
- return {
1372
- ...(input.RoleArn !== undefined && input.RoleArn !== null && { RoleArn: input.RoleArn }),
1373
- ...(input.SNSTopicArn !== undefined && input.SNSTopicArn !== null && { SNSTopicArn: input.SNSTopicArn }),
1374
- };
1375
- };
1376
-
1377
- const serializeAws_json1_1OutputConfig = (input: OutputConfig, context: __SerdeContext): any => {
1378
- return {
1379
- ...(input.S3Bucket !== undefined && input.S3Bucket !== null && { S3Bucket: input.S3Bucket }),
1380
- ...(input.S3Prefix !== undefined && input.S3Prefix !== null && { S3Prefix: input.S3Prefix }),
1381
- };
1382
- };
1383
-
1384
- const serializeAws_json1_1S3Object = (input: S3Object, context: __SerdeContext): any => {
1385
- return {
1386
- ...(input.Bucket !== undefined && input.Bucket !== null && { Bucket: input.Bucket }),
1387
- ...(input.Name !== undefined && input.Name !== null && { Name: input.Name }),
1388
- ...(input.Version !== undefined && input.Version !== null && { Version: input.Version }),
1389
- };
1390
- };
1391
-
1392
- const serializeAws_json1_1StartDocumentAnalysisRequest = (
1393
- input: StartDocumentAnalysisRequest,
1394
- context: __SerdeContext
1395
- ): any => {
1396
- return {
1397
- ...(input.ClientRequestToken !== undefined &&
1398
- input.ClientRequestToken !== null && { ClientRequestToken: input.ClientRequestToken }),
1399
- ...(input.DocumentLocation !== undefined &&
1400
- input.DocumentLocation !== null && {
1401
- DocumentLocation: serializeAws_json1_1DocumentLocation(input.DocumentLocation, context),
1402
- }),
1403
- ...(input.FeatureTypes !== undefined &&
1404
- input.FeatureTypes !== null && { FeatureTypes: serializeAws_json1_1FeatureTypes(input.FeatureTypes, context) }),
1405
- ...(input.JobTag !== undefined && input.JobTag !== null && { JobTag: input.JobTag }),
1406
- ...(input.KMSKeyId !== undefined && input.KMSKeyId !== null && { KMSKeyId: input.KMSKeyId }),
1407
- ...(input.NotificationChannel !== undefined &&
1408
- input.NotificationChannel !== null && {
1409
- NotificationChannel: serializeAws_json1_1NotificationChannel(input.NotificationChannel, context),
1410
- }),
1411
- ...(input.OutputConfig !== undefined &&
1412
- input.OutputConfig !== null && { OutputConfig: serializeAws_json1_1OutputConfig(input.OutputConfig, context) }),
1413
- };
1414
- };
1415
-
1416
- const serializeAws_json1_1StartDocumentTextDetectionRequest = (
1417
- input: StartDocumentTextDetectionRequest,
1418
- context: __SerdeContext
1419
- ): any => {
1420
- return {
1421
- ...(input.ClientRequestToken !== undefined &&
1422
- input.ClientRequestToken !== null && { ClientRequestToken: input.ClientRequestToken }),
1423
- ...(input.DocumentLocation !== undefined &&
1424
- input.DocumentLocation !== null && {
1425
- DocumentLocation: serializeAws_json1_1DocumentLocation(input.DocumentLocation, context),
1426
- }),
1427
- ...(input.JobTag !== undefined && input.JobTag !== null && { JobTag: input.JobTag }),
1428
- ...(input.KMSKeyId !== undefined && input.KMSKeyId !== null && { KMSKeyId: input.KMSKeyId }),
1429
- ...(input.NotificationChannel !== undefined &&
1430
- input.NotificationChannel !== null && {
1431
- NotificationChannel: serializeAws_json1_1NotificationChannel(input.NotificationChannel, context),
1432
- }),
1433
- ...(input.OutputConfig !== undefined &&
1434
- input.OutputConfig !== null && { OutputConfig: serializeAws_json1_1OutputConfig(input.OutputConfig, context) }),
1435
- };
1436
- };
1437
-
1438
- const deserializeAws_json1_1AccessDeniedException = (output: any, context: __SerdeContext): AccessDeniedException => {
1439
- return {
1440
- Code: __expectString(output.Code),
1441
- Message: __expectString(output.Message),
1442
- } as any;
1443
- };
1444
-
1445
- const deserializeAws_json1_1AnalyzeDocumentResponse = (
1446
- output: any,
1447
- context: __SerdeContext
1448
- ): AnalyzeDocumentResponse => {
1449
- return {
1450
- AnalyzeDocumentModelVersion: __expectString(output.AnalyzeDocumentModelVersion),
1451
- Blocks:
1452
- output.Blocks !== undefined && output.Blocks !== null
1453
- ? deserializeAws_json1_1BlockList(output.Blocks, context)
1454
- : undefined,
1455
- DocumentMetadata:
1456
- output.DocumentMetadata !== undefined && output.DocumentMetadata !== null
1457
- ? deserializeAws_json1_1DocumentMetadata(output.DocumentMetadata, context)
1458
- : undefined,
1459
- HumanLoopActivationOutput:
1460
- output.HumanLoopActivationOutput !== undefined && output.HumanLoopActivationOutput !== null
1461
- ? deserializeAws_json1_1HumanLoopActivationOutput(output.HumanLoopActivationOutput, context)
1462
- : undefined,
1463
- } as any;
1464
- };
1465
-
1466
- const deserializeAws_json1_1AnalyzeExpenseResponse = (output: any, context: __SerdeContext): AnalyzeExpenseResponse => {
1467
- return {
1468
- DocumentMetadata:
1469
- output.DocumentMetadata !== undefined && output.DocumentMetadata !== null
1470
- ? deserializeAws_json1_1DocumentMetadata(output.DocumentMetadata, context)
1471
- : undefined,
1472
- ExpenseDocuments:
1473
- output.ExpenseDocuments !== undefined && output.ExpenseDocuments !== null
1474
- ? deserializeAws_json1_1ExpenseDocumentList(output.ExpenseDocuments, context)
1475
- : undefined,
1476
- } as any;
1477
- };
1478
-
1479
- const deserializeAws_json1_1BadDocumentException = (output: any, context: __SerdeContext): BadDocumentException => {
1480
- return {
1481
- Code: __expectString(output.Code),
1482
- Message: __expectString(output.Message),
1483
- } as any;
1484
- };
1485
-
1486
- const deserializeAws_json1_1Block = (output: any, context: __SerdeContext): Block => {
1487
- return {
1488
- BlockType: __expectString(output.BlockType),
1489
- ColumnIndex: __expectInt32(output.ColumnIndex),
1490
- ColumnSpan: __expectInt32(output.ColumnSpan),
1491
- Confidence: __limitedParseFloat32(output.Confidence),
1492
- EntityTypes:
1493
- output.EntityTypes !== undefined && output.EntityTypes !== null
1494
- ? deserializeAws_json1_1EntityTypes(output.EntityTypes, context)
1495
- : undefined,
1496
- Geometry:
1497
- output.Geometry !== undefined && output.Geometry !== null
1498
- ? deserializeAws_json1_1Geometry(output.Geometry, context)
1499
- : undefined,
1500
- Id: __expectString(output.Id),
1501
- Page: __expectInt32(output.Page),
1502
- Relationships:
1503
- output.Relationships !== undefined && output.Relationships !== null
1504
- ? deserializeAws_json1_1RelationshipList(output.Relationships, context)
1505
- : undefined,
1506
- RowIndex: __expectInt32(output.RowIndex),
1507
- RowSpan: __expectInt32(output.RowSpan),
1508
- SelectionStatus: __expectString(output.SelectionStatus),
1509
- Text: __expectString(output.Text),
1510
- TextType: __expectString(output.TextType),
1511
- } as any;
1512
- };
1513
-
1514
- const deserializeAws_json1_1BlockList = (output: any, context: __SerdeContext): Block[] => {
1515
- return (output || [])
1516
- .filter((e: any) => e != null)
1517
- .map((entry: any) => {
1518
- if (entry === null) {
1519
- return null as any;
1520
- }
1521
- return deserializeAws_json1_1Block(entry, context);
1522
- });
1523
- };
1524
-
1525
- const deserializeAws_json1_1BoundingBox = (output: any, context: __SerdeContext): BoundingBox => {
1526
- return {
1527
- Height: __limitedParseFloat32(output.Height),
1528
- Left: __limitedParseFloat32(output.Left),
1529
- Top: __limitedParseFloat32(output.Top),
1530
- Width: __limitedParseFloat32(output.Width),
1531
- } as any;
1532
- };
1533
-
1534
- const deserializeAws_json1_1DetectDocumentTextResponse = (
1535
- output: any,
1536
- context: __SerdeContext
1537
- ): DetectDocumentTextResponse => {
1538
- return {
1539
- Blocks:
1540
- output.Blocks !== undefined && output.Blocks !== null
1541
- ? deserializeAws_json1_1BlockList(output.Blocks, context)
1542
- : undefined,
1543
- DetectDocumentTextModelVersion: __expectString(output.DetectDocumentTextModelVersion),
1544
- DocumentMetadata:
1545
- output.DocumentMetadata !== undefined && output.DocumentMetadata !== null
1546
- ? deserializeAws_json1_1DocumentMetadata(output.DocumentMetadata, context)
1547
- : undefined,
1548
- } as any;
1549
- };
1550
-
1551
- const deserializeAws_json1_1DocumentMetadata = (output: any, context: __SerdeContext): DocumentMetadata => {
1552
- return {
1553
- Pages: __expectInt32(output.Pages),
1554
- } as any;
1555
- };
1556
-
1557
- const deserializeAws_json1_1DocumentTooLargeException = (
1558
- output: any,
1559
- context: __SerdeContext
1560
- ): DocumentTooLargeException => {
1561
- return {
1562
- Code: __expectString(output.Code),
1563
- Message: __expectString(output.Message),
1564
- } as any;
1565
- };
1566
-
1567
- const deserializeAws_json1_1EntityTypes = (output: any, context: __SerdeContext): (EntityType | string)[] => {
1568
- return (output || [])
1569
- .filter((e: any) => e != null)
1570
- .map((entry: any) => {
1571
- if (entry === null) {
1572
- return null as any;
1573
- }
1574
- return __expectString(entry) as any;
1575
- });
1576
- };
1577
-
1578
- const deserializeAws_json1_1ExpenseDetection = (output: any, context: __SerdeContext): ExpenseDetection => {
1579
- return {
1580
- Confidence: __limitedParseFloat32(output.Confidence),
1581
- Geometry:
1582
- output.Geometry !== undefined && output.Geometry !== null
1583
- ? deserializeAws_json1_1Geometry(output.Geometry, context)
1584
- : undefined,
1585
- Text: __expectString(output.Text),
1586
- } as any;
1587
- };
1588
-
1589
- const deserializeAws_json1_1ExpenseDocument = (output: any, context: __SerdeContext): ExpenseDocument => {
1590
- return {
1591
- ExpenseIndex: __expectInt32(output.ExpenseIndex),
1592
- LineItemGroups:
1593
- output.LineItemGroups !== undefined && output.LineItemGroups !== null
1594
- ? deserializeAws_json1_1LineItemGroupList(output.LineItemGroups, context)
1595
- : undefined,
1596
- SummaryFields:
1597
- output.SummaryFields !== undefined && output.SummaryFields !== null
1598
- ? deserializeAws_json1_1ExpenseFieldList(output.SummaryFields, context)
1599
- : undefined,
1600
- } as any;
1601
- };
1602
-
1603
- const deserializeAws_json1_1ExpenseDocumentList = (output: any, context: __SerdeContext): ExpenseDocument[] => {
1604
- return (output || [])
1605
- .filter((e: any) => e != null)
1606
- .map((entry: any) => {
1607
- if (entry === null) {
1608
- return null as any;
1609
- }
1610
- return deserializeAws_json1_1ExpenseDocument(entry, context);
1611
- });
1612
- };
1613
-
1614
- const deserializeAws_json1_1ExpenseField = (output: any, context: __SerdeContext): ExpenseField => {
1615
- return {
1616
- LabelDetection:
1617
- output.LabelDetection !== undefined && output.LabelDetection !== null
1618
- ? deserializeAws_json1_1ExpenseDetection(output.LabelDetection, context)
1619
- : undefined,
1620
- PageNumber: __expectInt32(output.PageNumber),
1621
- Type:
1622
- output.Type !== undefined && output.Type !== null
1623
- ? deserializeAws_json1_1ExpenseType(output.Type, context)
1624
- : undefined,
1625
- ValueDetection:
1626
- output.ValueDetection !== undefined && output.ValueDetection !== null
1627
- ? deserializeAws_json1_1ExpenseDetection(output.ValueDetection, context)
1628
- : undefined,
1629
- } as any;
1630
- };
1631
-
1632
- const deserializeAws_json1_1ExpenseFieldList = (output: any, context: __SerdeContext): ExpenseField[] => {
1633
- return (output || [])
1634
- .filter((e: any) => e != null)
1635
- .map((entry: any) => {
1636
- if (entry === null) {
1637
- return null as any;
1638
- }
1639
- return deserializeAws_json1_1ExpenseField(entry, context);
1640
- });
1641
- };
1642
-
1643
- const deserializeAws_json1_1ExpenseType = (output: any, context: __SerdeContext): ExpenseType => {
1644
- return {
1645
- Confidence: __limitedParseFloat32(output.Confidence),
1646
- Text: __expectString(output.Text),
1647
- } as any;
1648
- };
1649
-
1650
- const deserializeAws_json1_1Geometry = (output: any, context: __SerdeContext): Geometry => {
1651
- return {
1652
- BoundingBox:
1653
- output.BoundingBox !== undefined && output.BoundingBox !== null
1654
- ? deserializeAws_json1_1BoundingBox(output.BoundingBox, context)
1655
- : undefined,
1656
- Polygon:
1657
- output.Polygon !== undefined && output.Polygon !== null
1658
- ? deserializeAws_json1_1Polygon(output.Polygon, context)
1659
- : undefined,
1660
- } as any;
1661
- };
1662
-
1663
- const deserializeAws_json1_1GetDocumentAnalysisResponse = (
1664
- output: any,
1665
- context: __SerdeContext
1666
- ): GetDocumentAnalysisResponse => {
1667
- return {
1668
- AnalyzeDocumentModelVersion: __expectString(output.AnalyzeDocumentModelVersion),
1669
- Blocks:
1670
- output.Blocks !== undefined && output.Blocks !== null
1671
- ? deserializeAws_json1_1BlockList(output.Blocks, context)
1672
- : undefined,
1673
- DocumentMetadata:
1674
- output.DocumentMetadata !== undefined && output.DocumentMetadata !== null
1675
- ? deserializeAws_json1_1DocumentMetadata(output.DocumentMetadata, context)
1676
- : undefined,
1677
- JobStatus: __expectString(output.JobStatus),
1678
- NextToken: __expectString(output.NextToken),
1679
- StatusMessage: __expectString(output.StatusMessage),
1680
- Warnings:
1681
- output.Warnings !== undefined && output.Warnings !== null
1682
- ? deserializeAws_json1_1Warnings(output.Warnings, context)
1683
- : undefined,
1684
- } as any;
1685
- };
1686
-
1687
- const deserializeAws_json1_1GetDocumentTextDetectionResponse = (
1688
- output: any,
1689
- context: __SerdeContext
1690
- ): GetDocumentTextDetectionResponse => {
1691
- return {
1692
- Blocks:
1693
- output.Blocks !== undefined && output.Blocks !== null
1694
- ? deserializeAws_json1_1BlockList(output.Blocks, context)
1695
- : undefined,
1696
- DetectDocumentTextModelVersion: __expectString(output.DetectDocumentTextModelVersion),
1697
- DocumentMetadata:
1698
- output.DocumentMetadata !== undefined && output.DocumentMetadata !== null
1699
- ? deserializeAws_json1_1DocumentMetadata(output.DocumentMetadata, context)
1700
- : undefined,
1701
- JobStatus: __expectString(output.JobStatus),
1702
- NextToken: __expectString(output.NextToken),
1703
- StatusMessage: __expectString(output.StatusMessage),
1704
- Warnings:
1705
- output.Warnings !== undefined && output.Warnings !== null
1706
- ? deserializeAws_json1_1Warnings(output.Warnings, context)
1707
- : undefined,
1708
- } as any;
1709
- };
1710
-
1711
- const deserializeAws_json1_1HumanLoopActivationOutput = (
1712
- output: any,
1713
- context: __SerdeContext
1714
- ): HumanLoopActivationOutput => {
1715
- return {
1716
- HumanLoopActivationConditionsEvaluationResults:
1717
- output.HumanLoopActivationConditionsEvaluationResults !== undefined &&
1718
- output.HumanLoopActivationConditionsEvaluationResults !== null
1719
- ? new __LazyJsonString(output.HumanLoopActivationConditionsEvaluationResults)
1720
- : undefined,
1721
- HumanLoopActivationReasons:
1722
- output.HumanLoopActivationReasons !== undefined && output.HumanLoopActivationReasons !== null
1723
- ? deserializeAws_json1_1HumanLoopActivationReasons(output.HumanLoopActivationReasons, context)
1724
- : undefined,
1725
- HumanLoopArn: __expectString(output.HumanLoopArn),
1726
- } as any;
1727
- };
1728
-
1729
- const deserializeAws_json1_1HumanLoopActivationReasons = (output: any, context: __SerdeContext): string[] => {
1730
- return (output || [])
1731
- .filter((e: any) => e != null)
1732
- .map((entry: any) => {
1733
- if (entry === null) {
1734
- return null as any;
1735
- }
1736
- return __expectString(entry) as any;
1737
- });
1738
- };
1739
-
1740
- const deserializeAws_json1_1HumanLoopQuotaExceededException = (
1741
- output: any,
1742
- context: __SerdeContext
1743
- ): HumanLoopQuotaExceededException => {
1744
- return {
1745
- Code: __expectString(output.Code),
1746
- Message: __expectString(output.Message),
1747
- QuotaCode: __expectString(output.QuotaCode),
1748
- ResourceType: __expectString(output.ResourceType),
1749
- ServiceCode: __expectString(output.ServiceCode),
1750
- } as any;
1751
- };
1752
-
1753
- const deserializeAws_json1_1IdempotentParameterMismatchException = (
1754
- output: any,
1755
- context: __SerdeContext
1756
- ): IdempotentParameterMismatchException => {
1757
- return {
1758
- Code: __expectString(output.Code),
1759
- Message: __expectString(output.Message),
1760
- } as any;
1761
- };
1762
-
1763
- const deserializeAws_json1_1IdList = (output: any, context: __SerdeContext): string[] => {
1764
- return (output || [])
1765
- .filter((e: any) => e != null)
1766
- .map((entry: any) => {
1767
- if (entry === null) {
1768
- return null as any;
1769
- }
1770
- return __expectString(entry) as any;
1771
- });
1772
- };
1773
-
1774
- const deserializeAws_json1_1InternalServerError = (output: any, context: __SerdeContext): InternalServerError => {
1775
- return {
1776
- Code: __expectString(output.Code),
1777
- Message: __expectString(output.Message),
1778
- } as any;
1779
- };
1780
-
1781
- const deserializeAws_json1_1InvalidJobIdException = (output: any, context: __SerdeContext): InvalidJobIdException => {
1782
- return {
1783
- Code: __expectString(output.Code),
1784
- Message: __expectString(output.Message),
1785
- } as any;
1786
- };
1787
-
1788
- const deserializeAws_json1_1InvalidKMSKeyException = (output: any, context: __SerdeContext): InvalidKMSKeyException => {
1789
- return {
1790
- Code: __expectString(output.Code),
1791
- Message: __expectString(output.Message),
1792
- } as any;
1793
- };
1794
-
1795
- const deserializeAws_json1_1InvalidParameterException = (
1796
- output: any,
1797
- context: __SerdeContext
1798
- ): InvalidParameterException => {
1799
- return {
1800
- Code: __expectString(output.Code),
1801
- Message: __expectString(output.Message),
1802
- } as any;
1803
- };
1804
-
1805
- const deserializeAws_json1_1InvalidS3ObjectException = (
1806
- output: any,
1807
- context: __SerdeContext
1808
- ): InvalidS3ObjectException => {
1809
- return {
1810
- Code: __expectString(output.Code),
1811
- Message: __expectString(output.Message),
1812
- } as any;
1813
- };
1814
-
1815
- const deserializeAws_json1_1LimitExceededException = (output: any, context: __SerdeContext): LimitExceededException => {
1816
- return {
1817
- Code: __expectString(output.Code),
1818
- Message: __expectString(output.Message),
1819
- } as any;
1820
- };
1821
-
1822
- const deserializeAws_json1_1LineItemFields = (output: any, context: __SerdeContext): LineItemFields => {
1823
- return {
1824
- LineItemExpenseFields:
1825
- output.LineItemExpenseFields !== undefined && output.LineItemExpenseFields !== null
1826
- ? deserializeAws_json1_1ExpenseFieldList(output.LineItemExpenseFields, context)
1827
- : undefined,
1828
- } as any;
1829
- };
1830
-
1831
- const deserializeAws_json1_1LineItemGroup = (output: any, context: __SerdeContext): LineItemGroup => {
1832
- return {
1833
- LineItemGroupIndex: __expectInt32(output.LineItemGroupIndex),
1834
- LineItems:
1835
- output.LineItems !== undefined && output.LineItems !== null
1836
- ? deserializeAws_json1_1LineItemList(output.LineItems, context)
1837
- : undefined,
1838
- } as any;
1839
- };
1840
-
1841
- const deserializeAws_json1_1LineItemGroupList = (output: any, context: __SerdeContext): LineItemGroup[] => {
1842
- return (output || [])
1843
- .filter((e: any) => e != null)
1844
- .map((entry: any) => {
1845
- if (entry === null) {
1846
- return null as any;
1847
- }
1848
- return deserializeAws_json1_1LineItemGroup(entry, context);
1849
- });
1850
- };
1851
-
1852
- const deserializeAws_json1_1LineItemList = (output: any, context: __SerdeContext): LineItemFields[] => {
1853
- return (output || [])
1854
- .filter((e: any) => e != null)
1855
- .map((entry: any) => {
1856
- if (entry === null) {
1857
- return null as any;
1858
- }
1859
- return deserializeAws_json1_1LineItemFields(entry, context);
1860
- });
1861
- };
1862
-
1863
- const deserializeAws_json1_1Pages = (output: any, context: __SerdeContext): number[] => {
1864
- return (output || [])
1865
- .filter((e: any) => e != null)
1866
- .map((entry: any) => {
1867
- if (entry === null) {
1868
- return null as any;
1869
- }
1870
- return __expectInt32(entry) as any;
1871
- });
1872
- };
1873
-
1874
- const deserializeAws_json1_1Point = (output: any, context: __SerdeContext): Point => {
1875
- return {
1876
- X: __limitedParseFloat32(output.X),
1877
- Y: __limitedParseFloat32(output.Y),
1878
- } as any;
1879
- };
1880
-
1881
- const deserializeAws_json1_1Polygon = (output: any, context: __SerdeContext): Point[] => {
1882
- return (output || [])
1883
- .filter((e: any) => e != null)
1884
- .map((entry: any) => {
1885
- if (entry === null) {
1886
- return null as any;
1887
- }
1888
- return deserializeAws_json1_1Point(entry, context);
1889
- });
1890
- };
1891
-
1892
- const deserializeAws_json1_1ProvisionedThroughputExceededException = (
1893
- output: any,
1894
- context: __SerdeContext
1895
- ): ProvisionedThroughputExceededException => {
1896
- return {
1897
- Code: __expectString(output.Code),
1898
- Message: __expectString(output.Message),
1899
- } as any;
1900
- };
1901
-
1902
- const deserializeAws_json1_1Relationship = (output: any, context: __SerdeContext): Relationship => {
1903
- return {
1904
- Ids:
1905
- output.Ids !== undefined && output.Ids !== null ? deserializeAws_json1_1IdList(output.Ids, context) : undefined,
1906
- Type: __expectString(output.Type),
1907
- } as any;
1908
- };
1909
-
1910
- const deserializeAws_json1_1RelationshipList = (output: any, context: __SerdeContext): Relationship[] => {
1911
- return (output || [])
1912
- .filter((e: any) => e != null)
1913
- .map((entry: any) => {
1914
- if (entry === null) {
1915
- return null as any;
1916
- }
1917
- return deserializeAws_json1_1Relationship(entry, context);
1918
- });
1919
- };
1920
-
1921
- const deserializeAws_json1_1StartDocumentAnalysisResponse = (
1922
- output: any,
1923
- context: __SerdeContext
1924
- ): StartDocumentAnalysisResponse => {
1925
- return {
1926
- JobId: __expectString(output.JobId),
1927
- } as any;
1928
- };
1929
-
1930
- const deserializeAws_json1_1StartDocumentTextDetectionResponse = (
1931
- output: any,
1932
- context: __SerdeContext
1933
- ): StartDocumentTextDetectionResponse => {
1934
- return {
1935
- JobId: __expectString(output.JobId),
1936
- } as any;
1937
- };
1938
-
1939
- const deserializeAws_json1_1ThrottlingException = (output: any, context: __SerdeContext): ThrottlingException => {
1940
- return {
1941
- Code: __expectString(output.Code),
1942
- Message: __expectString(output.Message),
1943
- } as any;
1944
- };
1945
-
1946
- const deserializeAws_json1_1UnsupportedDocumentException = (
1947
- output: any,
1948
- context: __SerdeContext
1949
- ): UnsupportedDocumentException => {
1950
- return {
1951
- Code: __expectString(output.Code),
1952
- Message: __expectString(output.Message),
1953
- } as any;
1954
- };
1955
-
1956
- const deserializeAws_json1_1Warning = (output: any, context: __SerdeContext): Warning => {
1957
- return {
1958
- ErrorCode: __expectString(output.ErrorCode),
1959
- Pages:
1960
- output.Pages !== undefined && output.Pages !== null
1961
- ? deserializeAws_json1_1Pages(output.Pages, context)
1962
- : undefined,
1963
- } as any;
1964
- };
1965
-
1966
- const deserializeAws_json1_1Warnings = (output: any, context: __SerdeContext): Warning[] => {
1967
- return (output || [])
1968
- .filter((e: any) => e != null)
1969
- .map((entry: any) => {
1970
- if (entry === null) {
1971
- return null as any;
1972
- }
1973
- return deserializeAws_json1_1Warning(entry, context);
1974
- });
1975
- };
1976
-
1977
- const deserializeMetadata = (output: __HttpResponse): __ResponseMetadata => ({
1978
- httpStatusCode: output.statusCode,
1979
- requestId: output.headers["x-amzn-requestid"] ?? output.headers["x-amzn-request-id"],
1980
- extendedRequestId: output.headers["x-amz-id-2"],
1981
- cfId: output.headers["x-amz-cf-id"],
1982
- });
1983
-
1984
- // Collect low-level response body stream to Uint8Array.
1985
- const collectBody = (streamBody: any = new Uint8Array(), context: __SerdeContext): Promise<Uint8Array> => {
1986
- if (streamBody instanceof Uint8Array) {
1987
- return Promise.resolve(streamBody);
1988
- }
1989
- return context.streamCollector(streamBody) || Promise.resolve(new Uint8Array());
1990
- };
1991
-
1992
- // Encode Uint8Array data into string with utf-8.
1993
- const collectBodyString = (streamBody: any, context: __SerdeContext): Promise<string> =>
1994
- collectBody(streamBody, context).then((body) => context.utf8Encoder(body));
1995
-
1996
- const buildHttpRpcRequest = async (
1997
- context: __SerdeContext,
1998
- headers: __HeaderBag,
1999
- path: string,
2000
- resolvedHostname: string | undefined,
2001
- body: any
2002
- ): Promise<__HttpRequest> => {
2003
- const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
2004
- const contents: any = {
2005
- protocol,
2006
- hostname,
2007
- port,
2008
- method: "POST",
2009
- path: basePath.endsWith("/") ? basePath.slice(0, -1) + path : basePath + path,
2010
- headers,
2011
- };
2012
- if (resolvedHostname !== undefined) {
2013
- contents.hostname = resolvedHostname;
2014
- }
2015
- if (body !== undefined) {
2016
- contents.body = body;
2017
- }
2018
- return new __HttpRequest(contents);
2019
- };
2020
-
2021
- const parseBody = (streamBody: any, context: __SerdeContext): any =>
2022
- collectBodyString(streamBody, context).then((encoded) => {
2023
- if (encoded.length) {
2024
- return JSON.parse(encoded);
2025
- }
2026
- return {};
2027
- });
2028
-
2029
- /**
2030
- * Load an error code for the aws.rest-json-1.1 protocol.
2031
- */
2032
- const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => {
2033
- const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase());
2034
-
2035
- const sanitizeErrorCode = (rawValue: string): string => {
2036
- let cleanValue = rawValue;
2037
- if (cleanValue.indexOf(":") >= 0) {
2038
- cleanValue = cleanValue.split(":")[0];
2039
- }
2040
- if (cleanValue.indexOf("#") >= 0) {
2041
- cleanValue = cleanValue.split("#")[1];
2042
- }
2043
- return cleanValue;
2044
- };
2045
-
2046
- const headerKey = findKey(output.headers, "x-amzn-errortype");
2047
- if (headerKey !== undefined) {
2048
- return sanitizeErrorCode(output.headers[headerKey]);
2049
- }
2050
-
2051
- if (data.code !== undefined) {
2052
- return sanitizeErrorCode(data.code);
2053
- }
2054
-
2055
- if (data["__type"] !== undefined) {
2056
- return sanitizeErrorCode(data["__type"]);
2057
- }
2058
-
2059
- return "";
2060
- };