The best way to control Claude Code, Codex and more from any computer or phone
| 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 { ApiToken, ApiTokenProvider } from "./ApiToken.ts"; |
| 7 | import { TursoAuth } from "./AuthProvider.ts"; |
| 8 | import * as Credentials from "./Credentials.ts"; |
| 9 | import { Database, DatabaseProvider } from "./Database.ts"; |
| 10 | import { DatabaseToken, DatabaseTokenProvider } from "./DatabaseToken.ts"; |
| 11 | import { Group, GroupProvider } from "./Group.ts"; |
| 12 | import { GroupToken, GroupTokenProvider } from "./GroupToken.ts"; |
| 13 | import { OrganizationInvite, OrganizationInviteProvider } from "./OrganizationInvite.ts"; |
| 14 | import { OrganizationMember, OrganizationMemberProvider } from "./OrganizationMember.ts"; |
| 15 | import { OrganizationSettings, OrganizationSettingsProvider } from "./OrganizationSettings.ts"; |
| 16 | |
| 17 | /** |
| 18 | * Service tag bundling all Turso providers + auth + credentials. Use |
| 19 | * `Turso.providers()` to materialize the full layer. |
| 20 | */ |
| 21 | export class Providers extends Provider.ProviderCollection<Providers>()("Turso") {} |
| 22 | |
| 23 | export type ProviderRequirements = Layer.Services<ReturnType<typeof providers>>; |
| 24 | |
| 25 | /** |
| 26 | * Build the complete Turso providers Layer: every Turso resource, the |
| 27 | * Turso AuthProvider registration (so `alchemy profile edit` can configure |
| 28 | * it), and credential resolution. |
| 29 | * |
| 30 | * @example |
| 31 | * ```ts |
| 32 | * Alchemy.Stack("App", { providers: Turso.providers() }, ...) |
| 33 | * ``` |
| 34 | */ |
| 35 | export const providers = () => |
| 36 | Layer.effect( |
| 37 | Providers, |
| 38 | Provider.collection([ |
| 39 | ApiToken, |
| 40 | Database, |
| 41 | DatabaseToken, |
| 42 | Group, |
| 43 | GroupToken, |
| 44 | OrganizationInvite, |
| 45 | OrganizationMember, |
| 46 | OrganizationSettings, |
| 47 | ]), |
| 48 | ).pipe( |
| 49 | Layer.provide( |
| 50 | Layer.mergeAll( |
| 51 | ApiTokenProvider(), |
| 52 | DatabaseProvider(), |
| 53 | DatabaseTokenProvider(), |
| 54 | GroupProvider(), |
| 55 | GroupTokenProvider(), |
| 56 | OrganizationInviteProvider(), |
| 57 | OrganizationMemberProvider(), |
| 58 | OrganizationSettingsProvider(), |
| 59 | ), |
| 60 | ), |
| 61 | Layer.provideMerge(Credentials.fromAuthProvider()), |
| 62 | Layer.provideMerge(FetchHttpClient.layer), |
| 63 | Layer.provideMerge(TursoAuth), |
| 64 | Layer.provideMerge(ProfileStoreLive), |
| 65 | Layer.provideMerge(CredentialsStoreLive), |
| 66 | Layer.orDie, |
| 67 | ); |