import { issues, labels } from "@rudderhq/db";
import { type IssueSearchMatch } from "@rudderhq/shared";
export declare const ALL_ISSUE_STATUSES: string[];
export declare const MAX_ISSUE_COMMENT_PAGE_LIMIT = 500;
export declare const BOARD_ORDER_STEP = 1000;
export declare function isUniqueConstraintConflict(error: unknown, constraintName: string): boolean;
export declare function assertTransition(from: string, to: string): void;
export declare function applyStatusSideEffects(status: string | undefined, patch: Partial<typeof issues.$inferInsert>): Partial<typeof issues.$inferInsert>;
export interface IssueFilters {
    status?: string;
    assigneeAgentId?: string;
    participantAgentId?: string;
    assigneeUserId?: string;
    reviewerAgentId?: string;
    reviewerUserId?: string;
    excludeReviewerConfirmedBlockedHandoff?: boolean;
    touchedByUserId?: string;
    unreadForUserId?: string;
    projectId?: string;
    parentId?: string;
    labelId?: string;
    originKind?: string;
    originId?: string;
    includeAutomationExecutions?: boolean;
    q?: string;
}
export type IssueRow = typeof issues.$inferSelect;
export type IssueLabelRow = typeof labels.$inferSelect;
export type IssueActiveRunRow = {
    id: string;
    status: string;
    agentId: string;
    invocationSource: string;
    triggerDetail: string | null;
    startedAt: Date | null;
    finishedAt: Date | null;
    createdAt: Date;
};
export type IssueWithLabels = IssueRow & {
    labels: IssueLabelRow[];
    labelIds: string[];
};
export type IssueWithLabelsAndRun = IssueWithLabels & {
    activeRun: IssueActiveRunRow | null;
};
export type IssueWithSearchMatch = IssueWithLabelsAndRun & {
    searchMatch?: IssueSearchMatch | null;
};
export type IssueUserCommentStats = {
    issueId: string;
    myLastCommentAt: Date | null;
    lastExternalCommentAt: Date | null;
};
export type IssueUserContextInput = {
    createdByUserId: string | null;
    assigneeUserId: string | null;
    reviewerUserId: string | null;
    createdAt: Date | string;
    updatedAt: Date | string;
};
export declare function sameRunLock(checkoutRunId: string | null, actorRunId: string | null): boolean;
export declare const TERMINAL_HEARTBEAT_RUN_STATUSES: Set<string>;
export declare function escapeLikePattern(value: string): string;
export declare function textContains(value: string | null | undefined, query: string): value is string;
export declare function buildSearchSnippet(value: string, query: string, maxLength?: number): string;
export declare function fieldSearchMatch(row: IssueRow, query: string): IssueSearchMatch | null;
export declare function touchedByUserCondition(orgId: string, userId: string): import("drizzle-orm").SQL<boolean>;
export declare function participatedByAgentCondition(orgId: string, agentId: string): import("drizzle-orm").SQL<boolean>;
export declare function myLastCommentAtExpr(orgId: string, userId: string): import("drizzle-orm").SQL<Date | null>;
export declare function myLastReadAtExpr(orgId: string, userId: string): import("drizzle-orm").SQL<Date | null>;
export declare function myLastTouchAtExpr(orgId: string, userId: string): import("drizzle-orm").SQL<Date | null>;
export declare function unreadForUserCondition(orgId: string, userId: string): import("drizzle-orm").SQL<boolean>;
export declare function deriveIssueUserContext(issue: IssueUserContextInput, userId: string, stats: {
    myLastCommentAt: Date | string | null;
    myLastReadAt: Date | string | null;
    lastExternalCommentAt: Date | string | null;
} | null | undefined): {
    myLastTouchAt: Date;
    lastExternalCommentAt: Date | null;
    isUnreadForMe: boolean;
};
export declare function labelMapForIssues(dbOrTx: any, issueIds: string[]): Promise<Map<string, IssueLabelRow[]>>;
export declare function withIssueLabels(dbOrTx: any, rows: IssueRow[]): Promise<IssueWithLabels[]>;
export declare const ACTIVE_RUN_STATUSES: string[];
export declare function activeRunMapForIssues(dbOrTx: any, issueRows: IssueWithLabels[]): Promise<Map<string, IssueActiveRunRow>>;
export declare function withActiveRuns(issueRows: IssueWithLabels[], runMap: Map<string, IssueActiveRunRow>): IssueWithLabelsAndRun[];
//# sourceMappingURL=issues.helpers.d.ts.map