| 1 | import type * as bedrock from "@distilled.cloud/aws/bedrock-agent"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { DataSource } from "./DataSource.ts"; |
| 5 | |
| 6 | /** |
| 7 | * The `GetKnowledgeBaseDocuments` request with the binding-injected |
| 8 | * `knowledgeBaseId` and `dataSourceId` removed — they are supplied |
| 9 | * automatically from the bound {@link DataSource}. |
| 10 | */ |
| 11 | export interface GetKnowledgeBaseDocumentsRequest extends Omit< |
| 12 | bedrock.GetKnowledgeBaseDocumentsRequest, |
| 13 | "knowledgeBaseId" | "dataSourceId" |
| 14 | > {} |
| 15 | |
| 16 | /** |
| 17 | * Runtime binding for `bedrock-agent:GetKnowledgeBaseDocuments` — read the |
| 18 | * ingestion status of specific documents in the bound {@link DataSource}. |
| 19 | * |
| 20 | * The binding grants the function `bedrock:GetKnowledgeBaseDocuments` |
| 21 | * scoped to the data source's parent knowledge base. |
| 22 | * |
| 23 | * ### Direct Document Ingestion |
| 24 | * **Example:** Check a Document's Ingestion Status |
| 25 | * ```typescript |
| 26 | * // init |
| 27 | * const getDocuments = yield* Bedrock.GetKnowledgeBaseDocuments(dataSource); |
| 28 | * |
| 29 | * // runtime |
| 30 | * const { documentDetails } = yield* getDocuments({ |
| 31 | * documentIdentifiers: [ |
| 32 | * { dataSourceType: "CUSTOM", custom: { id: "welcome-doc" } }, |
| 33 | * ], |
| 34 | * }); |
| 35 | * const status = documentDetails?.[0]?.status; // e.g. "INDEXED" |
| 36 | * ``` |
| 37 | * |
| 38 | * @binding |
| 39 | */ |
| 40 | export interface GetKnowledgeBaseDocuments extends Binding.Service< |
| 41 | GetKnowledgeBaseDocuments, |
| 42 | "AWS.Bedrock.GetKnowledgeBaseDocuments", |
| 43 | <D extends DataSource>( |
| 44 | dataSource: D, |
| 45 | ) => Effect.Effect< |
| 46 | ( |
| 47 | request: GetKnowledgeBaseDocumentsRequest, |
| 48 | ) => Effect.Effect< |
| 49 | bedrock.GetKnowledgeBaseDocumentsResponse, |
| 50 | bedrock.GetKnowledgeBaseDocumentsError |
| 51 | > |
| 52 | > |
| 53 | > {} |
| 54 | export const GetKnowledgeBaseDocuments = |
| 55 | Binding.Service<GetKnowledgeBaseDocuments>( |
| 56 | "AWS.Bedrock.GetKnowledgeBaseDocuments", |
| 57 | ); |