Skip to content

Commit be0312b

Browse files
author
awstools
committed
feat(client-textract): This release adds support for classifying and splitting lending documents by type, and extracting information by using the Analyze Lending APIs. This release also includes support for summarized information of the processed lending document package, in addition to per document results.
1 parent 0ac256b commit be0312b

File tree

11 files changed

+2535
-154
lines changed

11 files changed

+2535
-154
lines changed

clients/client-textract/src/Textract.ts

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ import {
3232
GetExpenseAnalysisCommandInput,
3333
GetExpenseAnalysisCommandOutput,
3434
} from "./commands/GetExpenseAnalysisCommand";
35+
import {
36+
GetLendingAnalysisCommand,
37+
GetLendingAnalysisCommandInput,
38+
GetLendingAnalysisCommandOutput,
39+
} from "./commands/GetLendingAnalysisCommand";
40+
import {
41+
GetLendingAnalysisSummaryCommand,
42+
GetLendingAnalysisSummaryCommandInput,
43+
GetLendingAnalysisSummaryCommandOutput,
44+
} from "./commands/GetLendingAnalysisSummaryCommand";
3545
import {
3646
StartDocumentAnalysisCommand,
3747
StartDocumentAnalysisCommandInput,
@@ -47,6 +57,11 @@ import {
4757
StartExpenseAnalysisCommandInput,
4858
StartExpenseAnalysisCommandOutput,
4959
} from "./commands/StartExpenseAnalysisCommand";
60+
import {
61+
StartLendingAnalysisCommand,
62+
StartLendingAnalysisCommandInput,
63+
StartLendingAnalysisCommandOutput,
64+
} from "./commands/StartLendingAnalysisCommand";
5065
import { TextractClient } from "./TextractClient";
5166

5267
/**
@@ -456,6 +471,91 @@ export class Textract extends TextractClient {
456471
}
457472
}
458473

474+
/**
475+
* <p>Gets the results for an Amazon Textract asynchronous operation that analyzes text in a
476+
* lending document. </p>
477+
* <p>You start asynchronous text analysis by calling <code>StartLendingAnalysis</code>,
478+
* which returns a job identifier (<code>JobId</code>). When the text analysis operation
479+
* finishes, Amazon Textract publishes a completion status to the Amazon Simple
480+
* Notification Service (Amazon SNS) topic that's registered in the initial call to
481+
* <code>StartLendingAnalysis</code>. </p>
482+
* <p>To get the results of the text analysis operation, first check that the status value
483+
* published to the Amazon SNS topic is SUCCEEDED. If so, call GetLendingAnalysis, and pass
484+
* the job identifier (<code>JobId</code>) from the initial call to
485+
* <code>StartLendingAnalysis</code>.</p>
486+
*/
487+
public getLendingAnalysis(
488+
args: GetLendingAnalysisCommandInput,
489+
options?: __HttpHandlerOptions
490+
): Promise<GetLendingAnalysisCommandOutput>;
491+
public getLendingAnalysis(
492+
args: GetLendingAnalysisCommandInput,
493+
cb: (err: any, data?: GetLendingAnalysisCommandOutput) => void
494+
): void;
495+
public getLendingAnalysis(
496+
args: GetLendingAnalysisCommandInput,
497+
options: __HttpHandlerOptions,
498+
cb: (err: any, data?: GetLendingAnalysisCommandOutput) => void
499+
): void;
500+
public getLendingAnalysis(
501+
args: GetLendingAnalysisCommandInput,
502+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: GetLendingAnalysisCommandOutput) => void),
503+
cb?: (err: any, data?: GetLendingAnalysisCommandOutput) => void
504+
): Promise<GetLendingAnalysisCommandOutput> | void {
505+
const command = new GetLendingAnalysisCommand(args);
506+
if (typeof optionsOrCb === "function") {
507+
this.send(command, optionsOrCb);
508+
} else if (typeof cb === "function") {
509+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
510+
this.send(command, optionsOrCb || {}, cb);
511+
} else {
512+
return this.send(command, optionsOrCb);
513+
}
514+
}
515+
516+
/**
517+
* <p>Gets summarized results for the <code>StartLendingAnalysis</code> operation, which analyzes
518+
* text in a lending document. The returned summary consists of information about documents grouped
519+
* together by a common document type. Information like detected signatures, page numbers, and split
520+
* documents is returned with respect to the type of grouped document. </p>
521+
* <p>You start asynchronous text analysis by calling <code>StartLendingAnalysis</code>, which
522+
* returns a job identifier (<code>JobId</code>). When the text analysis operation finishes, Amazon
523+
* Textract publishes a completion status to the Amazon Simple Notification Service (Amazon SNS)
524+
* topic that's registered in the initial call to <code>StartLendingAnalysis</code>. </p>
525+
* <p>To get the results of the text analysis operation, first check that the status value
526+
* published to the Amazon SNS topic is SUCCEEDED. If so, call
527+
* <code>GetLendingAnalysisSummary</code>, and pass the job identifier (<code>JobId</code>) from
528+
* the initial call to <code>StartLendingAnalysis</code>.</p>
529+
*/
530+
public getLendingAnalysisSummary(
531+
args: GetLendingAnalysisSummaryCommandInput,
532+
options?: __HttpHandlerOptions
533+
): Promise<GetLendingAnalysisSummaryCommandOutput>;
534+
public getLendingAnalysisSummary(
535+
args: GetLendingAnalysisSummaryCommandInput,
536+
cb: (err: any, data?: GetLendingAnalysisSummaryCommandOutput) => void
537+
): void;
538+
public getLendingAnalysisSummary(
539+
args: GetLendingAnalysisSummaryCommandInput,
540+
options: __HttpHandlerOptions,
541+
cb: (err: any, data?: GetLendingAnalysisSummaryCommandOutput) => void
542+
): void;
543+
public getLendingAnalysisSummary(
544+
args: GetLendingAnalysisSummaryCommandInput,
545+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: GetLendingAnalysisSummaryCommandOutput) => void),
546+
cb?: (err: any, data?: GetLendingAnalysisSummaryCommandOutput) => void
547+
): Promise<GetLendingAnalysisSummaryCommandOutput> | void {
548+
const command = new GetLendingAnalysisSummaryCommand(args);
549+
if (typeof optionsOrCb === "function") {
550+
this.send(command, optionsOrCb);
551+
} else if (typeof cb === "function") {
552+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
553+
this.send(command, optionsOrCb || {}, cb);
554+
} else {
555+
return this.send(command, optionsOrCb);
556+
}
557+
}
558+
459559
/**
460560
* <p>Starts the asynchronous analysis of an input document for relationships between detected
461561
* items such as key-value pairs, tables, and selection elements.</p>
@@ -599,4 +699,66 @@ export class Textract extends TextractClient {
599699
return this.send(command, optionsOrCb);
600700
}
601701
}
702+
703+
/**
704+
* <p>Starts the classification and analysis of an input document.
705+
* <code>StartLendingAnalysis</code> initiates the classification and analysis of a packet of
706+
* lending documents. <code>StartLendingAnalysis</code> operates on a document file located in an
707+
* Amazon S3 bucket.</p>
708+
* <p>
709+
* <code>StartLendingAnalysis</code> can analyze text in documents that are in one of the
710+
* following formats: JPEG, PNG, TIFF, PDF. Use <code>DocumentLocation</code> to specify the bucket
711+
* name and the file name of the document. </p>
712+
* <p>
713+
* <code>StartLendingAnalysis</code> returns a job identifier (<code>JobId</code>) that you use
714+
* to get the results of the operation. When the text analysis is finished, Amazon Textract
715+
* publishes a completion status to the Amazon Simple Notification Service (Amazon SNS) topic that
716+
* you specify in <code>NotificationChannel</code>. To get the results of the text analysis
717+
* operation, first check that the status value published to the Amazon SNS topic is SUCCEEDED. If
718+
* the status is SUCCEEDED you can call either <code>GetLendingAnalysis</code> or
719+
* <code>GetLendingAnalysisSummary</code> and provide the <code>JobId</code> to obtain the results
720+
* of the analysis.</p>
721+
* <p>If using <code>OutputConfig</code> to specify an Amazon S3 bucket, the output will be contained
722+
* within the specified prefix in a directory labeled with the job-id. In the directory there are 3
723+
* sub-directories: </p>
724+
* <ul>
725+
* <li>
726+
* <p>detailedResponse (contains the GetLendingAnalysis response)</p>
727+
* </li>
728+
* <li>
729+
* <p>summaryResponse (for the GetLendingAnalysisSummary response)</p>
730+
* </li>
731+
* <li>
732+
* <p>splitDocuments (documents split across logical boundaries)</p>
733+
* </li>
734+
* </ul>
735+
*/
736+
public startLendingAnalysis(
737+
args: StartLendingAnalysisCommandInput,
738+
options?: __HttpHandlerOptions
739+
): Promise<StartLendingAnalysisCommandOutput>;
740+
public startLendingAnalysis(
741+
args: StartLendingAnalysisCommandInput,
742+
cb: (err: any, data?: StartLendingAnalysisCommandOutput) => void
743+
): void;
744+
public startLendingAnalysis(
745+
args: StartLendingAnalysisCommandInput,
746+
options: __HttpHandlerOptions,
747+
cb: (err: any, data?: StartLendingAnalysisCommandOutput) => void
748+
): void;
749+
public startLendingAnalysis(
750+
args: StartLendingAnalysisCommandInput,
751+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: StartLendingAnalysisCommandOutput) => void),
752+
cb?: (err: any, data?: StartLendingAnalysisCommandOutput) => void
753+
): Promise<StartLendingAnalysisCommandOutput> | void {
754+
const command = new StartLendingAnalysisCommand(args);
755+
if (typeof optionsOrCb === "function") {
756+
this.send(command, optionsOrCb);
757+
} else if (typeof cb === "function") {
758+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
759+
this.send(command, optionsOrCb || {}, cb);
760+
} else {
761+
return this.send(command, optionsOrCb);
762+
}
763+
}
602764
}

clients/client-textract/src/TextractClient.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ import {
6060
GetDocumentTextDetectionCommandOutput,
6161
} from "./commands/GetDocumentTextDetectionCommand";
6262
import { GetExpenseAnalysisCommandInput, GetExpenseAnalysisCommandOutput } from "./commands/GetExpenseAnalysisCommand";
63+
import { GetLendingAnalysisCommandInput, GetLendingAnalysisCommandOutput } from "./commands/GetLendingAnalysisCommand";
64+
import {
65+
GetLendingAnalysisSummaryCommandInput,
66+
GetLendingAnalysisSummaryCommandOutput,
67+
} from "./commands/GetLendingAnalysisSummaryCommand";
6368
import {
6469
StartDocumentAnalysisCommandInput,
6570
StartDocumentAnalysisCommandOutput,
@@ -72,6 +77,10 @@ import {
7277
StartExpenseAnalysisCommandInput,
7378
StartExpenseAnalysisCommandOutput,
7479
} from "./commands/StartExpenseAnalysisCommand";
80+
import {
81+
StartLendingAnalysisCommandInput,
82+
StartLendingAnalysisCommandOutput,
83+
} from "./commands/StartLendingAnalysisCommand";
7584
import {
7685
ClientInputEndpointParameters,
7786
ClientResolvedEndpointParameters,
@@ -88,9 +97,12 @@ export type ServiceInputTypes =
8897
| GetDocumentAnalysisCommandInput
8998
| GetDocumentTextDetectionCommandInput
9099
| GetExpenseAnalysisCommandInput
100+
| GetLendingAnalysisCommandInput
101+
| GetLendingAnalysisSummaryCommandInput
91102
| StartDocumentAnalysisCommandInput
92103
| StartDocumentTextDetectionCommandInput
93-
| StartExpenseAnalysisCommandInput;
104+
| StartExpenseAnalysisCommandInput
105+
| StartLendingAnalysisCommandInput;
94106

95107
export type ServiceOutputTypes =
96108
| AnalyzeDocumentCommandOutput
@@ -100,9 +112,12 @@ export type ServiceOutputTypes =
100112
| GetDocumentAnalysisCommandOutput
101113
| GetDocumentTextDetectionCommandOutput
102114
| GetExpenseAnalysisCommandOutput
115+
| GetLendingAnalysisCommandOutput
116+
| GetLendingAnalysisSummaryCommandOutput
103117
| StartDocumentAnalysisCommandOutput
104118
| StartDocumentTextDetectionCommandOutput
105-
| StartExpenseAnalysisCommandOutput;
119+
| StartExpenseAnalysisCommandOutput
120+
| StartLendingAnalysisCommandOutput;
106121

107122
export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__HttpHandlerOptions>> {
108123
/**
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
// smithy-typescript generated code
2+
import { EndpointParameterInstructions, getEndpointPlugin } from "@aws-sdk/middleware-endpoint";
3+
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
4+
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
5+
import { Command as $Command } from "@aws-sdk/smithy-client";
6+
import {
7+
FinalizeHandlerArguments,
8+
Handler,
9+
HandlerExecutionContext,
10+
HttpHandlerOptions as __HttpHandlerOptions,
11+
MetadataBearer as __MetadataBearer,
12+
MiddlewareStack,
13+
SerdeContext as __SerdeContext,
14+
} from "@aws-sdk/types";
15+
16+
import {
17+
GetLendingAnalysisRequest,
18+
GetLendingAnalysisRequestFilterSensitiveLog,
19+
GetLendingAnalysisResponse,
20+
GetLendingAnalysisResponseFilterSensitiveLog,
21+
} from "../models/models_0";
22+
import {
23+
deserializeAws_json1_1GetLendingAnalysisCommand,
24+
serializeAws_json1_1GetLendingAnalysisCommand,
25+
} from "../protocols/Aws_json1_1";
26+
import { ServiceInputTypes, ServiceOutputTypes, TextractClientResolvedConfig } from "../TextractClient";
27+
28+
export interface GetLendingAnalysisCommandInput extends GetLendingAnalysisRequest {}
29+
export interface GetLendingAnalysisCommandOutput extends GetLendingAnalysisResponse, __MetadataBearer {}
30+
31+
/**
32+
* <p>Gets the results for an Amazon Textract asynchronous operation that analyzes text in a
33+
* lending document. </p>
34+
* <p>You start asynchronous text analysis by calling <code>StartLendingAnalysis</code>,
35+
* which returns a job identifier (<code>JobId</code>). When the text analysis operation
36+
* finishes, Amazon Textract publishes a completion status to the Amazon Simple
37+
* Notification Service (Amazon SNS) topic that's registered in the initial call to
38+
* <code>StartLendingAnalysis</code>. </p>
39+
* <p>To get the results of the text analysis operation, first check that the status value
40+
* published to the Amazon SNS topic is SUCCEEDED. If so, call GetLendingAnalysis, and pass
41+
* the job identifier (<code>JobId</code>) from the initial call to
42+
* <code>StartLendingAnalysis</code>.</p>
43+
* @example
44+
* Use a bare-bones client and the command you need to make an API call.
45+
* ```javascript
46+
* import { TextractClient, GetLendingAnalysisCommand } from "@aws-sdk/client-textract"; // ES Modules import
47+
* // const { TextractClient, GetLendingAnalysisCommand } = require("@aws-sdk/client-textract"); // CommonJS import
48+
* const client = new TextractClient(config);
49+
* const command = new GetLendingAnalysisCommand(input);
50+
* const response = await client.send(command);
51+
* ```
52+
*
53+
* @see {@link GetLendingAnalysisCommandInput} for command's `input` shape.
54+
* @see {@link GetLendingAnalysisCommandOutput} for command's `response` shape.
55+
* @see {@link TextractClientResolvedConfig | config} for TextractClient's `config` shape.
56+
*
57+
*/
58+
export class GetLendingAnalysisCommand extends $Command<
59+
GetLendingAnalysisCommandInput,
60+
GetLendingAnalysisCommandOutput,
61+
TextractClientResolvedConfig
62+
> {
63+
// Start section: command_properties
64+
// End section: command_properties
65+
66+
public static getEndpointParameterInstructions(): EndpointParameterInstructions {
67+
return {
68+
UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
69+
Endpoint: { type: "builtInParams", name: "endpoint" },
70+
Region: { type: "builtInParams", name: "region" },
71+
UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" },
72+
};
73+
}
74+
75+
constructor(readonly input: GetLendingAnalysisCommandInput) {
76+
// Start section: command_constructor
77+
super();
78+
// End section: command_constructor
79+
}
80+
81+
/**
82+
* @internal
83+
*/
84+
resolveMiddleware(
85+
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
86+
configuration: TextractClientResolvedConfig,
87+
options?: __HttpHandlerOptions
88+
): Handler<GetLendingAnalysisCommandInput, GetLendingAnalysisCommandOutput> {
89+
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
90+
this.middlewareStack.use(
91+
getEndpointPlugin(configuration, GetLendingAnalysisCommand.getEndpointParameterInstructions())
92+
);
93+
94+
const stack = clientStack.concat(this.middlewareStack);
95+
96+
const { logger } = configuration;
97+
const clientName = "TextractClient";
98+
const commandName = "GetLendingAnalysisCommand";
99+
const handlerExecutionContext: HandlerExecutionContext = {
100+
logger,
101+
clientName,
102+
commandName,
103+
inputFilterSensitiveLog: GetLendingAnalysisRequestFilterSensitiveLog,
104+
outputFilterSensitiveLog: GetLendingAnalysisResponseFilterSensitiveLog,
105+
};
106+
const { requestHandler } = configuration;
107+
return stack.resolve(
108+
(request: FinalizeHandlerArguments<any>) =>
109+
requestHandler.handle(request.request as __HttpRequest, options || {}),
110+
handlerExecutionContext
111+
);
112+
}
113+
114+
private serialize(input: GetLendingAnalysisCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
115+
return serializeAws_json1_1GetLendingAnalysisCommand(input, context);
116+
}
117+
118+
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<GetLendingAnalysisCommandOutput> {
119+
return deserializeAws_json1_1GetLendingAnalysisCommand(output, context);
120+
}
121+
122+
// Start section: command_body_extra
123+
// End section: command_body_extra
124+
}

0 commit comments

Comments
 (0)