import { AgentScopeConfig } from "../../db/manage/scope-definitions.js";
import { PaginationConfig } from "../../types/utility.js";
import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
import { ScheduledTrigger, ScheduledTriggerInsert } from "../../types/entities.js";

//#region src/data-access/runtime/scheduledTriggers.d.ts
declare const getScheduledTriggerById: (db: AgentsRunDatabaseClient) => (params: {
  scopes: {
    tenantId: string;
    projectId: string;
    agentId?: string;
  };
  scheduledTriggerId: string;
}) => Promise<ScheduledTrigger | undefined>;
declare const listScheduledTriggersPaginated: (db: AgentsRunDatabaseClient) => (params: {
  scopes: AgentScopeConfig;
  pagination?: PaginationConfig;
}) => Promise<{
  data: {
    createdAt: string;
    updatedAt: string;
    agentId: string | null;
    name: string;
    description: string | null;
    enabled: boolean;
    cronExpression: string | null;
    cronTimezone: string | null;
    runAt: string | null;
    payload: Record<string, unknown> | null;
    messageTemplate: string | null;
    maxRetries: number;
    retryDelaySeconds: number;
    timeoutSeconds: number;
    runAsUserId: string | null;
    createdBy: string | null;
    nextRunAt: string | null;
    ref: string;
    dispatchDelayMs: number | null;
    datasetRunConfigId: string | null;
    projectId: string;
    tenantId: string;
    id: string;
  }[];
  pagination: {
    page: number;
    limit: number;
    total: number;
    pages: number;
  };
}>;
declare const createScheduledTrigger: (db: AgentsRunDatabaseClient) => (params: ScheduledTriggerInsert & {
  nextRunAt?: string | null;
}) => Promise<ScheduledTrigger>;
declare const updateScheduledTrigger: (db: AgentsRunDatabaseClient) => (params: {
  scopes: {
    tenantId: string;
    projectId: string;
    agentId?: string;
  };
  scheduledTriggerId: string;
  data: Partial<ScheduledTriggerInsert> & {
    nextRunAt?: string | null;
  };
}) => Promise<ScheduledTrigger>;
declare const deleteScheduledTrigger: (db: AgentsRunDatabaseClient) => (params: {
  scopes: {
    tenantId: string;
    projectId: string;
    agentId?: string;
  };
  scheduledTriggerId: string;
}) => Promise<void>;
declare const upsertScheduledTrigger: (db: AgentsRunDatabaseClient) => (params: {
  scopes: AgentScopeConfig;
  data: ScheduledTriggerInsert;
}) => Promise<ScheduledTrigger>;
declare const deleteScheduledTriggersByRunAsUserId: (db: AgentsRunDatabaseClient) => (params: {
  tenantId: string;
  projectId: string;
  runAsUserId: string;
}) => Promise<void>;
declare const listScheduledTriggers: (db: AgentsRunDatabaseClient) => (params: {
  scopes: AgentScopeConfig;
}) => Promise<ScheduledTrigger[]>;
/**
 * Query due scheduled triggers across all projects directly from the runtime DB.
 * No AS OF queries needed - simple WHERE clause on enabled + nextRunAt.
 */
declare const findDueScheduledTriggersAcrossProjects: (db: AgentsRunDatabaseClient) => (params: {
  asOf: string;
}) => Promise<ScheduledTrigger[]>;
/**
 * Advance the next_run_at timestamp for a scheduled trigger in the runtime DB.
 * No withRef scope needed - direct update.
 */
declare const advanceScheduledTriggerNextRunAt: (db: AgentsRunDatabaseClient) => (params: {
  scopes: {
    tenantId: string;
    projectId: string;
    agentId?: string;
  };
  scheduledTriggerId: string;
  nextRunAt: string | null;
  enabled?: boolean;
}) => Promise<void>;
declare const findScheduledTriggerByDatasetRunConfigId: (db: AgentsRunDatabaseClient) => (params: {
  tenantId: string;
  projectId: string;
  datasetRunConfigId: string;
}) => Promise<ScheduledTrigger | undefined>;
//#endregion
export { advanceScheduledTriggerNextRunAt, createScheduledTrigger, deleteScheduledTrigger, deleteScheduledTriggersByRunAsUserId, findDueScheduledTriggersAcrossProjects, findScheduledTriggerByDatasetRunConfigId, getScheduledTriggerById, listScheduledTriggers, listScheduledTriggersPaginated, updateScheduledTrigger, upsertScheduledTrigger };