| 1 | import type * as kendra from "@distilled.cloud/aws/kendra"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Index } from "./SearchIndex.ts"; |
| 5 | |
| 6 | /** |
| 7 | * `BatchPutDocument` request with `IndexId` injected from the bound index. |
| 8 | */ |
| 9 | export interface BatchPutDocumentRequest extends Omit< |
| 10 | kendra.BatchPutDocumentRequest, |
| 11 | "IndexId" |
| 12 | > {} |
| 13 | |
| 14 | /** |
| 15 | * Runtime binding for the `BatchPutDocument` operation (IAM action |
| 16 | * `kendra:BatchPutDocument`), scoped to one {@link Index}. |
| 17 | * |
| 18 | * Adds documents directly to the index (inline blobs or S3 paths) — |
| 19 | * the push-API alternative to a data-source sync. Check the response's |
| 20 | * `FailedDocuments` for per-document errors; documents index |
| 21 | * asynchronously (poll with {@link BatchGetDocumentStatus}). |
| 22 | * Provide the implementation with |
| 23 | * `Effect.provide(AWS.Kendra.BatchPutDocumentHttp)`. |
| 24 | * |
| 25 | * ### Indexing Documents |
| 26 | * **Example:** Index Documents Inline |
| 27 | * ```typescript |
| 28 | * const putDocuments = yield* AWS.Kendra.BatchPutDocument(index); |
| 29 | * |
| 30 | * const result = yield* putDocuments({ |
| 31 | * Documents: [ |
| 32 | * { |
| 33 | * Id: "welcome", |
| 34 | * Title: "Welcome", |
| 35 | * Blob: new TextEncoder().encode("Hello from Alchemy"), |
| 36 | * ContentType: "PLAIN_TEXT", |
| 37 | * }, |
| 38 | * ], |
| 39 | * }); |
| 40 | * // result.FailedDocuments is empty on success |
| 41 | * ``` |
| 42 | * |
| 43 | * @binding |
| 44 | */ |
| 45 | export interface BatchPutDocument extends Binding.Service< |
| 46 | BatchPutDocument, |
| 47 | "AWS.Kendra.BatchPutDocument", |
| 48 | ( |
| 49 | index: Index, |
| 50 | ) => Effect.Effect< |
| 51 | ( |
| 52 | request: BatchPutDocumentRequest, |
| 53 | ) => Effect.Effect< |
| 54 | kendra.BatchPutDocumentResponse, |
| 55 | kendra.BatchPutDocumentError |
| 56 | > |
| 57 | > |
| 58 | > {} |
| 59 | export const BatchPutDocument = Binding.Service<BatchPutDocument>( |
| 60 | "AWS.Kendra.BatchPutDocument", |
| 61 | ); |