The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as AWS from "@alchemy.run/aws"; |
| 2 | import { expect } from "@alchemy.run/test"; |
| 3 | import * as Test from "@alchemy.run/test/Alchemy"; |
| 4 | import * as bedrock from "@distilled.cloud/aws/bedrock-agent"; |
| 5 | import * as Effect from "effect/Effect"; |
| 6 | |
| 7 | const { test } = Test.make({ providers: AWS.providers() }); |
| 8 | |
| 9 | // Ungated typed-error probes. The full KnowledgeBase + DataSource + Retrieve |
| 10 | // lifecycle is gated behind a vector store (see KnowledgeBase.slow.test.ts); |
| 11 | // these cheap probes prove the distilled error union that the reconcilers' |
| 12 | // observe/read/delete catch paths depend on, at near-zero cost. |
| 13 | |
| 14 | test.provider( |
| 15 | "getKnowledgeBase on a missing id returns a typed ResourceNotFoundException", |
| 16 | (_stack) => |
| 17 | Effect.gen(function* () { |
| 18 | const result = yield* bedrock.getKnowledgeBase({ knowledgeBaseId: "AAAAAAAAAA" }).pipe( |
| 19 | Effect.map(() => "found" as const), |
| 20 | // Compiles only if ResourceNotFoundException is in the typed union. |
| 21 | Effect.catchTag("ResourceNotFoundException", () => Effect.succeed("not-found" as const)), |
| 22 | ); |
| 23 | expect(result).toBe("not-found"); |
| 24 | }), |
| 25 | { tags: ["provider:aws", "provider:aws:bedrock", "live"], timeout: 60_000 }, |
| 26 | ); |
| 27 | |
| 28 | test.provider( |
| 29 | "getDataSource on a missing id returns a typed ResourceNotFoundException", |
| 30 | (_stack) => |
| 31 | Effect.gen(function* () { |
| 32 | const result = yield* bedrock |
| 33 | .getDataSource({ |
| 34 | knowledgeBaseId: "AAAAAAAAAA", |
| 35 | dataSourceId: "BBBBBBBBBB", |
| 36 | }) |
| 37 | .pipe( |
| 38 | Effect.map(() => "found" as const), |
| 39 | Effect.catchTag("ResourceNotFoundException", () => Effect.succeed("not-found" as const)), |
| 40 | ); |
| 41 | expect(result).toBe("not-found"); |
| 42 | }), |
| 43 | { tags: ["provider:aws", "provider:aws:bedrock", "live"], timeout: 60_000 }, |
| 44 | ); |
| 45 | |
| 46 | test.provider( |
| 47 | "getAgent on a missing id returns a typed ResourceNotFoundException", |
| 48 | (_stack) => |
| 49 | Effect.gen(function* () { |
| 50 | const result = yield* bedrock.getAgent({ agentId: "AAAAAAAAAA" }).pipe( |
| 51 | Effect.map(() => "found" as const), |
| 52 | Effect.catchTag("ResourceNotFoundException", () => Effect.succeed("not-found" as const)), |
| 53 | ); |
| 54 | expect(result).toBe("not-found"); |
| 55 | }), |
| 56 | { tags: ["provider:aws", "provider:aws:bedrock", "live"], timeout: 60_000 }, |
| 57 | ); |
| 58 | |
| 59 | test.provider( |
| 60 | "listIngestionJobs on a missing data source returns a typed ResourceNotFoundException", |
| 61 | (_stack) => |
| 62 | Effect.gen(function* () { |
| 63 | const result = yield* bedrock |
| 64 | .listIngestionJobs({ |
| 65 | knowledgeBaseId: "AAAAAAAAAA", |
| 66 | dataSourceId: "BBBBBBBBBB", |
| 67 | }) |
| 68 | .pipe( |
| 69 | Effect.map(() => "found" as const), |
| 70 | // Compiles only if ResourceNotFoundException is in the typed union |
| 71 | // — the error path the ingestion-job bindings depend on. |
| 72 | Effect.catchTag("ResourceNotFoundException", () => Effect.succeed("not-found" as const)), |
| 73 | ); |
| 74 | expect(result).toBe("not-found"); |
| 75 | }), |
| 76 | { tags: ["provider:aws", "provider:aws:bedrock", "live"], timeout: 60_000 }, |
| 77 | ); |
| 78 | |
| 79 | test.provider( |
| 80 | "listKnowledgeBaseDocuments on a missing data source returns a typed ResourceNotFoundException", |
| 81 | (_stack) => |
| 82 | Effect.gen(function* () { |
| 83 | const result = yield* bedrock |
| 84 | .listKnowledgeBaseDocuments({ |
| 85 | knowledgeBaseId: "AAAAAAAAAA", |
| 86 | dataSourceId: "BBBBBBBBBB", |
| 87 | }) |
| 88 | .pipe( |
| 89 | Effect.map(() => "found" as const), |
| 90 | // Compiles only if ResourceNotFoundException is in the typed union |
| 91 | // — the error path the document bindings depend on. |
| 92 | Effect.catchTag("ResourceNotFoundException", () => Effect.succeed("not-found" as const)), |
| 93 | ); |
| 94 | expect(result).toBe("not-found"); |
| 95 | }), |
| 96 | { tags: ["provider:aws", "provider:aws:bedrock", "live"], timeout: 60_000 }, |
| 97 | ); |