From 73013332aeb8a361692f116ca675c52d4e01d19c Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 18 Jun 2024 11:16:21 +0100 Subject: [PATCH] Adding countRows to search validators. --- packages/server/src/api/controllers/row/views.ts | 3 ++- packages/server/src/api/routes/row.ts | 1 + packages/server/src/api/routes/utils/validators.ts | 1 + yarn.lock | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/server/src/api/controllers/row/views.ts b/packages/server/src/api/controllers/row/views.ts index 800cc29ceb..63ce12f0ab 100644 --- a/packages/server/src/api/controllers/row/views.ts +++ b/packages/server/src/api/controllers/row/views.ts @@ -60,7 +60,7 @@ export async function searchView( user: sdk.users.getUserContextBindings(ctx.user), }) - const searchOptions: RequiredKeys> & + const searchOptions: RequiredKeys & RequiredKeys> = { tableId: view.tableId, query: enrichedQuery, @@ -69,6 +69,7 @@ export async function searchView( limit: body.limit, bookmark: body.bookmark, paginate: body.paginate, + countRows: body.countRows, } const result = await sdk.rows.search(searchOptions) diff --git a/packages/server/src/api/routes/row.ts b/packages/server/src/api/routes/row.ts index f1aa39a461..e443b2daeb 100644 --- a/packages/server/src/api/routes/row.ts +++ b/packages/server/src/api/routes/row.ts @@ -86,6 +86,7 @@ router router.post( "/api/v2/views/:viewId/search", + internalSearchValidator(), authorizedResource(PermissionType.VIEW, PermissionLevel.READ, "viewId"), rowController.views.searchView ) diff --git a/packages/server/src/api/routes/utils/validators.ts b/packages/server/src/api/routes/utils/validators.ts index a63b29fe5a..671ce95038 100644 --- a/packages/server/src/api/routes/utils/validators.ts +++ b/packages/server/src/api/routes/utils/validators.ts @@ -109,6 +109,7 @@ export function internalSearchValidator() { sortOrder: OPTIONAL_STRING, sortType: OPTIONAL_STRING, paginate: Joi.boolean(), + countRows: Joi.boolean(), bookmark: Joi.alternatives() .try(OPTIONAL_STRING, OPTIONAL_NUMBER) .optional(), diff --git a/yarn.lock b/yarn.lock index d71dd4da78..7f7def28b3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -21102,7 +21102,7 @@ tar@6.1.15: mkdirp "^1.0.3" yallist "^4.0.0" -tar@^6.1.11, tar@^6.1.2: +tar@6.2.1, tar@^6.1.11, tar@^6.1.2: version "6.2.1" resolved "https://registry.yarnpkg.com/tar/-/tar-6.2.1.tgz#717549c541bc3c2af15751bea94b1dd068d4b03a" integrity sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==