@budibase/server 2.11.23 → 2.11.25

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.
@@ -9,7 +9,7 @@
9
9
  <link href="/builder/fonts/source-sans-pro/600.css" rel="stylesheet" />
10
10
  <link href="/builder/fonts/source-sans-pro/700.css" rel="stylesheet" />
11
11
  <link href="/builder/fonts/remixicon.css" rel="stylesheet" />
12
- <script type="module" crossorigin src="/builder/assets/index.9e3141b5.js"></script>
12
+ <script type="module" crossorigin src="/builder/assets/index.a3158469.js"></script>
13
13
  <link rel="stylesheet" href="/builder/assets/index.a14aa274.css">
14
14
  </head>
15
15
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "2.11.23",
4
+ "version": "2.11.25",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -20,7 +20,6 @@
20
20
  "test:watch": "jest --watch",
21
21
  "predocker": "copyfiles -f ../client/dist/budibase-client.js ../client/manifest.json client && yarn build && cp ../../yarn.lock ./dist/",
22
22
  "build:docker": "yarn predocker && docker build . -t app-service --label version=$BUDIBASE_RELEASE_VERSION",
23
- "build:docs": "node ./scripts/docs/generate.js open",
24
23
  "run:docker": "node dist/index.js",
25
24
  "run:docker:cluster": "pm2-runtime start pm2.config.js",
26
25
  "dev:stack:up": "node scripts/dev/manage.js up",
@@ -46,12 +45,12 @@
46
45
  "license": "GPL-3.0",
47
46
  "dependencies": {
48
47
  "@apidevtools/swagger-parser": "10.0.3",
49
- "@budibase/backend-core": "2.11.23",
50
- "@budibase/client": "2.11.23",
51
- "@budibase/pro": "2.11.23",
52
- "@budibase/shared-core": "2.11.23",
53
- "@budibase/string-templates": "2.11.23",
54
- "@budibase/types": "2.11.23",
48
+ "@budibase/backend-core": "2.11.25",
49
+ "@budibase/client": "2.11.25",
50
+ "@budibase/pro": "2.11.25",
51
+ "@budibase/shared-core": "2.11.25",
52
+ "@budibase/string-templates": "2.11.25",
53
+ "@budibase/types": "2.11.25",
55
54
  "@bull-board/api": "3.7.0",
56
55
  "@bull-board/koa": "3.9.4",
57
56
  "@elastic/elasticsearch": "7.10.0",
@@ -175,5 +174,5 @@
175
174
  }
176
175
  }
177
176
  },
178
- "gitHead": "e018d4dc00b9d85e343df734b7a12be157c1a118"
177
+ "gitHead": "6b08e7f9b409ac01aabaf12428b43ae699c45d11"
179
178
  }
@@ -859,7 +859,8 @@
859
859
  "json",
860
860
  "internal",
861
861
  "barcodeqr",
862
- "bigint"
862
+ "bigint",
863
+ "bb_reference"
863
864
  ],
864
865
  "description": "Defines the type of the column, most explain themselves, a link column is a relationship."
865
866
  },
@@ -1064,7 +1065,8 @@
1064
1065
  "json",
1065
1066
  "internal",
1066
1067
  "barcodeqr",
1067
- "bigint"
1068
+ "bigint",
1069
+ "bb_reference"
1068
1070
  ],
1069
1071
  "description": "Defines the type of the column, most explain themselves, a link column is a relationship."
1070
1072
  },
@@ -1280,7 +1282,8 @@
1280
1282
  "json",
1281
1283
  "internal",
1282
1284
  "barcodeqr",
1283
- "bigint"
1285
+ "bigint",
1286
+ "bb_reference"
1284
1287
  ],
1285
1288
  "description": "Defines the type of the column, most explain themselves, a link column is a relationship."
1286
1289
  },
@@ -782,6 +782,7 @@ components:
782
782
  - internal
783
783
  - barcodeqr
784
784
  - bigint
785
+ - bb_reference
785
786
  description: Defines the type of the column, most explain themselves, a link
786
787
  column is a relationship.
787
788
  constraints:
@@ -946,6 +947,7 @@ components:
946
947
  - internal
947
948
  - barcodeqr
948
949
  - bigint
950
+ - bb_reference
949
951
  description: Defines the type of the column, most explain themselves, a link
950
952
  column is a relationship.
951
953
  constraints:
@@ -1117,6 +1119,7 @@ components:
1117
1119
  - internal
1118
1120
  - barcodeqr
1119
1121
  - bigint
1122
+ - bb_reference
1120
1123
  description: Defines the type of the column, most explain themselves, a link
1121
1124
  column is a relationship.
1122
1125
  constraints:
@@ -279,7 +279,8 @@ export interface components {
279
279
  | "json"
280
280
  | "internal"
281
281
  | "barcodeqr"
282
- | "bigint";
282
+ | "bigint"
283
+ | "bb_reference";
283
284
  /** @description A constraint can be applied to the column which will be validated against when a row is saved. */
284
285
  constraints?: {
285
286
  /** @enum {string} */
@@ -386,7 +387,8 @@ export interface components {
386
387
  | "json"
387
388
  | "internal"
388
389
  | "barcodeqr"
389
- | "bigint";
390
+ | "bigint"
391
+ | "bb_reference";
390
392
  /** @description A constraint can be applied to the column which will be validated against when a row is saved. */
391
393
  constraints?: {
392
394
  /** @enum {string} */
@@ -495,7 +497,8 @@ export interface components {
495
497
  | "json"
496
498
  | "internal"
497
499
  | "barcodeqr"
498
- | "bigint";
500
+ | "bigint"
501
+ | "bb_reference";
499
502
  /** @description A constraint can be applied to the column which will be validated against when a row is saved. */
500
503
  constraints?: {
501
504
  /** @enum {string} */
@@ -1,31 +0,0 @@
1
- ### Documentation
2
-
3
- This directory contains the scripts required to generate the APIDoc based documentation.
4
- You can find the docs about comment structure at the [APIDocs page](https://apidocjs.com/).
5
-
6
- In general most API endpoints will look like:
7
- ```js
8
- /**
9
- * @api {post} /api/:param/url Give it a name
10
- * @apiName Give it a name
11
- * @apiGroup group
12
- * @apiPermission permission
13
- * @apiDescription Describe what the endpoint does, any special cases the user
14
- * should be aware of.
15
- *
16
- * @apiParam {string} param describe a URL parameter.
17
- *
18
- * @apiParam (Body) input describe a field on the body.
19
- *
20
- * @apiSuccess {object} output describe the output.
21
- */
22
- ```
23
-
24
- There are a few key points to note when writing API docs:
25
- 1. Don't use `@apiBody` - this isn't currently supported by our swagger converter.
26
- 2. Make sure to always have an `@api` definition at the start, which must always have the
27
- HTTP verb, the endpoint URL and the name.
28
- 3. There are three ways you can specify parameters used as inputs for your endpoint,
29
- `@apiParam` for a URL param, `@apiParam (Body)` for a field on the request body and `@apiParam (Query)`
30
- for query string parameters.
31
- 4. The `@apiGroup` should be the same for all API Doc comments in a route file.
@@ -1,74 +0,0 @@
1
- const fs = require("fs")
2
- const { join } = require("path")
3
- const { createDoc } = require("apidoc")
4
- const packageJson = require("../../package.json")
5
- const toSwagger = require("./toSwagger")
6
- const open = require("open")
7
-
8
- const config = {
9
- name: "Budibase API",
10
- version: packageJson.version,
11
- description: "Documenting the Budibase backend API",
12
- title: "Budibase app service API",
13
- }
14
-
15
- const shouldOpen = process.argv[2]
16
- const disallowed = []
17
-
18
- function filter(parsedRouteFiles) {
19
- const tagToSearch = "url"
20
- for (let routeFile of parsedRouteFiles) {
21
- for (let route of routeFile) {
22
- let routeInfo = route["local"]
23
- if (disallowed.includes(routeInfo[tagToSearch])) {
24
- const idx = routeFile.indexOf(route)
25
- routeFile.splice(idx, 1)
26
- }
27
- }
28
- }
29
- }
30
-
31
- async function generate() {
32
- // start by writing a config file
33
- const configPath = join(__dirname, "config.json")
34
- fs.writeFileSync(configPath, JSON.stringify(config))
35
- const mainPath = join(__dirname, "..", "..")
36
- const srcPath = join(mainPath, "src", "api", "routes")
37
- const assetsPath = join(mainPath, "builder", "assets", "docs")
38
- if (!fs.existsSync(assetsPath)) {
39
- fs.mkdirSync(assetsPath, { recursive: true })
40
- }
41
- const options = {
42
- src: [srcPath],
43
- dest: assetsPath,
44
- filters: {
45
- main: {
46
- postFilter: filter,
47
- },
48
- },
49
- config: configPath,
50
- }
51
- const doc = createDoc(options)
52
- if (typeof doc !== "boolean") {
53
- const swagger = toSwagger(JSON.parse(doc.data), JSON.parse(doc.project))
54
- fs.writeFileSync(join(assetsPath, "swagger.json"), JSON.stringify(swagger))
55
- fs.writeFileSync(join(assetsPath, "apidoc.json"), doc.data)
56
- fs.writeFileSync(join(assetsPath, "project.json"), doc.project)
57
- console.log(
58
- `Docs generated successfully, find in ${assetsPath}, swagger.json, apidoc.json and project.json`
59
- )
60
- } else {
61
- throw "Unable to generate docs."
62
- }
63
- // delete the temporary config file
64
- fs.unlinkSync(configPath)
65
- setTimeout(async () => {
66
- if (shouldOpen === "open") {
67
- await open(join(assetsPath, "index.html"), { wait: false })
68
- }
69
- }, 2000)
70
- }
71
-
72
- generate().catch(err => {
73
- console.error(err)
74
- })
@@ -1,320 +0,0 @@
1
- let _ = require("lodash")
2
- let { pathToRegexp } = require("path-to-regexp")
3
-
4
- /********************************************************
5
- * Based on: https://github.com/fsbahman/apidoc-swagger *
6
- ********************************************************/
7
-
8
- let swagger = {
9
- swagger: "2.0",
10
- info: {},
11
- paths: {},
12
- definitions: {},
13
- }
14
-
15
- function toSwagger(apidocJson, projectJson) {
16
- swagger.info = addInfo(projectJson)
17
- swagger.paths = extractPaths(apidocJson)
18
- return swagger
19
- }
20
-
21
- let tagsRegex = /(<([^>]+)>)/gi
22
- // Removes <p> </p> tags from text
23
- function removeTags(text) {
24
- return text ? text.replace(tagsRegex, "") : text
25
- }
26
-
27
- function addInfo(projectJson) {
28
- let info = {}
29
- info["title"] = projectJson.title || projectJson.name
30
- info["version"] = projectJson.version
31
- info["description"] = projectJson.description
32
- return info
33
- }
34
-
35
- /**
36
- * Extracts paths provided in json format
37
- * post, patch, put request parameters are extracted in body
38
- * get and delete are extracted to path parameters
39
- * @param apidocJson
40
- * @returns {{}}
41
- */
42
- function extractPaths(apidocJson) {
43
- let apiPaths = groupByUrl(apidocJson)
44
- let paths = {}
45
- for (let i = 0; i < apiPaths.length; i++) {
46
- let verbs = apiPaths[i].verbs
47
- let url = verbs[0].url
48
- let pattern = pathToRegexp(url, null)
49
- let matches = pattern.exec(url)
50
-
51
- // Surrounds URL parameters with curly brackets -> :email with {email}
52
- let pathKeys = []
53
- for (let j = 1; j < matches.length; j++) {
54
- let key = matches[j].slice(1)
55
- url = url.replace(matches[j], "{" + key + "}")
56
- pathKeys.push(key)
57
- }
58
-
59
- for (let j = 0; j < verbs.length; j++) {
60
- let verb = verbs[j]
61
- let type = verb.type
62
-
63
- let obj = (paths[url] = paths[url] || {})
64
-
65
- if (type === "post" || type === "patch" || type === "put") {
66
- _.extend(
67
- obj,
68
- createPostPushPutOutput(verb, swagger.definitions, pathKeys)
69
- )
70
- } else {
71
- _.extend(obj, createGetDeleteOutput(verb, swagger.definitions))
72
- }
73
- }
74
- }
75
- return paths
76
- }
77
-
78
- function createPostPushPutOutput(verbs, definitions, pathKeys) {
79
- let pathItemObject = {}
80
- let verbDefinitionResult = createVerbDefinitions(verbs, definitions)
81
-
82
- let params = []
83
- let pathParams = createPathParameters(verbs, pathKeys)
84
- pathParams = _.filter(pathParams, function (param) {
85
- let hasKey = pathKeys.indexOf(param.name) !== -1
86
- return !(param.in === "path" && !hasKey)
87
- })
88
-
89
- params = params.concat(pathParams)
90
- let required =
91
- verbs.parameter &&
92
- verbs.parameter.fields &&
93
- verbs.parameter.fields.Parameter &&
94
- verbs.parameter.fields.Parameter.length > 0
95
-
96
- params.push({
97
- in: "body",
98
- name: "body",
99
- description: removeTags(verbs.description),
100
- required: required,
101
- schema: {
102
- $ref: "#/definitions/" + verbDefinitionResult.topLevelParametersRef,
103
- },
104
- })
105
-
106
- pathItemObject[verbs.type] = {
107
- tags: [verbs.group],
108
- summary: removeTags(verbs.description),
109
- consumes: ["application/json"],
110
- produces: ["application/json"],
111
- parameters: params,
112
- }
113
-
114
- if (verbDefinitionResult.topLevelSuccessRef) {
115
- pathItemObject[verbs.type].responses = {
116
- 200: {
117
- description: "successful operation",
118
- schema: {
119
- type: verbDefinitionResult.topLevelSuccessRefType,
120
- items: {
121
- $ref: "#/definitions/" + verbDefinitionResult.topLevelSuccessRef,
122
- },
123
- },
124
- },
125
- }
126
- }
127
-
128
- return pathItemObject
129
- }
130
-
131
- function createVerbDefinitions(verbs, definitions) {
132
- let result = {
133
- topLevelParametersRef: null,
134
- topLevelSuccessRef: null,
135
- topLevelSuccessRefType: null,
136
- }
137
- let defaultObjectName = verbs.name
138
-
139
- let fieldArrayResult = {}
140
- if (verbs && verbs.parameter && verbs.parameter.fields) {
141
- fieldArrayResult = createFieldArrayDefinitions(
142
- verbs.parameter.fields.Parameter,
143
- definitions,
144
- verbs.name,
145
- defaultObjectName
146
- )
147
- result.topLevelParametersRef = fieldArrayResult.topLevelRef
148
- }
149
-
150
- if (verbs && verbs.success && verbs.success.fields) {
151
- fieldArrayResult = createFieldArrayDefinitions(
152
- verbs.success.fields["Success 200"],
153
- definitions,
154
- verbs.name,
155
- defaultObjectName
156
- )
157
- result.topLevelSuccessRef = fieldArrayResult.topLevelRef
158
- result.topLevelSuccessRefType = fieldArrayResult.topLevelRefType
159
- }
160
-
161
- return result
162
- }
163
-
164
- function createFieldArrayDefinitions(
165
- fieldArray,
166
- definitions,
167
- topLevelRef,
168
- defaultObjectName
169
- ) {
170
- let result = {
171
- topLevelRef: topLevelRef,
172
- topLevelRefType: null,
173
- }
174
-
175
- if (!fieldArray) {
176
- return result
177
- }
178
-
179
- for (let i = 0; i < fieldArray.length; i++) {
180
- let parameter = fieldArray[i]
181
-
182
- let nestedName = createNestedName(parameter.field)
183
- let objectName = nestedName.objectName
184
- if (!objectName) {
185
- objectName = defaultObjectName
186
- }
187
- let type = parameter.type
188
- if (i === 0) {
189
- result.topLevelRefType = type
190
- if (parameter.type === "Object") {
191
- objectName = nestedName.propertyName
192
- nestedName.propertyName = null
193
- } else if (parameter.type === "Array") {
194
- objectName = nestedName.propertyName
195
- nestedName.propertyName = null
196
- result.topLevelRefType = "array"
197
- }
198
- result.topLevelRef = objectName
199
- }
200
-
201
- definitions[objectName] = definitions[objectName] || {
202
- properties: {},
203
- required: [],
204
- }
205
-
206
- if (nestedName.propertyName) {
207
- let prop = {
208
- type: (parameter.type || "").toLowerCase(),
209
- description: removeTags(parameter.description),
210
- }
211
- if (parameter.type === "Object") {
212
- prop.$ref = "#/definitions/" + parameter.field
213
- }
214
-
215
- let typeIndex = type.indexOf("[]")
216
- if (typeIndex !== -1 && typeIndex === type.length - 2) {
217
- prop.type = "array"
218
- prop.items = {
219
- type: type.slice(0, type.length - 2),
220
- }
221
- }
222
-
223
- definitions[objectName]["properties"][nestedName.propertyName] = prop
224
- if (!parameter.optional) {
225
- let arr = definitions[objectName]["required"]
226
- if (arr.indexOf(nestedName.propertyName) === -1) {
227
- arr.push(nestedName.propertyName)
228
- }
229
- }
230
- }
231
- }
232
-
233
- return result
234
- }
235
-
236
- function createNestedName(field) {
237
- let propertyName = field
238
- let objectName
239
- let propertyNames = field.split(".")
240
- if (propertyNames && propertyNames.length > 1) {
241
- propertyName = propertyNames[propertyNames.length - 1]
242
- propertyNames.pop()
243
- objectName = propertyNames.join(".")
244
- }
245
-
246
- return {
247
- propertyName: propertyName,
248
- objectName: objectName,
249
- }
250
- }
251
-
252
- /**
253
- * Generate get, delete method output
254
- * @param verbs
255
- * @param definitions
256
- * @returns {{}}
257
- */
258
- function createGetDeleteOutput(verbs, definitions) {
259
- let pathItemObject = {}
260
- verbs.type = verbs.type === "del" ? "delete" : verbs.type
261
-
262
- let verbDefinitionResult = createVerbDefinitions(verbs, definitions)
263
- pathItemObject[verbs.type] = {
264
- tags: [verbs.group],
265
- summary: removeTags(verbs.description),
266
- consumes: ["application/json"],
267
- produces: ["application/json"],
268
- parameters: createPathParameters(verbs),
269
- }
270
- if (verbDefinitionResult.topLevelSuccessRef) {
271
- pathItemObject[verbs.type].responses = {
272
- 200: {
273
- description: "successful operation",
274
- schema: {
275
- type: verbDefinitionResult.topLevelSuccessRefType,
276
- items: {
277
- $ref: "#/definitions/" + verbDefinitionResult.topLevelSuccessRef,
278
- },
279
- },
280
- },
281
- }
282
- }
283
- return pathItemObject
284
- }
285
-
286
- /**
287
- * Iterate through all method parameters and create array of parameter objects which are stored as path parameters
288
- * @param verbs
289
- * @returns {Array}
290
- */
291
- function createPathParameters(verbs) {
292
- let pathItemObject = []
293
- if (verbs.parameter && verbs.parameter.fields.Parameter) {
294
- for (let i = 0; i < verbs.parameter.fields.Parameter.length; i++) {
295
- let param = verbs.parameter.fields.Parameter[i]
296
- let field = param.field
297
- let type = param.type
298
- pathItemObject.push({
299
- name: field,
300
- in: type === "file" ? "formData" : "path",
301
- required: !param.optional,
302
- type: param.type.toLowerCase(),
303
- description: removeTags(param.description),
304
- })
305
- }
306
- }
307
- return pathItemObject
308
- }
309
-
310
- function groupByUrl(apidocJson) {
311
- return _.chain(apidocJson)
312
- .groupBy("url")
313
- .toPairs()
314
- .map(function (element) {
315
- return _.zipObject(["url", "verbs"], element)
316
- })
317
- .value()
318
- }
319
-
320
- module.exports = toSwagger