The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 06:00 UTC
| 1 | import { CredentialsStoreLive } from "alchemy/Auth/Credentials"; |
| 2 | import { ProfileStoreLive } from "alchemy/Auth/Profile"; |
| 3 | import * as Provider from "alchemy/Provider"; |
| 4 | import * as FetchHttpClient from "effect/http/FetchHttpClient"; |
| 5 | import * as Layer from "effect/Layer"; |
| 6 | import { PlanetscaleAuth } from "./AuthProvider.ts"; |
| 7 | import * as Credentials from "./Credentials.ts"; |
| 8 | import { MySQLBranch, MySQLBranchProvider } from "./MySQL/MySQLBranch.ts"; |
| 9 | import { MySQLDatabase, MySQLDatabaseProvider } from "./MySQL/MySQLDatabase.ts"; |
| 10 | import { MySQLPassword, MySQLPasswordProvider } from "./MySQL/MySQLPassword.ts"; |
| 11 | import { PostgresBranch, PostgresBranchProvider } from "./Postgres/PostgresBranch.ts"; |
| 12 | import { PostgresDatabase, PostgresDatabaseProvider } from "./Postgres/PostgresDatabase.ts"; |
| 13 | import { |
| 14 | PostgresDefaultRole, |
| 15 | PostgresDefaultRoleProvider, |
| 16 | } from "./Postgres/PostgresDefaultRole.ts"; |
| 17 | import { PostgresRole, PostgresRoleProvider } from "./Postgres/PostgresRole.ts"; |
| 18 | |
| 19 | /** |
| 20 | * Service tag bundling all PlanetScale providers + auth + credentials. Use |
| 21 | * `Planetscale.providers()` to materialize the full layer. |
| 22 | */ |
| 23 | export class Providers extends Provider.ProviderCollection<Providers>()("Planetscale") {} |
| 24 | |
| 25 | export type ProviderRequirements = Layer.Services<ReturnType<typeof providers>>; |
| 26 | |
| 27 | /** |
| 28 | * Build the complete PlanetScale providers Layer. Provide this on a Stack |
| 29 | * (or via `Effect.provide` at test time) to enable all PlanetScale |
| 30 | * resources, the AuthProvider registration, and credential resolution. |
| 31 | * |
| 32 | * @example |
| 33 | * ```ts |
| 34 | * Effect.provide(Planetscale.providers()) |
| 35 | * ``` |
| 36 | */ |
| 37 | export const providers = () => |
| 38 | Layer.effect( |
| 39 | Providers, |
| 40 | Provider.collection([ |
| 41 | MySQLDatabase, |
| 42 | PostgresDatabase, |
| 43 | MySQLBranch, |
| 44 | PostgresBranch, |
| 45 | MySQLPassword, |
| 46 | PostgresRole, |
| 47 | PostgresDefaultRole, |
| 48 | ]), |
| 49 | ).pipe( |
| 50 | Layer.provide( |
| 51 | Layer.mergeAll( |
| 52 | MySQLDatabaseProvider(), |
| 53 | PostgresDatabaseProvider(), |
| 54 | MySQLBranchProvider(), |
| 55 | PostgresBranchProvider(), |
| 56 | MySQLPasswordProvider(), |
| 57 | PostgresRoleProvider(), |
| 58 | PostgresDefaultRoleProvider(), |
| 59 | ), |
| 60 | ), |
| 61 | Layer.provideMerge(Credentials.fromAuthProvider()), |
| 62 | Layer.provideMerge(FetchHttpClient.layer), |
| 63 | Layer.provideMerge(PlanetscaleAuth), |
| 64 | Layer.provideMerge(ProfileStoreLive), |
| 65 | Layer.provideMerge(CredentialsStoreLive), |
| 66 | Layer.orDie, |
| 67 | ); |