refactor(api): use audit operation constants and the shared zone not found error in zone handlers

- refactor(api): use audit operation constants and the shared zone not found error in zone handlers
- fix(api): return the stored content of rows with check errors
- fix(api): return warnings from record deletes, zone creation and import apply
- fix(api): allow repairing rows stored with a non canonical zone and invalid SOA sets
- fix(check): accept JSON column formatting and an absent SOA serial as canonical content
- fix(ui): match audit diff items by identity instead of array index
- fix(ui): count the SOA change once, report import warnings and check the request size
- fix(ui): edit the selected SOA row, keep the server order, show error rows raw and report write warnings
- test(check): cover triggering and clean pairs with exact codes and record ids
- test(records): cover SRV port, SOA timer and CAA value boundaries
- test(cli): check the exact check output and the exit code of warning-only zones
- refactor(import): order current rows with cmp.Compare
- test(check): cover malformed stored content and a mailbox stored as an address
- test(api): cover zone write failure paths, ambiguous SOA updates and unchanged record detection
This commit is contained in:
bryanpedini committed 2026-11-19 15:46:12 +01:00
1 parent 53444bec7a
commit a7ba01fc77
21 files changed
+1315 -170

No files matched your search

+29 -3
View File
@@ -20,9 +20,25 @@ function show(value) {
return value === undefined ? "(none)" : JSON.stringify(value);
}
export function diffRows(before, after) {
const left = flatten(before === undefined ? null : before, "", new Map());
const right = flatten(after === undefined ? null : after, "", new Map());
function itemLabel(item, index) {
if (item !== null && typeof item === "object" && !Array.isArray(item)) {
if ("record_type" in item && "id" in item) return "record " + item.id;
if ("zone" in item && "username" in item && !("id" in item)) return "delegation " + item.zone + " " + item.username;
if ("username" in item && "id" in item) return "user " + item.id;
}
return "[" + index + "]";
}
function keyed(value) {
const out = new Map();
const items = Array.isArray(value) ? value : value === null || value === undefined ? [] : [value];
items.forEach((item, index) => out.set(itemLabel(item, index), item));
return out;
}
function diffValues(before, after, prefix) {
const left = before === undefined ? new Map() : flatten(before, prefix, new Map());
const right = after === undefined ? new Map() : flatten(after, prefix, new Map());
const paths = [...new Set([...left.keys(), ...right.keys()])].filter((path) => path !== "");
return paths.map((path) => {
const old = left.get(path);
@@ -35,6 +51,16 @@ export function diffRows(before, after) {
});
}
export function diffRows(before, after) {
if (!Array.isArray(before) && !Array.isArray(after)) {
return diffValues(before === undefined ? null : before, after === undefined ? null : after, "");
}
const left = keyed(before);
const right = keyed(after);
const labels = [...new Set([...left.keys(), ...right.keys()])];
return labels.flatMap((label) => diffValues(left.has(label) ? left.get(label) : undefined, right.has(label) ? right.get(label) : undefined, label));
}
function diffTable(entry) {
const rows = diffRows(entry.before, entry.after);
if (rows.length === 0) return h("p", { class: "muted", text: "No field-level data." });