@budibase/server 2.4.43 → 2.4.44-alpha.1
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.8b377b88.js → index.76deb808.js} +385 -384
- package/builder/assets/index.7f9a008b.css +6 -0
- package/builder/index.html +7 -7
- package/dist/api/controllers/application.js +28 -24
- package/dist/api/controllers/public/metrics.js +113 -0
- package/dist/api/controllers/row/external.js +15 -0
- package/dist/api/controllers/static/index.js +84 -24
- package/dist/api/controllers/static/templates/BudibaseApp.svelte +34 -11
- package/dist/api/controllers/table/utils.js +2 -4
- package/dist/api/routes/public/index.js +8 -0
- package/dist/api/routes/public/metrics.js +30 -0
- package/dist/app.js +1 -0
- package/dist/integrations/googlesheets.js +4 -0
- package/dist/integrations/redis.js +1 -1
- package/dist/middleware/currentapp.js +1 -27
- package/dist/package.json +12 -11
- package/dist/sdk/users/utils.js +11 -6
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/app.js +1 -10
- package/dist/utilities/global.js +17 -7
- package/jest.config.ts +1 -0
- package/package.json +13 -12
- package/specs/openapi.json +39 -0
- package/specs/openapi.yaml +169 -0
- package/specs/resources/application.ts +11 -0
- package/specs/resources/index.ts +2 -0
- package/specs/resources/metrics.ts +81 -0
- package/src/api/controllers/application.ts +20 -21
- package/src/api/controllers/component.ts +2 -2
- package/src/api/controllers/public/metrics.ts +251 -0
- package/src/api/controllers/row/external.ts +14 -0
- package/src/api/controllers/static/index.ts +69 -26
- package/src/api/controllers/static/templates/BudibaseApp.svelte +34 -11
- package/src/api/controllers/table/tests/utils.spec.ts +97 -0
- package/src/api/controllers/table/utils.ts +20 -12
- package/src/api/controllers/view/tests/__snapshots__/viewBuilder.spec.js.snap +48 -48
- package/src/api/routes/public/index.ts +10 -1
- package/src/api/routes/public/metrics.ts +28 -0
- package/src/api/routes/public/tests/metrics.spec.js +34 -0
- package/src/api/routes/tests/__snapshots__/datasource.spec.ts.snap +22 -22
- package/src/api/routes/tests/__snapshots__/view.spec.js.snap +5 -5
- package/src/api/routes/tests/appSync.spec.ts +1 -1
- package/src/api/routes/tests/internalSearch.spec.js +6 -6
- package/src/api/routes/tests/user.spec.js +2 -2
- package/src/app.ts +2 -1
- package/src/automations/automationUtils.ts +1 -1
- package/src/automations/tests/automation.spec.ts +99 -0
- package/src/db/defaultData/datasource_bb_default.ts +1 -1
- package/src/definitions/openapi.ts +15 -0
- package/src/integrations/googlesheets.ts +4 -0
- package/src/integrations/redis.ts +1 -1
- package/src/integrations/tests/googlesheets.spec.ts +4 -0
- package/src/integrations/tests/redis.spec.ts +9 -5
- package/src/middleware/currentapp.ts +3 -32
- package/src/middleware/tests/currentapp.spec.js +6 -42
- package/src/sdk/users/tests/utils.spec.ts +159 -0
- package/src/sdk/users/utils.ts +18 -7
- package/src/tests/jestSetup.ts +5 -1
- package/src/tests/utilities/TestConfiguration.ts +7 -19
- package/src/tests/utilities/structures.ts +13 -1
- package/src/utilities/fileSystem/app.ts +2 -9
- package/src/utilities/global.ts +21 -9
- package/src/utilities/rowProcessor/index.ts +1 -1
- package/builder/assets/favicon.e7fc7733.png +0 -0
- package/builder/assets/index.b0e3aca6.css +0 -6
- package/src/automations/tests/automation.spec.js +0 -84
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { FieldType } from "@budibase/types"
|
|
2
|
+
import { AutoFieldSubTypes } from "../../../../constants"
|
|
3
|
+
import TestConfiguration from "../../../../tests/utilities/TestConfiguration"
|
|
4
|
+
import { importToRows } from "../utils"
|
|
5
|
+
|
|
6
|
+
describe("utils", () => {
|
|
7
|
+
const config = new TestConfiguration()
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await config.init()
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
afterAll(config.end)
|
|
14
|
+
|
|
15
|
+
describe("importToRows", () => {
|
|
16
|
+
it("consecutive row have consecutive auto ids", async () => {
|
|
17
|
+
await config.doInContext(config.appId, async () => {
|
|
18
|
+
const table = await config.createTable({
|
|
19
|
+
name: "table",
|
|
20
|
+
type: "table",
|
|
21
|
+
schema: {
|
|
22
|
+
autoId: {
|
|
23
|
+
name: "autoId",
|
|
24
|
+
type: FieldType.NUMBER,
|
|
25
|
+
subtype: AutoFieldSubTypes.AUTO_ID,
|
|
26
|
+
autocolumn: true,
|
|
27
|
+
constraints: {
|
|
28
|
+
type: FieldType.NUMBER,
|
|
29
|
+
presence: true,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
name: {
|
|
33
|
+
name: "name",
|
|
34
|
+
type: FieldType.STRING,
|
|
35
|
+
constraints: {
|
|
36
|
+
type: FieldType.STRING,
|
|
37
|
+
presence: true,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
const data = [{ name: "Alice" }, { name: "Bob" }, { name: "Claire" }]
|
|
44
|
+
|
|
45
|
+
const result = importToRows(data, table, config.user)
|
|
46
|
+
expect(result).toEqual([
|
|
47
|
+
expect.objectContaining({
|
|
48
|
+
autoId: 1,
|
|
49
|
+
name: "Alice",
|
|
50
|
+
}),
|
|
51
|
+
expect.objectContaining({
|
|
52
|
+
autoId: 2,
|
|
53
|
+
name: "Bob",
|
|
54
|
+
}),
|
|
55
|
+
expect.objectContaining({
|
|
56
|
+
autoId: 3,
|
|
57
|
+
name: "Claire",
|
|
58
|
+
}),
|
|
59
|
+
])
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it("can import data without a specific user performing the action", async () => {
|
|
64
|
+
await config.doInContext(config.appId, async () => {
|
|
65
|
+
const table = await config.createTable({
|
|
66
|
+
name: "table",
|
|
67
|
+
type: "table",
|
|
68
|
+
schema: {
|
|
69
|
+
autoId: {
|
|
70
|
+
name: "autoId",
|
|
71
|
+
type: FieldType.NUMBER,
|
|
72
|
+
subtype: AutoFieldSubTypes.AUTO_ID,
|
|
73
|
+
autocolumn: true,
|
|
74
|
+
constraints: {
|
|
75
|
+
type: FieldType.NUMBER,
|
|
76
|
+
presence: true,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
name: {
|
|
80
|
+
name: "name",
|
|
81
|
+
type: FieldType.STRING,
|
|
82
|
+
constraints: {
|
|
83
|
+
type: FieldType.STRING,
|
|
84
|
+
presence: true,
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
const data = [{ name: "Alice" }, { name: "Bob" }, { name: "Claire" }]
|
|
91
|
+
|
|
92
|
+
const result = importToRows(data, table)
|
|
93
|
+
expect(result).toHaveLength(3)
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
})
|
|
@@ -20,7 +20,13 @@ import viewTemplate from "../view/viewBuilder"
|
|
|
20
20
|
import { cloneDeep } from "lodash/fp"
|
|
21
21
|
import { quotas } from "@budibase/pro"
|
|
22
22
|
import { events, context } from "@budibase/backend-core"
|
|
23
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
ContextUser,
|
|
25
|
+
Database,
|
|
26
|
+
Datasource,
|
|
27
|
+
SourceName,
|
|
28
|
+
Table,
|
|
29
|
+
} from "@budibase/types"
|
|
24
30
|
|
|
25
31
|
export async function clearColumns(table: any, columnNames: any) {
|
|
26
32
|
const db: Database = context.getAppDB()
|
|
@@ -99,33 +105,35 @@ export function makeSureTableUpToDate(table: any, tableToSave: any) {
|
|
|
99
105
|
return tableToSave
|
|
100
106
|
}
|
|
101
107
|
|
|
102
|
-
export function importToRows(
|
|
108
|
+
export function importToRows(
|
|
109
|
+
data: any[],
|
|
110
|
+
table: Table,
|
|
111
|
+
user: ContextUser | null = null
|
|
112
|
+
) {
|
|
103
113
|
let finalData: any = []
|
|
104
114
|
for (let i = 0; i < data.length; i++) {
|
|
105
115
|
let row = data[i]
|
|
106
|
-
row._id = generateRowID(table._id)
|
|
116
|
+
row._id = generateRowID(table._id!)
|
|
107
117
|
row.tableId = table._id
|
|
108
|
-
const processed
|
|
118
|
+
const processed = inputProcessing(user, table, row, {
|
|
109
119
|
noAutoRelationships: true,
|
|
110
120
|
})
|
|
111
121
|
row = processed.row
|
|
112
122
|
table = processed.table
|
|
113
123
|
|
|
114
|
-
|
|
115
|
-
let schema: any
|
|
116
|
-
for ([fieldName, schema] of Object.entries(table.schema)) {
|
|
124
|
+
for (const [fieldName, schema] of Object.entries(table.schema)) {
|
|
117
125
|
// check whether the options need to be updated for inclusion as part of the data import
|
|
118
126
|
if (
|
|
119
127
|
schema.type === FieldTypes.OPTIONS &&
|
|
120
128
|
row[fieldName] &&
|
|
121
|
-
(!schema.constraints
|
|
122
|
-
schema.constraints
|
|
129
|
+
(!schema.constraints!.inclusion ||
|
|
130
|
+
schema.constraints!.inclusion.indexOf(row[fieldName]) === -1)
|
|
123
131
|
) {
|
|
124
|
-
schema.constraints
|
|
125
|
-
...schema.constraints
|
|
132
|
+
schema.constraints!.inclusion = [
|
|
133
|
+
...schema.constraints!.inclusion!,
|
|
126
134
|
row[fieldName],
|
|
127
135
|
]
|
|
128
|
-
schema.constraints
|
|
136
|
+
schema.constraints!.inclusion.sort()
|
|
129
137
|
}
|
|
130
138
|
}
|
|
131
139
|
|
|
@@ -1,48 +1,48 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`viewBuilder Calculate and filter creates a view with the calculation statistics and filter schema 1`] = `
|
|
4
|
-
|
|
4
|
+
{
|
|
5
5
|
"map": "function (doc) {
|
|
6
|
-
if ((doc.tableId ===
|
|
7
|
-
doc[
|
|
8
|
-
doc[
|
|
9
|
-
doc[
|
|
10
|
-
(Array.isArray(doc[
|
|
11
|
-
)) && (doc[
|
|
12
|
-
emit(doc[
|
|
6
|
+
if ((doc.tableId === "14f1c4e94d6a47b682ce89d35d4c78b0" && !(
|
|
7
|
+
doc["myField"] === undefined ||
|
|
8
|
+
doc["myField"] === null ||
|
|
9
|
+
doc["myField"] === "" ||
|
|
10
|
+
(Array.isArray(doc["myField"]) && doc["myField"].length === 0)
|
|
11
|
+
)) && (doc["age"] > 17)) {
|
|
12
|
+
emit(doc["_id"], doc["myField"]);
|
|
13
13
|
}
|
|
14
14
|
}",
|
|
15
|
-
"meta":
|
|
15
|
+
"meta": {
|
|
16
16
|
"calculation": "stats",
|
|
17
17
|
"field": "myField",
|
|
18
|
-
"filters":
|
|
19
|
-
|
|
18
|
+
"filters": [
|
|
19
|
+
{
|
|
20
20
|
"condition": "MT",
|
|
21
21
|
"key": "age",
|
|
22
22
|
"value": 17,
|
|
23
23
|
},
|
|
24
24
|
],
|
|
25
25
|
"groupBy": undefined,
|
|
26
|
-
"schema":
|
|
27
|
-
"avg":
|
|
26
|
+
"schema": {
|
|
27
|
+
"avg": {
|
|
28
28
|
"type": "number",
|
|
29
29
|
},
|
|
30
|
-
"count":
|
|
30
|
+
"count": {
|
|
31
31
|
"type": "number",
|
|
32
32
|
},
|
|
33
|
-
"field":
|
|
33
|
+
"field": {
|
|
34
34
|
"type": "string",
|
|
35
35
|
},
|
|
36
|
-
"max":
|
|
36
|
+
"max": {
|
|
37
37
|
"type": "number",
|
|
38
38
|
},
|
|
39
|
-
"min":
|
|
39
|
+
"min": {
|
|
40
40
|
"type": "number",
|
|
41
41
|
},
|
|
42
|
-
"sum":
|
|
42
|
+
"sum": {
|
|
43
43
|
"type": "number",
|
|
44
44
|
},
|
|
45
|
-
"sumsqr":
|
|
45
|
+
"sumsqr": {
|
|
46
46
|
"type": "number",
|
|
47
47
|
},
|
|
48
48
|
},
|
|
@@ -53,42 +53,42 @@ Object {
|
|
|
53
53
|
`;
|
|
54
54
|
|
|
55
55
|
exports[`viewBuilder Calculate creates a view with the calculation statistics schema 1`] = `
|
|
56
|
-
|
|
56
|
+
{
|
|
57
57
|
"map": "function (doc) {
|
|
58
|
-
if ((doc.tableId ===
|
|
59
|
-
doc[
|
|
60
|
-
doc[
|
|
61
|
-
doc[
|
|
62
|
-
(Array.isArray(doc[
|
|
58
|
+
if ((doc.tableId === "14f1c4e94d6a47b682ce89d35d4c78b0" && !(
|
|
59
|
+
doc["myField"] === undefined ||
|
|
60
|
+
doc["myField"] === null ||
|
|
61
|
+
doc["myField"] === "" ||
|
|
62
|
+
(Array.isArray(doc["myField"]) && doc["myField"].length === 0)
|
|
63
63
|
)) ) {
|
|
64
|
-
emit(doc[
|
|
64
|
+
emit(doc["_id"], doc["myField"]);
|
|
65
65
|
}
|
|
66
66
|
}",
|
|
67
|
-
"meta":
|
|
67
|
+
"meta": {
|
|
68
68
|
"calculation": "stats",
|
|
69
69
|
"field": "myField",
|
|
70
|
-
"filters":
|
|
70
|
+
"filters": [],
|
|
71
71
|
"groupBy": undefined,
|
|
72
|
-
"schema":
|
|
73
|
-
"avg":
|
|
72
|
+
"schema": {
|
|
73
|
+
"avg": {
|
|
74
74
|
"type": "number",
|
|
75
75
|
},
|
|
76
|
-
"count":
|
|
76
|
+
"count": {
|
|
77
77
|
"type": "number",
|
|
78
78
|
},
|
|
79
|
-
"field":
|
|
79
|
+
"field": {
|
|
80
80
|
"type": "string",
|
|
81
81
|
},
|
|
82
|
-
"max":
|
|
82
|
+
"max": {
|
|
83
83
|
"type": "number",
|
|
84
84
|
},
|
|
85
|
-
"min":
|
|
85
|
+
"min": {
|
|
86
86
|
"type": "number",
|
|
87
87
|
},
|
|
88
|
-
"sum":
|
|
88
|
+
"sum": {
|
|
89
89
|
"type": "number",
|
|
90
90
|
},
|
|
91
|
-
"sumsqr":
|
|
91
|
+
"sumsqr": {
|
|
92
92
|
"type": "number",
|
|
93
93
|
},
|
|
94
94
|
},
|
|
@@ -99,22 +99,22 @@ Object {
|
|
|
99
99
|
`;
|
|
100
100
|
|
|
101
101
|
exports[`viewBuilder Filter creates a view with multiple filters and conjunctions 1`] = `
|
|
102
|
-
|
|
102
|
+
{
|
|
103
103
|
"map": "function (doc) {
|
|
104
|
-
if (doc.tableId ===
|
|
105
|
-
emit(doc[
|
|
104
|
+
if (doc.tableId === "14f1c4e94d6a47b682ce89d35d4c78b0" && (doc["Name"] === "Test" || doc["Yes"] > "Value")) {
|
|
105
|
+
emit(doc["_id"], doc["undefined"]);
|
|
106
106
|
}
|
|
107
107
|
}",
|
|
108
|
-
"meta":
|
|
108
|
+
"meta": {
|
|
109
109
|
"calculation": undefined,
|
|
110
110
|
"field": undefined,
|
|
111
|
-
"filters":
|
|
112
|
-
|
|
111
|
+
"filters": [
|
|
112
|
+
{
|
|
113
113
|
"condition": "EQUALS",
|
|
114
114
|
"key": "Name",
|
|
115
115
|
"value": "Test",
|
|
116
116
|
},
|
|
117
|
-
|
|
117
|
+
{
|
|
118
118
|
"condition": "MT",
|
|
119
119
|
"conjunction": "OR",
|
|
120
120
|
"key": "Yes",
|
|
@@ -129,16 +129,16 @@ Object {
|
|
|
129
129
|
`;
|
|
130
130
|
|
|
131
131
|
exports[`viewBuilder Group By creates a view emitting the group by field 1`] = `
|
|
132
|
-
|
|
132
|
+
{
|
|
133
133
|
"map": "function (doc) {
|
|
134
|
-
if (doc.tableId ===
|
|
135
|
-
emit(doc[
|
|
134
|
+
if (doc.tableId === "14f1c4e94d6a47b682ce89d35d4c78b0" ) {
|
|
135
|
+
emit(doc["age"], doc["score"]);
|
|
136
136
|
}
|
|
137
137
|
}",
|
|
138
|
-
"meta":
|
|
138
|
+
"meta": {
|
|
139
139
|
"calculation": undefined,
|
|
140
140
|
"field": "score",
|
|
141
|
-
"filters":
|
|
141
|
+
"filters": [],
|
|
142
142
|
"groupBy": "age",
|
|
143
143
|
"schema": null,
|
|
144
144
|
"tableId": "14f1c4e94d6a47b682ce89d35d4c78b0",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import appEndpoints from "./applications"
|
|
2
|
+
import metricEndpoints from "./metrics"
|
|
2
3
|
import queryEndpoints from "./queries"
|
|
3
4
|
import tableEndpoints from "./tables"
|
|
4
5
|
import rowEndpoints from "./rows"
|
|
@@ -12,7 +13,7 @@ import env from "../../../environment"
|
|
|
12
13
|
// below imports don't have declaration files
|
|
13
14
|
const Router = require("@koa/router")
|
|
14
15
|
const { RateLimit, Stores } = require("koa2-ratelimit")
|
|
15
|
-
import { redis, permissions } from "@budibase/backend-core"
|
|
16
|
+
import { middleware, redis, permissions } from "@budibase/backend-core"
|
|
16
17
|
const { PermissionType, PermissionLevel } = permissions
|
|
17
18
|
|
|
18
19
|
const PREFIX = "/api/public/v1"
|
|
@@ -91,6 +92,13 @@ function addToRouter(endpoints: any) {
|
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
94
|
|
|
95
|
+
function applyAdminRoutes(endpoints: any) {
|
|
96
|
+
addMiddleware(endpoints.read, middleware.builderOrAdmin)
|
|
97
|
+
addMiddleware(endpoints.write, middleware.builderOrAdmin)
|
|
98
|
+
addToRouter(endpoints.read)
|
|
99
|
+
addToRouter(endpoints.write)
|
|
100
|
+
}
|
|
101
|
+
|
|
94
102
|
function applyRoutes(
|
|
95
103
|
endpoints: any,
|
|
96
104
|
permType: string,
|
|
@@ -119,6 +127,7 @@ function applyRoutes(
|
|
|
119
127
|
addToRouter(endpoints.write)
|
|
120
128
|
}
|
|
121
129
|
|
|
130
|
+
applyAdminRoutes(metricEndpoints)
|
|
122
131
|
applyRoutes(appEndpoints, PermissionType.APP, "appId")
|
|
123
132
|
applyRoutes(tableEndpoints, PermissionType.TABLE, "tableId")
|
|
124
133
|
applyRoutes(userEndpoints, PermissionType.USER, "userId")
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import controller from "../../controllers/public/metrics"
|
|
2
|
+
import Endpoint from "./utils/Endpoint"
|
|
3
|
+
|
|
4
|
+
const read = []
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @openapi
|
|
8
|
+
* /metrics:
|
|
9
|
+
* get:
|
|
10
|
+
* operationId: metricsGet
|
|
11
|
+
* summary: Retrieve Budibase tenant metrics
|
|
12
|
+
* description: Output metrics in OpenMetrics format compatible with Prometheus
|
|
13
|
+
* tags:
|
|
14
|
+
* - metrics
|
|
15
|
+
* responses:
|
|
16
|
+
* 200:
|
|
17
|
+
* description: Returns tenant metrics.
|
|
18
|
+
* content:
|
|
19
|
+
* text/plain:
|
|
20
|
+
* schema:
|
|
21
|
+
* type: string
|
|
22
|
+
* examples:
|
|
23
|
+
* metrics:
|
|
24
|
+
* $ref: '#/components/examples/metrics'
|
|
25
|
+
*/
|
|
26
|
+
read.push(new Endpoint("get", "/metrics", controller.fetch))
|
|
27
|
+
|
|
28
|
+
export default { read }
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const setup = require("../../tests/utilities")
|
|
2
|
+
|
|
3
|
+
jest.setTimeout(30000)
|
|
4
|
+
|
|
5
|
+
describe("/metrics", () => {
|
|
6
|
+
let request = setup.getRequest()
|
|
7
|
+
let config = setup.getConfig()
|
|
8
|
+
|
|
9
|
+
afterAll(setup.afterAll)
|
|
10
|
+
|
|
11
|
+
// For some reason this cannot be a beforeAll or the test "should be able to update the user" fail
|
|
12
|
+
beforeEach(async () => {
|
|
13
|
+
await config.init()
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
describe("get", () => {
|
|
17
|
+
it("returns a list of metrics", async () => {
|
|
18
|
+
const res = await request
|
|
19
|
+
.get(`/api/public/v1/metrics`)
|
|
20
|
+
.set(config.defaultHeaders())
|
|
21
|
+
.expect("Content-Type", /text\/plain/)
|
|
22
|
+
.expect(200)
|
|
23
|
+
expect(res.text).toContain("budibase_tenant_user_count")
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it("endpoint should not be publicly exposed", async () => {
|
|
27
|
+
await request
|
|
28
|
+
.get(`/api/public/v1/metrics`)
|
|
29
|
+
.set(config.publicHeaders())
|
|
30
|
+
.expect(403)
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
})
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`/datasources fetch returns all the datasources from the server 1`] = `
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"config":
|
|
7
|
-
"entities":
|
|
8
|
-
|
|
4
|
+
[
|
|
5
|
+
{
|
|
6
|
+
"config": {},
|
|
7
|
+
"entities": [
|
|
8
|
+
{
|
|
9
9
|
"_id": "ta_users",
|
|
10
10
|
"_rev": "1-2375e1bc58aeec664dc1b1f04ad43e44",
|
|
11
11
|
"createdAt": "2020-01-01T00:00:00.000Z",
|
|
12
12
|
"name": "Users",
|
|
13
13
|
"primaryDisplay": "email",
|
|
14
|
-
"schema":
|
|
15
|
-
"email":
|
|
16
|
-
"constraints":
|
|
14
|
+
"schema": {
|
|
15
|
+
"email": {
|
|
16
|
+
"constraints": {
|
|
17
17
|
"email": true,
|
|
18
|
-
"length":
|
|
18
|
+
"length": {
|
|
19
19
|
"maximum": "",
|
|
20
20
|
},
|
|
21
21
|
"presence": true,
|
|
@@ -25,8 +25,8 @@ Array [
|
|
|
25
25
|
"name": "email",
|
|
26
26
|
"type": "string",
|
|
27
27
|
},
|
|
28
|
-
"firstName":
|
|
29
|
-
"constraints":
|
|
28
|
+
"firstName": {
|
|
29
|
+
"constraints": {
|
|
30
30
|
"presence": false,
|
|
31
31
|
"type": "string",
|
|
32
32
|
},
|
|
@@ -34,8 +34,8 @@ Array [
|
|
|
34
34
|
"name": "firstName",
|
|
35
35
|
"type": "string",
|
|
36
36
|
},
|
|
37
|
-
"lastName":
|
|
38
|
-
"constraints":
|
|
37
|
+
"lastName": {
|
|
38
|
+
"constraints": {
|
|
39
39
|
"presence": false,
|
|
40
40
|
"type": "string",
|
|
41
41
|
},
|
|
@@ -43,9 +43,9 @@ Array [
|
|
|
43
43
|
"name": "lastName",
|
|
44
44
|
"type": "string",
|
|
45
45
|
},
|
|
46
|
-
"roleId":
|
|
47
|
-
"constraints":
|
|
48
|
-
"inclusion":
|
|
46
|
+
"roleId": {
|
|
47
|
+
"constraints": {
|
|
48
|
+
"inclusion": [
|
|
49
49
|
"ADMIN",
|
|
50
50
|
"POWER",
|
|
51
51
|
"BASIC",
|
|
@@ -58,9 +58,9 @@ Array [
|
|
|
58
58
|
"name": "roleId",
|
|
59
59
|
"type": "options",
|
|
60
60
|
},
|
|
61
|
-
"status":
|
|
62
|
-
"constraints":
|
|
63
|
-
"inclusion":
|
|
61
|
+
"status": {
|
|
62
|
+
"constraints": {
|
|
63
|
+
"inclusion": [
|
|
64
64
|
"active",
|
|
65
65
|
"inactive",
|
|
66
66
|
],
|
|
@@ -74,15 +74,15 @@ Array [
|
|
|
74
74
|
},
|
|
75
75
|
"type": "table",
|
|
76
76
|
"updatedAt": "2020-01-01T00:00:00.000Z",
|
|
77
|
-
"views":
|
|
77
|
+
"views": {},
|
|
78
78
|
},
|
|
79
79
|
],
|
|
80
80
|
"name": "Budibase DB",
|
|
81
81
|
"source": "BUDIBASE",
|
|
82
82
|
"type": "budibase",
|
|
83
83
|
},
|
|
84
|
-
|
|
85
|
-
"config":
|
|
84
|
+
{
|
|
85
|
+
"config": {},
|
|
86
86
|
"createdAt": "2020-01-01T00:00:00.000Z",
|
|
87
87
|
"name": "Test",
|
|
88
88
|
"source": "POSTGRES",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`/views query returns data for the created view 1`] = `
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
[
|
|
5
|
+
{
|
|
6
6
|
"avg": 2333.3333333333335,
|
|
7
7
|
"count": 3,
|
|
8
8
|
"group": null,
|
|
@@ -15,8 +15,8 @@ Array [
|
|
|
15
15
|
`;
|
|
16
16
|
|
|
17
17
|
exports[`/views query returns data for the created view using a group by 1`] = `
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
[
|
|
19
|
+
{
|
|
20
20
|
"avg": 1500,
|
|
21
21
|
"count": 2,
|
|
22
22
|
"group": "One",
|
|
@@ -25,7 +25,7 @@ Array [
|
|
|
25
25
|
"sum": 3000,
|
|
26
26
|
"sumsqr": 5000000,
|
|
27
27
|
},
|
|
28
|
-
|
|
28
|
+
{
|
|
29
29
|
"avg": 4000,
|
|
30
30
|
"count": 1,
|
|
31
31
|
"group": "Two",
|
|
@@ -24,7 +24,7 @@ describe("/api/applications/:appId/sync", () => {
|
|
|
24
24
|
return rows
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
it("make sure
|
|
27
|
+
it("make sure that user metadata is correctly sync'd", async () => {
|
|
28
28
|
const rows = await getUserMetadata()
|
|
29
29
|
expect(rows.length).toBe(1)
|
|
30
30
|
})
|
|
@@ -21,7 +21,7 @@ function checkLucene(resp, expected, params = PARAMS) {
|
|
|
21
21
|
expect(json.bookmark).toBe(PARAMS.bookmark)
|
|
22
22
|
}
|
|
23
23
|
expect(json.include_docs).toBe(true)
|
|
24
|
-
expect(json.q).toBe(
|
|
24
|
+
expect(json.q).toBe(`${expected} AND tableId:"${params.tableId}"`)
|
|
25
25
|
expect(json.limit).toBe(params.limit || 50)
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -60,7 +60,7 @@ describe("internal search", () => {
|
|
|
60
60
|
"column": "1",
|
|
61
61
|
}
|
|
62
62
|
}, PARAMS)
|
|
63
|
-
checkLucene(response, `column:"2" OR !column:"1"`)
|
|
63
|
+
checkLucene(response, `(column:"2" OR !column:"1")`)
|
|
64
64
|
})
|
|
65
65
|
|
|
66
66
|
it("test AND query", async () => {
|
|
@@ -72,7 +72,7 @@ describe("internal search", () => {
|
|
|
72
72
|
"column": "1",
|
|
73
73
|
}
|
|
74
74
|
}, PARAMS)
|
|
75
|
-
checkLucene(response,
|
|
75
|
+
checkLucene(response, `(*:* AND column:"2" AND !column:"1")`)
|
|
76
76
|
})
|
|
77
77
|
|
|
78
78
|
it("test pagination query", async () => {
|
|
@@ -133,7 +133,7 @@ describe("internal search", () => {
|
|
|
133
133
|
"colArr": [1, 2, 3],
|
|
134
134
|
},
|
|
135
135
|
}, PARAMS)
|
|
136
|
-
checkLucene(response,
|
|
136
|
+
checkLucene(response, `(*:* AND column:a AND colArr:(1 AND 2 AND 3))`, PARAMS)
|
|
137
137
|
})
|
|
138
138
|
|
|
139
139
|
it("test multiple of same column", async () => {
|
|
@@ -145,7 +145,7 @@ describe("internal search", () => {
|
|
|
145
145
|
"3:column": "c",
|
|
146
146
|
},
|
|
147
147
|
}, PARAMS)
|
|
148
|
-
checkLucene(response, `column:"a" OR column:"b" OR column:"c"`, PARAMS)
|
|
148
|
+
checkLucene(response, `(column:"a" OR column:"b" OR column:"c")`, PARAMS)
|
|
149
149
|
})
|
|
150
150
|
|
|
151
151
|
it("check a weird case for lucene building", async () => {
|
|
@@ -192,6 +192,6 @@ describe("internal search", () => {
|
|
|
192
192
|
expect(json.bookmark).toBe(PARAMS.bookmark)
|
|
193
193
|
}
|
|
194
194
|
expect(json.include_docs).toBe(true)
|
|
195
|
-
expect(json.q).toBe(
|
|
195
|
+
expect(json.q).toBe(`*:* AND column:"1" AND tableId:${PARAMS.tableId}`)
|
|
196
196
|
})
|
|
197
197
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { roles } = require("@budibase/backend-core")
|
|
1
|
+
const { roles, utils } = require("@budibase/backend-core")
|
|
2
2
|
const { checkPermissionsEndpoint } = require("./utilities/TestFunctions")
|
|
3
3
|
const setup = require("./utilities")
|
|
4
4
|
const { BUILTIN_ROLE_IDS } = roles
|
|
@@ -55,7 +55,7 @@ describe("/users", () => {
|
|
|
55
55
|
|
|
56
56
|
describe("update", () => {
|
|
57
57
|
it("should be able to update the user", async () => {
|
|
58
|
-
const user = await config.createUser({ id: `us_update${
|
|
58
|
+
const user = await config.createUser({ id: `us_update${utils.newid()}` })
|
|
59
59
|
user.roleId = BUILTIN_ROLE_IDS.BASIC
|
|
60
60
|
const res = await request
|
|
61
61
|
.put(`/api/users/metadata`)
|
package/src/app.ts
CHANGED
|
@@ -27,7 +27,7 @@ import * as api from "./api"
|
|
|
27
27
|
import * as automations from "./automations"
|
|
28
28
|
import { Thread } from "./threads"
|
|
29
29
|
import * as redis from "./utilities/redis"
|
|
30
|
-
import { events, logging, middleware } from "@budibase/backend-core"
|
|
30
|
+
import { events, logging, middleware, timers } from "@budibase/backend-core"
|
|
31
31
|
import { initialise as initialiseWebsockets } from "./websocket"
|
|
32
32
|
import { startup } from "./startup"
|
|
33
33
|
const Sentry = require("@sentry/node")
|
|
@@ -84,6 +84,7 @@ server.on("close", async () => {
|
|
|
84
84
|
}
|
|
85
85
|
shuttingDown = true
|
|
86
86
|
console.log("Server Closed")
|
|
87
|
+
timers.cleanup()
|
|
87
88
|
await automations.shutdown()
|
|
88
89
|
await redis.shutdown()
|
|
89
90
|
events.shutdown()
|
|
@@ -23,7 +23,7 @@ import { LoopStep, LoopStepType, LoopInput } from "../definitions/automations"
|
|
|
23
23
|
* @returns {object} The inputs object which has had all the various types supported by this function converted to their
|
|
24
24
|
* primitive types.
|
|
25
25
|
*/
|
|
26
|
-
export function cleanInputValues(inputs: Record<string, any>, schema
|
|
26
|
+
export function cleanInputValues(inputs: Record<string, any>, schema?: any) {
|
|
27
27
|
if (schema == null) {
|
|
28
28
|
return inputs
|
|
29
29
|
}
|