@harbinger-ai/harbinger 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -98,6 +98,51 @@ export async function getFindingCounts() {
98
98
  return dbCounts();
99
99
  }
100
100
 
101
+ // ── Target Counts ───────────────────────────────────────────────────────────
102
+
103
+ export async function getProgramTargetCounts() {
104
+ await requireAuth();
105
+ const { getDb } = await import('../db/index.js');
106
+ const db = getDb();
107
+ const rows = db.prepare(`
108
+ SELECT program_id, COUNT(*) as total,
109
+ SUM(CASE WHEN status = 'in_scope' THEN 1 ELSE 0 END) as in_scope,
110
+ SUM(CASE WHEN status = 'out_of_scope' THEN 1 ELSE 0 END) as out_of_scope
111
+ FROM targets WHERE program_id IS NOT NULL
112
+ GROUP BY program_id
113
+ `).all();
114
+ const counts = {};
115
+ for (const r of rows) {
116
+ counts[r.program_id] = { total: r.total, inScope: r.in_scope, outOfScope: r.out_of_scope };
117
+ }
118
+ return counts;
119
+ }
120
+
121
+ export async function bulkImportTargets(programId, items) {
122
+ await requireAuth();
123
+ if (!programId || !Array.isArray(items) || items.length === 0) return { imported: 0 };
124
+ const { createTarget: dbCreate } = await import('./targets.js');
125
+ let imported = 0;
126
+ for (const item of items) {
127
+ if (!item.value) continue;
128
+ dbCreate({
129
+ programId,
130
+ type: item.type || 'domain',
131
+ value: item.value.trim(),
132
+ status: item.status || 'in_scope',
133
+ notes: item.notes || null,
134
+ });
135
+ imported++;
136
+ }
137
+ return { imported };
138
+ }
139
+
140
+ export async function exportTargets(programId) {
141
+ await requireAuth();
142
+ const { getTargets: dbGet } = await import('./targets.js');
143
+ return dbGet(programId);
144
+ }
145
+
101
146
  // ── Target Sync ─────────────────────────────────────────────────────────────
102
147
 
103
148
  export async function syncTargetsFromPlatform(platform, options = {}) {