@budibase/server 2.3.17-alpha.4 → 2.3.17-alpha.5
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.41b2f148.js → index.2e46de1a.js} +282 -282
- package/builder/index.html +1 -1
- package/dist/api/index.js +1 -21
- package/dist/package.json +8 -7
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +9 -8
- package/specs/openapi.json +6 -6
- package/specs/openapi.yaml +3 -3
- package/src/api/index.ts +3 -22
- package/src/api/routes/tests/backup.spec.ts +0 -1
- package/src/integrations/tests/couchdb.spec.ts +0 -2
- package/src/tests/jestEnv.ts +7 -6
- package/src/tests/jestSetup.ts +1 -0
- package/src/tests/logging.ts +34 -0
- package/src/tests/utilities/TestConfiguration.ts +47 -49
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "2.3.17-alpha.
|
|
4
|
+
"version": "2.3.17-alpha.5",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"license": "GPL-3.0",
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@apidevtools/swagger-parser": "10.0.3",
|
|
46
|
-
"@budibase/backend-core": "2.3.17-alpha.
|
|
47
|
-
"@budibase/client": "2.3.17-alpha.
|
|
48
|
-
"@budibase/pro": "2.3.17-alpha.
|
|
49
|
-
"@budibase/string-templates": "2.3.17-alpha.
|
|
50
|
-
"@budibase/types": "2.3.17-alpha.
|
|
46
|
+
"@budibase/backend-core": "2.3.17-alpha.5",
|
|
47
|
+
"@budibase/client": "2.3.17-alpha.5",
|
|
48
|
+
"@budibase/pro": "2.3.17-alpha.4",
|
|
49
|
+
"@budibase/string-templates": "2.3.17-alpha.5",
|
|
50
|
+
"@budibase/types": "2.3.17-alpha.5",
|
|
51
51
|
"@bull-board/api": "3.7.0",
|
|
52
52
|
"@bull-board/koa": "3.9.4",
|
|
53
53
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -142,6 +142,7 @@
|
|
|
142
142
|
"@types/pouchdb": "6.4.0",
|
|
143
143
|
"@types/redis": "4.0.11",
|
|
144
144
|
"@types/server-destroy": "1.0.1",
|
|
145
|
+
"@types/supertest": "2.0.12",
|
|
145
146
|
"@types/tar": "6.1.3",
|
|
146
147
|
"@typescript-eslint/parser": "5.45.0",
|
|
147
148
|
"apidoc": "0.50.4",
|
|
@@ -160,7 +161,7 @@
|
|
|
160
161
|
"path-to-regexp": "6.2.0",
|
|
161
162
|
"prettier": "2.5.1",
|
|
162
163
|
"rimraf": "3.0.2",
|
|
163
|
-
"supertest": "
|
|
164
|
+
"supertest": "6.2.2",
|
|
164
165
|
"swagger-jsdoc": "6.1.0",
|
|
165
166
|
"timekeeper": "2.2.0",
|
|
166
167
|
"ts-jest": "28.0.4",
|
|
@@ -172,5 +173,5 @@
|
|
|
172
173
|
"optionalDependencies": {
|
|
173
174
|
"oracledb": "5.3.0"
|
|
174
175
|
},
|
|
175
|
-
"gitHead": "
|
|
176
|
+
"gitHead": "f336cec967d590cae2b6bb5ff78b9ccc84c418f1"
|
|
176
177
|
}
|
package/specs/openapi.json
CHANGED
|
@@ -817,7 +817,6 @@
|
|
|
817
817
|
"type": "string",
|
|
818
818
|
"enum": [
|
|
819
819
|
"string",
|
|
820
|
-
"barcodeqr",
|
|
821
820
|
"longform",
|
|
822
821
|
"options",
|
|
823
822
|
"number",
|
|
@@ -829,7 +828,8 @@
|
|
|
829
828
|
"formula",
|
|
830
829
|
"auto",
|
|
831
830
|
"json",
|
|
832
|
-
"internal"
|
|
831
|
+
"internal",
|
|
832
|
+
"barcodeqr"
|
|
833
833
|
],
|
|
834
834
|
"description": "Defines the type of the column, most explain themselves, a link column is a relationship."
|
|
835
835
|
},
|
|
@@ -1021,7 +1021,6 @@
|
|
|
1021
1021
|
"type": "string",
|
|
1022
1022
|
"enum": [
|
|
1023
1023
|
"string",
|
|
1024
|
-
"barcodeqr",
|
|
1025
1024
|
"longform",
|
|
1026
1025
|
"options",
|
|
1027
1026
|
"number",
|
|
@@ -1033,7 +1032,8 @@
|
|
|
1033
1032
|
"formula",
|
|
1034
1033
|
"auto",
|
|
1035
1034
|
"json",
|
|
1036
|
-
"internal"
|
|
1035
|
+
"internal",
|
|
1036
|
+
"barcodeqr"
|
|
1037
1037
|
],
|
|
1038
1038
|
"description": "Defines the type of the column, most explain themselves, a link column is a relationship."
|
|
1039
1039
|
},
|
|
@@ -1236,7 +1236,6 @@
|
|
|
1236
1236
|
"type": "string",
|
|
1237
1237
|
"enum": [
|
|
1238
1238
|
"string",
|
|
1239
|
-
"barcodeqr",
|
|
1240
1239
|
"longform",
|
|
1241
1240
|
"options",
|
|
1242
1241
|
"number",
|
|
@@ -1248,7 +1247,8 @@
|
|
|
1248
1247
|
"formula",
|
|
1249
1248
|
"auto",
|
|
1250
1249
|
"json",
|
|
1251
|
-
"internal"
|
|
1250
|
+
"internal",
|
|
1251
|
+
"barcodeqr"
|
|
1252
1252
|
],
|
|
1253
1253
|
"description": "Defines the type of the column, most explain themselves, a link column is a relationship."
|
|
1254
1254
|
},
|
package/specs/openapi.yaml
CHANGED
|
@@ -603,7 +603,6 @@ components:
|
|
|
603
603
|
type: string
|
|
604
604
|
enum:
|
|
605
605
|
- string
|
|
606
|
-
- barcodeqr
|
|
607
606
|
- longform
|
|
608
607
|
- options
|
|
609
608
|
- number
|
|
@@ -616,6 +615,7 @@ components:
|
|
|
616
615
|
- auto
|
|
617
616
|
- json
|
|
618
617
|
- internal
|
|
618
|
+
- barcodeqr
|
|
619
619
|
description: Defines the type of the column, most explain themselves, a link
|
|
620
620
|
column is a relationship.
|
|
621
621
|
constraints:
|
|
@@ -766,7 +766,6 @@ components:
|
|
|
766
766
|
type: string
|
|
767
767
|
enum:
|
|
768
768
|
- string
|
|
769
|
-
- barcodeqr
|
|
770
769
|
- longform
|
|
771
770
|
- options
|
|
772
771
|
- number
|
|
@@ -779,6 +778,7 @@ components:
|
|
|
779
778
|
- auto
|
|
780
779
|
- json
|
|
781
780
|
- internal
|
|
781
|
+
- barcodeqr
|
|
782
782
|
description: Defines the type of the column, most explain themselves, a link
|
|
783
783
|
column is a relationship.
|
|
784
784
|
constraints:
|
|
@@ -936,7 +936,6 @@ components:
|
|
|
936
936
|
type: string
|
|
937
937
|
enum:
|
|
938
938
|
- string
|
|
939
|
-
- barcodeqr
|
|
940
939
|
- longform
|
|
941
940
|
- options
|
|
942
941
|
- number
|
|
@@ -949,6 +948,7 @@ components:
|
|
|
949
948
|
- auto
|
|
950
949
|
- json
|
|
951
950
|
- internal
|
|
951
|
+
- barcodeqr
|
|
952
952
|
description: Defines the type of the column, most explain themselves, a link
|
|
953
953
|
column is a relationship.
|
|
954
954
|
constraints:
|
package/src/api/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Router from "@koa/router"
|
|
2
|
-
import {
|
|
2
|
+
import { auth, middleware } from "@budibase/backend-core"
|
|
3
3
|
import currentApp from "../middleware/currentapp"
|
|
4
4
|
import zlib from "zlib"
|
|
5
5
|
import { mainRoutes, staticRoutes, publicRoutes } from "./routes"
|
|
@@ -14,6 +14,8 @@ export const router: Router = new Router()
|
|
|
14
14
|
router.get("/health", ctx => (ctx.status = 200))
|
|
15
15
|
router.get("/version", ctx => (ctx.body = pkg.version))
|
|
16
16
|
|
|
17
|
+
router.use(middleware.errorHandling)
|
|
18
|
+
|
|
17
19
|
router
|
|
18
20
|
.use(
|
|
19
21
|
compress({
|
|
@@ -54,27 +56,6 @@ router
|
|
|
54
56
|
.use(currentApp)
|
|
55
57
|
.use(auth.auditLog)
|
|
56
58
|
|
|
57
|
-
// error handling middleware
|
|
58
|
-
router.use(async (ctx, next) => {
|
|
59
|
-
try {
|
|
60
|
-
await next()
|
|
61
|
-
} catch (err: any) {
|
|
62
|
-
ctx.status = err.status || err.statusCode || 500
|
|
63
|
-
const error = errors.getPublicError(err)
|
|
64
|
-
ctx.body = {
|
|
65
|
-
message: err.message,
|
|
66
|
-
status: ctx.status,
|
|
67
|
-
validationErrors: err.validation,
|
|
68
|
-
error,
|
|
69
|
-
}
|
|
70
|
-
ctx.log.error(err)
|
|
71
|
-
// unauthorised errors don't provide a useful trace
|
|
72
|
-
if (!env.isTest()) {
|
|
73
|
-
console.trace(err)
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
})
|
|
77
|
-
|
|
78
59
|
// authenticated routes
|
|
79
60
|
for (let route of mainRoutes) {
|
|
80
61
|
router.use(route.routes())
|
|
@@ -19,7 +19,6 @@ describe("/backups", () => {
|
|
|
19
19
|
.get(`/api/backups/export?appId=${config.getAppId()}&appname=test`)
|
|
20
20
|
.set(config.defaultHeaders())
|
|
21
21
|
.expect(200)
|
|
22
|
-
expect(res.text).toBeDefined()
|
|
23
22
|
expect(res.headers["content-type"]).toEqual("application/gzip")
|
|
24
23
|
expect(events.app.exported).toBeCalledTimes(1)
|
|
25
24
|
})
|
package/src/tests/jestEnv.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import env from "../environment"
|
|
2
1
|
import { tmpdir } from "os"
|
|
3
2
|
|
|
4
|
-
env.
|
|
5
|
-
env.
|
|
6
|
-
env.
|
|
3
|
+
process.env.SELF_HOSTED = "1"
|
|
4
|
+
process.env.NODE_ENV = "jest"
|
|
5
|
+
process.env.MULTI_TENANCY = "1"
|
|
7
6
|
// @ts-ignore
|
|
8
|
-
env.
|
|
9
|
-
env.
|
|
7
|
+
process.env.BUDIBASE_DIR = tmpdir("budibase-unittests")
|
|
8
|
+
process.env.LOG_LEVEL = process.env.LOG_LEVEL || "error"
|
|
9
|
+
process.env.ENABLE_4XX_HTTP_LOGGING = "0"
|
|
10
|
+
process.env.MOCK_REDIS = "1"
|
package/src/tests/jestSetup.ts
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export enum LogLevel {
|
|
2
|
+
TRACE = "trace",
|
|
3
|
+
DEBUG = "debug",
|
|
4
|
+
INFO = "info",
|
|
5
|
+
WARN = "warn",
|
|
6
|
+
ERROR = "error",
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const LOG_INDEX: { [key in LogLevel]: number } = {
|
|
10
|
+
[LogLevel.TRACE]: 1,
|
|
11
|
+
[LogLevel.DEBUG]: 2,
|
|
12
|
+
[LogLevel.INFO]: 3,
|
|
13
|
+
[LogLevel.WARN]: 4,
|
|
14
|
+
[LogLevel.ERROR]: 5,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const setIndex = LOG_INDEX[process.env.LOG_LEVEL as LogLevel]
|
|
18
|
+
|
|
19
|
+
if (setIndex > LOG_INDEX.trace) {
|
|
20
|
+
global.console.trace = jest.fn()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (setIndex > LOG_INDEX.debug) {
|
|
24
|
+
global.console.debug = jest.fn()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (setIndex > LOG_INDEX.info) {
|
|
28
|
+
global.console.info = jest.fn()
|
|
29
|
+
global.console.log = jest.fn()
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (setIndex > LOG_INDEX.warn) {
|
|
33
|
+
global.console.warn = jest.fn()
|
|
34
|
+
}
|
|
@@ -236,42 +236,41 @@ class TestConfiguration {
|
|
|
236
236
|
email = this.defaultUserValues.email,
|
|
237
237
|
roles,
|
|
238
238
|
}: any = {}) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
})
|
|
259
|
-
if (builder) {
|
|
260
|
-
user.builder = { global: true }
|
|
261
|
-
} else {
|
|
262
|
-
user.builder = { global: false }
|
|
263
|
-
}
|
|
264
|
-
if (admin) {
|
|
265
|
-
user.admin = { global: true }
|
|
266
|
-
} else {
|
|
267
|
-
user.admin = { global: false }
|
|
268
|
-
}
|
|
269
|
-
const resp = await db.put(user)
|
|
270
|
-
return {
|
|
271
|
-
_rev: resp.rev,
|
|
272
|
-
...user,
|
|
273
|
-
}
|
|
239
|
+
const db = tenancy.getTenantDB(this.getTenantId())
|
|
240
|
+
let existing
|
|
241
|
+
try {
|
|
242
|
+
existing = await db.get(id)
|
|
243
|
+
} catch (err) {
|
|
244
|
+
existing = { email }
|
|
245
|
+
}
|
|
246
|
+
const user = {
|
|
247
|
+
_id: id,
|
|
248
|
+
...existing,
|
|
249
|
+
roles: roles || {},
|
|
250
|
+
tenantId: this.getTenantId(),
|
|
251
|
+
firstName,
|
|
252
|
+
lastName,
|
|
253
|
+
}
|
|
254
|
+
await sessions.createASession(id, {
|
|
255
|
+
sessionId: "sessionid",
|
|
256
|
+
tenantId: this.getTenantId(),
|
|
257
|
+
csrfToken: this.defaultUserValues.csrfToken,
|
|
274
258
|
})
|
|
259
|
+
if (builder) {
|
|
260
|
+
user.builder = { global: true }
|
|
261
|
+
} else {
|
|
262
|
+
user.builder = { global: false }
|
|
263
|
+
}
|
|
264
|
+
if (admin) {
|
|
265
|
+
user.admin = { global: true }
|
|
266
|
+
} else {
|
|
267
|
+
user.admin = { global: false }
|
|
268
|
+
}
|
|
269
|
+
const resp = await db.put(user)
|
|
270
|
+
return {
|
|
271
|
+
_rev: resp.rev,
|
|
272
|
+
...user,
|
|
273
|
+
}
|
|
275
274
|
}
|
|
276
275
|
|
|
277
276
|
async createUser(
|
|
@@ -417,20 +416,19 @@ class TestConfiguration {
|
|
|
417
416
|
// API
|
|
418
417
|
|
|
419
418
|
async generateApiKey(userId = this.defaultUserValues.globalUserId) {
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
})
|
|
419
|
+
const db = tenancy.getTenantDB(this.getTenantId())
|
|
420
|
+
const id = dbCore.generateDevInfoID(userId)
|
|
421
|
+
let devInfo
|
|
422
|
+
try {
|
|
423
|
+
devInfo = await db.get(id)
|
|
424
|
+
} catch (err) {
|
|
425
|
+
devInfo = { _id: id, userId }
|
|
426
|
+
}
|
|
427
|
+
devInfo.apiKey = encryption.encrypt(
|
|
428
|
+
`${this.getTenantId()}${dbCore.SEPARATOR}${newid()}`
|
|
429
|
+
)
|
|
430
|
+
await db.put(devInfo)
|
|
431
|
+
return devInfo.apiKey
|
|
434
432
|
}
|
|
435
433
|
|
|
436
434
|
// APP
|