/** * @fileoverview AdvisoryRepository — vulnerability advisory storage and retrieval * @module @skillsmith/core/repositories/AdvisoryRepository * @see SMI-skill-version-tracking Wave 3 * * Provides CRUD operations for skill security advisories stored in * the skill_advisories table (introduced in migration v6). * * Design notes: * - No FK on skill_id — soft reference, advisory history survives skill removal * - upsertAdvisory is idempotent via INSERT OR REPLACE * - "Active" advisories are those where withdrawn_at IS NULL */ import type { Database as DatabaseType } from '../db/database-interface.js'; /** * A skill security advisory record */ export interface SkillAdvisory { /** SSA-YYYY-NNN format advisory identifier */ id: string; /** Registry skill identifier (soft reference — no FK) */ skillId: string; /** Advisory severity level */ severity: 'low' | 'medium' | 'high' | 'critical'; /** Short advisory title */ title: string; /** Full advisory description */ description: string; /** JSON array of affected version ranges */ affectedVersions?: string; /** JSON array of patched version ranges */ patchedVersions?: string; /** JSON array of CWE identifiers */ cweIds?: string; /** JSON array of reference URLs */ advisoryRefs?: string; /** ISO datetime when advisory was published */ publishedAt: string; /** ISO datetime if advisory was retracted (undefined = still active) */ withdrawnAt?: string; /** Row creation timestamp (set by DB default on insert) */ createdAt?: string; } /** * Repository for reading and writing skill advisory records */ export declare class AdvisoryRepository { private db; constructor(db: DatabaseType); private rowToAdvisory; /** * Insert or replace an advisory record. * * Idempotent: re-running with the same id replaces the existing row. * * @param advisory - Advisory data to persist */ upsertAdvisory(advisory: SkillAdvisory): void; /** * Mark an advisory as withdrawn by setting withdrawn_at to the current time. * * @param id - Advisory identifier to withdraw */ withdrawAdvisory(id: string): void; /** * Get all active (non-withdrawn) advisories for a specific skill. * * @param skillId - Registry skill identifier * @returns Array of active SkillAdvisory records ordered by published_at DESC */ getAdvisoriesForSkill(skillId: string): SkillAdvisory[]; /** * Get all active advisories, optionally filtered by severity. * * @param severity - Optional severity filter; omit to return all active advisories * @returns Array of active SkillAdvisory records ordered by published_at DESC */ getActiveAdvisories(severity?: 'low' | 'medium' | 'high' | 'critical'): SkillAdvisory[]; } //# sourceMappingURL=AdvisoryRepository.d.ts.map