import { workAppSlackChannelAgentConfigs, workAppSlackUserMappings, workAppSlackWorkspaces } from "../../db/runtime/runtime-schema.js";
import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";

//#region src/data-access/runtime/workAppSlack.d.ts
type WorkAppSlackWorkspaceInsert = typeof workAppSlackWorkspaces.$inferInsert;
type WorkAppSlackWorkspaceSelect = typeof workAppSlackWorkspaces.$inferSelect;
type WorkAppSlackUserMappingInsert = typeof workAppSlackUserMappings.$inferInsert;
type WorkAppSlackUserMappingSelect = typeof workAppSlackUserMappings.$inferSelect;
type WorkAppSlackChannelAgentConfigInsert = typeof workAppSlackChannelAgentConfigs.$inferInsert;
type WorkAppSlackChannelAgentConfigSelect = typeof workAppSlackChannelAgentConfigs.$inferSelect;
declare const createWorkAppSlackWorkspace: (db: AgentsRunDatabaseClient) => (data: Omit<WorkAppSlackWorkspaceInsert, "id" | "createdAt" | "updatedAt">) => Promise<WorkAppSlackWorkspaceSelect>;
declare const findWorkAppSlackWorkspaceByTeamId: (db: AgentsRunDatabaseClient) => (tenantId: string, slackTeamId: string) => Promise<WorkAppSlackWorkspaceSelect | null>;
/**
 * Find a workspace by Slack team ID only (without tenant filter).
 * Slack team IDs are globally unique, so this is safe for resolving
 * the tenant from an incoming Slack event where tenant is unknown.
 */
declare const findWorkAppSlackWorkspaceBySlackTeamId: (db: AgentsRunDatabaseClient) => (slackTeamId: string) => Promise<WorkAppSlackWorkspaceSelect | null>;
/**
 * Find a workspace by its Nango connection ID.
 *
 * One Nango connection = one OAuth token = one Slack workspace.
 * The nangoConnectionId should be globally unique (not per-tenant).
 * The schema has a unique constraint on nangoConnectionId ensuring this.
 */
declare const findWorkAppSlackWorkspaceByNangoConnectionId: (db: AgentsRunDatabaseClient) => (nangoConnectionId: string) => Promise<WorkAppSlackWorkspaceSelect | null>;
declare const listWorkAppSlackWorkspacesByTenant: (db: AgentsRunDatabaseClient) => (tenantId: string) => Promise<WorkAppSlackWorkspaceSelect[]>;
declare const updateWorkAppSlackWorkspace: (db: AgentsRunDatabaseClient) => (id: string, data: Partial<Pick<WorkAppSlackWorkspaceInsert, "status" | "slackTeamName" | "shouldAllowJoinFromWorkspace" | "defaultAgentId" | "defaultProjectId" | "defaultGrantAccessToMembers">>) => Promise<WorkAppSlackWorkspaceSelect | null>;
declare const deleteWorkAppSlackWorkspace: (db: AgentsRunDatabaseClient) => (id: string) => Promise<boolean>;
declare const deleteWorkAppSlackWorkspaceByNangoConnectionId: (db: AgentsRunDatabaseClient) => (nangoConnectionId: string) => Promise<boolean>;
declare const findWorkAppSlackUserMapping: (db: AgentsRunDatabaseClient) => (tenantId: string, slackUserId: string, slackTeamId: string, clientId?: string) => Promise<WorkAppSlackUserMappingSelect | null>;
declare const findWorkAppSlackUserMappingByInkeepUserId: (db: AgentsRunDatabaseClient) => (inkeepUserId: string) => Promise<WorkAppSlackUserMappingSelect[]>;
/**
 * Find a user mapping by Slack user ID and team ID only (ignores tenant).
 * Use this when you need to find the user's tenant from their mapping.
 */
declare const findWorkAppSlackUserMappingBySlackUser: (db: AgentsRunDatabaseClient) => (slackUserId: string, slackTeamId: string, clientId?: string) => Promise<WorkAppSlackUserMappingSelect | null>;
declare const listWorkAppSlackUserMappingsByTeam: (db: AgentsRunDatabaseClient) => (tenantId: string, slackTeamId: string) => Promise<WorkAppSlackUserMappingSelect[]>;
declare const createWorkAppSlackUserMapping: (db: AgentsRunDatabaseClient) => (data: Omit<WorkAppSlackUserMappingInsert, "id" | "clientId" | "createdAt" | "updatedAt"> & {
  clientId?: string;
}) => Promise<WorkAppSlackUserMappingSelect>;
declare const deleteWorkAppSlackUserMapping: (db: AgentsRunDatabaseClient) => (tenantId: string, slackUserId: string, slackTeamId: string, clientId?: string) => Promise<boolean>;
declare const deleteAllWorkAppSlackUserMappingsByTeam: (db: AgentsRunDatabaseClient) => (tenantId: string, slackTeamId: string, clientId?: string) => Promise<number>;
declare const createWorkAppSlackChannelAgentConfig: (db: AgentsRunDatabaseClient) => (data: Omit<WorkAppSlackChannelAgentConfigInsert, "id" | "createdAt" | "updatedAt">) => Promise<WorkAppSlackChannelAgentConfigSelect>;
declare const findWorkAppSlackChannelAgentConfig: (db: AgentsRunDatabaseClient) => (tenantId: string, slackTeamId: string, slackChannelId: string) => Promise<WorkAppSlackChannelAgentConfigSelect | null>;
declare const listWorkAppSlackChannelAgentConfigsByTeam: (db: AgentsRunDatabaseClient) => (tenantId: string, slackTeamId: string) => Promise<WorkAppSlackChannelAgentConfigSelect[]>;
/**
 * Atomic upsert using onConflictDoUpdate to avoid TOCTOU race conditions.
 * Uses the unique constraint on (tenantId, slackTeamId, slackChannelId).
 */
declare const upsertWorkAppSlackChannelAgentConfig: (db: AgentsRunDatabaseClient) => (data: Omit<WorkAppSlackChannelAgentConfigInsert, "id" | "createdAt" | "updatedAt">) => Promise<WorkAppSlackChannelAgentConfigSelect>;
declare const deleteWorkAppSlackChannelAgentConfig: (db: AgentsRunDatabaseClient) => (tenantId: string, slackTeamId: string, slackChannelId: string) => Promise<boolean>;
declare const deleteAllWorkAppSlackChannelAgentConfigsByTeam: (db: AgentsRunDatabaseClient) => (tenantId: string, slackTeamId: string) => Promise<number>;
declare const deleteWorkAppSlackChannelAgentConfigsByAgent: (db: AgentsRunDatabaseClient) => (tenantId: string, projectId: string, agentId: string) => Promise<number>;
declare const deleteWorkAppSlackChannelAgentConfigsByProject: (db: AgentsRunDatabaseClient) => (tenantId: string, projectId: string) => Promise<number>;
declare const clearWorkspaceDefaultsByAgent: (db: AgentsRunDatabaseClient) => (tenantId: string, projectId: string, agentId: string) => Promise<number>;
declare const clearWorkspaceDefaultsByProject: (db: AgentsRunDatabaseClient) => (tenantId: string, projectId: string) => Promise<number>;
declare function clearDevConfigWorkspaceDefaultsByAgent(projectId: string, agentId: string): void;
declare function clearDevConfigWorkspaceDefaultsByProject(projectId: string): void;
//#endregion
export { WorkAppSlackChannelAgentConfigInsert, WorkAppSlackChannelAgentConfigSelect, WorkAppSlackUserMappingInsert, WorkAppSlackUserMappingSelect, WorkAppSlackWorkspaceInsert, WorkAppSlackWorkspaceSelect, clearDevConfigWorkspaceDefaultsByAgent, clearDevConfigWorkspaceDefaultsByProject, clearWorkspaceDefaultsByAgent, clearWorkspaceDefaultsByProject, createWorkAppSlackChannelAgentConfig, createWorkAppSlackUserMapping, createWorkAppSlackWorkspace, deleteAllWorkAppSlackChannelAgentConfigsByTeam, deleteAllWorkAppSlackUserMappingsByTeam, deleteWorkAppSlackChannelAgentConfig, deleteWorkAppSlackChannelAgentConfigsByAgent, deleteWorkAppSlackChannelAgentConfigsByProject, deleteWorkAppSlackUserMapping, deleteWorkAppSlackWorkspace, deleteWorkAppSlackWorkspaceByNangoConnectionId, findWorkAppSlackChannelAgentConfig, findWorkAppSlackUserMapping, findWorkAppSlackUserMappingByInkeepUserId, findWorkAppSlackUserMappingBySlackUser, findWorkAppSlackWorkspaceByNangoConnectionId, findWorkAppSlackWorkspaceBySlackTeamId, findWorkAppSlackWorkspaceByTeamId, listWorkAppSlackChannelAgentConfigsByTeam, listWorkAppSlackUserMappingsByTeam, listWorkAppSlackWorkspacesByTenant, updateWorkAppSlackWorkspace, upsertWorkAppSlackChannelAgentConfig };