refactor: tighten LuaCATS annotations and canonicalize metadata fields (#141)
* refactor: tighten LuaCATS annotations across modules Problem: type annotations repeated inline unions with no aliases, used `table<string, any>` where structured types exist, and had loose `string` where union types should be used. Solution: add `pending.TaskStatus`, `pending.RecurMode`, `pending.TaskExtra`, `pending.ForgeType`, `pending.ForgeState`, `pending.ForgeAuthStatus` aliases and `pending.SyncBackend` interface. Replace inline unions and loose types with the new aliases in `store.lua`, `forge.lua`, `config.lua`, `diff.lua`, `views.lua`, `parse.lua`, `init.lua`, and `oauth.lua`. * refactor: canonicalize internal metadata field names Problem: `pending.Metadata` used shorthand field names (`cat`, `rec`, `rec_mode`) matching user-facing token syntax, coupling internal representation to config. `RecurSpec.from_completion` used a boolean where a `pending.RecurMode` alias exists. `category_syntax` was hardcoded to `'cat'` with no config option. Solution: rename `Metadata` fields to `category`/`recur`/`recur_mode`, add `category_syntax` config option (default `'cat'`), rename `ParsedEntry` fields to match, replace `RecurSpec.from_completion` with `mode: pending.RecurMode`, and restore `[string]` indexer on `pending.ForgeConfig` alongside explicit fields.
This commit is contained in:
parent
287a4e32e3
commit
b131d6d391
16 changed files with 144 additions and 80 deletions
|
|
@ -7,11 +7,11 @@ local parse = require('pending.parse')
|
|||
---@field id? integer
|
||||
---@field description? string
|
||||
---@field priority? integer
|
||||
---@field status? string
|
||||
---@field status? pending.TaskStatus
|
||||
---@field category? string
|
||||
---@field due? string
|
||||
---@field rec? string
|
||||
---@field rec_mode? string
|
||||
---@field recur? string
|
||||
---@field recur_mode? pending.RecurMode
|
||||
---@field forge_ref? pending.ForgeRef
|
||||
---@field lnum integer
|
||||
|
||||
|
|
@ -65,10 +65,10 @@ function M.parse_buffer(lines)
|
|||
description = description,
|
||||
priority = priority,
|
||||
status = status,
|
||||
category = metadata.cat or current_category or config.get().default_category,
|
||||
category = metadata.category or current_category or config.get().default_category,
|
||||
due = metadata.due,
|
||||
rec = metadata.rec,
|
||||
rec_mode = metadata.rec_mode,
|
||||
recur = metadata.recur,
|
||||
recur_mode = metadata.recur_mode,
|
||||
forge_ref = forge_ref,
|
||||
lnum = i,
|
||||
})
|
||||
|
|
@ -126,8 +126,8 @@ function M.apply(lines, s, hidden_ids)
|
|||
category = entry.category,
|
||||
priority = entry.priority,
|
||||
due = entry.due,
|
||||
recur = entry.rec,
|
||||
recur_mode = entry.rec_mode,
|
||||
recur = entry.recur,
|
||||
recur_mode = entry.recur_mode,
|
||||
order = order_counter,
|
||||
_extra = entry.forge_ref and { _forge_ref = entry.forge_ref } or nil,
|
||||
})
|
||||
|
|
@ -157,13 +157,13 @@ function M.apply(lines, s, hidden_ids)
|
|||
task.due = entry.due
|
||||
changed = true
|
||||
end
|
||||
if entry.rec ~= nil then
|
||||
if task.recur ~= entry.rec then
|
||||
task.recur = entry.rec
|
||||
if entry.recur ~= nil then
|
||||
if task.recur ~= entry.recur then
|
||||
task.recur = entry.recur
|
||||
changed = true
|
||||
end
|
||||
if task.recur_mode ~= entry.rec_mode then
|
||||
task.recur_mode = entry.rec_mode
|
||||
if task.recur_mode ~= entry.recur_mode then
|
||||
task.recur_mode = entry.recur_mode
|
||||
changed = true
|
||||
end
|
||||
end
|
||||
|
|
@ -201,8 +201,8 @@ function M.apply(lines, s, hidden_ids)
|
|||
category = entry.category,
|
||||
priority = entry.priority,
|
||||
due = entry.due,
|
||||
recur = entry.rec,
|
||||
recur_mode = entry.rec_mode,
|
||||
recur = entry.recur,
|
||||
recur_mode = entry.recur_mode,
|
||||
order = order_counter,
|
||||
_extra = entry.forge_ref and { _forge_ref = entry.forge_ref } or nil,
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue