Description
Summary
The batch endpoint (POST /deco/invoke, and /live/invoke via the alias from #645) only understands the framework's own shape { "<handler key>": props }. deco-runtime's contract (runtime/routes/batchInvoke.ts + utils/invoke.ts), which existing clients (mobile apps, partner integrations) were built against, is an InvokePayload:
- a single call:
{ "key": "site/actions/foo.ts", "props": {…}, "select": ["a.b"] } - or aliases whose values are calls or nested aliases:
{ "alias": { "key": "…", "props": {…} } } - where
keyis a loader/action or a saved block name ("Global Config","PLP Banners"), resolved with the saved props over the call's props, following block references.
Today dispatchInvoke treats each top-level key as a handler name, so both forms answer 200 with per-key errors:
POST /live/invoke {"key":"site/actions/apple-auth/exchange.ts","props":{…}}
→ 200 {"key":{"error":"Unknown handler: key…"},"props":{"error":"Unknown handler: props…"}} (Fresh: the action's own 401)
POST /live/invoke {"globalConfig":{"key":"Global Config"}}
→ 200 {"globalConfig":{"error":"Unknown handler: globalConfig…"}} (Fresh: the resolved block)
The framework's own useLoadMore (blocks/src/hooks/useLoadMore.ts) posts { key, props } to /deco/invoke, so it hits the same bug.
deco-runtime semantics worth matching
isInvokeFunc= haskey; otherwise recurse into the object as aliases.invokeresolver: registered handler → run; saved block →resolve({ ...props, ...savedProps, __resolveType }); unknown →{ ...props, __resolveType: key }. A leading#inkeyis stripped. Function keys carry the extension (…/storeConfig.ts).select: dot paths (pickPaths, mapped over arrays).- Result: a handler
Responseis returned as is (single call) / serializes to{}(inside a batch);undefined→ 204; any throw fails the whole call with 500 and the error text as body. - CORS headers only for admin origins / localhost.
Proposal
Teach dispatchInvoke the InvokePayload shape (keeping the __resolveType batch for existing callers). Site-level workaround in deco-sites/oficina-tanstack: src/sdk/fresh-invoke.ts (QA-155 / QA-157).
Activity