import * as Context from "effect/Context"; import type * as Effect from "effect/Effect"; import type { AuthArtifact, AuthLease, Execution, ExecutionInteraction, ExecutionStep, ProviderAuthGrant, SecretMaterial, SourceAuthSession, WorkspaceOauthClient, WorkspaceSourceOauthClient, } from "#schema"; type SecretMaterialSummary = { id: string; providerId: string; name: string | null; purpose: string; createdAt: number; updatedAt: number; }; export type ControlPlaneStoreShape = { authArtifacts: { listByWorkspaceId: ( workspaceId: AuthArtifact["workspaceId"], ) => Effect.Effect; listByWorkspaceAndSourceId: (input: { workspaceId: AuthArtifact["workspaceId"]; sourceId: AuthArtifact["sourceId"]; }) => Effect.Effect; getByWorkspaceSourceAndActor: (input: { workspaceId: AuthArtifact["workspaceId"]; sourceId: AuthArtifact["sourceId"]; actorAccountId: AuthArtifact["actorAccountId"]; slot: AuthArtifact["slot"]; }) => Effect.Effect, Error, never>; upsert: (artifact: AuthArtifact) => Effect.Effect; removeByWorkspaceSourceAndActor: (input: { workspaceId: AuthArtifact["workspaceId"]; sourceId: AuthArtifact["sourceId"]; actorAccountId: AuthArtifact["actorAccountId"]; slot?: AuthArtifact["slot"]; }) => Effect.Effect; removeByWorkspaceAndSourceId: (input: { workspaceId: AuthArtifact["workspaceId"]; sourceId: AuthArtifact["sourceId"]; }) => Effect.Effect; }; authLeases: { listAll: () => Effect.Effect; getByAuthArtifactId: ( authArtifactId: AuthLease["authArtifactId"], ) => Effect.Effect, Error, never>; upsert: (lease: AuthLease) => Effect.Effect; removeByAuthArtifactId: ( authArtifactId: AuthLease["authArtifactId"], ) => Effect.Effect; }; sourceOauthClients: { getByWorkspaceSourceAndProvider: (input: { workspaceId: WorkspaceSourceOauthClient["workspaceId"]; sourceId: WorkspaceSourceOauthClient["sourceId"]; providerKey: string; }) => Effect.Effect< import("effect/Option").Option, Error, never >; upsert: ( oauthClient: WorkspaceSourceOauthClient, ) => Effect.Effect; removeByWorkspaceAndSourceId: (input: { workspaceId: WorkspaceSourceOauthClient["workspaceId"]; sourceId: WorkspaceSourceOauthClient["sourceId"]; }) => Effect.Effect; }; workspaceOauthClients: { listByWorkspaceAndProvider: (input: { workspaceId: WorkspaceOauthClient["workspaceId"]; providerKey: string; }) => Effect.Effect; getById: ( id: WorkspaceOauthClient["id"], ) => Effect.Effect, Error, never>; upsert: (oauthClient: WorkspaceOauthClient) => Effect.Effect; removeById: (id: WorkspaceOauthClient["id"]) => Effect.Effect; }; providerAuthGrants: { listByWorkspaceId: ( workspaceId: ProviderAuthGrant["workspaceId"], ) => Effect.Effect; listByWorkspaceActorAndProvider: (input: { workspaceId: ProviderAuthGrant["workspaceId"]; actorAccountId: ProviderAuthGrant["actorAccountId"]; providerKey: string; }) => Effect.Effect; getById: ( id: ProviderAuthGrant["id"], ) => Effect.Effect, Error, never>; upsert: (grant: ProviderAuthGrant) => Effect.Effect; removeById: (id: ProviderAuthGrant["id"]) => Effect.Effect; }; sourceAuthSessions: { listAll: () => Effect.Effect; listByWorkspaceId: ( workspaceId: SourceAuthSession["workspaceId"], ) => Effect.Effect; getById: ( id: SourceAuthSession["id"], ) => Effect.Effect, Error, never>; getByState: ( state: SourceAuthSession["state"], ) => Effect.Effect, Error, never>; getPendingByWorkspaceSourceAndActor: (input: { workspaceId: SourceAuthSession["workspaceId"]; sourceId: SourceAuthSession["sourceId"]; actorAccountId: SourceAuthSession["actorAccountId"]; credentialSlot?: SourceAuthSession["credentialSlot"]; }) => Effect.Effect< import("effect/Option").Option, Error, never >; insert: (session: SourceAuthSession) => Effect.Effect; update: ( id: SourceAuthSession["id"], patch: Partial< Omit >, ) => Effect.Effect, Error, never>; upsert: (session: SourceAuthSession) => Effect.Effect; removeByWorkspaceAndSourceId: ( workspaceId: SourceAuthSession["workspaceId"], sourceId: SourceAuthSession["sourceId"], ) => Effect.Effect; }; secretMaterials: { getById: ( id: SecretMaterial["id"], ) => Effect.Effect, Error, never>; listAll: () => Effect.Effect; upsert: (material: SecretMaterial) => Effect.Effect; updateById: ( id: SecretMaterial["id"], update: { name?: string | null; value?: string }, ) => Effect.Effect< import("effect/Option").Option, Error, never >; removeById: (id: SecretMaterial["id"]) => Effect.Effect; }; executions: { getById: ( executionId: Execution["id"], ) => Effect.Effect, Error, never>; getByWorkspaceAndId: ( workspaceId: Execution["workspaceId"], executionId: Execution["id"], ) => Effect.Effect, Error, never>; insert: (execution: Execution) => Effect.Effect; update: ( executionId: Execution["id"], patch: Partial< Omit >, ) => Effect.Effect, Error, never>; }; executionInteractions: { getById: ( interactionId: ExecutionInteraction["id"], ) => Effect.Effect< import("effect/Option").Option, Error, never >; listByExecutionId: ( executionId: ExecutionInteraction["executionId"], ) => Effect.Effect; getPendingByExecutionId: ( executionId: ExecutionInteraction["executionId"], ) => Effect.Effect< import("effect/Option").Option, Error, never >; insert: ( interaction: ExecutionInteraction, ) => Effect.Effect; update: ( interactionId: ExecutionInteraction["id"], patch: Partial< Omit >, ) => Effect.Effect< import("effect/Option").Option, Error, never >; }; executionSteps: { getByExecutionAndSequence: ( executionId: ExecutionStep["executionId"], sequence: ExecutionStep["sequence"], ) => Effect.Effect, Error, never>; listByExecutionId: ( executionId: ExecutionStep["executionId"], ) => Effect.Effect; insert: (step: ExecutionStep) => Effect.Effect; deleteByExecutionId: ( executionId: ExecutionStep["executionId"], ) => Effect.Effect; updateByExecutionAndSequence: ( executionId: ExecutionStep["executionId"], sequence: ExecutionStep["sequence"], patch: Partial< Omit >, ) => Effect.Effect, Error, never>; }; }; export class ControlPlaneStore extends Context.Tag( "#runtime/ControlPlaneStore", )() {}