@budibase/server 2.4.17 → 2.4.18
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.0f1e5695.js → index.925413cf.js} +372 -372
- package/builder/index.html +1 -1
- package/dist/api/controllers/row/ExternalRequest.js +10 -2
- package/dist/api/controllers/row/external.js +1 -1
- package/dist/integrations/base/sql.js +1 -1
- package/dist/integrations/googlesheets.js +14 -3
- package/dist/package.json +7 -6
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/jest.config.ts +1 -0
- package/package.json +8 -7
- package/src/api/controllers/row/ExternalRequest.ts +12 -2
- package/src/api/controllers/row/external.ts +3 -3
- package/src/integrations/base/sql.ts +2 -1
- package/src/integrations/googlesheets.ts +30 -4
- package/tsconfig.json +5 -10
package/jest.config.ts
CHANGED
|
@@ -14,6 +14,7 @@ const baseConfig: Config.InitialProjectOptions = {
|
|
|
14
14
|
moduleNameMapper: {
|
|
15
15
|
"@budibase/backend-core/(.*)": "<rootDir>/../backend-core/$1",
|
|
16
16
|
"@budibase/backend-core": "<rootDir>/../backend-core/src",
|
|
17
|
+
"@budibase/shared-core": "<rootDir>/../shared-core/src",
|
|
17
18
|
"@budibase/types": "<rootDir>/../types/src",
|
|
18
19
|
},
|
|
19
20
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "2.4.
|
|
4
|
+
"version": "2.4.18",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -43,11 +43,12 @@
|
|
|
43
43
|
"license": "GPL-3.0",
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@apidevtools/swagger-parser": "10.0.3",
|
|
46
|
-
"@budibase/backend-core": "^2.4.
|
|
47
|
-
"@budibase/client": "^2.4.
|
|
48
|
-
"@budibase/pro": "2.4.
|
|
49
|
-
"@budibase/
|
|
50
|
-
"@budibase/
|
|
46
|
+
"@budibase/backend-core": "^2.4.18",
|
|
47
|
+
"@budibase/client": "^2.4.18",
|
|
48
|
+
"@budibase/pro": "2.4.17",
|
|
49
|
+
"@budibase/shared-core": "^2.4.18",
|
|
50
|
+
"@budibase/string-templates": "^2.4.18",
|
|
51
|
+
"@budibase/types": "^2.4.18",
|
|
51
52
|
"@bull-board/api": "3.7.0",
|
|
52
53
|
"@bull-board/koa": "3.9.4",
|
|
53
54
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -174,5 +175,5 @@
|
|
|
174
175
|
"optionalDependencies": {
|
|
175
176
|
"oracledb": "5.3.0"
|
|
176
177
|
},
|
|
177
|
-
"gitHead": "
|
|
178
|
+
"gitHead": "e73b6d3cded7b7ec40fb31e0665c4e1a43423202"
|
|
178
179
|
}
|
|
@@ -11,6 +11,8 @@ import {
|
|
|
11
11
|
Row,
|
|
12
12
|
Table,
|
|
13
13
|
RelationshipTypes,
|
|
14
|
+
FieldType,
|
|
15
|
+
SortType,
|
|
14
16
|
} from "@budibase/types"
|
|
15
17
|
import {
|
|
16
18
|
breakRowIdField,
|
|
@@ -749,8 +751,16 @@ export class ExternalRequest {
|
|
|
749
751
|
)
|
|
750
752
|
//if the sort column is a formula, remove it
|
|
751
753
|
for (let sortColumn of Object.keys(sort || {})) {
|
|
752
|
-
if (
|
|
753
|
-
|
|
754
|
+
if (!sort?.[sortColumn]) {
|
|
755
|
+
continue
|
|
756
|
+
}
|
|
757
|
+
switch (table.schema[sortColumn]?.type) {
|
|
758
|
+
case FieldType.FORMULA:
|
|
759
|
+
delete sort?.[sortColumn]
|
|
760
|
+
break
|
|
761
|
+
case FieldType.NUMBER:
|
|
762
|
+
sort[sortColumn].type = SortType.number
|
|
763
|
+
break
|
|
754
764
|
}
|
|
755
765
|
}
|
|
756
766
|
filters = buildFilters(id, filters || {}, table)
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
breakRowIdField,
|
|
9
9
|
} from "../../../integrations/utils"
|
|
10
10
|
import { ExternalRequest, RunConfig } from "./ExternalRequest"
|
|
11
|
-
import { context } from "@budibase/backend-core"
|
|
12
11
|
import * as exporters from "../view/exporters"
|
|
13
12
|
import { apiFileReturn } from "../../../utilities/fileSystem"
|
|
14
13
|
import {
|
|
@@ -19,6 +18,7 @@ import {
|
|
|
19
18
|
Table,
|
|
20
19
|
Datasource,
|
|
21
20
|
IncludeRelationship,
|
|
21
|
+
SortJson,
|
|
22
22
|
} from "@budibase/types"
|
|
23
23
|
import sdk from "../../../sdk"
|
|
24
24
|
|
|
@@ -142,14 +142,14 @@ export async function search(ctx: BBContext) {
|
|
|
142
142
|
limit: limit,
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
let sort
|
|
145
|
+
let sort: SortJson | undefined
|
|
146
146
|
if (params.sort) {
|
|
147
147
|
const direction =
|
|
148
148
|
params.sortOrder === "descending"
|
|
149
149
|
? SortDirection.DESCENDING
|
|
150
150
|
: SortDirection.ASCENDING
|
|
151
151
|
sort = {
|
|
152
|
-
[params.sort]: direction,
|
|
152
|
+
[params.sort]: { direction },
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
try {
|
|
@@ -317,7 +317,8 @@ class InternalBuilder {
|
|
|
317
317
|
const table = json.meta?.table
|
|
318
318
|
if (sort) {
|
|
319
319
|
for (let [key, value] of Object.entries(sort)) {
|
|
320
|
-
const direction =
|
|
320
|
+
const direction =
|
|
321
|
+
value.direction === SortDirection.ASCENDING ? "asc" : "desc"
|
|
321
322
|
query = query.orderBy(`${table?.name}.${key}`, direction)
|
|
322
323
|
}
|
|
323
324
|
} else if (this.client === SqlClient.MS_SQL && paginate?.limit) {
|
|
@@ -2,8 +2,11 @@ import {
|
|
|
2
2
|
DatasourceFieldType,
|
|
3
3
|
DatasourcePlus,
|
|
4
4
|
Integration,
|
|
5
|
+
PaginationJson,
|
|
5
6
|
QueryJson,
|
|
6
7
|
QueryType,
|
|
8
|
+
SearchFilters,
|
|
9
|
+
SortJson,
|
|
7
10
|
Table,
|
|
8
11
|
TableSchema,
|
|
9
12
|
} from "@budibase/types"
|
|
@@ -13,6 +16,7 @@ import { DataSourceOperation, FieldTypes } from "../constants"
|
|
|
13
16
|
import { GoogleSpreadsheet } from "google-spreadsheet"
|
|
14
17
|
import fetch from "node-fetch"
|
|
15
18
|
import { configs, HTTPError } from "@budibase/backend-core"
|
|
19
|
+
import { dataFilters } from "@budibase/shared-core"
|
|
16
20
|
|
|
17
21
|
interface GoogleSheetsConfig {
|
|
18
22
|
spreadsheetId: string
|
|
@@ -237,7 +241,7 @@ class GoogleSheetsIntegration implements DatasourcePlus {
|
|
|
237
241
|
const handlers = {
|
|
238
242
|
[DataSourceOperation.CREATE]: () =>
|
|
239
243
|
this.create({ sheet, row: json.body }),
|
|
240
|
-
[DataSourceOperation.READ]: () => this.read({ sheet }),
|
|
244
|
+
[DataSourceOperation.READ]: () => this.read({ ...json, sheet }),
|
|
241
245
|
[DataSourceOperation.UPDATE]: () =>
|
|
242
246
|
this.update({
|
|
243
247
|
// exclude the header row and zero index
|
|
@@ -345,18 +349,40 @@ class GoogleSheetsIntegration implements DatasourcePlus {
|
|
|
345
349
|
}
|
|
346
350
|
}
|
|
347
351
|
|
|
348
|
-
async read(query: {
|
|
352
|
+
async read(query: {
|
|
353
|
+
sheet: string
|
|
354
|
+
filters?: SearchFilters
|
|
355
|
+
sort?: SortJson
|
|
356
|
+
paginate?: PaginationJson
|
|
357
|
+
}) {
|
|
349
358
|
try {
|
|
350
359
|
await this.connect()
|
|
351
360
|
const sheet = this.client.sheetsByTitle[query.sheet]
|
|
352
361
|
const rows = await sheet.getRows()
|
|
362
|
+
const filtered = dataFilters.runLuceneQuery(rows, query.filters)
|
|
353
363
|
const headerValues = sheet.headerValues
|
|
354
|
-
|
|
355
|
-
for (let row of
|
|
364
|
+
let response = []
|
|
365
|
+
for (let row of filtered) {
|
|
356
366
|
response.push(
|
|
357
367
|
this.buildRowObject(headerValues, row._rawData, row._rowNumber)
|
|
358
368
|
)
|
|
359
369
|
}
|
|
370
|
+
|
|
371
|
+
if (query.sort) {
|
|
372
|
+
if (Object.keys(query.sort).length !== 1) {
|
|
373
|
+
console.warn("Googlesheets does not support multiple sorting", {
|
|
374
|
+
sortInfo: query.sort,
|
|
375
|
+
})
|
|
376
|
+
}
|
|
377
|
+
const [sortField, sortInfo] = Object.entries(query.sort)[0]
|
|
378
|
+
response = dataFilters.luceneSort(
|
|
379
|
+
response,
|
|
380
|
+
sortField,
|
|
381
|
+
sortInfo.direction,
|
|
382
|
+
sortInfo.type
|
|
383
|
+
)
|
|
384
|
+
}
|
|
385
|
+
|
|
360
386
|
return response
|
|
361
387
|
} catch (err) {
|
|
362
388
|
console.error("Error reading from google sheets", err)
|
package/tsconfig.json
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"@budibase/types": ["../types/src"],
|
|
10
10
|
"@budibase/backend-core": ["../backend-core/src"],
|
|
11
11
|
"@budibase/backend-core/*": ["../backend-core/*"],
|
|
12
|
+
"@budibase/shared-core": ["../shared-core/src"],
|
|
12
13
|
"@budibase/pro": ["../../../budibase-pro/packages/pro/src"]
|
|
13
14
|
}
|
|
14
15
|
},
|
|
@@ -19,15 +20,9 @@
|
|
|
19
20
|
"references": [
|
|
20
21
|
{ "path": "../types" },
|
|
21
22
|
{ "path": "../backend-core" },
|
|
23
|
+
{ "path": "../shared-core" },
|
|
22
24
|
{ "path": "../../../budibase-pro/packages/pro" }
|
|
23
25
|
],
|
|
24
|
-
"include": [
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"package.json"
|
|
28
|
-
],
|
|
29
|
-
"exclude": [
|
|
30
|
-
"node_modules",
|
|
31
|
-
"dist"
|
|
32
|
-
]
|
|
33
|
-
}
|
|
26
|
+
"include": ["src/**/*", "specs", "package.json"],
|
|
27
|
+
"exclude": ["node_modules", "dist"]
|
|
28
|
+
}
|