From 0845bde7b4fc9fcb9aac8906c38df34127319654 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 23 Jul 2021 15:55:58 +0100 Subject: [PATCH 1/3] Add missing version to paginated search endpoint --- packages/server/src/api/controllers/row/internalSearch.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/server/src/api/controllers/row/internalSearch.js b/packages/server/src/api/controllers/row/internalSearch.js index a1aa77b34a..e525a95675 100644 --- a/packages/server/src/api/controllers/row/internalSearch.js +++ b/packages/server/src/api/controllers/row/internalSearch.js @@ -335,6 +335,7 @@ exports.paginatedSearch = async (appId, query, params) => { } limit = Math.min(limit, 200) const search = new QueryBuilder(appId, query) + .setVersion(params.version) .setTable(params.tableId) .setSort(params.sort) .setSortOrder(params.sortOrder) From 143135151a0c62c79a3502bf62261fdcd2c5886d Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 23 Jul 2021 15:56:18 +0100 Subject: [PATCH 2/3] Send api version as header with every request from client library --- packages/client/src/api/api.js | 5 ++++- packages/client/src/constants.js | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/client/src/api/api.js b/packages/client/src/api/api.js index 280b580164..b915f14fd1 100644 --- a/packages/client/src/api/api.js +++ b/packages/client/src/api/api.js @@ -1,7 +1,9 @@ +import { notificationStore } from "../store" +import { ApiVersion } from "../constants" + /** * API cache for cached request responses. */ -import { notificationStore } from "../store" let cache = {} /** @@ -22,6 +24,7 @@ const makeApiCall = async ({ method, url, body, json = true }) => { const headers = { Accept: "application/json", "x-budibase-app-id": window["##BUDIBASE_APP_ID##"], + "x-budibase-api-version": ApiVersion, ...(json && { "Content-Type": "application/json" }), ...(!inBuilder && { "x-budibase-type": "client" }), } diff --git a/packages/client/src/constants.js b/packages/client/src/constants.js index 31ac4b285e..e0595c0ce9 100644 --- a/packages/client/src/constants.js +++ b/packages/client/src/constants.js @@ -7,3 +7,11 @@ export const ActionTypes = { RefreshDatasource: "RefreshDatasource", SetDataProviderQuery: "SetDataProviderQuery", } + +export const ApiVersion = "1" + +/** + * API Version Changelog + * v1: + * - Coerce types for search endpoint + */ From 78dc524f79c5a48dc0406dfa61f0a857a70f7e14 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 23 Jul 2021 15:57:50 +0100 Subject: [PATCH 3/3] Fix setVersion not returning itself to restore builder syntax compatibility --- packages/server/src/api/controllers/row/internalSearch.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/server/src/api/controllers/row/internalSearch.js b/packages/server/src/api/controllers/row/internalSearch.js index e525a95675..c13091d6e8 100644 --- a/packages/server/src/api/controllers/row/internalSearch.js +++ b/packages/server/src/api/controllers/row/internalSearch.js @@ -28,6 +28,7 @@ class QueryBuilder { setVersion(version) { this.version = version + return this } setTable(tableId) {