1import * as Context from "effect/Context";
2import type * as Effect from "effect/Effect";
3import type * as Option from "effect/Option";
4
5import type { ConnectionCredential } from "./catalog.ts";
6import type { ConnectionAttemptError } from "./model.ts";
7
8export class ConnectionCredentialStore extends Context.Service<
9 ConnectionCredentialStore,
10 {
11 readonly get: (
12 connectionId: string,
13 ) => Effect.Effect<Option.Option<ConnectionCredential>, ConnectionAttemptError>;
14 readonly put: (
15 connectionId: string,
16 credential: ConnectionCredential,
17 ) => Effect.Effect<void, ConnectionAttemptError>;
18 readonly remove: (connectionId: string) => Effect.Effect<void, ConnectionAttemptError>;
19 }
20>()("@t3tools/client-runtime/connection/credentialStore/ConnectionCredentialStore") {}
21
22export const make = (service: ConnectionCredentialStore["Service"]) =>
23 ConnectionCredentialStore.of(service);