Tidy the structure the audit found

- The colour defaults have one source, server/src/themeDefaults.js,
  read by the server and the admin; the build stops if src/index.css
  disagrees with it
- server/src/admin-schema.js split into admin-schema/, one file per
  entity plus columns.js (the registry checked identical)
- loadOwned() in shape.js replaces the same three loads on four
  detail routes (every public route checked identical); one NO_STORE
- One OrgLogo component for the org lists and the chapter map; an
  organization's own page now shows the same initials as the lists
- One localISO() for the viewer's calendar day, in place of three
- Boot refuses a descriptor dropdown value the table's CHECK doesn't
  allow, instead of it failing on save
- Deleted the unused Other.tsx and white-background logo;
  chapters.ts is useCommunity.ts; isSuper() in the Panel; stale
  comments and docs corrected

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-29 03:02:21 -05:00
parent 048c7599ce
commit f934b1dd93
44 changed files with 1187 additions and 1170 deletions

View file

@ -22,6 +22,15 @@
than waiting to surface one row at a time.
═══════════════════════════════════════════════════════════════ */
/* The values a CHECK (column IN (...)) on the table allows, read from
its CREATE TABLE, or null when there's no such CHECK. */
function checkValues(db, table, column) {
const sql = db.prepare(`SELECT sql FROM sqlite_schema WHERE type = 'table' AND name = ?`).get(table)?.sql ?? "";
const match = new RegExp(`\\b${column}"?\\s+IN\\s*\\(([^)]*)\\)`, "i").exec(sql);
if (!match) return null;
return new Set([...match[1].matchAll(/'((?:[^']|'')*)'/g)].map((m) => m[1].replace(/''/g, "'")));
}
function tableMeta(db, table) {
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
if (!rows.length) return null;
@ -114,6 +123,19 @@ export function syncDescriptorsWithSchema(db, entities) {
inferred.push(`${name}: ${group.table}.${column.name}`);
}
if (info.notNullable) column.notNullable = true;
// A dropdown value the table's CHECK refuses would only fail
// when someone saves it; say so at boot instead.
if (column.type === "enum") {
const allowed = checkValues(db, group.table, column.name);
const refused = allowed ? column.values.filter((value) => !allowed.has(value)) : [];
if (refused.length) {
problems.push(
`${name}: ${group.table}.${column.name} offers ${refused.join(", ")}, ` +
`which the table's CHECK doesn't allow.`,
);
}
}
}
for (const [columnName, info] of meta) {