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',