| 1 | import type * as textract from "@distilled.cloud/aws/textract"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | |
| 5 | /** |
| 6 | * Runtime binding for `textract:DetectDocumentText` — synchronous OCR that |
| 7 | * detects lines and words of text in a JPEG, PNG, PDF, or TIFF document. |
| 8 | * |
| 9 | * Textract is a pure pay-per-call service with no resource to manage: the |
| 10 | * binding takes no arguments and grants the function |
| 11 | * `textract:DetectDocumentText` (the action has no resource-level IAM). |
| 12 | * Pass the document as raw bytes (`Document.Bytes`) or as an S3 object |
| 13 | * reference (`Document.S3Object`) — raw distilled types, no marshalling. |
| 14 | * |
| 15 | * ### Detecting Document Text |
| 16 | * **Example:** Detect Text in Document Bytes |
| 17 | * ```typescript |
| 18 | * // init |
| 19 | * const detectDocumentText = yield* AWS.Textract.DetectDocumentText(); |
| 20 | * |
| 21 | * // runtime |
| 22 | * const result = yield* detectDocumentText({ |
| 23 | * Document: { Bytes: documentBytes }, |
| 24 | * }); |
| 25 | * const lines = (result.Blocks ?? []) |
| 26 | * .filter((block) => block.BlockType === "LINE") |
| 27 | * .map((block) => block.Text); |
| 28 | * ``` |
| 29 | * |
| 30 | * @binding |
| 31 | */ |
| 32 | export interface DetectDocumentText extends Binding.Service< |
| 33 | DetectDocumentText, |
| 34 | "AWS.Textract.DetectDocumentText", |
| 35 | () => Effect.Effect< |
| 36 | ( |
| 37 | request: textract.DetectDocumentTextRequest, |
| 38 | ) => Effect.Effect< |
| 39 | textract.DetectDocumentTextResponse, |
| 40 | textract.DetectDocumentTextError |
| 41 | > |
| 42 | > |
| 43 | > {} |
| 44 | export const DetectDocumentText = Binding.Service<DetectDocumentText>( |
| 45 | "AWS.Textract.DetectDocumentText", |
| 46 | ); |