From 7a86118169681ceab31b8f8b29eaee0fe8f15df6 Mon Sep 17 00:00:00 2001 From: Yashas Date: Mon, 24 Aug 2026 15:52:19 +0530 Subject: [PATCH] fix(api): correct the record-view POST body shape MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The POST body is not the GET query params with a different verb. The view is named by rv_template_uid (rv_id is the GET spelling) and paging, sort and filters all live inside search_query. Sending them at the top level returns 400 "Missing param: rv_template_uid (body)". This would have failed the moment the record view was seeded, and the 400 would have read as "the view is missing" rather than "the request was wrong" — the queue screen renders exactly that notice on any error. Verified against dev: the old shape returns the missing-param 400, the new one returns "record view not found", which is the view genuinely not existing yet. Also adds rows(), which normalises the response key — workflow views return `data`, rdbms views have been seen returning `records`. Co-Authored-By: Claude Opus 5 (1M context) --- src/api/client.js | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/src/api/client.js b/src/api/client.js index b3de5bb..2ddaf15 100644 --- a/src/api/client.js +++ b/src/api/client.js @@ -90,18 +90,42 @@ export class ZinoClient { this.setStoredUser(null) } - /** Paginated records for a record view, filtered server-side. */ + /** + * Paginated records for a record view, filtered server-side. + * + * The POST body is NOT the same shape as the GET query params: the view is + * named by `rv_template_uid` (not `rv_id`, which is the GET spelling), and + * paging/sort/filters all live INSIDE `search_query`. Sending them at the top + * level returns `400 Missing param: rv_template_uid (body)`. + */ recordView(rvUid, params = {}) { return this.request('POST', `/app/${APP_ID}/view/recordview`, { - rv_id: rvUid, - page: params.page ?? 1, - limit: params.limit ?? 50, - ...(params.search ? { search: params.search } : {}), - ...(params.sort_by ? { sort_by: params.sort_by, sort_dir: params.sort_dir ?? 'desc' } : {}), - ...(params.filters ? { search_query: { filters: params.filters } } : {}), + rv_template_uid: rvUid, + search_query: { + page: params.page ?? 1, + limit: params.limit ?? 50, + sort_by: params.sort_by ?? '', + sort_dir: params.sort_dir ?? 'desc', + search: params.search ?? '', + filters: (params.filters ?? []).map((f) => ({ + field_key: f.field_key, + value: f.value, + value2: '', + data_type: f.data_type ?? 'string', + })), + }, }) } + /** + * Rows only. The response key differs by source type — workflow views return + * `data`, rdbms views have been seen returning `records`. + */ + async rows(rvUid, params = {}) { + const r = await this.recordView(rvUid, params) + return r?.data ?? r?.records ?? r?.rows ?? [] + } + detailView(dvUid, instanceId) { return this.request( 'GET',