refactor: centralize host evidence actions (#194)
This commit is contained in:
@@ -1,19 +1,16 @@
|
||||
import type { Database } from 'bun:sqlite';
|
||||
import {
|
||||
DB_EVIDENCE_ACTIONS,
|
||||
isDbEvidenceAction,
|
||||
type DbEvidenceAction,
|
||||
} from 'ejclaw-runners-shared';
|
||||
|
||||
import { parseGitHubCiMetadata } from './github-ci.js';
|
||||
import { extractWatchCiTarget } from './task-watch-status.js';
|
||||
|
||||
type SqlBinding = string | number | bigint | boolean | null | Uint8Array;
|
||||
|
||||
export const DB_EVIDENCE_ACTIONS = [
|
||||
'db_paired_task_status',
|
||||
'db_paired_task_flow',
|
||||
'db_recent_paired_failures',
|
||||
'db_recent_scheduled_tasks',
|
||||
'db_scheduled_task_runs',
|
||||
] as const;
|
||||
|
||||
export type DbEvidenceAction = (typeof DB_EVIDENCE_ACTIONS)[number];
|
||||
export { DB_EVIDENCE_ACTIONS, isDbEvidenceAction, type DbEvidenceAction };
|
||||
|
||||
export interface DbEvidenceRequest {
|
||||
action: DbEvidenceAction;
|
||||
@@ -33,13 +30,6 @@ const DEFAULT_ROW_LIMIT = 20;
|
||||
const MAX_ROW_LIMIT = 100;
|
||||
const TASK_ID_PATTERN = /^[A-Za-z0-9._:@/-]{1,200}$/;
|
||||
|
||||
export function isDbEvidenceAction(value: unknown): value is DbEvidenceAction {
|
||||
return (
|
||||
typeof value === 'string' &&
|
||||
DB_EVIDENCE_ACTIONS.includes(value as DbEvidenceAction)
|
||||
);
|
||||
}
|
||||
|
||||
export function normalizeDbEvidenceMinutes(value?: number): number {
|
||||
if (!Number.isFinite(value)) {
|
||||
return DEFAULT_RECENT_MINUTES;
|
||||
|
||||
Reference in New Issue
Block a user