v0.5.170: action=wipe — удаление всех записей компании

This commit is contained in:
2026-06-22 18:20:25 +04:00
parent 4c39eae4a7
commit 4c764eb794
3 changed files with 11 additions and 2 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
// ═══════════════════════════════════════════════════════════════════════════════
module.exports = {
version: '0.5.169',
version: '0.5.170',
// ── IAM ──────────────────────────────────────────────────────────────────
iamUrl: process.env.V2_IAM_URL || 'https://auth-api.ngcloud.ru/api/v1/auth/user',
+9
View File
@@ -114,6 +114,15 @@ function createTestRouter() {
return res.json({ ok: true });
}
// ── WIPE: удалить все записи и аудит компании (clientId) ─
case 'wipe': {
const clientId = req.query.clientId;
if (!clientId) return res.json({ ok: false, error: 'clientId required' });
const e = await pool.query('DELETE FROM v2_entries WHERE company_id IN (SELECT id FROM v2_companies WHERE client_id=$1)', [clientId]);
const a = await pool.query('DELETE FROM v2_audit WHERE company_id IN (SELECT id FROM v2_companies WHERE client_id=$1)', [clientId]);
return res.json({ ok: true, entriesDeleted: e.rowCount, auditDeleted: a.rowCount, clientId });
}
// ── USERFLOW: полная эмуляция юзера через все слои ──────
// Отличие от add/edit/delete: здесь выставляется мок-сессия
// как после KC+IAM+resolveContext, и вызывается crud.