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 { DataIntegration } from "@alchemy.run/aws/AppIntegrations"; |
| 3 | import { Key } from "@alchemy.run/aws/KMS"; |
| 4 | import { Bucket } from "@alchemy.run/aws/S3"; |
| 5 | import { expect } from "@alchemy.run/test"; |
| 6 | import * as Test from "@alchemy.run/test/Alchemy"; |
| 7 | import * as appintegrations from "@distilled.cloud/aws/appintegrations"; |
| 8 | import * as Output from "alchemy/Output"; |
| 9 | import * as Effect from "effect/Effect"; |
| 10 | import * as Schedule from "effect/Schedule"; |
| 11 | |
| 12 | const { test } = Test.make({ providers: AWS.providers() }); |
| 13 | |
| 14 | // Ungated typed-error probe: prove the distilled error union carries the |
| 15 | // not-found tag this provider's read/delete paths depend on. |
| 16 | test.provider( |
| 17 | "getDataIntegration on a nonexistent id fails with ResourceNotFoundException", |
| 18 | () => |
| 19 | Effect.gen(function* () { |
| 20 | const error = yield* Effect.flip( |
| 21 | appintegrations.getDataIntegration({ Identifier: "00000000-0000-0000-0000-000000000000" }), |
| 22 | ); |
| 23 | expect(error._tag).toBe("ResourceNotFoundException"); |
| 24 | }), |
| 25 | { tags: ["provider:aws", "provider:aws:appintegrations", "live"] }, |
| 26 | ); |
| 27 | |
| 28 | const assertGone = (id: string) => |
| 29 | appintegrations.getDataIntegration({ Identifier: id }).pipe( |
| 30 | Effect.flatMap(() => Effect.fail(new Error(`data integration '${id}' still exists`))), |
| 31 | Effect.catchTag("ResourceNotFoundException", () => Effect.void), |
| 32 | Effect.retry({ schedule: Schedule.max([Schedule.fixed("2 seconds"), Schedule.recurs(10)]) }), |
| 33 | ); |
| 34 | |
| 35 | test.provider( |
| 36 | "create an S3 data integration, update description, delete", |
| 37 | (stack) => |
| 38 | Effect.gen(function* () { |
| 39 | yield* stack.destroy(); |
| 40 | |
| 41 | const { integration } = yield* stack.deploy( |
| 42 | Effect.gen(function* () { |
| 43 | const bucket = yield* Bucket("Content", { forceDestroy: true }); |
| 44 | const key = yield* Key("ContentKey", { |
| 45 | description: "alchemy appintegrations test key", |
| 46 | deletionWindow: "7 days", |
| 47 | }); |
| 48 | const integration = yield* DataIntegration("ContentIntegration", { |
| 49 | kmsKey: key.keyArn, |
| 50 | sourceURI: Output.interpolate`s3://${bucket.bucketName}`, |
| 51 | description: "alchemy data integration", |
| 52 | tags: { purpose: "alchemy-test" }, |
| 53 | }); |
| 54 | return { integration }; |
| 55 | }), |
| 56 | ); |
| 57 | |
| 58 | expect(integration.dataIntegrationId).toBeDefined(); |
| 59 | expect(integration.dataIntegrationArn).toContain(":data-integration/"); |
| 60 | expect(integration.sourceURI).toMatch(/^s3:\/\//); |
| 61 | |
| 62 | // Out-of-band verification via distilled. |
| 63 | const observed = yield* appintegrations.getDataIntegration({ |
| 64 | Identifier: integration.dataIntegrationId, |
| 65 | }); |
| 66 | expect(observed.Name).toBe(integration.dataIntegrationName); |
| 67 | expect(observed.Description).toBe("alchemy data integration"); |
| 68 | expect(observed.SourceURI).toBe(integration.sourceURI); |
| 69 | expect(observed.KmsKey).toBe(integration.kmsKey); |
| 70 | expect(observed.Tags?.purpose).toBe("alchemy-test"); |
| 71 | |
| 72 | // Update the description in place (id/arn stable). |
| 73 | const { integration: updated } = yield* stack.deploy( |
| 74 | Effect.gen(function* () { |
| 75 | const bucket = yield* Bucket("Content", { forceDestroy: true }); |
| 76 | const key = yield* Key("ContentKey", { |
| 77 | description: "alchemy appintegrations test key", |
| 78 | deletionWindow: "7 days", |
| 79 | }); |
| 80 | const integration = yield* DataIntegration("ContentIntegration", { |
| 81 | kmsKey: key.keyArn, |
| 82 | sourceURI: Output.interpolate`s3://${bucket.bucketName}`, |
| 83 | description: "alchemy data integration v2", |
| 84 | tags: { purpose: "alchemy-test", phase: "two" }, |
| 85 | }); |
| 86 | return { integration }; |
| 87 | }), |
| 88 | ); |
| 89 | expect(updated.dataIntegrationId).toBe(integration.dataIntegrationId); |
| 90 | expect(updated.dataIntegrationArn).toBe(integration.dataIntegrationArn); |
| 91 | |
| 92 | const reobserved = yield* appintegrations.getDataIntegration({ |
| 93 | Identifier: integration.dataIntegrationId, |
| 94 | }); |
| 95 | expect(reobserved.Description).toBe("alchemy data integration v2"); |
| 96 | expect(reobserved.Tags?.phase).toBe("two"); |
| 97 | |
| 98 | yield* stack.destroy(); |
| 99 | yield* assertGone(integration.dataIntegrationId); |
| 100 | }), |
| 101 | { |
| 102 | tags: [ |
| 103 | "provider:aws", |
| 104 | "provider:aws:appintegrations", |
| 105 | "provider:aws:kms", |
| 106 | "provider:aws:s3", |
| 107 | "live", |
| 108 | ], |
| 109 | timeout: 240_000, |
| 110 | }, |
| 111 | ); |