feat(core): type definitions with an emoji icon, synced as PutTypeDef

Schema v8 adds type_defs (name, icon, tombstone, hlc). create_type,
set_type_icon, remove_type and rename_type; rename_tag moves the icon and
type_catalog lists icons and defined-but-unused types.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Opus 5.5 committed 2026-10-26 06:33:33 +01:00
1 parent a8559fd467
commit 206b62d4ab
8 files changed
+471 -16

No files matched your search

+29
View File
@@ -1161,6 +1161,19 @@ impl Graph {
true
}
}
Op::PutTypeDef { def } => {
let local: Option<String> = self
.row(
"SELECT hlc FROM type_defs WHERE type_key=?1",
[title_key(&def.name)],
|r| r.get(0),
)
.optional()?;
local.is_none_or(|l| hlc > l.as_str()) && {
self.write_type_def_row(def, hlc)?;
true
}
}
};
if applied {
self.log(hlc, op)?;
@@ -1404,6 +1417,22 @@ impl Graph {
Ok(())
}
/// Stores a type definition row (no op logged), keyed by the name's [`title_key`].
pub(crate) fn write_type_def_row(&self, def: &TypeDef, hlc: &str) -> Result<()> {
self.exec(
"INSERT OR REPLACE INTO type_defs(type_key, name, icon, removed, hlc)
VALUES (?1, ?2, ?3, ?4, ?5)",
params![
title_key(&def.name),
def.name.trim(),
def.icon,
def.removed,
hlc
],
)?;
Ok(())
}
/// Page whose own title (not alias) matches, case-insensitively.
fn page_by_exact_title(&self, title: &str) -> Result<Option<Page>> {
Ok(self