import { WorkAppGitHubInstallationStatus } from "../../types/utility.js"; import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js"; import { McpTool, ToolSelect, WorkAppGitHubInstallationInsert, WorkAppGitHubInstallationSelect, WorkAppGitHubProjectRepositoryAccessSelect, WorkAppGitHubRepositoryInput, WorkAppGitHubRepositorySelect } from "../../types/entities.js"; //#region src/data-access/runtime/github-work-app-installations.d.ts /** * Create a new GitHub App installation record */ declare const createInstallation: (db: AgentsRunDatabaseClient) => (input: WorkAppGitHubInstallationInsert) => Promise; /** * Get installation by GitHub installation ID */ declare const getInstallationByGitHubId: (db: AgentsRunDatabaseClient) => (gitHubInstallationId: string) => Promise; /** * Get installation by internal ID with tenant validation */ declare const getInstallationById: (db: AgentsRunDatabaseClient) => (params: { tenantId: string; id: string; }) => Promise; /** * Get all installations for a tenant */ declare const getInstallationsByTenantId: (db: AgentsRunDatabaseClient) => (params: { tenantId: string; includeDisconnected?: boolean; }) => Promise; /** * Update installation status */ declare const updateInstallationStatus: (db: AgentsRunDatabaseClient) => (params: { tenantId: string; id: string; status: WorkAppGitHubInstallationStatus; }) => Promise; /** * Update installation status by GitHub installation ID (for webhook handlers) */ declare const updateInstallationStatusByGitHubId: (db: AgentsRunDatabaseClient) => (params: { gitHubInstallationId: string; status: WorkAppGitHubInstallationStatus; }) => Promise; /** * Soft delete an installation (set status to 'disconnected') * Also removes all project repository access for this installation's repositories */ declare const disconnectInstallation: (db: AgentsRunDatabaseClient) => (params: { tenantId: string; id: string; }) => Promise; /** * Delete an installation (hard delete) * Returns the deleted installation if found, null otherwise */ declare const deleteInstallation: (db: AgentsRunDatabaseClient) => (params: { tenantId: string; id: string; }) => Promise; /** * Sync repositories for an installation * Adds new repos, removes missing repos, updates existing */ declare const syncRepositories: (db: AgentsRunDatabaseClient) => (params: { installationId: string; repositories: WorkAppGitHubRepositoryInput[]; }) => Promise<{ added: number; removed: number; updated: number; }>; /** * Add repositories to an installation (for webhook 'added' events) */ declare const addRepositories: (db: AgentsRunDatabaseClient) => (params: { installationId: string; repositories: WorkAppGitHubRepositoryInput[]; }) => Promise; /** * Remove repositories from an installation (for webhook 'removed' events) * Also removes associated project repository access entries */ declare const removeRepositories: (db: AgentsRunDatabaseClient) => (params: { installationId: string; repositoryIds: string[]; }) => Promise; /** * Get all repositories for an installation */ declare const getRepositoriesByInstallationId: (db: AgentsRunDatabaseClient) => (installationId: string) => Promise; /** * Get repository by full name (e.g., "org/repo") */ declare const getRepositoryByFullName: (db: AgentsRunDatabaseClient) => (repositoryFullName: string) => Promise; /** * Get repository by internal ID */ declare const getRepositoryById: (db: AgentsRunDatabaseClient) => (id: string) => Promise; /** * Get all repositories for a tenant (across all installations) */ declare const getRepositoriesByTenantId: (db: AgentsRunDatabaseClient) => (tenantId: string) => Promise<(WorkAppGitHubRepositorySelect & { installationAccountLogin: string; installationId: string; })[]>; /** * Set project repository access (full replacement) * Used when mode='selected' to specify which repositories the project can access. * Pass empty array to clear all access entries. * * Also cascades changes to MCP tools: any MCP tool in this project with mode='selected' * will have its selected repositories filtered to only include repos that remain * in the project's access list. */ declare const setProjectRepositoryAccess: (db: AgentsRunDatabaseClient) => (params: { tenantId: string; projectId: string; repositoryIds: string[]; }) => Promise; /** * Get project repository access entries * These entries are used when mode='selected'. Check mode via getProjectAccessMode(). */ declare const getProjectRepositoryAccess: (db: AgentsRunDatabaseClient) => (projectId: string) => Promise; /** * Get project repository access with full repository details. * If project access mode is 'all', returns all tenant repositories. * If mode is 'selected' (or not set), returns only explicitly granted repositories. */ declare const getProjectRepositoryAccessWithDetails: (db: AgentsRunDatabaseClient) => (params: { tenantId: string; projectId: string; }) => Promise<(WorkAppGitHubRepositorySelect & { accessId: string; installationAccountLogin: string; installationId: string; })[]>; /** * Check if a project has access to a specific repository * Returns true if: * - Project mode is 'all' and repository belongs to tenant installations * - Project mode is 'selected' and repository is explicitly in the project's access list */ declare const checkProjectRepositoryAccess: (db: AgentsRunDatabaseClient) => (params: { projectId: string; repositoryFullName: string; tenantId: string; }) => Promise<{ hasAccess: boolean; reason: string; }>; /** * Remove all project repository access for a specific project */ declare const clearProjectRepositoryAccess: (db: AgentsRunDatabaseClient) => (projectId: string) => Promise; /** * Validate that all repository IDs belong to installations owned by a tenant * Returns list of invalid repository IDs */ declare const validateRepositoryOwnership: (db: AgentsRunDatabaseClient) => (params: { tenantId: string; repositoryIds: string[]; }) => Promise; /** * Get repository count for an installation */ declare const getRepositoryCount: (db: AgentsRunDatabaseClient) => (installationId: string) => Promise; /** * Get repository counts for all installations belonging to a tenant */ declare const getRepositoryCountsByTenantId: (db: AgentsRunDatabaseClient) => (params: { tenantId: string; includeDisconnected?: boolean; }) => Promise>; /** * Set MCP tool repository access (full replacement) * Used when mode='selected' to specify which repositories the tool can access. * Pass empty array to clear all access entries. */ declare const setMcpToolRepositoryAccess: (db: AgentsRunDatabaseClient) => (params: { toolId: string; tenantId: string; projectId: string; repositoryIds: string[]; }) => Promise; /** * Get MCP tool repository access entries * These entries are used when mode='selected'. Check mode via getMcpToolAccessMode(). */ declare const getMcpToolRepositoryAccess: (db: AgentsRunDatabaseClient) => (scope: { tenantId: string; projectId: string; toolId: string; }) => Promise<{ id: string; toolId: string; tenantId: string; projectId: string; repositoryDbId: string; createdAt: string; updatedAt: string; }[]>; /** * Get MCP tool repository access with full repository details. * If the tool's access mode is 'all', returns all repositories the project has access to. * If mode is 'selected' (or not set), returns only explicitly granted repositories. */ declare const getMcpToolRepositoryAccessWithDetails: (db: AgentsRunDatabaseClient) => (scope: { tenantId: string; projectId: string; toolId: string; }) => Promise<(WorkAppGitHubRepositorySelect & { accessId: string; installationAccountLogin: string; installationId: string; })[]>; /** * Remove all MCP tool repository access for a specific tool */ declare const clearMcpToolRepositoryAccess: (db: AgentsRunDatabaseClient) => (scope: { tenantId: string; projectId: string; toolId: string; }) => Promise; declare const isGithubWorkAppTool: (tool: ToolSelect | McpTool) => boolean | undefined; type WorkAppGitHubAccessMode = 'all' | 'selected'; /** * Set the access mode for a project's GitHub repository access. * - 'all': Project has access to all repositories from tenant GitHub installations * - 'selected': Project only has access to repositories listed in work_app_github_project_repository_access */ declare const setProjectAccessMode: (db: AgentsRunDatabaseClient) => (params: { tenantId: string; projectId: string; mode: WorkAppGitHubAccessMode; }) => Promise; /** * Get the access mode for a project's GitHub repository access. * Returns 'selected' if no mode is explicitly set (fail-safe default). */ declare const getProjectAccessMode: (db: AgentsRunDatabaseClient) => (params: { tenantId: string; projectId: string; }) => Promise; /** * Delete the access mode entry for a project */ declare const deleteProjectAccessMode: (db: AgentsRunDatabaseClient) => (params: { tenantId: string; projectId: string; }) => Promise; /** * Set the access mode for an MCP tool's GitHub repository access. * - 'all': Tool has access to all repositories the project has access to * - 'selected': Tool only has access to repositories listed in work_app_github_mcp_tool_repository_access */ declare const setMcpToolAccessMode: (db: AgentsRunDatabaseClient) => (params: { toolId: string; tenantId: string; projectId: string; mode: WorkAppGitHubAccessMode; }) => Promise; /** * Get the access mode for an MCP tool's GitHub repository access. * Returns 'selected' if no mode is explicitly set (fail-safe default). */ declare const getMcpToolAccessMode: (db: AgentsRunDatabaseClient) => (scope: { tenantId: string; projectId: string; toolId: string; }) => Promise; /** * Delete the access mode entry for an MCP tool */ declare const deleteMcpToolAccessMode: (db: AgentsRunDatabaseClient) => (scope: { tenantId: string; projectId: string; toolId: string; }) => Promise; //#endregion export { WorkAppGitHubAccessMode, addRepositories, checkProjectRepositoryAccess, clearMcpToolRepositoryAccess, clearProjectRepositoryAccess, createInstallation, deleteInstallation, deleteMcpToolAccessMode, deleteProjectAccessMode, disconnectInstallation, getInstallationByGitHubId, getInstallationById, getInstallationsByTenantId, getMcpToolAccessMode, getMcpToolRepositoryAccess, getMcpToolRepositoryAccessWithDetails, getProjectAccessMode, getProjectRepositoryAccess, getProjectRepositoryAccessWithDetails, getRepositoriesByInstallationId, getRepositoriesByTenantId, getRepositoryByFullName, getRepositoryById, getRepositoryCount, getRepositoryCountsByTenantId, isGithubWorkAppTool, removeRepositories, setMcpToolAccessMode, setMcpToolRepositoryAccess, setProjectAccessMode, setProjectRepositoryAccess, syncRepositories, updateInstallationStatus, updateInstallationStatusByGitHubId, validateRepositoryOwnership };