Hub 2.6.0: paged lists, job status filters, one-product updates, installs found on servers

- Jobs: Succeeded/Cancelled filters, product, type and church search, paged
  on the server; audit log and alerts paged on the server with search;
  every other list paged.
- Updates: one product at a time with its own releases; an Events update
  pins the church's Accounts (or updates it when the release needs it, or
  installs it first); fixes the requirement check comparing an object.
- A status job adds installs found on a server and ties them to their
  registration; unlinked registered sites trigger one (daily); heartbeats
  tie install records too; the install page shows its registration.
13 new tests (209).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-19 20:09:31 +02:00
co-authored by Claude Opus 5.5
parent ff176681a7
commit de6a14c229
24 changed files with 641 additions and 130 deletions
+23 -7
View File
@@ -3,6 +3,7 @@
const express = require('express');
const rateLimit = require('express-rate-limit');
const prisma = require('../config/db');
const { pageOf, paged, searchTerm } = require('../utils/paging');
const { protect } = require('../middleware/auth');
const { generateLicence, checkReopen } = require('../utils/licences');
const { PRODUCTS, isProduct, PRODUCT_NAMES } = require('../utils/products');
@@ -288,17 +289,32 @@ router.post('/installs/:id/public-key/clear', wrap(async (req, res) => {
// ─── Alerts and history ───────────────────────────────────────────────────────
// Hub 2.6.0: both paged (?page, ?pageSize) with a search (?q), instead of the last 200 / 300.
router.get('/events', wrap(async (req, res) => {
const where = req.query.open === 'true' ? { resolvedAt: null, level: { not: 'info' } } : {};
const events = await prisma.installEvent.findMany({
where, orderBy: { createdAt: 'desc' }, take: 200,
include: { install: { select: { id: true, name: true, url: true } } },
});
res.json(events);
const and = [];
if (req.query.open === 'true') and.push({ resolvedAt: null, level: { not: 'info' } });
const term = searchTerm(req.query.q);
if (term) {
and.push({ OR: [
{ message: { contains: term, mode: 'insensitive' } },
{ level: { contains: term, mode: 'insensitive' } },
{ install: { name: { contains: term, mode: 'insensitive' } } },
{ install: { url: { contains: term, mode: 'insensitive' } } },
] });
}
const out = await paged(prisma.installEvent, { where: and.length ? { AND: and } : {}, orderBy: { createdAt: 'desc' }, include: { install: { select: { id: true, name: true, url: true } } } }, pageOf(req.query));
res.json({ events: out.rows, total: out.total, page: out.page, pageSize: out.pageSize, pages: out.pages });
}));
router.get('/audit', wrap(async (req, res) => {
res.json(await prisma.auditLog.findMany({ orderBy: { createdAt: 'desc' }, take: 300, include: { actor: { select: { name: true } } } }));
const term = searchTerm(req.query.q);
const where = term ? { OR: [
{ action: { contains: term.replace(/s+/g, '_'), mode: 'insensitive' } },
{ target: { contains: term, mode: 'insensitive' } },
{ actor: { name: { contains: term, mode: 'insensitive' } } },
] } : {};
const out = await paged(prisma.auditLog, { where, orderBy: { createdAt: 'desc' }, include: { actor: { select: { name: true } } } }, pageOf(req.query));
res.json({ entries: out.rows, total: out.total, page: out.page, pageSize: out.pageSize, pages: out.pages });
}));
// ─── Releases ─────────────────────────────────────────────────────────────────