export {
  getUsers,
  getUserById,
  getUserByEmail,
  getUserByUsername,
  getOwnerUser,
  getUserCount,
  createUser,
  updateUser,
  deleteUser,
  getPasskeysByUserId,
  getPasskeysByUserIdAndOrigin,
  getPasskeyByCredentialId,
  createPasskey,
  updatePasskey,
  storeChallenge,
  consumeChallenge,
  blacklistToken,
  isTokenBlacklisted,
  cleanupExpiredTokens,
} from './queries/auth';

export {
  findLiveApiKeyByHash,
  createApiKey,
  listApiKeys,
  revokeApiKey,
  touchApiKey,
  type ApiKeyIdentity,
} from './queries/api-keys';

export { readServerSettings, writeServerSettings, readConfigValue, writeConfigValue } from './queries/server-config';

export {
  getUserSettings,
  setUserSettings,
  getUserState,
  patchUserState,
  getDockPaths,
  setDockPaths,
} from './queries/user-data';

export {
  getServerIntegrations,
  getServerIntegration,
  upsertServerIntegration,
  deleteServerIntegration,
  getUserIntegrations,
  getUserIntegration,
  getIntegrationsByProvider,
  upsertUserIntegration,
  deleteUserIntegration,
  findUserByIntegrationConfig,
} from './queries/integrations';

export {
  getEmailAccounts,
  getEmailAccount,
  createEmailAccount,
  deleteEmailAccount,
  updateEmailAccountStatus,
  updateEmailAccountSyncMeta,
  getAllSyncedAccounts,
} from './queries/email-accounts';

export {
  getAllDashboardState,
  upsertDashboard,
  updateDashboard,
  deleteDashboard,
  setDashboardPanelState,
  upsertScreen,
  deleteScreen,
  upsertDefaults,
  setDefaultsPanelState,
} from './queries/dashboards';

export {
  createPipelineJob,
  getPipelineJob,
  updatePipelineJob,
  getPipelineJobsForUser,
  getOldestPendingJob,
  getPendingJobs,
  countPendingJobs,
  deletePipelineJob,
  deleteTerminalJobsForUser,
  markInterruptedJobs,
} from './queries/pipeline-jobs';

export {
  appendChatEvent,
  getChatEventsSince,
  getLastChatEventSeq,
  pruneChatEventsOlderThan,
} from './queries/chat-events';

export {
  listAgentPanels,
  getAgentPanelByPanelId,
  getAgentPanelByName,
  getAgentPanelByHandoffToken,
  createAgentPanel,
  updateAgentPanel,
  markAgentPanelIntroduced,
  deleteAgentPanel,
  toAgentPanelView,
} from './queries/agent-panels';
export type { AgentPanel, AgentPanelView, CreateAgentPanelInput, UpdateAgentPanelInput } from './queries/agent-panels';

export {
  getMusicFavorites,
  addMusicFavorite,
  removeMusicFavorite,
  getNowPlaying,
  setNowPlaying,
  clearNowPlaying,
  getPlaylists,
  getPlaylist,
  createPlaylist,
  renamePlaylist,
  deletePlaylist,
  addPlaylistItems,
  setPlaylistItems,
} from './queries/music';
export type {
  FavoriteKind,
  GroupedFavorites,
  NowPlaying,
  NowPlayingInput,
  PlaylistSummary,
  Playlist,
} from './queries/music';
export { getSoulseekFavorites, addSoulseekFavorite, removeSoulseekFavorite } from './queries/soulseek';
export {
  getSoulseekBrowseSnapshots,
  getSoulseekBrowseSnapshot,
  startSoulseekBrowse,
  finishSoulseekBrowse,
  failSoulseekBrowse,
  resetStaleSoulseekBrowses,
  getSoulseekBrowseLevel,
  searchSoulseekBrowseTree,
  getSoulseekBrowseDirFiles,
  getSoulseekBrowseDownload,
  deleteSoulseekBrowse,
} from './queries/soulseek';
export type {
  BrowseDownloadFile,
  BrowsedFile,
  BrowseDirInput,
  BrowseDirRow,
  BrowseTreeNode,
  BrowseLevel,
  BrowseTreeSearch,
  SoulseekBrowseSnapshot,
} from './queries/soulseek';
export {
  listHeadscaleServers,
  getActiveHeadscaleCredentials,
  getHeadscaleCredentials,
  createHeadscaleServer,
  updateHeadscaleServer,
  setActiveHeadscaleServer,
  deleteHeadscaleServer,
  recordHeadscaleProbe,
} from './queries/headscale';
export type { HeadscaleServer, HeadscaleServerCredentials } from './queries/headscale';
export {
  listInvoiceshelfAccounts,
  getActiveInvoiceshelfCredentials,
  getInvoiceshelfCredentials,
  createInvoiceshelfAccount,
  updateInvoiceshelfAccount,
  setActiveInvoiceshelfAccount,
  deleteInvoiceshelfAccount,
  recordInvoiceshelfProbe,
} from './queries/invoiceshelf';
export type { InvoiceshelfAccount, InvoiceshelfCredentials } from './queries/invoiceshelf';
export {
  listJellyfinServers,
  getActiveJellyfinCredentials,
  getJellyfinCredentials,
  createJellyfinServer,
  updateJellyfinServer,
  setActiveJellyfinServer,
  deleteJellyfinServer,
  recordJellyfinProbe,
} from './queries/jellyfin';
export type { JellyfinServer, JellyfinCredentials } from './queries/jellyfin';
export {
  listPhotosAccounts,
  getActivePhotosCredentials,
  getPhotosCredentials,
  createPhotosAccount,
  updatePhotosAccount,
  setActivePhotosAccount,
  deletePhotosAccount,
  recordPhotosProbe,
} from './queries/photos';
export type { PhotosAccount, PhotosCredentials } from './queries/photos';
export {
  listDavAppPasswords,
  createDavAppPassword,
  revokeDavAppPassword,
  deleteDavAppPassword,
  verifyDavAppPassword,
} from './queries/dav';
export type { DavAppPassword, DavAppPasswordView } from './queries/dav';
export {
  getServiceConnection,
  getServiceCredentials,
  saveServiceConnection,
  deleteServiceConnection,
  recordServiceProbe,
  getServiceInstanceUrl,
  getResolvedServiceCredentials,
} from './queries/service-connections';
export type { ServiceName, ServiceConnection, ServiceCredentials } from './queries/service-connections';
export {
  getAllRoleGrants,
  getRoleGrants,
  setRoleGrant,
  revokeRoleGrant,
  replaceRoleGrants,
} from './queries/capabilities';
export type { RoleGrant } from './queries/capabilities';
export type { CapabilityLevelValue } from './schema/capabilities';
export {
  getVaultTokens,
  setVaultTokens,
  updateVaultAccess,
  clearVaultTokens,
  getVaultUnlockKey,
  setVaultUnlockKey,
  clearVaultUnlockKey,
} from './queries/vault';
export type { VaultTokenSet } from './queries/vault';
export {
  listWallets,
  getWallet,
  getActiveWallet,
  getWalletSecrets,
  getSealedSeed,
  createWallet,
  updateWallet,
  replaceSealedSeed,
  setActiveWallet,
  deleteWallet,
  getWalletLabels,
  setWalletLabel,
  getFrozenOutpoints,
  setUtxoFrozen,
  getWalletChainCache,
  saveWalletChainCache,
  recordWalletChainError,
} from './queries/wallet';
export type {
  WalletKind,
  WalletSummary,
  WalletSecrets,
  WalletLabel,
  CreateWalletParams,
  WalletChainCache,
} from './queries/wallet';
export type { WalletChainSnapshot } from './schema/wallet';

// Exported as a value, not just a type: the API and the UI need to enumerate the roles, and the
// column definition is the only place that list should exist.
export { USER_ROLES, OWNER_USER_ID } from './schema/auth';
export type { UserRole } from './schema/auth';

export { db } from './db';
export * as schema from './schema';

export {
  upsertPushDevice,
  getPushDevices,
  deletePushDevice,
  recordPushFailure,
  markPushDeviceSeen,
} from './queries/notify';
export type { PushDeviceSelect, PushDeviceInsert } from './types';

// App store — what the owner has installed, and whether it should be running.
export {
  listSidecarInstalls,
  getSidecarInstall,
  beginInstall,
  recordSteps,
  markInstalled,
  markFailed,
  markBlocked,
  setEnabled,
  removeInstall,
  type SidecarInstall,
} from './queries/sidecar-installs';
