From 86ab50fe33b6048e397ada4e70413988e62d8dd9 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 11 Aug 2022 14:40:17 +0100 Subject: [PATCH] Fixing viewname enumeration. --- packages/server/src/api/controllers/view/utils.js | 4 ++-- packages/server/src/db/linkedRows/linkUtils.js | 4 ++-- packages/server/src/db/utils.js | 4 ++-- packages/server/src/db/views/staticViews.js | 11 +++-------- packages/server/src/utilities/routing/index.js | 4 ++-- 5 files changed, 11 insertions(+), 16 deletions(-) diff --git a/packages/server/src/api/controllers/view/utils.js b/packages/server/src/api/controllers/view/utils.js index bb3819f290..97a179532e 100644 --- a/packages/server/src/api/controllers/view/utils.js +++ b/packages/server/src/api/controllers/view/utils.js @@ -1,5 +1,5 @@ const { - ViewNames, + ViewName, generateMemoryViewID, getMemoryViewParams, DocumentType, @@ -32,7 +32,7 @@ exports.getViews = async () => { const designDoc = await db.get("_design/database") for (let name of Object.keys(designDoc.views)) { // Only return custom views, not built ins - if (Object.values(ViewNames).indexOf(name) !== -1) { + if (Object.values(ViewName).indexOf(name) !== -1) { continue } response.push({ diff --git a/packages/server/src/db/linkedRows/linkUtils.js b/packages/server/src/db/linkedRows/linkUtils.js index 5af4aa919a..5fc393ecf0 100644 --- a/packages/server/src/db/linkedRows/linkUtils.js +++ b/packages/server/src/db/linkedRows/linkUtils.js @@ -1,5 +1,5 @@ const Sentry = require("@sentry/node") -const { ViewNames, getQueryIndex } = require("../utils") +const { ViewName, getQueryIndex } = require("../utils") const { FieldTypes } = require("../../constants") const { createLinkView } = require("../views/staticViews") const { getAppDB } = require("@budibase/backend-core/context") @@ -41,7 +41,7 @@ exports.getLinkDocuments = async function (args) { } params.include_docs = !!includeDocs try { - let linkRows = (await db.query(getQueryIndex(ViewNames.LINK), params)).rows + let linkRows = (await db.query(getQueryIndex(ViewName.LINK), params)).rows // filter to get unique entries const foundIds = [] linkRows = linkRows.filter(link => { diff --git a/packages/server/src/db/utils.js b/packages/server/src/db/utils.js index 8a556dd854..d23152a663 100644 --- a/packages/server/src/db/utils.js +++ b/packages/server/src/db/utils.js @@ -12,7 +12,7 @@ const { getDevelopmentAppID, generateAppID, getQueryIndex, - ViewNames, + ViewName, } = require("@budibase/backend-core/db") const UNICODE_MAX = "\ufff0" @@ -69,7 +69,7 @@ exports.isProdAppID = isProdAppID exports.USER_METDATA_PREFIX = `${DocumentType.ROW}${SEPARATOR}${InternalTables.USER_METADATA}${SEPARATOR}` exports.LINK_USER_METADATA_PREFIX = `${DocumentType.LINK}${SEPARATOR}${InternalTables.USER_METADATA}${SEPARATOR}` exports.TABLE_ROW_PREFIX = `${DocumentType.ROW}${SEPARATOR}${DocumentType.TABLE}` -exports.ViewNames = ViewNames +exports.ViewName = ViewName exports.InternalTables = InternalTables exports.DocumentType = DocumentType exports.SEPARATOR = SEPARATOR diff --git a/packages/server/src/db/views/staticViews.js b/packages/server/src/db/views/staticViews.js index f51e695f27..d715c02968 100644 --- a/packages/server/src/db/views/staticViews.js +++ b/packages/server/src/db/views/staticViews.js @@ -1,10 +1,5 @@ const { getAppDB } = require("@budibase/backend-core/context") -const { - DocumentType, - SEPARATOR, - ViewNames, - SearchIndexes, -} = require("../utils") +const { DocumentType, SEPARATOR, ViewName, SearchIndexes } = require("../utils") const SCREEN_PREFIX = DocumentType.SCREEN + SEPARATOR /************************************************** @@ -53,7 +48,7 @@ exports.createLinkView = async () => { } designDoc.views = { ...designDoc.views, - [ViewNames.LINK]: view, + [ViewName.LINK]: view, } await db.put(designDoc) } @@ -74,7 +69,7 @@ exports.createRoutingView = async () => { } designDoc.views = { ...designDoc.views, - [ViewNames.ROUTING]: view, + [ViewName.ROUTING]: view, } await db.put(designDoc) } diff --git a/packages/server/src/utilities/routing/index.js b/packages/server/src/utilities/routing/index.js index b68001c3c3..963119130b 100644 --- a/packages/server/src/utilities/routing/index.js +++ b/packages/server/src/utilities/routing/index.js @@ -1,11 +1,11 @@ const { createRoutingView } = require("../../db/views/staticViews") -const { ViewNames, getQueryIndex, UNICODE_MAX } = require("../../db/utils") +const { ViewName, getQueryIndex, UNICODE_MAX } = require("../../db/utils") const { getAppDB } = require("@budibase/backend-core/context") exports.getRoutingInfo = async () => { const db = getAppDB() try { - const allRouting = await db.query(getQueryIndex(ViewNames.ROUTING), { + const allRouting = await db.query(getQueryIndex(ViewName.ROUTING), { startKey: "", endKey: UNICODE_MAX, })