@budibase/server 2.3.18-alpha.2 → 2.3.18-alpha.20
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/__mocks__/node-fetch.ts +3 -0
- package/builder/assets/blankScreenPreview.72634dd1.png +0 -0
- package/builder/assets/{index.bbe4c16b.js → index.07aa249f.js} +430 -417
- package/builder/assets/index.dc0472d8.css +6 -0
- package/builder/assets/listScreenPreview.599c0aae.png +0 -0
- package/builder/index.html +2 -2
- package/dist/api/controllers/automation.js +11 -2
- package/dist/api/controllers/cloud.js +2 -2
- package/dist/api/controllers/row/ExternalRequest.js +49 -24
- package/dist/api/controllers/row/external.js +1 -1
- package/dist/api/controllers/row/internalSearch.js +6 -450
- package/dist/api/controllers/row/utils.js +1 -3
- package/dist/api/routes/automation.js +1 -1
- package/dist/api/routes/public/applications.js +7 -7
- package/dist/api/routes/public/queries.js +2 -2
- package/dist/api/routes/public/rows.js +5 -5
- package/dist/api/routes/public/tables.js +5 -5
- package/dist/api/routes/public/users.js +5 -5
- package/dist/app.js +2 -0
- package/dist/db/index.js +25 -2
- package/dist/db/utils.js +2 -5
- package/dist/db/views/staticViews.js +2 -1
- package/dist/integrations/base/sql.js +4 -8
- package/dist/integrations/googlesheets.js +17 -20
- package/dist/middleware/authorized.js +5 -3
- package/dist/middleware/builder.js +6 -3
- package/dist/migrations/functions/backfill/global/configs.js +10 -4
- package/dist/migrations/tests/helpers.js +1 -1
- package/dist/migrations/tests/structures.js +1 -1
- package/dist/package.json +9 -8
- package/dist/startup.js +3 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/jest.config.ts +1 -0
- package/package.json +10 -9
- package/scripts/test.sh +12 -0
- package/specs/{generate.js → generate.ts} +7 -9
- package/specs/openapi.json +24 -24
- package/specs/openapi.yaml +24 -24
- package/specs/{parameters.js → parameters.ts} +6 -6
- package/specs/resources/{application.js → application.ts} +4 -4
- package/specs/resources/{index.js → index.ts} +8 -8
- package/specs/resources/{misc.js → misc.ts} +3 -3
- package/specs/resources/{query.js → query.ts} +4 -4
- package/specs/resources/{row.js → row.ts} +3 -4
- package/specs/resources/{table.js → table.ts} +5 -5
- package/specs/resources/{user.js → user.ts} +3 -3
- package/specs/resources/utils/Resource.ts +39 -0
- package/specs/resources/utils/{index.js → index.ts} +1 -1
- package/specs/{security.js → security.ts} +1 -1
- package/src/api/controllers/automation.ts +13 -2
- package/src/api/controllers/cloud.ts +2 -2
- package/src/api/controllers/row/ExternalRequest.ts +95 -28
- package/src/api/controllers/row/external.ts +1 -1
- package/src/api/controllers/row/internalSearch.ts +11 -524
- package/src/api/controllers/row/utils.ts +1 -2
- package/src/api/routes/automation.ts +1 -1
- package/src/api/routes/public/applications.ts +7 -7
- package/src/api/routes/public/queries.ts +2 -2
- package/src/api/routes/public/rows.ts +5 -5
- package/src/api/routes/public/tables.ts +5 -5
- package/src/api/routes/public/tests/{compare.spec.js → compare.spec.ts} +44 -25
- package/src/api/routes/public/users.ts +5 -5
- package/src/api/routes/tests/{cloud.seq.spec.ts → cloud.spec.ts} +13 -20
- package/src/api/routes/tests/utilities/TestFunctions.ts +1 -2
- package/src/app.ts +2 -0
- package/src/db/index.ts +2 -2
- package/src/db/utils.ts +0 -4
- package/src/db/views/staticViews.ts +3 -3
- package/src/definitions/openapi.ts +449 -63
- package/src/integration-test/postgres.spec.ts +351 -81
- package/src/integrations/base/sql.ts +4 -8
- package/src/integrations/googlesheets.ts +21 -22
- package/src/integrations/tests/googlesheets.spec.ts +122 -0
- package/src/middleware/authorized.ts +6 -4
- package/src/middleware/builder.ts +8 -3
- package/src/migrations/functions/backfill/global/configs.ts +15 -9
- package/src/migrations/functions/tests/userEmailViewCasing.spec.js +3 -4
- package/src/migrations/tests/helpers.ts +2 -2
- package/src/migrations/tests/structures.ts +1 -0
- package/src/startup.ts +4 -1
- package/src/tests/jestEnv.ts +1 -0
- package/src/tests/utilities/TestConfiguration.ts +42 -30
- package/src/tests/utilities/structures.ts +0 -2
- package/builder/assets/index.7e76c039.css +0 -6
- package/dist/integrations/base/utils.js +0 -16
- package/specs/resources/utils/Resource.js +0 -26
- package/src/integrations/base/utils.ts +0 -12
|
@@ -9,7 +9,7 @@ const read = [],
|
|
|
9
9
|
* @openapi
|
|
10
10
|
* /tables:
|
|
11
11
|
* post:
|
|
12
|
-
* operationId:
|
|
12
|
+
* operationId: tableCreate
|
|
13
13
|
* summary: Create a table
|
|
14
14
|
* description: Create a table, this could be internal or external.
|
|
15
15
|
* tags:
|
|
@@ -46,7 +46,7 @@ write.push(
|
|
|
46
46
|
* @openapi
|
|
47
47
|
* /tables/{tableId}:
|
|
48
48
|
* put:
|
|
49
|
-
* operationId:
|
|
49
|
+
* operationId: tableUpdate
|
|
50
50
|
* summary: Update a table
|
|
51
51
|
* description: Update a table, this could be internal or external.
|
|
52
52
|
* tags:
|
|
@@ -83,7 +83,7 @@ write.push(
|
|
|
83
83
|
* @openapi
|
|
84
84
|
* /tables/{tableId}:
|
|
85
85
|
* delete:
|
|
86
|
-
* operationId:
|
|
86
|
+
* operationId: tableDestroy
|
|
87
87
|
* summary: Delete a table
|
|
88
88
|
* description: Delete a table, this could be internal or external.
|
|
89
89
|
* tags:
|
|
@@ -108,7 +108,7 @@ write.push(new Endpoint("delete", "/tables/:tableId", controller.destroy))
|
|
|
108
108
|
* @openapi
|
|
109
109
|
* /tables/{tableId}:
|
|
110
110
|
* get:
|
|
111
|
-
* operationId:
|
|
111
|
+
* operationId: tableGetById
|
|
112
112
|
* summary: Retrieve a table
|
|
113
113
|
* description: Lookup a table, this could be internal or external.
|
|
114
114
|
* tags:
|
|
@@ -133,7 +133,7 @@ read.push(new Endpoint("get", "/tables/:tableId", controller.read))
|
|
|
133
133
|
* @openapi
|
|
134
134
|
* /tables/search:
|
|
135
135
|
* post:
|
|
136
|
-
* operationId:
|
|
136
|
+
* operationId: tableSearch
|
|
137
137
|
* summary: Search for tables
|
|
138
138
|
* description: Based on table properties (currently only name) search for tables. This could be
|
|
139
139
|
* an internal or an external table.
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import jestOpenAPI from "jest-openapi"
|
|
2
|
+
import { run as generateSchema } from "../../../../../specs/generate"
|
|
3
|
+
import * as setup from "../../tests/utilities"
|
|
4
|
+
import { generateMakeRequest } from "./utils"
|
|
5
|
+
import { Table, App, Row, User } from "@budibase/types"
|
|
5
6
|
|
|
6
7
|
const yamlPath = generateSchema()
|
|
7
|
-
jestOpenAPI(yamlPath)
|
|
8
|
+
jestOpenAPI(yamlPath!)
|
|
8
9
|
|
|
9
10
|
let config = setup.getConfig()
|
|
10
|
-
let apiKey, table, app, makeRequest
|
|
11
|
+
let apiKey: string, table: Table, app: App, makeRequest: any
|
|
11
12
|
|
|
12
13
|
beforeAll(async () => {
|
|
13
14
|
app = await config.init()
|
|
@@ -25,19 +26,29 @@ describe("check the applications endpoints", () => {
|
|
|
25
26
|
})
|
|
26
27
|
|
|
27
28
|
it("should allow creating an application", async () => {
|
|
28
|
-
const res = await makeRequest(
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
const res = await makeRequest(
|
|
30
|
+
"post",
|
|
31
|
+
"/applications",
|
|
32
|
+
{
|
|
33
|
+
name: "new App",
|
|
34
|
+
},
|
|
35
|
+
null
|
|
36
|
+
)
|
|
31
37
|
expect(res).toSatisfyApiSpec()
|
|
32
38
|
})
|
|
33
39
|
|
|
34
40
|
it("should allow updating an application", async () => {
|
|
35
41
|
const app = config.getApp()
|
|
36
42
|
const appId = config.getAppId()
|
|
37
|
-
const res = await makeRequest(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
const res = await makeRequest(
|
|
44
|
+
"put",
|
|
45
|
+
`/applications/${appId}`,
|
|
46
|
+
{
|
|
47
|
+
...app,
|
|
48
|
+
name: "updated app name",
|
|
49
|
+
},
|
|
50
|
+
appId
|
|
51
|
+
)
|
|
41
52
|
expect(res).toSatisfyApiSpec()
|
|
42
53
|
})
|
|
43
54
|
|
|
@@ -47,7 +58,10 @@ describe("check the applications endpoints", () => {
|
|
|
47
58
|
})
|
|
48
59
|
|
|
49
60
|
it("should allow deleting an application", async () => {
|
|
50
|
-
const res = await makeRequest(
|
|
61
|
+
const res = await makeRequest(
|
|
62
|
+
"delete",
|
|
63
|
+
`/applications/${config.getAppId()}`
|
|
64
|
+
)
|
|
51
65
|
expect(res).toSatisfyApiSpec()
|
|
52
66
|
})
|
|
53
67
|
})
|
|
@@ -68,8 +82,8 @@ describe("check the tables endpoints", () => {
|
|
|
68
82
|
column1: {
|
|
69
83
|
type: "string",
|
|
70
84
|
constraints: {},
|
|
71
|
-
}
|
|
72
|
-
}
|
|
85
|
+
},
|
|
86
|
+
},
|
|
73
87
|
})
|
|
74
88
|
expect(res).toSatisfyApiSpec()
|
|
75
89
|
})
|
|
@@ -92,12 +106,11 @@ describe("check the tables endpoints", () => {
|
|
|
92
106
|
})
|
|
93
107
|
|
|
94
108
|
describe("check the rows endpoints", () => {
|
|
95
|
-
let row
|
|
109
|
+
let row: Row
|
|
96
110
|
it("should allow retrieving rows through search", async () => {
|
|
97
111
|
table = await config.updateTable()
|
|
98
112
|
const res = await makeRequest("post", `/tables/${table._id}/rows/search`, {
|
|
99
|
-
query: {
|
|
100
|
-
},
|
|
113
|
+
query: {},
|
|
101
114
|
})
|
|
102
115
|
expect(res).toSatisfyApiSpec()
|
|
103
116
|
})
|
|
@@ -111,9 +124,13 @@ describe("check the rows endpoints", () => {
|
|
|
111
124
|
})
|
|
112
125
|
|
|
113
126
|
it("should allow updating a row", async () => {
|
|
114
|
-
const res = await makeRequest(
|
|
115
|
-
|
|
116
|
-
|
|
127
|
+
const res = await makeRequest(
|
|
128
|
+
"put",
|
|
129
|
+
`/tables/${table._id}/rows/${row._id}`,
|
|
130
|
+
{
|
|
131
|
+
name: "test row updated",
|
|
132
|
+
}
|
|
133
|
+
)
|
|
117
134
|
expect(res).toSatisfyApiSpec()
|
|
118
135
|
})
|
|
119
136
|
|
|
@@ -123,13 +140,16 @@ describe("check the rows endpoints", () => {
|
|
|
123
140
|
})
|
|
124
141
|
|
|
125
142
|
it("should allow deleting a row", async () => {
|
|
126
|
-
const res = await makeRequest(
|
|
143
|
+
const res = await makeRequest(
|
|
144
|
+
"delete",
|
|
145
|
+
`/tables/${table._id}/rows/${row._id}`
|
|
146
|
+
)
|
|
127
147
|
expect(res).toSatisfyApiSpec()
|
|
128
148
|
})
|
|
129
149
|
})
|
|
130
150
|
|
|
131
151
|
describe("check the users endpoints", () => {
|
|
132
|
-
let user
|
|
152
|
+
let user: User
|
|
133
153
|
it("should allow retrieving users through search", async () => {
|
|
134
154
|
user = await config.createUser()
|
|
135
155
|
const res = await makeRequest("post", "/users/search")
|
|
@@ -163,4 +183,3 @@ describe("check the queries endpoints", () => {
|
|
|
163
183
|
expect(res).toSatisfyApiSpec()
|
|
164
184
|
})
|
|
165
185
|
})
|
|
166
|
-
|
|
@@ -9,7 +9,7 @@ const read = [],
|
|
|
9
9
|
* @openapi
|
|
10
10
|
* /users:
|
|
11
11
|
* post:
|
|
12
|
-
* operationId:
|
|
12
|
+
* operationId: userCreate
|
|
13
13
|
* summary: Create a user
|
|
14
14
|
* tags:
|
|
15
15
|
* - users
|
|
@@ -36,7 +36,7 @@ write.push(new Endpoint("post", "/users", controller.create))
|
|
|
36
36
|
* @openapi
|
|
37
37
|
* /users/{userId}:
|
|
38
38
|
* put:
|
|
39
|
-
* operationId:
|
|
39
|
+
* operationId: userUpdate
|
|
40
40
|
* summary: Update a user
|
|
41
41
|
* tags:
|
|
42
42
|
* - users
|
|
@@ -65,7 +65,7 @@ write.push(new Endpoint("put", "/users/:userId", controller.update))
|
|
|
65
65
|
* @openapi
|
|
66
66
|
* /users/{userId}:
|
|
67
67
|
* delete:
|
|
68
|
-
* operationId:
|
|
68
|
+
* operationId: userDestroy
|
|
69
69
|
* summary: Delete a user
|
|
70
70
|
* tags:
|
|
71
71
|
* - users
|
|
@@ -88,7 +88,7 @@ write.push(new Endpoint("delete", "/users/:userId", controller.destroy))
|
|
|
88
88
|
* @openapi
|
|
89
89
|
* /users/{userId}:
|
|
90
90
|
* get:
|
|
91
|
-
* operationId:
|
|
91
|
+
* operationId: userGetById
|
|
92
92
|
* summary: Retrieve a user
|
|
93
93
|
* tags:
|
|
94
94
|
* - users
|
|
@@ -111,7 +111,7 @@ read.push(new Endpoint("get", "/users/:userId", controller.read))
|
|
|
111
111
|
* @openapi
|
|
112
112
|
* /users/search:
|
|
113
113
|
* post:
|
|
114
|
-
* operationId:
|
|
114
|
+
* operationId: userSearch
|
|
115
115
|
* summary: Search for users
|
|
116
116
|
* description: Based on user properties (currently only name) search for users.
|
|
117
117
|
* tags:
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { App } from "@budibase/types"
|
|
2
|
+
|
|
1
3
|
jest.setTimeout(30000)
|
|
2
4
|
|
|
3
5
|
import { AppStatus } from "../../../db/utils"
|
|
@@ -5,6 +7,7 @@ import { AppStatus } from "../../../db/utils"
|
|
|
5
7
|
import * as setup from "./utilities"
|
|
6
8
|
|
|
7
9
|
import { wipeDb } from "./utilities/TestFunctions"
|
|
10
|
+
import { tenancy } from "@budibase/backend-core"
|
|
8
11
|
|
|
9
12
|
describe("/cloud", () => {
|
|
10
13
|
let request = setup.getRequest()!
|
|
@@ -12,18 +15,10 @@ describe("/cloud", () => {
|
|
|
12
15
|
|
|
13
16
|
afterAll(setup.afterAll)
|
|
14
17
|
|
|
15
|
-
beforeAll(() => {
|
|
18
|
+
beforeAll(async () => {
|
|
16
19
|
// Importing is only allowed in self hosted environments
|
|
17
|
-
config.modeSelf()
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
beforeEach(async () => {
|
|
21
20
|
await config.init()
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
afterEach(async () => {
|
|
25
|
-
// clear all mocks
|
|
26
|
-
jest.clearAllMocks()
|
|
21
|
+
config.modeSelf()
|
|
27
22
|
})
|
|
28
23
|
|
|
29
24
|
describe("import", () => {
|
|
@@ -32,30 +27,28 @@ describe("/cloud", () => {
|
|
|
32
27
|
// import will not run
|
|
33
28
|
await wipeDb()
|
|
34
29
|
|
|
35
|
-
// get a count of apps before the import
|
|
36
|
-
const preImportApps = await request
|
|
37
|
-
.get(`/api/applications?status=${AppStatus.ALL}`)
|
|
38
|
-
.set(config.defaultHeaders())
|
|
39
|
-
.expect("Content-Type", /json/)
|
|
40
|
-
.expect(200)
|
|
41
|
-
|
|
42
30
|
// Perform the import
|
|
43
31
|
const res = await request
|
|
44
32
|
.post(`/api/cloud/import`)
|
|
33
|
+
.set(config.publicHeaders())
|
|
45
34
|
.attach("importFile", "src/api/routes/tests/data/export-test.tar.gz")
|
|
46
|
-
.set(config.defaultHeaders())
|
|
47
35
|
.expect(200)
|
|
48
36
|
expect(res.body.message).toEqual("Apps successfully imported.")
|
|
49
37
|
|
|
50
38
|
// get a count of apps after the import
|
|
51
39
|
const postImportApps = await request
|
|
52
40
|
.get(`/api/applications?status=${AppStatus.ALL}`)
|
|
53
|
-
.set(config.
|
|
41
|
+
.set(config.publicHeaders())
|
|
54
42
|
.expect("Content-Type", /json/)
|
|
55
43
|
.expect(200)
|
|
56
44
|
|
|
45
|
+
const apps = postImportApps.body as App[]
|
|
57
46
|
// There are two apps in the file that was imported so check for this
|
|
58
|
-
expect(
|
|
47
|
+
expect(apps.length).toEqual(2)
|
|
48
|
+
// The new tenant id was assigned to the imported apps
|
|
49
|
+
expect(tenancy.getTenantIDFromAppID(apps[0].appId)).toBe(
|
|
50
|
+
config.getTenantId()
|
|
51
|
+
)
|
|
59
52
|
})
|
|
60
53
|
})
|
|
61
54
|
})
|
|
@@ -2,7 +2,6 @@ import * as rowController from "../../../controllers/row"
|
|
|
2
2
|
import * as appController from "../../../controllers/application"
|
|
3
3
|
import { AppStatus } from "../../../../db/utils"
|
|
4
4
|
import { roles, tenancy, context } from "@budibase/backend-core"
|
|
5
|
-
import { TENANT_ID } from "../../../../tests/utilities/structures"
|
|
6
5
|
import env from "../../../../environment"
|
|
7
6
|
import { db } from "@budibase/backend-core"
|
|
8
7
|
import Nano from "@budibase/nano"
|
|
@@ -33,7 +32,7 @@ export const getAllTableRows = async (config: any) => {
|
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
export const clearAllApps = async (
|
|
36
|
-
tenantId
|
|
35
|
+
tenantId: string,
|
|
37
36
|
exceptions: Array<string> = []
|
|
38
37
|
) => {
|
|
39
38
|
await tenancy.doInTenant(tenantId, async () => {
|
package/src/app.ts
CHANGED
|
@@ -32,6 +32,7 @@ import { initialise as initialiseWebsockets } from "./websocket"
|
|
|
32
32
|
import { startup } from "./startup"
|
|
33
33
|
const Sentry = require("@sentry/node")
|
|
34
34
|
const destroyable = require("server-destroy")
|
|
35
|
+
const { userAgent } = require("koa-useragent")
|
|
35
36
|
|
|
36
37
|
const app = new Koa()
|
|
37
38
|
|
|
@@ -53,6 +54,7 @@ app.use(
|
|
|
53
54
|
)
|
|
54
55
|
|
|
55
56
|
app.use(middleware.logging)
|
|
57
|
+
app.use(userAgent)
|
|
56
58
|
|
|
57
59
|
if (env.isProd()) {
|
|
58
60
|
env._set("NODE_ENV", "production")
|
package/src/db/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as core from "@budibase/backend-core"
|
|
2
2
|
import env from "../environment"
|
|
3
3
|
|
|
4
4
|
export function init() {
|
|
@@ -12,5 +12,5 @@ export function init() {
|
|
|
12
12
|
dbConfig.allDbs = true
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
core.init({ db: dbConfig })
|
|
16
16
|
}
|
package/src/db/utils.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { context } from "@budibase/backend-core"
|
|
2
|
-
import { DocumentType, SEPARATOR, ViewName
|
|
3
|
-
import { LinkDocument, Row } from "@budibase/types"
|
|
2
|
+
import { DocumentType, SEPARATOR, ViewName } from "../utils"
|
|
3
|
+
import { LinkDocument, Row, SearchIndex } from "@budibase/types"
|
|
4
4
|
const SCREEN_PREFIX = DocumentType.SCREEN + SEPARATOR
|
|
5
5
|
|
|
6
6
|
/**************************************************
|
|
@@ -91,7 +91,7 @@ async function searchIndex(indexName: string, fnString: string) {
|
|
|
91
91
|
|
|
92
92
|
export async function createAllSearchIndex() {
|
|
93
93
|
await searchIndex(
|
|
94
|
-
|
|
94
|
+
SearchIndex.ROWS,
|
|
95
95
|
function (doc: Row) {
|
|
96
96
|
function idx(input: Row, prev?: string) {
|
|
97
97
|
for (let key of Object.keys(input)) {
|