| 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 `StartIngestionJob` request with the binding-injected |
| 8 | * `knowledgeBaseId` and `dataSourceId` removed — they are supplied |
| 9 | * automatically from the bound {@link DataSource}. |
| 10 | */ |
| 11 | export interface StartIngestionJobRequest extends Omit< |
| 12 | bedrock.StartIngestionJobRequest, |
| 13 | "knowledgeBaseId" | "dataSourceId" |
| 14 | > {} |
| 15 | |
| 16 | /** |
| 17 | * Runtime binding for `bedrock-agent:StartIngestionJob` — kick off an |
| 18 | * ingestion (sync) job that reads the bound {@link DataSource}'s content |
| 19 | * and indexes it into its knowledge base. |
| 20 | * |
| 21 | * The binding grants the function `bedrock:StartIngestionJob` scoped to the |
| 22 | * data source's parent knowledge base. Poll the returned job with |
| 23 | * {@link GetIngestionJob} until its status settles. |
| 24 | * |
| 25 | * ### Syncing a Data Source |
| 26 | * **Example:** Start an Ingestion Job |
| 27 | * ```typescript |
| 28 | * // init |
| 29 | * const startIngestionJob = yield* Bedrock.StartIngestionJob(dataSource); |
| 30 | * |
| 31 | * // runtime |
| 32 | * const { ingestionJob } = yield* startIngestionJob({ |
| 33 | * description: "nightly refresh", |
| 34 | * }); |
| 35 | * const jobId = ingestionJob.ingestionJobId; |
| 36 | * ``` |
| 37 | * |
| 38 | * @binding |
| 39 | */ |
| 40 | export interface StartIngestionJob extends Binding.Service< |
| 41 | StartIngestionJob, |
| 42 | "AWS.Bedrock.StartIngestionJob", |
| 43 | <D extends DataSource>( |
| 44 | dataSource: D, |
| 45 | ) => Effect.Effect< |
| 46 | ( |
| 47 | request: StartIngestionJobRequest, |
| 48 | ) => Effect.Effect< |
| 49 | bedrock.StartIngestionJobResponse, |
| 50 | bedrock.StartIngestionJobError |
| 51 | > |
| 52 | > |
| 53 | > {} |
| 54 | export const StartIngestionJob = Binding.Service<StartIngestionJob>( |
| 55 | "AWS.Bedrock.StartIngestionJob", |
| 56 | ); |