@budibase/server 2.4.8-alpha.2 → 2.4.8-alpha.4

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.
@@ -10,8 +10,8 @@
10
10
  href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@400;600;700&display=swap"
11
11
  rel="stylesheet"
12
12
  />
13
- <script type="module" crossorigin src="/builder/assets/index.3472f1b2.js"></script>
14
- <link rel="stylesheet" href="/builder/assets/index.f0a1d6ac.css">
13
+ <script type="module" crossorigin src="/builder/assets/index.d089b79b.js"></script>
14
+ <link rel="stylesheet" href="/builder/assets/index.af76a09d.css">
15
15
  </head>
16
16
  <body id="app">
17
17
 
@@ -614,8 +614,16 @@ class ExternalRequest {
614
614
  let { id, row, filters, sort, paginate, rows } = cleanupConfig(config, table);
615
615
  //if the sort column is a formula, remove it
616
616
  for (let sortColumn of Object.keys(sort || {})) {
617
- if (((_a = table.schema[sortColumn]) === null || _a === void 0 ? void 0 : _a.type) === "formula") {
618
- sort === null || sort === void 0 ? true : delete sort[sortColumn];
617
+ if (!(sort === null || sort === void 0 ? void 0 : sort[sortColumn])) {
618
+ continue;
619
+ }
620
+ switch ((_a = table.schema[sortColumn]) === null || _a === void 0 ? void 0 : _a.type) {
621
+ case types_1.FieldType.FORMULA:
622
+ sort === null || sort === void 0 ? true : delete sort[sortColumn];
623
+ break;
624
+ case types_1.FieldType.NUMBER:
625
+ sort[sortColumn].type = types_1.SortType.number;
626
+ break;
619
627
  }
620
628
  }
621
629
  filters = buildFilters(id, filters || {}, table);
@@ -188,7 +188,7 @@ function search(ctx) {
188
188
  ? constants_1.SortDirection.DESCENDING
189
189
  : constants_1.SortDirection.ASCENDING;
190
190
  sort = {
191
- [params.sort]: direction,
191
+ [params.sort]: { direction },
192
192
  };
193
193
  }
194
194
  try {
@@ -293,7 +293,7 @@ class InternalBuilder {
293
293
  const table = (_a = json.meta) === null || _a === void 0 ? void 0 : _a.table;
294
294
  if (sort) {
295
295
  for (let [key, value] of Object.entries(sort)) {
296
- const direction = value === types_1.SortDirection.ASCENDING ? "asc" : "desc";
296
+ const direction = value.direction === types_1.SortDirection.ASCENDING ? "asc" : "desc";
297
297
  query = query.orderBy(`${table === null || table === void 0 ? void 0 : table.name}.${key}`, direction);
298
298
  }
299
299
  }
@@ -19,6 +19,7 @@ const constants_1 = require("../constants");
19
19
  const google_spreadsheet_1 = require("google-spreadsheet");
20
20
  const node_fetch_1 = __importDefault(require("node-fetch"));
21
21
  const backend_core_1 = require("@budibase/backend-core");
22
+ const shared_core_1 = require("@budibase/shared-core");
22
23
  const SCHEMA = {
23
24
  plus: true,
24
25
  auth: {
@@ -196,7 +197,7 @@ class GoogleSheetsIntegration {
196
197
  const sheet = json.endpoint.entityId;
197
198
  const handlers = {
198
199
  [constants_1.DataSourceOperation.CREATE]: () => this.create({ sheet, row: json.body }),
199
- [constants_1.DataSourceOperation.READ]: () => this.read({ sheet }),
200
+ [constants_1.DataSourceOperation.READ]: () => this.read(Object.assign(Object.assign({}, json), { sheet })),
200
201
  [constants_1.DataSourceOperation.UPDATE]: () => {
201
202
  var _a, _b, _c;
202
203
  return this.update({
@@ -312,11 +313,21 @@ class GoogleSheetsIntegration {
312
313
  yield this.connect();
313
314
  const sheet = this.client.sheetsByTitle[query.sheet];
314
315
  const rows = yield sheet.getRows();
316
+ const filtered = shared_core_1.dataFilters.runLuceneQuery(rows, query.filters);
315
317
  const headerValues = sheet.headerValues;
316
- const response = [];
317
- for (let row of rows) {
318
+ let response = [];
319
+ for (let row of filtered) {
318
320
  response.push(this.buildRowObject(headerValues, row._rawData, row._rowNumber));
319
321
  }
322
+ if (query.sort) {
323
+ if (Object.keys(query.sort).length !== 1) {
324
+ console.warn("Googlesheets does not support multiple sorting", {
325
+ sortInfo: query.sort,
326
+ });
327
+ }
328
+ const [sortField, sortInfo] = Object.entries(query.sort)[0];
329
+ response = shared_core_1.dataFilters.luceneSort(response, sortField, sortInfo.direction, sortInfo.type);
330
+ }
320
331
  return response;
321
332
  }
322
333
  catch (err) {
package/dist/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "2.4.8-alpha.1",
4
+ "version": "2.4.8-alpha.3",
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.8-alpha.1",
47
- "@budibase/client": "2.4.8-alpha.1",
48
- "@budibase/pro": "2.4.8-alpha.1",
49
- "@budibase/string-templates": "2.4.8-alpha.1",
50
- "@budibase/types": "2.4.8-alpha.1",
46
+ "@budibase/backend-core": "2.4.8-alpha.3",
47
+ "@budibase/client": "2.4.8-alpha.3",
48
+ "@budibase/pro": "2.4.8-alpha.3",
49
+ "@budibase/shared-core": "2.4.8-alpha.3",
50
+ "@budibase/string-templates": "2.4.8-alpha.3",
51
+ "@budibase/types": "2.4.8-alpha.3",
51
52
  "@bull-board/api": "3.7.0",
52
53
  "@bull-board/koa": "3.9.4",
53
54
  "@elastic/elasticsearch": "7.10.0",