| 1 | import * as Alchemy from "alchemy"; |
| 2 | import * as AWS from "alchemy/AWS"; |
| 3 | import * as Effect from "effect/Effect"; |
| 4 | import Api from "./src/Api.ts"; |
| 5 | import { BootstrapDatabase } from "./src/bootstrap.ts"; |
| 6 | import { Database } from "./src/database.ts"; |
| 7 | |
| 8 | export default Alchemy.Stack( |
| 9 | "aws-dsql-drizzle", |
| 10 | { providers: AWS.providers(), state: Alchemy.localState() }, |
| 11 | Effect.gen(function* () { |
| 12 | const cluster = yield* Database; |
| 13 | const api = yield* Api; |
| 14 | const schemaVersion = yield* BootstrapDatabase({ |
| 15 | endpoint: cluster.endpoint, |
| 16 | roleArn: api.roleArn, |
| 17 | version: "1", |
| 18 | }); |
| 19 | return { |
| 20 | url: api.functionUrl, |
| 21 | functionName: api.functionName, |
| 22 | roleName: api.roleName, |
| 23 | clusterId: cluster.clusterId, |
| 24 | schemaVersion, |
| 25 | }; |
| 26 | }), |
| 27 | ); |