@budibase/backend-core 2.29.15 → 2.29.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/db/utils.ts CHANGED
@@ -206,3 +206,29 @@ export function pagination<T>(
206
206
  nextPage,
207
207
  }
208
208
  }
209
+
210
+ export function isSqsEnabledForTenant(): boolean {
211
+ const tenantId = getTenantId()
212
+ if (!env.SQS_SEARCH_ENABLE) {
213
+ return false
214
+ }
215
+
216
+ // This is to guard against the situation in tests where tests pass because
217
+ // we're not actually using SQS, we're using Lucene and the tests pass due to
218
+ // parity.
219
+ if (env.isTest() && env.SQS_SEARCH_ENABLE_TENANTS.length === 0) {
220
+ throw new Error(
221
+ "to enable SQS you must specify a list of tenants in the SQS_SEARCH_ENABLE_TENANTS env var"
222
+ )
223
+ }
224
+
225
+ // Special case to enable all tenants, for testing in QA.
226
+ if (
227
+ env.SQS_SEARCH_ENABLE_TENANTS.length === 1 &&
228
+ env.SQS_SEARCH_ENABLE_TENANTS[0] === "*"
229
+ ) {
230
+ return true
231
+ }
232
+
233
+ return env.SQS_SEARCH_ENABLE_TENANTS.includes(tenantId)
234
+ }
@@ -116,6 +116,9 @@ const environment = {
116
116
  COUCH_DB_URL: process.env.COUCH_DB_URL || "http://localhost:4005",
117
117
  COUCH_DB_SQL_URL: process.env.COUCH_DB_SQL_URL || "http://localhost:4006",
118
118
  SQS_SEARCH_ENABLE: process.env.SQS_SEARCH_ENABLE,
119
+ SQS_SEARCH_ENABLE_TENANTS:
120
+ process.env.SQS_SEARCH_ENABLE_TENANTS?.split(",") || [],
121
+ SQS_MIGRATION_ENABLE: process.env.SQS_MIGRATION_ENABLE,
119
122
  COUCH_DB_USERNAME: process.env.COUCH_DB_USER,
120
123
  COUCH_DB_PASSWORD: process.env.COUCH_DB_PASSWORD,
121
124
  GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID,
@@ -18,9 +18,10 @@ import {
18
18
  CouchFindOptions,
19
19
  DatabaseQueryOpts,
20
20
  SearchFilters,
21
- SearchFilterOperator,
22
21
  SearchUsersRequest,
23
22
  User,
23
+ BasicOperator,
24
+ ArrayOperator,
24
25
  } from "@budibase/types"
25
26
  import * as context from "../context"
26
27
  import { getGlobalDB } from "../context"
@@ -46,9 +47,9 @@ function removeUserPassword(users: User | User[]) {
46
47
 
47
48
  export function isSupportedUserSearch(query: SearchFilters) {
48
49
  const allowed = [
49
- { op: SearchFilterOperator.STRING, key: "email" },
50
- { op: SearchFilterOperator.EQUAL, key: "_id" },
51
- { op: SearchFilterOperator.ONE_OF, key: "_id" },
50
+ { op: BasicOperator.STRING, key: "email" },
51
+ { op: BasicOperator.EQUAL, key: "_id" },
52
+ { op: ArrayOperator.ONE_OF, key: "_id" },
52
53
  ]
53
54
  for (let [key, operation] of Object.entries(query)) {
54
55
  if (typeof operation !== "object") {