import { AgentScopeConfig } from "../../db/manage/scope-definitions.js";
import { PaginationConfig } from "../../types/utility.js";
import { AgentsManageDatabaseClient } from "../../db/manage/manage-client.js";
import { TriggerInsert, TriggerSelect, TriggerUpdate } from "../../types/entities.js";

//#region src/data-access/manage/triggers.d.ts
/**
 * Get a trigger by ID (agent-scoped)
 */
declare const getTriggerById: (db: AgentsManageDatabaseClient) => (params: {
  scopes: AgentScopeConfig;
  triggerId: string;
}) => Promise<TriggerSelect | undefined>;
/**
 * List all triggers for an agent
 */
declare const listTriggers: (db: AgentsManageDatabaseClient) => (params: {
  scopes: AgentScopeConfig;
}) => Promise<TriggerSelect[]>;
/**
 * List triggers for an agent with pagination
 */
declare const listTriggersPaginated: (db: AgentsManageDatabaseClient) => (params: {
  scopes: AgentScopeConfig;
  pagination?: PaginationConfig;
}) => Promise<{
  data: {
    createdAt: string;
    updatedAt: string;
    enabled: boolean;
    inputSchema: Record<string, unknown> | null;
    outputTransform: {
      jmespath?: string;
      objectTransformation?: Record<string, string>;
    } | null;
    messageTemplate: string | null;
    authentication: unknown;
    signingSecretCredentialReferenceId: string | null;
    signatureVerification: {
      algorithm: "sha256" | "sha512" | "sha384" | "sha1" | "md5";
      encoding: "hex" | "base64";
      signature: {
        source: "query" | "header" | "body";
        key: string;
        prefix?: string | undefined;
        regex?: string | undefined;
      };
      signedComponents: {
        source: "literal" | "header" | "body";
        required: boolean;
        key?: string | undefined;
        value?: string | undefined;
        regex?: string | undefined;
      }[];
      componentJoin: {
        strategy: "concatenate";
        separator: string;
      };
      validation?: {
        headerCaseSensitive: boolean;
        allowEmptyBody: boolean;
        normalizeUnicode: boolean;
      } | undefined;
    } | null;
    runAsUserId: string | null;
    dispatchDelayMs: number | null;
    createdBy: string | null;
    name: string;
    description: string | null;
    agentId: string;
    projectId: string;
    tenantId: string;
    id: string;
  }[];
  pagination: {
    page: number;
    limit: number;
    total: number;
    pages: number;
  };
}>;
/**
 * Create a new trigger (agent-scoped)
 */
declare const createTrigger: (db: AgentsManageDatabaseClient) => (params: TriggerInsert) => Promise<TriggerSelect>;
declare const createTriggerWithUsers: (db: AgentsManageDatabaseClient) => (params: {
  trigger: TriggerInsert;
  userIds: string[];
}) => Promise<TriggerSelect>;
/**
 * Update a trigger (agent-scoped)
 */
declare const updateTrigger: (db: AgentsManageDatabaseClient) => (params: {
  scopes: AgentScopeConfig;
  triggerId: string;
  data: TriggerUpdate;
}) => Promise<TriggerSelect>;
/**
 * Delete a trigger (agent-scoped)
 */
declare const deleteTrigger: (db: AgentsManageDatabaseClient) => (params: {
  scopes: AgentScopeConfig;
  triggerId: string;
}) => Promise<void>;
/**
 * Delete all webhook triggers for a given runAsUserId within a tenant+project scope.
 * Operates across all agents in the project (not agent-scoped).
 */
declare const deleteTriggersByRunAsUserId: (db: AgentsManageDatabaseClient) => (params: {
  tenantId: string;
  projectId: string;
  runAsUserId: string;
}) => Promise<void>;
declare const getTriggerUsers: (db: AgentsManageDatabaseClient) => (params: {
  scopes: AgentScopeConfig;
  triggerId: string;
}) => Promise<{
  tenantId: string;
  projectId: string;
  agentId: string;
  triggerId: string;
  userId: string;
  createdAt: string;
}[]>;
declare const getTriggerUsersBatch: (db: AgentsManageDatabaseClient) => (params: {
  scopes: AgentScopeConfig;
  triggerIds: string[];
}) => Promise<Map<string, string[]>>;
declare const createTriggerUser: (db: AgentsManageDatabaseClient) => (params: {
  scopes: AgentScopeConfig;
  triggerId: string;
  userId: string;
}) => Promise<{
  createdAt: string;
  tenantId: string;
  projectId: string;
  agentId: string;
  userId: string;
  triggerId: string;
}>;
declare const deleteTriggerUser: (db: AgentsManageDatabaseClient) => (params: {
  scopes: AgentScopeConfig;
  triggerId: string;
  userId: string;
}) => Promise<void>;
declare const setTriggerUsers: (db: AgentsManageDatabaseClient) => (params: {
  scopes: AgentScopeConfig;
  triggerId: string;
  userIds: string[];
}) => Promise<void>;
declare const getTriggerUserCount: (db: AgentsManageDatabaseClient) => (params: {
  scopes: AgentScopeConfig;
  triggerId: string;
}) => Promise<number>;
declare const getWebhookTriggerIdsWithUser: (db: AgentsManageDatabaseClient) => (params: {
  tenantId: string;
  projectId: string;
  userId: string;
}) => Promise<{
  agentId: string;
  id: string;
}[]>;
declare const removeUserFromProjectTriggerUsers: (db: AgentsManageDatabaseClient) => (params: {
  tenantId: string;
  projectId: string;
  userId: string;
}) => Promise<void>;
/**
 * Upsert a trigger (create or update based on existence)
 */
declare const upsertTrigger: (db: AgentsManageDatabaseClient) => (params: {
  scopes: AgentScopeConfig;
  data: TriggerInsert;
}) => Promise<TriggerSelect>;
//#endregion
export { createTrigger, createTriggerUser, createTriggerWithUsers, deleteTrigger, deleteTriggerUser, deleteTriggersByRunAsUserId, getTriggerById, getTriggerUserCount, getTriggerUsers, getTriggerUsersBatch, getWebhookTriggerIdsWithUser, listTriggers, listTriggersPaginated, removeUserFromProjectTriggerUsers, setTriggerUsers, updateTrigger, upsertTrigger };