@budibase/server 2.4.42-alpha.8 → 2.4.43
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/favicon.e7fc7733.png +0 -0
- package/builder/assets/{index.89bb7cf4.js → index.8b377b88.js} +384 -385
- package/builder/assets/index.b0e3aca6.css +6 -0
- package/builder/index.html +7 -7
- package/dist/api/controllers/application.js +24 -28
- package/dist/api/controllers/row/external.js +0 -15
- package/dist/api/controllers/static/index.js +24 -84
- package/dist/api/controllers/static/templates/BudibaseApp.svelte +11 -34
- package/dist/api/controllers/table/utils.js +4 -2
- package/dist/api/routes/public/index.js +0 -8
- package/dist/app.js +0 -1
- package/dist/integrations/googlesheets.js +0 -4
- package/dist/integrations/redis.js +1 -1
- package/dist/middleware/currentapp.js +27 -1
- package/dist/package.json +12 -13
- package/dist/sdk/users/utils.js +6 -11
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/filesystem.js +0 -4
- package/dist/utilities/global.js +7 -17
- package/jest.config.ts +1 -1
- package/package.json +13 -14
- package/scripts/test.sh +5 -3
- package/specs/openapi.json +0 -39
- package/specs/openapi.yaml +0 -169
- package/specs/resources/application.ts +0 -11
- package/specs/resources/index.ts +0 -2
- package/src/api/controllers/application.ts +21 -20
- package/src/api/controllers/row/external.ts +0 -14
- package/src/api/controllers/static/index.ts +26 -69
- package/src/api/controllers/static/templates/BudibaseApp.svelte +11 -34
- package/src/api/controllers/table/utils.ts +12 -20
- package/src/api/controllers/view/tests/__snapshots__/viewBuilder.spec.js.snap +48 -48
- package/src/api/routes/public/index.ts +1 -10
- 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/app.ts +1 -2
- package/src/automations/automationUtils.ts +1 -1
- package/src/automations/tests/automation.spec.js +84 -0
- package/src/db/defaultData/datasource_bb_default.ts +1 -1
- package/src/definitions/openapi.ts +0 -15
- package/src/integrations/googlesheets.ts +0 -4
- package/src/integrations/redis.ts +1 -1
- package/src/integrations/tests/googlesheets.spec.ts +0 -4
- package/src/integrations/tests/redis.spec.ts +5 -9
- package/src/middleware/currentapp.ts +32 -3
- package/src/middleware/tests/currentapp.spec.js +42 -6
- package/src/sdk/users/utils.ts +7 -18
- package/src/tests/jestSetup.ts +1 -5
- package/src/tests/utilities/TestConfiguration.ts +19 -7
- package/src/tests/utilities/structures.ts +1 -13
- package/src/utilities/fileSystem/filesystem.ts +0 -4
- package/src/utilities/global.ts +9 -21
- package/src/utilities/rowProcessor/index.ts +1 -1
- package/builder/assets/index.7f9a008b.css +0 -6
- package/dist/api/controllers/public/metrics.js +0 -113
- package/dist/api/routes/public/metrics.js +0 -30
- package/specs/resources/metrics.ts +0 -81
- package/src/api/controllers/public/metrics.ts +0 -251
- package/src/api/controllers/table/tests/utils.spec.ts +0 -97
- package/src/api/routes/public/metrics.ts +0 -28
- package/src/api/routes/public/tests/metrics.spec.js +0 -34
- package/src/automations/tests/automation.spec.ts +0 -99
- package/src/sdk/users/tests/utils.spec.ts +0 -159
|
@@ -11,12 +11,10 @@ import {
|
|
|
11
11
|
} from "../../../utilities/fileSystem"
|
|
12
12
|
import env from "../../../environment"
|
|
13
13
|
import { DocumentType } from "../../../db/utils"
|
|
14
|
-
import { context, objectStore, utils
|
|
14
|
+
import { context, objectStore, utils } from "@budibase/backend-core"
|
|
15
15
|
import AWS from "aws-sdk"
|
|
16
16
|
import fs from "fs"
|
|
17
17
|
import sdk from "../../../sdk"
|
|
18
|
-
import * as pro from "@budibase/pro"
|
|
19
|
-
|
|
20
18
|
const send = require("koa-send")
|
|
21
19
|
|
|
22
20
|
async function prepareUpload({ s3Key, bucket, metadata, file }: any) {
|
|
@@ -100,74 +98,33 @@ export const deleteObjects = async function (ctx: any) {
|
|
|
100
98
|
}
|
|
101
99
|
|
|
102
100
|
export const serveApp = async function (ctx: any) {
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
let db
|
|
108
|
-
try {
|
|
109
|
-
db = context.getAppDB({ skip_setup: true })
|
|
110
|
-
const appInfo = await db.get(DocumentType.APP_METADATA)
|
|
111
|
-
let appId = context.getAppId()
|
|
101
|
+
const db = context.getAppDB({ skip_setup: true })
|
|
102
|
+
const appInfo = await db.get(DocumentType.APP_METADATA)
|
|
103
|
+
let appId = context.getAppId()
|
|
112
104
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
appId,
|
|
126
|
-
clientLibPath: objectStore.clientLibraryUrl(appId!, appInfo.version),
|
|
127
|
-
usedPlugins: plugins,
|
|
128
|
-
favicon:
|
|
129
|
-
branding.faviconUrl !== ""
|
|
130
|
-
? objectStore.getGlobalFileUrl("settings", "faviconUrl")
|
|
131
|
-
: "",
|
|
132
|
-
logo:
|
|
133
|
-
config?.logoUrl !== ""
|
|
134
|
-
? objectStore.getGlobalFileUrl("settings", "logoUrl")
|
|
135
|
-
: "",
|
|
136
|
-
})
|
|
137
|
-
const appHbs = loadHandlebarsFile(`${__dirname}/templates/app.hbs`)
|
|
138
|
-
ctx.body = await processString(appHbs, {
|
|
139
|
-
head,
|
|
140
|
-
body: html,
|
|
141
|
-
style: css.code,
|
|
142
|
-
appId,
|
|
143
|
-
})
|
|
144
|
-
} else {
|
|
145
|
-
// just return the app info for jest to assert on
|
|
146
|
-
ctx.body = appInfo
|
|
147
|
-
}
|
|
148
|
-
} catch (error) {
|
|
149
|
-
if (!env.isJest()) {
|
|
150
|
-
const App = require("./templates/BudibaseApp.svelte").default
|
|
151
|
-
const { head, html, css } = App.render({
|
|
152
|
-
title: branding?.metaTitle,
|
|
153
|
-
metaTitle: branding?.metaTitle,
|
|
154
|
-
metaImage:
|
|
155
|
-
branding?.metaImageUrl ||
|
|
156
|
-
"https://res.cloudinary.com/daog6scxm/image/upload/v1666109324/meta-images/budibase-meta-image_uukc1m.png",
|
|
157
|
-
metaDescription: branding?.metaDescription || "",
|
|
158
|
-
favicon:
|
|
159
|
-
branding.faviconUrl !== ""
|
|
160
|
-
? objectStore.getGlobalFileUrl("settings", "faviconUrl")
|
|
161
|
-
: "",
|
|
162
|
-
})
|
|
105
|
+
if (!env.isJest()) {
|
|
106
|
+
const App = require("./templates/BudibaseApp.svelte").default
|
|
107
|
+
const plugins = objectStore.enrichPluginURLs(appInfo.usedPlugins)
|
|
108
|
+
const { head, html, css } = App.render({
|
|
109
|
+
metaImage:
|
|
110
|
+
"https://res.cloudinary.com/daog6scxm/image/upload/v1666109324/meta-images/budibase-meta-image_uukc1m.png",
|
|
111
|
+
title: appInfo.name,
|
|
112
|
+
production: env.isProd(),
|
|
113
|
+
appId,
|
|
114
|
+
clientLibPath: objectStore.clientLibraryUrl(appId!, appInfo.version),
|
|
115
|
+
usedPlugins: plugins,
|
|
116
|
+
})
|
|
163
117
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
118
|
+
const appHbs = loadHandlebarsFile(`${__dirname}/templates/app.hbs`)
|
|
119
|
+
ctx.body = await processString(appHbs, {
|
|
120
|
+
head,
|
|
121
|
+
body: html,
|
|
122
|
+
style: css.code,
|
|
123
|
+
appId,
|
|
124
|
+
})
|
|
125
|
+
} else {
|
|
126
|
+
// just return the app info for jest to assert on
|
|
127
|
+
ctx.body = appInfo
|
|
171
128
|
}
|
|
172
129
|
}
|
|
173
130
|
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
export let title = ""
|
|
3
3
|
export let favicon = ""
|
|
4
|
-
|
|
5
4
|
export let metaImage = ""
|
|
6
|
-
export let metaTitle = ""
|
|
7
|
-
export let metaDescription = ""
|
|
8
5
|
|
|
9
6
|
export let clientLibPath
|
|
10
7
|
export let usedPlugins
|
|
@@ -16,33 +13,18 @@
|
|
|
16
13
|
name="viewport"
|
|
17
14
|
content="width=device-width, initial-scale=1.0, viewport-fit=cover"
|
|
18
15
|
/>
|
|
19
|
-
|
|
20
|
-
<!-- Primary Meta Tags -->
|
|
21
|
-
<meta name="title" content={metaTitle} />
|
|
22
|
-
<meta name="description" content={metaDescription} />
|
|
23
|
-
|
|
24
16
|
<!-- Opengraph Meta Tags -->
|
|
17
|
+
<meta name="twitter:card" content="summary_large_image" />
|
|
18
|
+
<meta name="twitter:site" content="@budibase" />
|
|
19
|
+
<meta name="twitter:image" content={metaImage} />
|
|
20
|
+
<meta name="twitter:title" content="{title} - built with Budibase" />
|
|
25
21
|
<meta property="og:site_name" content="Budibase" />
|
|
26
|
-
<meta property="og:title" content={
|
|
27
|
-
<meta property="og:description" content={metaDescription} />
|
|
22
|
+
<meta property="og:title" content="{title} - built with Budibase" />
|
|
28
23
|
<meta property="og:type" content="website" />
|
|
29
24
|
<meta property="og:image" content={metaImage} />
|
|
30
25
|
|
|
31
|
-
<!-- Twitter -->
|
|
32
|
-
<meta property="twitter:card" content="summary_large_image" />
|
|
33
|
-
<meta property="twitter:site" content="@budibase" />
|
|
34
|
-
<meta property="twitter:image" content={metaImage} />
|
|
35
|
-
<meta property="twitter:image:alt" content={metaTitle} />
|
|
36
|
-
<meta property="twitter:title" content={metaTitle} />
|
|
37
|
-
<meta property="twitter:description" content={metaDescription} />
|
|
38
|
-
|
|
39
26
|
<title>{title}</title>
|
|
40
|
-
|
|
41
|
-
<link rel="icon" type="image/png" href={favicon} />
|
|
42
|
-
{:else}
|
|
43
|
-
<link rel="icon" type="image/png" href="https://i.imgur.com/Xhdt1YP.png" />
|
|
44
|
-
{/if}
|
|
45
|
-
|
|
27
|
+
<link rel="icon" type="image/png" href={favicon} />
|
|
46
28
|
<link rel="stylesheet" href="https://rsms.me/inter/inter.css" />
|
|
47
29
|
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
|
48
30
|
<link
|
|
@@ -101,16 +83,11 @@
|
|
|
101
83
|
|
|
102
84
|
<body id="app">
|
|
103
85
|
<div id="error">
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
</h2>
|
|
110
|
-
{:else}
|
|
111
|
-
<h2>We couldn't find that application</h2>
|
|
112
|
-
<p />
|
|
113
|
-
{/if}
|
|
86
|
+
<h1>There was an error loading your app</h1>
|
|
87
|
+
<h2>
|
|
88
|
+
The Budibase client library could not be loaded. Try republishing your
|
|
89
|
+
app.
|
|
90
|
+
</h2>
|
|
114
91
|
</div>
|
|
115
92
|
<script type="application/javascript">
|
|
116
93
|
window.INIT_TIME = Date.now()
|
|
@@ -20,13 +20,7 @@ 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 {
|
|
24
|
-
ContextUser,
|
|
25
|
-
Database,
|
|
26
|
-
Datasource,
|
|
27
|
-
SourceName,
|
|
28
|
-
Table,
|
|
29
|
-
} from "@budibase/types"
|
|
23
|
+
import { Database, Datasource, SourceName, Table } from "@budibase/types"
|
|
30
24
|
|
|
31
25
|
export async function clearColumns(table: any, columnNames: any) {
|
|
32
26
|
const db: Database = context.getAppDB()
|
|
@@ -105,35 +99,33 @@ export function makeSureTableUpToDate(table: any, tableToSave: any) {
|
|
|
105
99
|
return tableToSave
|
|
106
100
|
}
|
|
107
101
|
|
|
108
|
-
export function importToRows(
|
|
109
|
-
data: any[],
|
|
110
|
-
table: Table,
|
|
111
|
-
user: ContextUser | null = null
|
|
112
|
-
) {
|
|
102
|
+
export function importToRows(data: any, table: any, user: any = {}) {
|
|
113
103
|
let finalData: any = []
|
|
114
104
|
for (let i = 0; i < data.length; i++) {
|
|
115
105
|
let row = data[i]
|
|
116
|
-
row._id = generateRowID(table._id
|
|
106
|
+
row._id = generateRowID(table._id)
|
|
117
107
|
row.tableId = table._id
|
|
118
|
-
const processed = inputProcessing(user, table, row, {
|
|
108
|
+
const processed: any = inputProcessing(user, table, row, {
|
|
119
109
|
noAutoRelationships: true,
|
|
120
110
|
})
|
|
121
111
|
row = processed.row
|
|
122
112
|
table = processed.table
|
|
123
113
|
|
|
124
|
-
|
|
114
|
+
let fieldName: any
|
|
115
|
+
let schema: any
|
|
116
|
+
for ([fieldName, schema] of Object.entries(table.schema)) {
|
|
125
117
|
// check whether the options need to be updated for inclusion as part of the data import
|
|
126
118
|
if (
|
|
127
119
|
schema.type === FieldTypes.OPTIONS &&
|
|
128
120
|
row[fieldName] &&
|
|
129
|
-
(!schema.constraints
|
|
130
|
-
schema.constraints
|
|
121
|
+
(!schema.constraints.inclusion ||
|
|
122
|
+
schema.constraints.inclusion.indexOf(row[fieldName]) === -1)
|
|
131
123
|
) {
|
|
132
|
-
schema.constraints
|
|
133
|
-
...schema.constraints
|
|
124
|
+
schema.constraints.inclusion = [
|
|
125
|
+
...schema.constraints.inclusion,
|
|
134
126
|
row[fieldName],
|
|
135
127
|
]
|
|
136
|
-
schema.constraints
|
|
128
|
+
schema.constraints.inclusion.sort()
|
|
137
129
|
}
|
|
138
130
|
}
|
|
139
131
|
|
|
@@ -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
|
+
Object {
|
|
5
5
|
"map": "function (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"]);
|
|
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": Object {
|
|
16
16
|
"calculation": "stats",
|
|
17
17
|
"field": "myField",
|
|
18
|
-
"filters": [
|
|
19
|
-
{
|
|
18
|
+
"filters": Array [
|
|
19
|
+
Object {
|
|
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": Object {
|
|
27
|
+
"avg": Object {
|
|
28
28
|
"type": "number",
|
|
29
29
|
},
|
|
30
|
-
"count": {
|
|
30
|
+
"count": Object {
|
|
31
31
|
"type": "number",
|
|
32
32
|
},
|
|
33
|
-
"field": {
|
|
33
|
+
"field": Object {
|
|
34
34
|
"type": "string",
|
|
35
35
|
},
|
|
36
|
-
"max": {
|
|
36
|
+
"max": Object {
|
|
37
37
|
"type": "number",
|
|
38
38
|
},
|
|
39
|
-
"min": {
|
|
39
|
+
"min": Object {
|
|
40
40
|
"type": "number",
|
|
41
41
|
},
|
|
42
|
-
"sum": {
|
|
42
|
+
"sum": Object {
|
|
43
43
|
"type": "number",
|
|
44
44
|
},
|
|
45
|
-
"sumsqr": {
|
|
45
|
+
"sumsqr": Object {
|
|
46
46
|
"type": "number",
|
|
47
47
|
},
|
|
48
48
|
},
|
|
@@ -53,42 +53,42 @@ exports[`viewBuilder Calculate and filter creates a view with the calculation st
|
|
|
53
53
|
`;
|
|
54
54
|
|
|
55
55
|
exports[`viewBuilder Calculate creates a view with the calculation statistics schema 1`] = `
|
|
56
|
-
{
|
|
56
|
+
Object {
|
|
57
57
|
"map": "function (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)
|
|
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["_id"], doc["myField"]);
|
|
64
|
+
emit(doc[\\"_id\\"], doc[\\"myField\\"]);
|
|
65
65
|
}
|
|
66
66
|
}",
|
|
67
|
-
"meta": {
|
|
67
|
+
"meta": Object {
|
|
68
68
|
"calculation": "stats",
|
|
69
69
|
"field": "myField",
|
|
70
|
-
"filters": [],
|
|
70
|
+
"filters": Array [],
|
|
71
71
|
"groupBy": undefined,
|
|
72
|
-
"schema": {
|
|
73
|
-
"avg": {
|
|
72
|
+
"schema": Object {
|
|
73
|
+
"avg": Object {
|
|
74
74
|
"type": "number",
|
|
75
75
|
},
|
|
76
|
-
"count": {
|
|
76
|
+
"count": Object {
|
|
77
77
|
"type": "number",
|
|
78
78
|
},
|
|
79
|
-
"field": {
|
|
79
|
+
"field": Object {
|
|
80
80
|
"type": "string",
|
|
81
81
|
},
|
|
82
|
-
"max": {
|
|
82
|
+
"max": Object {
|
|
83
83
|
"type": "number",
|
|
84
84
|
},
|
|
85
|
-
"min": {
|
|
85
|
+
"min": Object {
|
|
86
86
|
"type": "number",
|
|
87
87
|
},
|
|
88
|
-
"sum": {
|
|
88
|
+
"sum": Object {
|
|
89
89
|
"type": "number",
|
|
90
90
|
},
|
|
91
|
-
"sumsqr": {
|
|
91
|
+
"sumsqr": Object {
|
|
92
92
|
"type": "number",
|
|
93
93
|
},
|
|
94
94
|
},
|
|
@@ -99,22 +99,22 @@ exports[`viewBuilder Calculate creates a view with the calculation statistics sc
|
|
|
99
99
|
`;
|
|
100
100
|
|
|
101
101
|
exports[`viewBuilder Filter creates a view with multiple filters and conjunctions 1`] = `
|
|
102
|
-
{
|
|
102
|
+
Object {
|
|
103
103
|
"map": "function (doc) {
|
|
104
|
-
if (doc.tableId === "14f1c4e94d6a47b682ce89d35d4c78b0" && (doc["Name"] === "Test" || doc["Yes"] > "Value")) {
|
|
105
|
-
emit(doc["_id"], doc["undefined"]);
|
|
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": Object {
|
|
109
109
|
"calculation": undefined,
|
|
110
110
|
"field": undefined,
|
|
111
|
-
"filters": [
|
|
112
|
-
{
|
|
111
|
+
"filters": Array [
|
|
112
|
+
Object {
|
|
113
113
|
"condition": "EQUALS",
|
|
114
114
|
"key": "Name",
|
|
115
115
|
"value": "Test",
|
|
116
116
|
},
|
|
117
|
-
{
|
|
117
|
+
Object {
|
|
118
118
|
"condition": "MT",
|
|
119
119
|
"conjunction": "OR",
|
|
120
120
|
"key": "Yes",
|
|
@@ -129,16 +129,16 @@ exports[`viewBuilder Filter creates a view with multiple filters and conjunction
|
|
|
129
129
|
`;
|
|
130
130
|
|
|
131
131
|
exports[`viewBuilder Group By creates a view emitting the group by field 1`] = `
|
|
132
|
-
{
|
|
132
|
+
Object {
|
|
133
133
|
"map": "function (doc) {
|
|
134
|
-
if (doc.tableId === "14f1c4e94d6a47b682ce89d35d4c78b0" ) {
|
|
135
|
-
emit(doc["age"], doc["score"]);
|
|
134
|
+
if (doc.tableId === \\"14f1c4e94d6a47b682ce89d35d4c78b0\\" ) {
|
|
135
|
+
emit(doc[\\"age\\"], doc[\\"score\\"]);
|
|
136
136
|
}
|
|
137
137
|
}",
|
|
138
|
-
"meta": {
|
|
138
|
+
"meta": Object {
|
|
139
139
|
"calculation": undefined,
|
|
140
140
|
"field": "score",
|
|
141
|
-
"filters": [],
|
|
141
|
+
"filters": Array [],
|
|
142
142
|
"groupBy": "age",
|
|
143
143
|
"schema": null,
|
|
144
144
|
"tableId": "14f1c4e94d6a47b682ce89d35d4c78b0",
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import appEndpoints from "./applications"
|
|
2
|
-
import metricEndpoints from "./metrics"
|
|
3
2
|
import queryEndpoints from "./queries"
|
|
4
3
|
import tableEndpoints from "./tables"
|
|
5
4
|
import rowEndpoints from "./rows"
|
|
@@ -13,7 +12,7 @@ import env from "../../../environment"
|
|
|
13
12
|
// below imports don't have declaration files
|
|
14
13
|
const Router = require("@koa/router")
|
|
15
14
|
const { RateLimit, Stores } = require("koa2-ratelimit")
|
|
16
|
-
import {
|
|
15
|
+
import { redis, permissions } from "@budibase/backend-core"
|
|
17
16
|
const { PermissionType, PermissionLevel } = permissions
|
|
18
17
|
|
|
19
18
|
const PREFIX = "/api/public/v1"
|
|
@@ -92,13 +91,6 @@ function addToRouter(endpoints: any) {
|
|
|
92
91
|
}
|
|
93
92
|
}
|
|
94
93
|
|
|
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
|
-
|
|
102
94
|
function applyRoutes(
|
|
103
95
|
endpoints: any,
|
|
104
96
|
permType: string,
|
|
@@ -127,7 +119,6 @@ function applyRoutes(
|
|
|
127
119
|
addToRouter(endpoints.write)
|
|
128
120
|
}
|
|
129
121
|
|
|
130
|
-
applyAdminRoutes(metricEndpoints)
|
|
131
122
|
applyRoutes(appEndpoints, PermissionType.APP, "appId")
|
|
132
123
|
applyRoutes(tableEndpoints, PermissionType.TABLE, "tableId")
|
|
133
124
|
applyRoutes(userEndpoints, PermissionType.USER, "userId")
|
|
@@ -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
|
+
Array [
|
|
5
|
+
Object {
|
|
6
|
+
"config": Object {},
|
|
7
|
+
"entities": Array [
|
|
8
|
+
Object {
|
|
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": Object {
|
|
15
|
+
"email": Object {
|
|
16
|
+
"constraints": Object {
|
|
17
17
|
"email": true,
|
|
18
|
-
"length": {
|
|
18
|
+
"length": Object {
|
|
19
19
|
"maximum": "",
|
|
20
20
|
},
|
|
21
21
|
"presence": true,
|
|
@@ -25,8 +25,8 @@ exports[`/datasources fetch returns all the datasources from the server 1`] = `
|
|
|
25
25
|
"name": "email",
|
|
26
26
|
"type": "string",
|
|
27
27
|
},
|
|
28
|
-
"firstName": {
|
|
29
|
-
"constraints": {
|
|
28
|
+
"firstName": Object {
|
|
29
|
+
"constraints": Object {
|
|
30
30
|
"presence": false,
|
|
31
31
|
"type": "string",
|
|
32
32
|
},
|
|
@@ -34,8 +34,8 @@ exports[`/datasources fetch returns all the datasources from the server 1`] = `
|
|
|
34
34
|
"name": "firstName",
|
|
35
35
|
"type": "string",
|
|
36
36
|
},
|
|
37
|
-
"lastName": {
|
|
38
|
-
"constraints": {
|
|
37
|
+
"lastName": Object {
|
|
38
|
+
"constraints": Object {
|
|
39
39
|
"presence": false,
|
|
40
40
|
"type": "string",
|
|
41
41
|
},
|
|
@@ -43,9 +43,9 @@ exports[`/datasources fetch returns all the datasources from the server 1`] = `
|
|
|
43
43
|
"name": "lastName",
|
|
44
44
|
"type": "string",
|
|
45
45
|
},
|
|
46
|
-
"roleId": {
|
|
47
|
-
"constraints": {
|
|
48
|
-
"inclusion": [
|
|
46
|
+
"roleId": Object {
|
|
47
|
+
"constraints": Object {
|
|
48
|
+
"inclusion": Array [
|
|
49
49
|
"ADMIN",
|
|
50
50
|
"POWER",
|
|
51
51
|
"BASIC",
|
|
@@ -58,9 +58,9 @@ exports[`/datasources fetch returns all the datasources from the server 1`] = `
|
|
|
58
58
|
"name": "roleId",
|
|
59
59
|
"type": "options",
|
|
60
60
|
},
|
|
61
|
-
"status": {
|
|
62
|
-
"constraints": {
|
|
63
|
-
"inclusion": [
|
|
61
|
+
"status": Object {
|
|
62
|
+
"constraints": Object {
|
|
63
|
+
"inclusion": Array [
|
|
64
64
|
"active",
|
|
65
65
|
"inactive",
|
|
66
66
|
],
|
|
@@ -74,15 +74,15 @@ exports[`/datasources fetch returns all the datasources from the server 1`] = `
|
|
|
74
74
|
},
|
|
75
75
|
"type": "table",
|
|
76
76
|
"updatedAt": "2020-01-01T00:00:00.000Z",
|
|
77
|
-
"views": {},
|
|
77
|
+
"views": Object {},
|
|
78
78
|
},
|
|
79
79
|
],
|
|
80
80
|
"name": "Budibase DB",
|
|
81
81
|
"source": "BUDIBASE",
|
|
82
82
|
"type": "budibase",
|
|
83
83
|
},
|
|
84
|
-
{
|
|
85
|
-
"config": {},
|
|
84
|
+
Object {
|
|
85
|
+
"config": Object {},
|
|
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
|
+
Array [
|
|
5
|
+
Object {
|
|
6
6
|
"avg": 2333.3333333333335,
|
|
7
7
|
"count": 3,
|
|
8
8
|
"group": null,
|
|
@@ -15,8 +15,8 @@ exports[`/views query returns data for the created view 1`] = `
|
|
|
15
15
|
`;
|
|
16
16
|
|
|
17
17
|
exports[`/views query returns data for the created view using a group by 1`] = `
|
|
18
|
-
[
|
|
19
|
-
{
|
|
18
|
+
Array [
|
|
19
|
+
Object {
|
|
20
20
|
"avg": 1500,
|
|
21
21
|
"count": 2,
|
|
22
22
|
"group": "One",
|
|
@@ -25,7 +25,7 @@ exports[`/views query returns data for the created view using a group by 1`] = `
|
|
|
25
25
|
"sum": 3000,
|
|
26
26
|
"sumsqr": 5000000,
|
|
27
27
|
},
|
|
28
|
-
{
|
|
28
|
+
Object {
|
|
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 its empty initially", 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, `
|
|
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, `
|
|
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
|
})
|
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
|
|
30
|
+
import { events, logging, middleware } 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,7 +84,6 @@ server.on("close", async () => {
|
|
|
84
84
|
}
|
|
85
85
|
shuttingDown = true
|
|
86
86
|
console.log("Server Closed")
|
|
87
|
-
timers.cleanup()
|
|
88
87
|
await automations.shutdown()
|
|
89
88
|
await redis.shutdown()
|
|
90
89
|
events.shutdown()
|