| 1 | import type * as documentai from "@distilled.cloud/gcp/documentai_v1"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { RuntimeContext } from "../../RuntimeContext.ts"; |
| 5 | import type { Processor } from "./Processor.ts"; |
| 6 | |
| 7 | export interface ProcessRequest extends Omit< |
| 8 | documentai.ProcessProjectsLocationsProcessorsRequest, |
| 9 | "name" |
| 10 | > {} |
| 11 | |
| 12 | /** |
| 13 | * Runtime binding for Document AI `processors.process`. |
| 14 | * |
| 15 | * Bind this operation to a {@link Processor} in a Function/Action init |
| 16 | * phase. Provide {@link ProcessHttp}. |
| 17 | * |
| 18 | * ### Processing a Document |
| 19 | * **Example:** OCR a raw PDF |
| 20 | * ```typescript |
| 21 | * const process = yield* GCP.DocumentAI.Process(processor); |
| 22 | * const result = yield* process({ |
| 23 | * body: { |
| 24 | * rawDocument: { |
| 25 | * content: pdfBase64, |
| 26 | * mimeType: "application/pdf", |
| 27 | * }, |
| 28 | * skipHumanReview: true, |
| 29 | * }, |
| 30 | * }); |
| 31 | * ``` |
| 32 | * |
| 33 | * @binding |
| 34 | * @category DocumentAI |
| 35 | */ |
| 36 | export interface Process extends Binding.Service< |
| 37 | Process, |
| 38 | "GCP.DocumentAI.Process", |
| 39 | ( |
| 40 | processor: Processor, |
| 41 | ) => Effect.Effect< |
| 42 | ( |
| 43 | request?: ProcessRequest, |
| 44 | ) => Effect.Effect< |
| 45 | documentai.GoogleCloudDocumentaiV1ProcessResponse, |
| 46 | documentai.ProcessProjectsLocationsProcessorsError, |
| 47 | RuntimeContext |
| 48 | > |
| 49 | > |
| 50 | > {} |
| 51 | |
| 52 | export const Process = Binding.Service<Process>("GCP.DocumentAI.Process"); |