Merge remote-tracking branch 'origin/develop' into feature/whitelabelling

This commit is contained in:
Dean 2023-03-13 14:58:54 +00:00
commit 8a288b37b4
19 changed files with 2560 additions and 125 deletions

View File

@ -1,5 +1,5 @@
{
"version": "2.4.12-alpha.2",
"version": "2.4.12-alpha.5",
"npmClient": "yarn",
"packages": [
"packages/*"

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/backend-core",
"version": "2.4.12-alpha.2",
"version": "2.4.12-alpha.5",
"description": "Budibase backend core libraries used in server and worker",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
@ -24,7 +24,7 @@
"dependencies": {
"@budibase/nano": "10.1.2",
"@budibase/pouchdb-replication-stream": "1.2.10",
"@budibase/types": "2.4.12-alpha.2",
"@budibase/types": "2.4.12-alpha.5",
"@shopify/jest-koa-mocks": "5.0.1",
"@techpass/passport-openidconnect": "0.3.2",
"aws-cloudfront-sign": "2.2.0",

View File

@ -199,6 +199,10 @@ export class QueryBuilder<T> {
return this
}
setAllOr() {
this.query.allOr = true
}
handleSpaces(input: string) {
if (this.noEscaping) {
return input
@ -236,6 +240,36 @@ export class QueryBuilder<T> {
return value
}
isMultiCondition() {
let count = 0
for (let filters of Object.values(this.query)) {
// not contains is one massive filter in allOr mode
if (typeof filters === "object") {
count += Object.keys(filters).length
}
}
return count > 1
}
compressFilters(filters: Record<string, string[]>) {
const compressed: typeof filters = {}
for (let key of Object.keys(filters)) {
const finalKey = removeKeyNumbering(key)
if (compressed[finalKey]) {
compressed[finalKey] = compressed[finalKey].concat(filters[key])
} else {
compressed[finalKey] = filters[key]
}
}
// add prefixes back
const final: typeof filters = {}
let count = 1
for (let [key, value] of Object.entries(compressed)) {
final[`${count++}:${key}`] = value
}
return final
}
buildSearchQuery() {
const builder = this
let allOr = this.query && this.query.allOr
@ -272,9 +306,9 @@ export class QueryBuilder<T> {
}
const notContains = (key: string, value: any) => {
// @ts-ignore
const allPrefix = allOr === "" ? "*:* AND" : ""
return allPrefix + "NOT " + contains(key, value)
const allPrefix = allOr ? "*:* AND " : ""
const mode = allOr ? "AND" : undefined
return allPrefix + "NOT " + contains(key, value, mode)
}
const containsAny = (key: string, value: any) => {
@ -299,21 +333,32 @@ export class QueryBuilder<T> {
return `${key}:(${orStatement})`
}
function build(structure: any, queryFn: any) {
function build(
structure: any,
queryFn: (key: string, value: any) => string | null,
opts?: { returnBuilt?: boolean; mode?: string }
) {
let built = ""
for (let [key, value] of Object.entries(structure)) {
// check for new format - remove numbering if needed
key = removeKeyNumbering(key)
key = builder.preprocess(builder.handleSpaces(key), {
escape: true,
})
const expression = queryFn(key, value)
let expression = queryFn(key, value)
if (expression == null) {
continue
}
if (query.length > 0) {
query += ` ${allOr ? "OR" : "AND"} `
if (built.length > 0 || query.length > 0) {
const mode = opts?.mode ? opts.mode : allOr ? "OR" : "AND"
built += ` ${mode} `
}
query += expression
built += expression
}
if (opts?.returnBuilt) {
return built
} else {
query += built
}
}
@ -384,14 +429,14 @@ export class QueryBuilder<T> {
build(this.query.contains, contains)
}
if (this.query.notContains) {
build(this.query.notContains, notContains)
build(this.compressFilters(this.query.notContains), notContains)
}
if (this.query.containsAny) {
build(this.query.containsAny, containsAny)
}
// make sure table ID is always added as an AND
if (tableId) {
query = `(${query})`
query = this.isMultiCondition() ? `(${query})` : query
allOr = false
build({ tableId }, equal)
}

View File

@ -6,9 +6,13 @@ import { QueryBuilder, paginatedSearch, fullSearch } from "../lucene"
const INDEX_NAME = "main"
const index = `function(doc) {
let props = ["property", "number"]
let props = ["property", "number", "array"]
for (let key of props) {
if (doc[key]) {
if (Array.isArray(doc[key])) {
for (let val of doc[key]) {
index(key, val)
}
} else if (doc[key]) {
index(key, doc[key])
}
}
@ -21,9 +25,14 @@ describe("lucene", () => {
dbName = `db-${newid()}`
// create the DB for testing
db = getDB(dbName)
await db.put({ _id: newid(), property: "word" })
await db.put({ _id: newid(), property: "word2" })
await db.put({ _id: newid(), property: "word3", number: 1 })
await db.put({ _id: newid(), property: "word", array: ["1", "4"] })
await db.put({ _id: newid(), property: "word2", array: ["3", "1"] })
await db.put({
_id: newid(),
property: "word3",
number: 1,
array: ["1", "2"],
})
})
it("should be able to create a lucene index", async () => {
@ -118,6 +127,15 @@ describe("lucene", () => {
const resp = await builder.run()
expect(resp.rows.length).toBe(2)
})
it("should be able to perform an or not contains search", async () => {
const builder = new QueryBuilder(dbName, INDEX_NAME)
builder.addNotContains("array", ["1"])
builder.addNotContains("array", ["2"])
builder.setAllOr()
const resp = await builder.run()
expect(resp.rows.length).toBe(2)
})
})
describe("paginated search", () => {

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/bbui",
"description": "A UI solution used in the different Budibase projects.",
"version": "2.4.12-alpha.2",
"version": "2.4.12-alpha.5",
"license": "MPL-2.0",
"svelte": "src/index.js",
"module": "dist/bbui.es.js",
@ -38,8 +38,8 @@
],
"dependencies": {
"@adobe/spectrum-css-workflow-icons": "1.2.1",
"@budibase/shared-core": "2.4.12-alpha.2",
"@budibase/string-templates": "2.4.12-alpha.2",
"@budibase/shared-core": "2.4.12-alpha.5",
"@budibase/string-templates": "2.4.12-alpha.5",
"@spectrum-css/accordion": "3.0.24",
"@spectrum-css/actionbutton": "1.0.1",
"@spectrum-css/actiongroup": "1.0.1",

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/builder",
"version": "2.4.12-alpha.2",
"version": "2.4.12-alpha.5",
"license": "GPL-3.0",
"private": true,
"scripts": {
@ -58,11 +58,11 @@
}
},
"dependencies": {
"@budibase/bbui": "2.4.12-alpha.2",
"@budibase/client": "2.4.12-alpha.2",
"@budibase/frontend-core": "2.4.12-alpha.2",
"@budibase/shared-core": "2.4.12-alpha.2",
"@budibase/string-templates": "2.4.12-alpha.2",
"@budibase/bbui": "2.4.12-alpha.5",
"@budibase/client": "2.4.12-alpha.5",
"@budibase/frontend-core": "2.4.12-alpha.5",
"@budibase/shared-core": "2.4.12-alpha.5",
"@budibase/string-templates": "2.4.12-alpha.5",
"@fortawesome/fontawesome-svg-core": "^6.2.1",
"@fortawesome/free-brands-svg-icons": "^6.2.1",
"@fortawesome/free-solid-svg-icons": "^6.2.1",

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/cli",
"version": "2.4.12-alpha.2",
"version": "2.4.12-alpha.5",
"description": "Budibase CLI, for developers, self hosting and migrations.",
"main": "dist/index.js",
"bin": {
@ -29,9 +29,9 @@
"outputPath": "build"
},
"dependencies": {
"@budibase/backend-core": "2.4.12-alpha.2",
"@budibase/string-templates": "2.4.12-alpha.2",
"@budibase/types": "2.4.12-alpha.2",
"@budibase/backend-core": "2.4.12-alpha.5",
"@budibase/string-templates": "2.4.12-alpha.5",
"@budibase/types": "2.4.12-alpha.5",
"axios": "0.21.2",
"chalk": "4.1.0",
"cli-progress": "3.11.2",

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/client",
"version": "2.4.12-alpha.2",
"version": "2.4.12-alpha.5",
"license": "MPL-2.0",
"module": "dist/budibase-client.js",
"main": "dist/budibase-client.js",
@ -19,11 +19,11 @@
"dev:builder": "rollup -cw"
},
"dependencies": {
"@budibase/bbui": "2.4.12-alpha.2",
"@budibase/frontend-core": "2.4.12-alpha.2",
"@budibase/shared-core": "2.4.12-alpha.2",
"@budibase/string-templates": "2.4.12-alpha.2",
"@budibase/types": "2.4.8-alpha.4",
"@budibase/bbui": "2.4.12-alpha.5",
"@budibase/frontend-core": "2.4.12-alpha.5",
"@budibase/shared-core": "2.4.12-alpha.5",
"@budibase/string-templates": "2.4.12-alpha.5",
"@budibase/types": "2.4.12-alpha.5",
"@spectrum-css/button": "^3.0.3",
"@spectrum-css/card": "^3.0.3",
"@spectrum-css/divider": "^1.0.3",

View File

@ -1,13 +1,13 @@
{
"name": "@budibase/frontend-core",
"version": "2.4.12-alpha.2",
"version": "2.4.12-alpha.5",
"description": "Budibase frontend core libraries used in builder and client",
"author": "Budibase",
"license": "MPL-2.0",
"svelte": "src/index.js",
"dependencies": {
"@budibase/bbui": "2.4.12-alpha.2",
"@budibase/shared-core": "2.4.12-alpha.2",
"@budibase/bbui": "2.4.12-alpha.5",
"@budibase/shared-core": "2.4.12-alpha.5",
"lodash": "^4.17.21",
"svelte": "^3.46.2"
}

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/sdk",
"version": "2.4.12-alpha.2",
"version": "2.4.12-alpha.5",
"description": "Budibase Public API SDK",
"author": "Budibase",
"license": "MPL-2.0",

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/server",
"email": "hi@budibase.com",
"version": "2.4.12-alpha.2",
"version": "2.4.12-alpha.5",
"description": "Budibase Web Server",
"main": "src/index.ts",
"repository": {
@ -43,12 +43,12 @@
"license": "GPL-3.0",
"dependencies": {
"@apidevtools/swagger-parser": "10.0.3",
"@budibase/backend-core": "2.4.12-alpha.2",
"@budibase/client": "2.4.12-alpha.2",
"@budibase/pro": "2.4.12-alpha.2",
"@budibase/shared-core": "2.4.12-alpha.2",
"@budibase/string-templates": "2.4.12-alpha.2",
"@budibase/types": "2.4.12-alpha.2",
"@budibase/backend-core": "2.4.12-alpha.5",
"@budibase/client": "2.4.12-alpha.5",
"@budibase/pro": "2.4.12-alpha.5",
"@budibase/shared-core": "2.4.12-alpha.5",
"@budibase/string-templates": "2.4.12-alpha.5",
"@budibase/types": "2.4.12-alpha.5",
"@bull-board/api": "3.7.0",
"@bull-board/koa": "3.9.4",
"@elastic/elasticsearch": "7.10.0",

View File

@ -1278,14 +1278,14 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@2.4.12-alpha.2":
version "2.4.12-alpha.2"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.4.12-alpha.2.tgz#515130613e4028d769ee0fc28be0fc1f59a251f6"
integrity sha512-LXo7D/z6zfh/IbJ3QD1zEQI40q3xlEFogqgIYUxOGXFMl+VfC91xxwe+zPvwsuaEQ/5dLwsyBOPFvb/AmNlzxQ==
"@budibase/backend-core@2.4.12-alpha.5":
version "2.4.12-alpha.5"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.4.12-alpha.5.tgz#6fc37b439e05f0806909954c5c9f01f37e99f4d8"
integrity sha512-TVXjKXT/67ZWK3L6Rs1eJ1+8li4o3+zxOisVuSzgAHTepm6tbF9GLNWIVlzMoLGh5k9M9GHjCkhRKmxozMrBYw==
dependencies:
"@budibase/nano" "10.1.2"
"@budibase/pouchdb-replication-stream" "1.2.10"
"@budibase/types" "2.4.12-alpha.2"
"@budibase/types" "2.4.12-alpha.5"
"@shopify/jest-koa-mocks" "5.0.1"
"@techpass/passport-openidconnect" "0.3.2"
aws-cloudfront-sign "2.2.0"
@ -1417,14 +1417,14 @@
pouchdb-promise "^6.0.4"
through2 "^2.0.0"
"@budibase/pro@2.4.12-alpha.2":
version "2.4.12-alpha.2"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.4.12-alpha.2.tgz#5801400478161ad310d3e1faf63ab0d7c33ee0a0"
integrity sha512-LWICv3ypAUU4XDcLSz/5k4jv+EOvxB0rspDFxlvkrmLzmVsGHoEPfPRxvthMGG5ahntnyV5LlBR9TTcCBkPdbw==
"@budibase/pro@2.4.12-alpha.5":
version "2.4.12-alpha.5"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.4.12-alpha.5.tgz#ebdaf6fe987a35c9dee00a36bbcf5acb738015de"
integrity sha512-j749G4I9NHnEE+0AlFckFjBa3Hkx8M93Raw5s+C7YxaPpChws2HfN/7fCSgY33aeCCGqB0SpwCKAm48BSwbwwQ==
dependencies:
"@budibase/backend-core" "2.4.12-alpha.2"
"@budibase/backend-core" "2.4.12-alpha.5"
"@budibase/string-templates" "2.3.20"
"@budibase/types" "2.4.12-alpha.2"
"@budibase/types" "2.4.12-alpha.5"
"@koa/router" "8.0.8"
bull "4.10.1"
joi "17.6.0"
@ -1463,10 +1463,10 @@
lodash "^4.17.20"
vm2 "^3.9.4"
"@budibase/types@2.4.12-alpha.2":
version "2.4.12-alpha.2"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.4.12-alpha.2.tgz#01be6f28266080372936a5a7632f128090c26296"
integrity sha512-8YiFM99icXRdQEu++WnibxJDB2LkTmVvDkF95QG5hv+JrmgJg7+cVV4rygUT8VzRqpoYiTP47mhI0qs6eTZpmg==
"@budibase/types@2.4.12-alpha.5":
version "2.4.12-alpha.5"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.4.12-alpha.5.tgz#3727ddef178aebb354e43de0efe03a329b37b91f"
integrity sha512-ddtKzLjNcqdQjwYv1lNRo1t5XHdxiHRsFl+xMFsMwpB/8IY8LDw7zvkoC58sFYPUvOP4c1cBA0Wne9YNxM5IiA==
"@bull-board/api@3.7.0":
version "3.7.0"

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/shared-core",
"version": "2.4.12-alpha.2",
"version": "2.4.12-alpha.5",
"description": "Shared data utils",
"main": "dist/cjs/src/index.js",
"types": "dist/mjs/src/index.d.ts",
@ -20,7 +20,7 @@
"dev:builder": "yarn prebuild && concurrently \"tsc -p tsconfig.build.json --watch\" \"tsc -p tsconfig-cjs.build.json --watch\""
},
"dependencies": {
"@budibase/types": "2.4.5-alpha.0"
"@budibase/types": "2.4.12-alpha.5"
},
"devDependencies": {
"concurrently": "^7.6.0",

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/string-templates",
"version": "2.4.12-alpha.2",
"version": "2.4.12-alpha.5",
"description": "Handlebars wrapper for Budibase templating.",
"main": "src/index.cjs",
"module": "dist/bundle.mjs",

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/types",
"version": "2.4.12-alpha.2",
"version": "2.4.12-alpha.5",
"description": "Budibase types",
"main": "dist/cjs/index.js",
"types": "dist/mjs/index.d.ts",

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/worker",
"email": "hi@budibase.com",
"version": "2.4.12-alpha.2",
"version": "2.4.12-alpha.5",
"description": "Budibase background service",
"main": "src/index.ts",
"repository": {
@ -36,10 +36,10 @@
"author": "Budibase",
"license": "GPL-3.0",
"dependencies": {
"@budibase/backend-core": "2.4.12-alpha.2",
"@budibase/pro": "2.4.12-alpha.2",
"@budibase/string-templates": "2.4.12-alpha.2",
"@budibase/types": "2.4.12-alpha.2",
"@budibase/backend-core": "2.4.12-alpha.5",
"@budibase/pro": "2.4.12-alpha.5",
"@budibase/string-templates": "2.4.12-alpha.5",
"@budibase/types": "2.4.12-alpha.5",
"@koa/router": "8.0.8",
"@sentry/node": "6.17.7",
"@techpass/passport-openidconnect": "0.3.2",

View File

@ -475,14 +475,14 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@2.4.12-alpha.2":
version "2.4.12-alpha.2"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.4.12-alpha.2.tgz#515130613e4028d769ee0fc28be0fc1f59a251f6"
integrity sha512-LXo7D/z6zfh/IbJ3QD1zEQI40q3xlEFogqgIYUxOGXFMl+VfC91xxwe+zPvwsuaEQ/5dLwsyBOPFvb/AmNlzxQ==
"@budibase/backend-core@2.4.12-alpha.5":
version "2.4.12-alpha.5"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.4.12-alpha.5.tgz#6fc37b439e05f0806909954c5c9f01f37e99f4d8"
integrity sha512-TVXjKXT/67ZWK3L6Rs1eJ1+8li4o3+zxOisVuSzgAHTepm6tbF9GLNWIVlzMoLGh5k9M9GHjCkhRKmxozMrBYw==
dependencies:
"@budibase/nano" "10.1.2"
"@budibase/pouchdb-replication-stream" "1.2.10"
"@budibase/types" "2.4.12-alpha.2"
"@budibase/types" "2.4.12-alpha.5"
"@shopify/jest-koa-mocks" "5.0.1"
"@techpass/passport-openidconnect" "0.3.2"
aws-cloudfront-sign "2.2.0"
@ -564,14 +564,14 @@
pouchdb-promise "^6.0.4"
through2 "^2.0.0"
"@budibase/pro@2.4.12-alpha.2":
version "2.4.12-alpha.2"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.4.12-alpha.2.tgz#5801400478161ad310d3e1faf63ab0d7c33ee0a0"
integrity sha512-LWICv3ypAUU4XDcLSz/5k4jv+EOvxB0rspDFxlvkrmLzmVsGHoEPfPRxvthMGG5ahntnyV5LlBR9TTcCBkPdbw==
"@budibase/pro@2.4.12-alpha.5":
version "2.4.12-alpha.5"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.4.12-alpha.5.tgz#ebdaf6fe987a35c9dee00a36bbcf5acb738015de"
integrity sha512-j749G4I9NHnEE+0AlFckFjBa3Hkx8M93Raw5s+C7YxaPpChws2HfN/7fCSgY33aeCCGqB0SpwCKAm48BSwbwwQ==
dependencies:
"@budibase/backend-core" "2.4.12-alpha.2"
"@budibase/backend-core" "2.4.12-alpha.5"
"@budibase/string-templates" "2.3.20"
"@budibase/types" "2.4.12-alpha.2"
"@budibase/types" "2.4.12-alpha.5"
"@koa/router" "8.0.8"
bull "4.10.1"
joi "17.6.0"
@ -592,10 +592,10 @@
lodash "^4.17.20"
vm2 "^3.9.4"
"@budibase/types@2.4.12-alpha.2":
version "2.4.12-alpha.2"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.4.12-alpha.2.tgz#01be6f28266080372936a5a7632f128090c26296"
integrity sha512-8YiFM99icXRdQEu++WnibxJDB2LkTmVvDkF95QG5hv+JrmgJg7+cVV4rygUT8VzRqpoYiTP47mhI0qs6eTZpmg==
"@budibase/types@2.4.12-alpha.5":
version "2.4.12-alpha.5"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.4.12-alpha.5.tgz#3727ddef178aebb354e43de0efe03a329b37b91f"
integrity sha512-ddtKzLjNcqdQjwYv1lNRo1t5XHdxiHRsFl+xMFsMwpB/8IY8LDw7zvkoC58sFYPUvOP4c1cBA0Wne9YNxM5IiA==
"@cspotcode/source-map-support@^0.8.0":
version "0.8.1"

View File

@ -716,9 +716,9 @@
"@hapi/hoek" "^9.0.0"
"@sideway/formula@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@sideway/formula/-/formula-3.0.0.tgz#fe158aee32e6bd5de85044be615bc08478a0a13c"
integrity sha512-vHe7wZ4NOXVfkoRb8T5otiENVlT7a3IAiw7H5M2+GO+9CDgcVUUsX1zalAztCmwyOr2RUTGJdgB+ZvSVqmdHmg==
version "3.0.1"
resolved "https://registry.yarnpkg.com/@sideway/formula/-/formula-3.0.1.tgz#80fcbcbaf7ce031e0ef2dd29b1bfc7c3f583611f"
integrity sha512-/poHZJJVjx3L+zVD6g9KgHfYnb443oi7wLu/XKojDviHy6HOEOA6z1Trk5aR1dGcmPenJEgb2sK2I80LeS3MIg==
"@sideway/pinpoint@^2.0.0":
version "2.0.0"