@budibase/server 1.0.219-alpha.8 → 1.0.220-alpha.0
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/builder/assets/{index.7e1f2be1.js → index.530f60fc.js} +153 -152
- package/builder/index.html +1 -1
- package/coverage/clover.xml +283 -262
- package/coverage/coverage-final.json +5 -5
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
- package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/api/controllers/component.js.html +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +1 -1
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
- package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
- package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
- package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/role.js.html +1 -1
- package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.html +15 -15
- package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +78 -24
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
- package/coverage/lcov-report/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
- package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +1 -1
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/backup.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +1 -1
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/utils/index.html +1 -1
- package/coverage/lcov-report/api/routes/utils/validators.js.html +5 -2
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +1 -1
- package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
- package/coverage/lcov-report/automations/bullboard.js.html +1 -1
- package/coverage/lcov-report/automations/index.html +1 -1
- package/coverage/lcov-report/automations/index.js.html +1 -1
- package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +2 -2
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
- package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
- package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
- package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/triggers.js.html +1 -1
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +1 -1
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +1 -1
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +1 -1
- package/coverage/lcov-report/db/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
- package/coverage/lcov-report/db/newid.js.html +1 -1
- package/coverage/lcov-report/db/utils.js.html +1 -1
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +1 -1
- package/coverage/lcov-report/events/utils.js.html +1 -1
- package/coverage/lcov-report/index.html +30 -30
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/builder.js.html +1 -1
- package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
- package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
- package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +1 -1
- package/coverage/lcov-report/threads/automation.js.html +1 -1
- package/coverage/lcov-report/threads/index.html +14 -14
- package/coverage/lcov-report/threads/query.js.html +40 -25
- package/coverage/lcov-report/threads/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
- package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +1 -1
- package/coverage/lcov-report/utilities/index.html +16 -16
- package/coverage/lcov-report/utilities/index.js.html +1 -1
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/utilities/security.js.html +1 -1
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +1 -1
- package/coverage/lcov-report/utilities/workerRequests.js.html +57 -9
- package/coverage/lcov.info +501 -462
- package/dist/api/controllers/public/applications.js +1 -1
- package/dist/api/controllers/public/utils.js +8 -1
- package/dist/api/controllers/query/index.js +7 -4
- package/dist/api/controllers/row/internalSearch.js +26 -10
- package/dist/api/routes/public/rows.js +7 -2
- package/dist/api/routes/utils/validators.js +1 -0
- package/dist/app.js +20 -0
- package/dist/automations/steps/executeQuery.js +1 -1
- package/dist/environment.js +2 -0
- package/dist/integrations/base/sql.js +4 -2
- package/dist/package.json +6 -6
- package/dist/threads/query.js +20 -13
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/workerRequests.js +8 -0
- package/package.json +7 -7
- package/scripts/dev/manage.js +2 -0
- package/specs/openapi.json +9 -5
- package/specs/openapi.yaml +10 -4
- package/src/api/controllers/public/applications.ts +2 -2
- package/src/api/controllers/public/utils.ts +8 -1
- package/src/api/controllers/query/index.ts +13 -5
- package/src/api/controllers/row/internalSearch.js +27 -9
- package/src/api/routes/public/rows.ts +7 -2
- package/src/api/routes/tests/query.spec.js +0 -1
- package/src/api/routes/utils/validators.js +1 -0
- package/src/app.ts +30 -1
- package/src/automations/steps/executeQuery.js +1 -1
- package/src/definitions/openapi.ts +471 -469
- package/src/environment.js +2 -0
- package/src/integrations/base/sql.ts +6 -2
- package/src/threads/query.js +20 -15
- package/src/utilities/workerRequests.js +16 -0
|
@@ -120,3 +120,11 @@ exports.readGlobalUser = (ctx) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
120
120
|
request(ctx, { method: "GET" }));
|
|
121
121
|
return checkResponse(response, "get user", { ctx });
|
|
122
122
|
});
|
|
123
|
+
exports.createAdminUser = (email, password, tenantId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
124
|
+
const response = yield fetch(checkSlashesInUrl(env.WORKER_URL + "/api/global/users/init"), request(null, { method: "POST", body: { email, password, tenantId } }));
|
|
125
|
+
return checkResponse(response, "create admin user");
|
|
126
|
+
});
|
|
127
|
+
exports.getChecklist = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
128
|
+
const response = yield fetch(checkSlashesInUrl(env.WORKER_URL + "/api/global/configs/checklist"), request(null, { method: "GET" }));
|
|
129
|
+
return checkResponse(response, "get checklist");
|
|
130
|
+
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.220-alpha.0",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -77,11 +77,10 @@
|
|
|
77
77
|
"license": "GPL-3.0",
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@apidevtools/swagger-parser": "10.0.3",
|
|
80
|
-
"@budibase/backend-core": "^1.0.
|
|
81
|
-
"@budibase/client": "^1.0.
|
|
82
|
-
"@budibase/pro": "1.0.219
|
|
83
|
-
"@budibase/string-templates": "^1.0.
|
|
84
|
-
"@budibase/types": "^1.0.219-alpha.8",
|
|
80
|
+
"@budibase/backend-core": "^1.0.220-alpha.0",
|
|
81
|
+
"@budibase/client": "^1.0.220-alpha.0",
|
|
82
|
+
"@budibase/pro": "1.0.219",
|
|
83
|
+
"@budibase/string-templates": "^1.0.220-alpha.0",
|
|
85
84
|
"@bull-board/api": "3.7.0",
|
|
86
85
|
"@bull-board/koa": "3.9.4",
|
|
87
86
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -152,6 +151,7 @@
|
|
|
152
151
|
"@babel/core": "7.17.4",
|
|
153
152
|
"@babel/preset-env": "7.16.11",
|
|
154
153
|
"@budibase/standard-components": "^0.9.139",
|
|
154
|
+
"@budibase/types": "^1.0.220-alpha.0",
|
|
155
155
|
"@jest/test-sequencer": "24.9.0",
|
|
156
156
|
"@types/apidoc": "0.50.0",
|
|
157
157
|
"@types/bson": "4.2.0",
|
|
@@ -195,5 +195,5 @@
|
|
|
195
195
|
"optionalDependencies": {
|
|
196
196
|
"oracledb": "5.3.0"
|
|
197
197
|
},
|
|
198
|
-
"gitHead": "
|
|
198
|
+
"gitHead": "00cefe45cc19f1151ad2a4590d6a5aed0afa0ea7"
|
|
199
199
|
}
|
package/scripts/dev/manage.js
CHANGED
package/specs/openapi.json
CHANGED
|
@@ -2137,6 +2137,10 @@
|
|
|
2137
2137
|
"query": {
|
|
2138
2138
|
"type": "object",
|
|
2139
2139
|
"properties": {
|
|
2140
|
+
"allOr": {
|
|
2141
|
+
"type": "boolean",
|
|
2142
|
+
"description": "Specifies that a row should be returned if it satisfies any of the specified options, rather than requiring it to fulfill all the search parameters. This defaults to false, meaning AND logic will be used."
|
|
2143
|
+
},
|
|
2140
2144
|
"string": {
|
|
2141
2145
|
"type": "object",
|
|
2142
2146
|
"example": {
|
|
@@ -2155,12 +2159,12 @@
|
|
|
2155
2159
|
},
|
|
2156
2160
|
"range": {
|
|
2157
2161
|
"type": "object",
|
|
2158
|
-
"description": "Searches within a range, the format of this must be
|
|
2162
|
+
"description": "Searches within a range, the format of this must be in the format of an object with a \"low\" and \"high\" property.",
|
|
2159
2163
|
"example": {
|
|
2160
|
-
"columnName1":
|
|
2161
|
-
10,
|
|
2162
|
-
20
|
|
2163
|
-
|
|
2164
|
+
"columnName1": {
|
|
2165
|
+
"low": 10,
|
|
2166
|
+
"high": 20
|
|
2167
|
+
}
|
|
2164
2168
|
}
|
|
2165
2169
|
},
|
|
2166
2170
|
"equal": {
|
package/specs/openapi.yaml
CHANGED
|
@@ -1551,6 +1551,12 @@ paths:
|
|
|
1551
1551
|
query:
|
|
1552
1552
|
type: object
|
|
1553
1553
|
properties:
|
|
1554
|
+
allOr:
|
|
1555
|
+
type: boolean
|
|
1556
|
+
description: Specifies that a row should be returned if it satisfies any of the
|
|
1557
|
+
specified options, rather than requiring it to fulfill
|
|
1558
|
+
all the search parameters. This defaults to false,
|
|
1559
|
+
meaning AND logic will be used.
|
|
1554
1560
|
string:
|
|
1555
1561
|
type: object
|
|
1556
1562
|
example:
|
|
@@ -1566,12 +1572,12 @@ paths:
|
|
|
1566
1572
|
description: A fuzzy search, only supported by internal tables.
|
|
1567
1573
|
range:
|
|
1568
1574
|
type: object
|
|
1569
|
-
description: Searches within a range, the format of this must be
|
|
1570
|
-
|
|
1575
|
+
description: Searches within a range, the format of this must be in the format
|
|
1576
|
+
of an object with a "low" and "high" property.
|
|
1571
1577
|
example:
|
|
1572
1578
|
columnName1:
|
|
1573
|
-
|
|
1574
|
-
|
|
1579
|
+
low: 10
|
|
1580
|
+
high: 20
|
|
1575
1581
|
equal:
|
|
1576
1582
|
type: object
|
|
1577
1583
|
description: Searches for rows that have a column value that is exactly the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { getAllApps } = require("@budibase/backend-core/db")
|
|
2
2
|
const { updateAppId } = require("@budibase/backend-core/context")
|
|
3
|
-
import { search as stringSearch } from "./utils"
|
|
3
|
+
import { search as stringSearch, addRev } from "./utils"
|
|
4
4
|
import * as controller from "../application"
|
|
5
5
|
import { Application } from "../../../definitions/common"
|
|
6
6
|
|
|
@@ -47,7 +47,7 @@ export async function read(ctx: any, next: any) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export async function update(ctx: any, next: any) {
|
|
50
|
-
ctx.request.body = fixAppID(ctx.request.body, ctx.params)
|
|
50
|
+
ctx.request.body = await addRev(fixAppID(ctx.request.body, ctx.params))
|
|
51
51
|
updateAppId(ctx.params.appId)
|
|
52
52
|
await controller.update(ctx)
|
|
53
53
|
await setResponseApp(ctx)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const { getAppDB } = require("@budibase/backend-core/context")
|
|
2
2
|
import { isExternalTable } from "../../../integrations/utils"
|
|
3
|
+
import { APP_PREFIX, DocumentTypes } from "../../../db/utils"
|
|
3
4
|
|
|
4
5
|
export async function addRev(
|
|
5
6
|
body: { _id?: string; _rev?: string },
|
|
@@ -8,9 +9,15 @@ export async function addRev(
|
|
|
8
9
|
if (!body._id || (tableId && isExternalTable(tableId))) {
|
|
9
10
|
return body
|
|
10
11
|
}
|
|
12
|
+
let id = body._id
|
|
13
|
+
if (body._id.startsWith(APP_PREFIX)) {
|
|
14
|
+
id = DocumentTypes.APP_METADATA
|
|
15
|
+
}
|
|
11
16
|
const db = getAppDB()
|
|
12
|
-
const dbDoc = await db.get(
|
|
17
|
+
const dbDoc = await db.get(id)
|
|
13
18
|
body._rev = dbDoc._rev
|
|
19
|
+
// update ID in case it is an app ID
|
|
20
|
+
body._id = id
|
|
14
21
|
return body
|
|
15
22
|
}
|
|
16
23
|
|
|
@@ -166,14 +166,19 @@ export async function preview(ctx: any) {
|
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
async function execute(
|
|
169
|
+
async function execute(
|
|
170
|
+
ctx: any,
|
|
171
|
+
opts: any = { rowsOnly: false, isAutomation: false }
|
|
172
|
+
) {
|
|
170
173
|
const db = getAppDB()
|
|
171
174
|
|
|
172
175
|
const query = await db.get(ctx.params.queryId)
|
|
173
176
|
const datasource = await db.get(query.datasourceId)
|
|
174
177
|
|
|
175
|
-
|
|
176
|
-
|
|
178
|
+
let authConfigCtx: any = {}
|
|
179
|
+
if (!opts.isAutomation) {
|
|
180
|
+
authConfigCtx = getAuthConfig(ctx)
|
|
181
|
+
}
|
|
177
182
|
const enrichedParameters = ctx.request.body.parameters || {}
|
|
178
183
|
// make sure parameters are fully enriched with defaults
|
|
179
184
|
if (query && query.parameters) {
|
|
@@ -217,8 +222,11 @@ export async function executeV1(ctx: any) {
|
|
|
217
222
|
return execute(ctx, { rowsOnly: true })
|
|
218
223
|
}
|
|
219
224
|
|
|
220
|
-
export async function executeV2(
|
|
221
|
-
|
|
225
|
+
export async function executeV2(
|
|
226
|
+
ctx: any,
|
|
227
|
+
{ isAutomation }: { isAutomation?: boolean } = {}
|
|
228
|
+
) {
|
|
229
|
+
return execute(ctx, { rowsOnly: false, isAutomation })
|
|
222
230
|
}
|
|
223
231
|
|
|
224
232
|
const removeDynamicVariables = async (queryId: any) => {
|
|
@@ -10,6 +10,7 @@ const { getAppId } = require("@budibase/backend-core/context")
|
|
|
10
10
|
class QueryBuilder {
|
|
11
11
|
constructor(base) {
|
|
12
12
|
this.query = {
|
|
13
|
+
allOr: false,
|
|
13
14
|
string: {},
|
|
14
15
|
fuzzy: {},
|
|
15
16
|
range: {},
|
|
@@ -146,8 +147,22 @@ class QueryBuilder {
|
|
|
146
147
|
|
|
147
148
|
buildSearchQuery() {
|
|
148
149
|
const builder = this
|
|
149
|
-
let
|
|
150
|
+
let allOr = this.query && this.query.allOr
|
|
151
|
+
let query = allOr ? "" : "*:*"
|
|
150
152
|
const allPreProcessingOpts = { escape: true, lowercase: true, wrap: true }
|
|
153
|
+
let tableId
|
|
154
|
+
if (this.query.equal.tableId) {
|
|
155
|
+
tableId = this.query.equal.tableId
|
|
156
|
+
delete this.query.equal.tableId
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const equal = (key, value) => {
|
|
160
|
+
// 0 evaluates to false, which means we would return all rows if we don't check it
|
|
161
|
+
if (!value && value !== 0) {
|
|
162
|
+
return null
|
|
163
|
+
}
|
|
164
|
+
return `${key}:${builder.preprocess(value, allPreProcessingOpts)}`
|
|
165
|
+
}
|
|
151
166
|
|
|
152
167
|
function build(structure, queryFn) {
|
|
153
168
|
for (let [key, value] of Object.entries(structure)) {
|
|
@@ -158,7 +173,10 @@ class QueryBuilder {
|
|
|
158
173
|
if (expression == null) {
|
|
159
174
|
continue
|
|
160
175
|
}
|
|
161
|
-
query
|
|
176
|
+
if (query.length > 0) {
|
|
177
|
+
query += ` ${allOr ? "OR" : "AND"} `
|
|
178
|
+
}
|
|
179
|
+
query += expression
|
|
162
180
|
}
|
|
163
181
|
}
|
|
164
182
|
|
|
@@ -204,13 +222,7 @@ class QueryBuilder {
|
|
|
204
222
|
})
|
|
205
223
|
}
|
|
206
224
|
if (this.query.equal) {
|
|
207
|
-
build(this.query.equal,
|
|
208
|
-
// 0 evaluates to false, which means we would return all rows if we don't check it
|
|
209
|
-
if (!value && value !== 0) {
|
|
210
|
-
return null
|
|
211
|
-
}
|
|
212
|
-
return `${key}:${builder.preprocess(value, allPreProcessingOpts)}`
|
|
213
|
-
})
|
|
225
|
+
build(this.query.equal, equal)
|
|
214
226
|
}
|
|
215
227
|
if (this.query.notEqual) {
|
|
216
228
|
build(this.query.notEqual, (key, value) => {
|
|
@@ -248,6 +260,12 @@ class QueryBuilder {
|
|
|
248
260
|
return `${key}:(${orStatement})`
|
|
249
261
|
})
|
|
250
262
|
}
|
|
263
|
+
// make sure table ID is always added as an AND
|
|
264
|
+
if (tableId) {
|
|
265
|
+
query = `(${query})`
|
|
266
|
+
allOr = false
|
|
267
|
+
build({ tableId }, equal)
|
|
268
|
+
}
|
|
251
269
|
return query
|
|
252
270
|
}
|
|
253
271
|
|
|
@@ -150,6 +150,11 @@ read.push(new Endpoint("get", "/tables/:tableId/rows/:rowId", controller.read))
|
|
|
150
150
|
* query:
|
|
151
151
|
* type: object
|
|
152
152
|
* properties:
|
|
153
|
+
* allOr:
|
|
154
|
+
* type: boolean
|
|
155
|
+
* description: Specifies that a row should be returned if it satisfies
|
|
156
|
+
* any of the specified options, rather than requiring it to fulfill all
|
|
157
|
+
* the search parameters. This defaults to false, meaning AND logic will be used.
|
|
153
158
|
* string:
|
|
154
159
|
* type: object
|
|
155
160
|
* example:
|
|
@@ -167,9 +172,9 @@ read.push(new Endpoint("get", "/tables/:tableId/rows/:rowId", controller.read))
|
|
|
167
172
|
* range:
|
|
168
173
|
* type: object
|
|
169
174
|
* description: Searches within a range, the format of this must be
|
|
170
|
-
*
|
|
175
|
+
* in the format of an object with a "low" and "high" property.
|
|
171
176
|
* example:
|
|
172
|
-
* columnName1:
|
|
177
|
+
* columnName1: { low: 10, high: 20 }
|
|
173
178
|
* equal:
|
|
174
179
|
* type: object
|
|
175
180
|
* description: Searches for rows that have a column value that is
|
|
@@ -218,7 +218,6 @@ describe("/queries", () => {
|
|
|
218
218
|
expect(res.body.schemaFields).toEqual(["a", "b"])
|
|
219
219
|
expect(res.body.rows.length).toEqual(1)
|
|
220
220
|
expect(events.query.previewed).toBeCalledTimes(1)
|
|
221
|
-
datasource.config = { schema: "public" }
|
|
222
221
|
expect(events.query.previewed).toBeCalledWith(datasource, query)
|
|
223
222
|
})
|
|
224
223
|
|
package/src/app.ts
CHANGED
|
@@ -18,7 +18,9 @@ const { logAlert } = require("@budibase/backend-core/logging")
|
|
|
18
18
|
const { Thread } = require("./threads")
|
|
19
19
|
import redis from "./utilities/redis"
|
|
20
20
|
import * as migrations from "./migrations"
|
|
21
|
-
import { events, installation } from "@budibase/backend-core"
|
|
21
|
+
import { events, installation, tenancy } from "@budibase/backend-core"
|
|
22
|
+
import { createAdminUser, getChecklist } from "./utilities/workerRequests"
|
|
23
|
+
import { tenantSucceeded } from "@budibase/backend-core/dist/src/events/publishers/backfill"
|
|
22
24
|
|
|
23
25
|
const app = new Koa()
|
|
24
26
|
|
|
@@ -110,6 +112,33 @@ module.exports = server.listen(env.PORT || 0, async () => {
|
|
|
110
112
|
}
|
|
111
113
|
}
|
|
112
114
|
|
|
115
|
+
// check and create admin user if required
|
|
116
|
+
if (
|
|
117
|
+
env.SELF_HOSTED &&
|
|
118
|
+
!env.MULTI_TENANCY &&
|
|
119
|
+
env.BB_ADMIN_USER_EMAIL &&
|
|
120
|
+
env.BB_ADMIN_USER_PASSWORD
|
|
121
|
+
) {
|
|
122
|
+
const checklist = await getChecklist()
|
|
123
|
+
if (!checklist?.adminUser?.checked) {
|
|
124
|
+
try {
|
|
125
|
+
const tenantId = tenancy.getTenantId()
|
|
126
|
+
await createAdminUser(
|
|
127
|
+
env.BB_ADMIN_USER_EMAIL,
|
|
128
|
+
env.BB_ADMIN_USER_PASSWORD,
|
|
129
|
+
tenantId
|
|
130
|
+
)
|
|
131
|
+
console.log(
|
|
132
|
+
"Admin account automatically created for",
|
|
133
|
+
env.BB_ADMIN_USER_EMAIL
|
|
134
|
+
)
|
|
135
|
+
} catch (e) {
|
|
136
|
+
logAlert("Error creating initial admin user. Exiting.", e)
|
|
137
|
+
shutdown()
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
113
142
|
// check for version updates
|
|
114
143
|
await installation.checkInstallVersion()
|
|
115
144
|
|