fix(plugins): JSON-serialize CallFunctionJSON return values + backward compat Lua args
Root cause: CallFunctionJSON used .String() on Lua return values, which for tables produces 'table: 0x...' — not valid JSON. Frontend does JSON.parse() on the result and silently caught the parse error. Fix: - runtime.go: convert Lua return value to JSON via luaValueToGo + json.Marshal so tables become proper JSON arrays/objects - main.lua: add backward compat in get_events() and update_event() to accept both positional args (start, end) and table params - CalendarPluginPage.svelte: show errors in UI instead of silent catch; restructure template to always show iframe + error overlay
This commit is contained in:
@@ -143,9 +143,13 @@ end
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- Get events within a date range (inclusive)
|
||||
function M.get_events(params)
|
||||
function M.get_events(params, end_date)
|
||||
-- Backward compat: support positional (start, end) and table {start=, end=}
|
||||
if type(params) == "string" then
|
||||
return M.get_events{ start_date = params, ["end"] = end_date or params }
|
||||
end
|
||||
local start_date = params.start_date or params.start
|
||||
local end_date = params.end_date or params["end"] or params.end_date
|
||||
local end_date = params["end"] or params.end_date or params.end_date
|
||||
if not start_date then error("start_date required") end
|
||||
if not end_date then end_date = start_date end
|
||||
return verstak.db.query(
|
||||
@@ -244,7 +248,15 @@ function M.create_event(opts)
|
||||
end
|
||||
|
||||
-- Update an event (partial fields)
|
||||
function M.update_event(params)
|
||||
function M.update_event(params, fields)
|
||||
-- Backward compat: support positional (id, fields) and table { id = ..., ... }
|
||||
if type(params) == "string" then
|
||||
local t = { id = params }
|
||||
if fields then
|
||||
for k, v in pairs(fields) do t[k] = v end
|
||||
end
|
||||
return M.update_event(t)
|
||||
end
|
||||
local id = params.id
|
||||
if not id then error("event id required") end
|
||||
local old = verstak.db.query_row("SELECT * FROM events WHERE id = ?", id)
|
||||
|
||||
Reference in New Issue
Block a user