fix(api): correct the record-view POST body shape

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) <noreply@anthropic.com>
This commit is contained in:
Yashas 2026-08-24 15:52:19 +05:30
parent 42cfef12bf
commit 7a86118169

View File

@ -90,18 +90,42 @@ export class ZinoClient {
this.setStoredUser(null) 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 = {}) { recordView(rvUid, params = {}) {
return this.request('POST', `/app/${APP_ID}/view/recordview`, { return this.request('POST', `/app/${APP_ID}/view/recordview`, {
rv_id: rvUid, rv_template_uid: rvUid,
page: params.page ?? 1, search_query: {
limit: params.limit ?? 50, page: params.page ?? 1,
...(params.search ? { search: params.search } : {}), limit: params.limit ?? 50,
...(params.sort_by ? { sort_by: params.sort_by, sort_dir: params.sort_dir ?? 'desc' } : {}), sort_by: params.sort_by ?? '',
...(params.filters ? { search_query: { filters: params.filters } } : {}), 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) { detailView(dvUid, instanceId) {
return this.request( return this.request(
'GET', 'GET',