@budibase/server 2.3.18-alpha.17 → 2.3.18-alpha.19
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.57df7f7b.js → index.db0385d0.js} +300 -300
- package/builder/index.html +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/package.json +7 -7
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +8 -8
- 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/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/definitions/openapi.ts +449 -63
- package/specs/resources/utils/Resource.js +0 -26
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { object } from "./utils"
|
|
2
|
+
import Resource from "./utils/Resource"
|
|
3
3
|
|
|
4
4
|
const user = {
|
|
5
5
|
_id: "us_693a73206518477283a8d5ae31103252",
|
|
@@ -105,7 +105,7 @@ const userOutputSchema = {
|
|
|
105
105
|
required: [...userSchema.required, "_id"],
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
export default new Resource()
|
|
109
109
|
.setExamples({
|
|
110
110
|
user: {
|
|
111
111
|
value: {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
type Example = {
|
|
2
|
+
[key: string]: {
|
|
3
|
+
[key: string]: any
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
type Schema = {
|
|
8
|
+
[key: string]: {
|
|
9
|
+
[key: string]: any
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default class Resource {
|
|
14
|
+
examples: Example
|
|
15
|
+
schemas: Schema
|
|
16
|
+
|
|
17
|
+
constructor() {
|
|
18
|
+
this.examples = {}
|
|
19
|
+
this.schemas = {}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
setExamples(examples: Example) {
|
|
23
|
+
this.examples = examples
|
|
24
|
+
return this
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
setSchemas(schemas: Schema) {
|
|
28
|
+
this.schemas = schemas
|
|
29
|
+
return this
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getExamples() {
|
|
33
|
+
return this.examples
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
getSchemas() {
|
|
37
|
+
return this.schemas
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -9,7 +9,7 @@ const read = [],
|
|
|
9
9
|
* @openapi
|
|
10
10
|
* /applications:
|
|
11
11
|
* post:
|
|
12
|
-
* operationId:
|
|
12
|
+
* operationId: appCreate
|
|
13
13
|
* summary: Create an application
|
|
14
14
|
* tags:
|
|
15
15
|
* - applications
|
|
@@ -42,7 +42,7 @@ write.push(
|
|
|
42
42
|
* @openapi
|
|
43
43
|
* /applications/{appId}:
|
|
44
44
|
* put:
|
|
45
|
-
* operationId:
|
|
45
|
+
* operationId: appUpdate
|
|
46
46
|
* summary: Update an application
|
|
47
47
|
* tags:
|
|
48
48
|
* - applications
|
|
@@ -75,7 +75,7 @@ write.push(
|
|
|
75
75
|
* @openapi
|
|
76
76
|
* /applications/{appId}:
|
|
77
77
|
* delete:
|
|
78
|
-
* operationId:
|
|
78
|
+
* operationId: appDestroy
|
|
79
79
|
* summary: Delete an application
|
|
80
80
|
* tags:
|
|
81
81
|
* - applications
|
|
@@ -98,7 +98,7 @@ write.push(new Endpoint("delete", "/applications/:appId", controller.destroy))
|
|
|
98
98
|
* @openapi
|
|
99
99
|
* /applications/{appId}/unpublish:
|
|
100
100
|
* post:
|
|
101
|
-
* operationId:
|
|
101
|
+
* operationId: appUnpublish
|
|
102
102
|
* summary: Unpublish an application
|
|
103
103
|
* tags:
|
|
104
104
|
* - applications
|
|
@@ -116,7 +116,7 @@ write.push(
|
|
|
116
116
|
* @openapi
|
|
117
117
|
* /applications/{appId}/publish:
|
|
118
118
|
* post:
|
|
119
|
-
* operationId:
|
|
119
|
+
* operationId: appPublish
|
|
120
120
|
* summary: Unpublish an application
|
|
121
121
|
* tags:
|
|
122
122
|
* - applications
|
|
@@ -141,7 +141,7 @@ write.push(
|
|
|
141
141
|
* @openapi
|
|
142
142
|
* /applications/{appId}:
|
|
143
143
|
* get:
|
|
144
|
-
* operationId:
|
|
144
|
+
* operationId: appGetById
|
|
145
145
|
* summary: Retrieve an application
|
|
146
146
|
* tags:
|
|
147
147
|
* - applications
|
|
@@ -164,7 +164,7 @@ read.push(new Endpoint("get", "/applications/:appId", controller.read))
|
|
|
164
164
|
* @openapi
|
|
165
165
|
* /applications/search:
|
|
166
166
|
* post:
|
|
167
|
-
* operationId:
|
|
167
|
+
* operationId: appSearch
|
|
168
168
|
* summary: Search for applications
|
|
169
169
|
* description: Based on application properties (currently only name) search for applications.
|
|
170
170
|
* tags:
|
|
@@ -9,7 +9,7 @@ const read = [],
|
|
|
9
9
|
* @openapi
|
|
10
10
|
* /queries/{queryId}:
|
|
11
11
|
* post:
|
|
12
|
-
* operationId:
|
|
12
|
+
* operationId: queryExecute
|
|
13
13
|
* summary: Execute a query
|
|
14
14
|
* description: Queries which have been created within a Budibase app can be executed using this,
|
|
15
15
|
* tags:
|
|
@@ -43,7 +43,7 @@ write.push(new Endpoint("post", "/queries/:queryId", controller.execute))
|
|
|
43
43
|
* @openapi
|
|
44
44
|
* /queries/search:
|
|
45
45
|
* post:
|
|
46
|
-
* operationId:
|
|
46
|
+
* operationId: querySearch
|
|
47
47
|
* summary: Search for queries
|
|
48
48
|
* description: Based on query properties (currently only name) search for queries.
|
|
49
49
|
* tags:
|
|
@@ -9,7 +9,7 @@ const read = [],
|
|
|
9
9
|
* @openapi
|
|
10
10
|
* /tables/{tableId}/rows:
|
|
11
11
|
* post:
|
|
12
|
-
* operationId:
|
|
12
|
+
* operationId: rowCreate
|
|
13
13
|
* summary: Create a row
|
|
14
14
|
* description: Creates a row within the specified table.
|
|
15
15
|
* tags:
|
|
@@ -44,7 +44,7 @@ write.push(new Endpoint("post", "/tables/:tableId/rows", controller.create))
|
|
|
44
44
|
* @openapi
|
|
45
45
|
* /tables/{tableId}/rows/{rowId}:
|
|
46
46
|
* put:
|
|
47
|
-
* operationId:
|
|
47
|
+
* operationId: rowUpdate
|
|
48
48
|
* summary: Update a row
|
|
49
49
|
* description: Updates a row within the specified table.
|
|
50
50
|
* tags:
|
|
@@ -81,7 +81,7 @@ write.push(
|
|
|
81
81
|
* @openapi
|
|
82
82
|
* /tables/{tableId}/rows/{rowId}:
|
|
83
83
|
* delete:
|
|
84
|
-
* operationId:
|
|
84
|
+
* operationId: rowDestroy
|
|
85
85
|
* summary: Delete a row
|
|
86
86
|
* description: Deletes a row within the specified table.
|
|
87
87
|
* tags:
|
|
@@ -109,7 +109,7 @@ write.push(
|
|
|
109
109
|
* @openapi
|
|
110
110
|
* /tables/{tableId}/rows/{rowId}:
|
|
111
111
|
* get:
|
|
112
|
-
* operationId:
|
|
112
|
+
* operationId: rowGetById
|
|
113
113
|
* summary: Retrieve a row
|
|
114
114
|
* description: This gets a single row, it will be enriched with the full related rows, rather than
|
|
115
115
|
* the squashed "primaryDisplay" format returned by the search endpoint.
|
|
@@ -136,7 +136,7 @@ read.push(new Endpoint("get", "/tables/:tableId/rows/:rowId", controller.read))
|
|
|
136
136
|
* @openapi
|
|
137
137
|
* /tables/{tableId}/rows/search:
|
|
138
138
|
* post:
|
|
139
|
-
* operationId:
|
|
139
|
+
* operationId: rowSearch
|
|
140
140
|
* summary: Search for rows
|
|
141
141
|
* tags:
|
|
142
142
|
* - rows
|
|
@@ -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:
|