@budibase/server 2.7.7 → 2.7.11
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.4ca5529d.js → index.80994fa2.js} +208 -208
- package/builder/index.html +1 -1
- package/dist/automation.js +13 -4
- package/dist/automation.js.map +2 -2
- package/dist/index.js +13 -4
- package/dist/index.js.map +2 -2
- package/dist/query.js +4 -1
- package/dist/query.js.map +2 -2
- package/package.json +8 -8
- package/src/api/controllers/row/external.ts +9 -3
- package/src/api/controllers/tests/row.spec.ts +120 -0
- package/src/sdk/app/datasources/datasources.ts +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "2.7.
|
|
4
|
+
"version": "2.7.11",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
"license": "GPL-3.0",
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@apidevtools/swagger-parser": "10.0.3",
|
|
49
|
-
"@budibase/backend-core": "2.7.
|
|
50
|
-
"@budibase/client": "2.7.
|
|
51
|
-
"@budibase/pro": "2.7.
|
|
52
|
-
"@budibase/shared-core": "2.7.
|
|
53
|
-
"@budibase/string-templates": "2.7.
|
|
54
|
-
"@budibase/types": "2.7.
|
|
49
|
+
"@budibase/backend-core": "2.7.11",
|
|
50
|
+
"@budibase/client": "2.7.11",
|
|
51
|
+
"@budibase/pro": "2.7.11",
|
|
52
|
+
"@budibase/shared-core": "2.7.11",
|
|
53
|
+
"@budibase/string-templates": "2.7.11",
|
|
54
|
+
"@budibase/types": "2.7.11",
|
|
55
55
|
"@bull-board/api": "3.7.0",
|
|
56
56
|
"@bull-board/koa": "3.9.4",
|
|
57
57
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -195,5 +195,5 @@
|
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
},
|
|
198
|
-
"gitHead": "
|
|
198
|
+
"gitHead": "a7aa42238389d36e5a23a11898a889d938a8d7ad"
|
|
199
199
|
}
|
|
@@ -237,9 +237,15 @@ export async function exportRows(ctx: UserCtx) {
|
|
|
237
237
|
ctx.request.body = {
|
|
238
238
|
query: {
|
|
239
239
|
oneOf: {
|
|
240
|
-
_id: ctx.request.body.rows.map(
|
|
241
|
-
|
|
242
|
-
|
|
240
|
+
_id: ctx.request.body.rows.map((row: string) => {
|
|
241
|
+
const ids = JSON.parse(
|
|
242
|
+
decodeURI(row).replace(/'/g, `"`).replace(/%2C/g, ",")
|
|
243
|
+
)
|
|
244
|
+
if (ids.length > 1) {
|
|
245
|
+
ctx.throw(400, "Export data does not support composite keys.")
|
|
246
|
+
}
|
|
247
|
+
return ids[0]
|
|
248
|
+
}),
|
|
243
249
|
},
|
|
244
250
|
},
|
|
245
251
|
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { exportRows } from "../row/external"
|
|
2
|
+
import sdk from "../../../sdk"
|
|
3
|
+
import { ExternalRequest } from "../row/ExternalRequest"
|
|
4
|
+
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
sdk.datasources = {
|
|
7
|
+
get: jest.fn(),
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
jest.mock("../row/ExternalRequest")
|
|
11
|
+
jest.mock("../view/exporters", () => ({
|
|
12
|
+
csv: jest.fn(),
|
|
13
|
+
Format: {
|
|
14
|
+
CSV: "csv",
|
|
15
|
+
},
|
|
16
|
+
}))
|
|
17
|
+
jest.mock("../../../utilities/fileSystem")
|
|
18
|
+
|
|
19
|
+
function getUserCtx() {
|
|
20
|
+
return {
|
|
21
|
+
params: {
|
|
22
|
+
tableId: "datasource__tablename",
|
|
23
|
+
},
|
|
24
|
+
query: {
|
|
25
|
+
format: "csv",
|
|
26
|
+
},
|
|
27
|
+
request: {
|
|
28
|
+
body: {},
|
|
29
|
+
},
|
|
30
|
+
throw: jest.fn(() => {
|
|
31
|
+
throw "Err"
|
|
32
|
+
}),
|
|
33
|
+
attachment: jest.fn(),
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
describe("external row controller", () => {
|
|
38
|
+
describe("exportRows", () => {
|
|
39
|
+
beforeAll(() => {
|
|
40
|
+
//@ts-ignore
|
|
41
|
+
jest.spyOn(ExternalRequest.prototype, "run").mockImplementation(() => [])
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
afterEach(() => {
|
|
45
|
+
jest.clearAllMocks()
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it("should throw a 400 if no datasource entities are present", async () => {
|
|
49
|
+
let userCtx = getUserCtx()
|
|
50
|
+
try {
|
|
51
|
+
//@ts-ignore
|
|
52
|
+
await exportRows(userCtx)
|
|
53
|
+
} catch (e) {
|
|
54
|
+
expect(userCtx.throw).toHaveBeenCalledWith(
|
|
55
|
+
400,
|
|
56
|
+
"Datasource has not been configured for plus API."
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it("should handle single quotes from a row ID", async () => {
|
|
62
|
+
//@ts-ignore
|
|
63
|
+
sdk.datasources.get.mockImplementation(() => ({
|
|
64
|
+
entities: {
|
|
65
|
+
tablename: {
|
|
66
|
+
schema: {},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
}))
|
|
70
|
+
let userCtx = getUserCtx()
|
|
71
|
+
userCtx.request.body = {
|
|
72
|
+
rows: ["['d001']"],
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
//@ts-ignore
|
|
76
|
+
await exportRows(userCtx)
|
|
77
|
+
|
|
78
|
+
expect(userCtx.request.body).toEqual({
|
|
79
|
+
query: {
|
|
80
|
+
oneOf: {
|
|
81
|
+
_id: ["d001"],
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
it("should throw a 400 if any composite keys are present", async () => {
|
|
88
|
+
let userCtx = getUserCtx()
|
|
89
|
+
userCtx.request.body = {
|
|
90
|
+
rows: ["[123]", "['d001'%2C'10111']"],
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
//@ts-ignore
|
|
94
|
+
await exportRows(userCtx)
|
|
95
|
+
} catch (e) {
|
|
96
|
+
expect(userCtx.throw).toHaveBeenCalledWith(
|
|
97
|
+
400,
|
|
98
|
+
"Export data does not support composite keys."
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it("should throw a 400 if no table name was found", async () => {
|
|
104
|
+
let userCtx = getUserCtx()
|
|
105
|
+
userCtx.params.tableId = "datasource__"
|
|
106
|
+
userCtx.request.body = {
|
|
107
|
+
rows: ["[123]"],
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
//@ts-ignore
|
|
111
|
+
await exportRows(userCtx)
|
|
112
|
+
} catch (e) {
|
|
113
|
+
expect(userCtx.throw).toHaveBeenCalledWith(
|
|
114
|
+
400,
|
|
115
|
+
"Could not find table name."
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
})
|
|
120
|
+
})
|
|
@@ -135,7 +135,7 @@ export function mergeConfigs(update: Datasource, old: Datasource) {
|
|
|
135
135
|
// specific to REST datasources, fix the auth configs again if required
|
|
136
136
|
if (hasAuthConfigs(update)) {
|
|
137
137
|
const configs = update.config.authConfigs as RestAuthConfig[]
|
|
138
|
-
const oldConfigs = old.config?.authConfigs as RestAuthConfig[]
|
|
138
|
+
const oldConfigs = (old.config?.authConfigs as RestAuthConfig[]) || []
|
|
139
139
|
for (let config of configs) {
|
|
140
140
|
if (config.type !== RestAuthType.BASIC) {
|
|
141
141
|
continue
|