import { ProjectScopeConfig } from "../../db/manage/scope-definitions.js";
import { PaginationConfig } from "../../types/utility.js";
import "../../types/index.js";
import { AgentsManageDatabaseClient } from "../../db/manage/manage-client.js";
import { CredentialReferenceInsert, CredentialReferenceSelect, CredentialReferenceUpdate, ExternalAgentSelect, ToolSelect } from "../../types/entities.js";

//#region src/data-access/manage/credentialReferences.d.ts
type CredentialReferenceWithResources = CredentialReferenceSelect & {
  tools: ToolSelect[];
  externalAgents: ExternalAgentSelect[];
};
/**
 * Get a credential reference by ID
 */
declare const getCredentialReference: (db: AgentsManageDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  id: string;
}) => Promise<CredentialReferenceSelect | undefined>;
/**
 * Get a user-scoped credential reference by toolId and userId
 */
declare const getUserScopedCredentialReference: (db: AgentsManageDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  toolId: string;
  userId: string;
}) => Promise<CredentialReferenceSelect | undefined>;
/**
 * Get a credential reference by ID with its related tools
 */
declare const getCredentialReferenceWithResources: (db: AgentsManageDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  id: string;
}) => Promise<CredentialReferenceWithResources | undefined>;
/**
 * List all credential references for a tenant/project
 */
declare const listCredentialReferences: (db: AgentsManageDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
}) => Promise<CredentialReferenceSelect[]>;
/**
 * List credential references with pagination
 */
declare const listCredentialReferencesPaginated: (db: AgentsManageDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  pagination?: PaginationConfig;
}) => Promise<{
  data: CredentialReferenceSelect[];
  pagination: {
    page: number;
    limit: number;
    total: number;
    pages: number;
  };
}>;
/**
 * Create a new credential reference
 */
declare const createCredentialReference: (db: AgentsManageDatabaseClient) => (params: CredentialReferenceInsert) => Promise<CredentialReferenceSelect>;
/**
 * Update a credential reference
 */
declare const updateCredentialReference: (db: AgentsManageDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  id: string;
  data: Partial<CredentialReferenceUpdate>;
}) => Promise<CredentialReferenceWithResources | undefined>;
/**
 * Delete a credential reference
 */
declare const deleteCredentialReference: (db: AgentsManageDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  id: string;
}) => Promise<boolean>;
/**
 * Check if a credential reference exists
 */
declare const hasCredentialReference: (db: AgentsManageDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  id: string;
}) => Promise<boolean>;
/**
 * Get credential reference by ID (simple version without tools)
 */
declare const getCredentialReferenceById: (db: AgentsManageDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  id: string;
}) => Promise<CredentialReferenceSelect | null>;
/**
 * Count credential references for a tenant/project
 */
declare const countCredentialReferences: (db: AgentsManageDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
}) => Promise<number>;
/**
 * Upsert a credential reference (create if it doesn't exist, update if it does).
 * For user-scoped credentials (toolId + userId set), also checks the unique constraint pair.
 * Uses application-level find-then-update since Doltgres does not support ON CONFLICT DO UPDATE.
 */
declare const upsertCredentialReference: (db: AgentsManageDatabaseClient) => (params: {
  data: CredentialReferenceInsert;
}) => Promise<CredentialReferenceSelect>;
//#endregion
export { CredentialReferenceWithResources, countCredentialReferences, createCredentialReference, deleteCredentialReference, getCredentialReference, getCredentialReferenceById, getCredentialReferenceWithResources, getUserScopedCredentialReference, hasCredentialReference, listCredentialReferences, listCredentialReferencesPaginated, updateCredentialReference, upsertCredentialReference };