import { PaginationConfig, PaginationResult, ProjectModels } from "../../types/utility.js";
import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
import { AgentsManageDatabaseClient } from "../../db/manage/manage-client.js";
import { StopWhen } from "../../validation/schemas.js";
import { ProjectMetadataSelect } from "../../types/entities.js";

//#region src/data-access/manage/projectLifecycle.d.ts
interface CreateProjectWithBranchParams {
  tenantId: string;
  projectId: string;
  createdBy?: string;
}
interface CreateProjectWithBranchResult {
  id: string;
  tenantId: string;
  mainBranchName: string;
  createdAt: string;
  createdBy: string | null;
}
interface DeleteProjectAndBranchesParams {
  tenantId: string;
  projectId: string;
}
/**
 * Generate the main branch name for a project
 */
declare function getProjectMainBranchName(tenantId: string, projectId: string): string;
/**
 * Create a project with its main branch
 *
 * This utility:
 * 1. Creates the project record in the runtime DB (source of truth for existence)
 * 2. Creates the project main branch in the config DB (Doltgres)
 *
 * @param runDb - Runtime database client (Postgres)
 * @param configDb - Config database client (Doltgres)
 */
declare const createProjectMetadataAndBranch: (runDb: AgentsRunDatabaseClient, configDb: AgentsManageDatabaseClient) => (params: CreateProjectWithBranchParams) => Promise<CreateProjectWithBranchResult>;
/**
 * Delete a project and ALL its branches
 *
 * This utility:
 * 1. Gets the project from runtime DB
 * 2. Lists and deletes ALL branches matching the project prefix from config DB (Doltgres)
 * 3. Deletes the project record from runtime DB
 *
 * Note: Callers should handle cascade deletion of runtime entities (conversations, etc.)
 * before calling this function.
 *
 * @param runDb - Runtime database client (Postgres)
 * @param configDb - Config database client (Doltgres)
 */
declare const deleteProjectAndBranches: (runDb: AgentsRunDatabaseClient, configDb: AgentsManageDatabaseClient) => (params: DeleteProjectAndBranchesParams) => Promise<boolean>;
/**
 * Get project with branch info
 *
 * Returns the project from runtime DB including the main branch name
 */
declare const getProjectWithBranchInfo: (runDb: AgentsRunDatabaseClient) => (params: {
  tenantId: string;
  projectId: string;
}) => Promise<ProjectMetadataSelect | null>;
/**
 * Project metadata from the versioned config DB
 */
interface ProjectConfigMetadata {
  name: string;
  description: string | null;
  models: ProjectModels | null;
  stopWhen: StopWhen | null;
  createdAt: string;
  updatedAt: string;
}
/**
 * Combined project data from runtime + config DBs
 */
interface ProjectWithMetadata {
  id: string;
  tenantId: string;
  createdAt: string;
  createdBy: string | null;
  mainBranchName: string;
  name: string | null;
  description: string | null;
  models: ProjectModels | null;
  stopWhen: StopWhen | null;
  configUpdatedAt: string | null;
}
interface ListProjectsWithMetadataResult {
  data: ProjectWithMetadata[];
  pagination: PaginationResult;
}
/**
 * List projects with metadata from both runtime and config DBs
 *
 * This function:
 * 1. Gets the list of projects from runtime DB (source of truth for existence)
 * 2. For each project, queries the config DB at the project's main branch to get metadata
 *
 * @param runDb - Runtime database client (Postgres)
 * @param configDb - Config database client (Doltgres)
 */
declare const listProjectsWithMetadataPaginated: (runDb: AgentsRunDatabaseClient, configDb: AgentsManageDatabaseClient) => (params: {
  tenantId: string;
  pagination?: PaginationConfig;
  projectIds?: string[];
}) => Promise<ListProjectsWithMetadataResult>;
/**
 * Get a single project with metadata from both runtime and config DBs
 *
 * @param runDb - Runtime database client (Postgres)
 * @param configDb - Config database client (Doltgres)
 */
declare const getProjectWithMetadata: (runDb: AgentsRunDatabaseClient, configDb: AgentsManageDatabaseClient) => (params: {
  tenantId: string;
  projectId: string;
}) => Promise<ProjectWithMetadata | null>;
//#endregion
export { CreateProjectWithBranchParams, CreateProjectWithBranchResult, DeleteProjectAndBranchesParams, ListProjectsWithMetadataResult, ProjectConfigMetadata, ProjectWithMetadata, createProjectMetadataAndBranch, deleteProjectAndBranches, getProjectMainBranchName, getProjectWithBranchInfo, getProjectWithMetadata, listProjectsWithMetadataPaginated };