@budibase/server 2.6.3 → 2.6.5

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.
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TYPE_TRANSFORM_MAP = void 0;
4
4
  // @ts-nocheck
5
5
  const constants_1 = require("../../constants");
6
+ const backend_core_1 = require("@budibase/backend-core");
6
7
  /**
7
8
  * A map of how we convert various properties in rows to each other based on the row type.
8
9
  */
@@ -69,9 +70,24 @@ exports.TYPE_TRANSFORM_MAP = {
69
70
  },
70
71
  },
71
72
  [constants_1.FieldTypes.ATTACHMENT]: {
72
- "": [],
73
73
  [null]: [],
74
74
  [undefined]: undefined,
75
+ parse: attachments => {
76
+ if (typeof attachments === "string") {
77
+ if (attachments === "") {
78
+ return [];
79
+ }
80
+ let result;
81
+ try {
82
+ result = JSON.parse(attachments);
83
+ }
84
+ catch (e) {
85
+ backend_core_1.logging.logAlert("Could not parse attachments", e);
86
+ }
87
+ return result;
88
+ }
89
+ return attachments;
90
+ },
75
91
  },
76
92
  [constants_1.FieldTypes.BOOLEAN]: {
77
93
  "": null,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "2.6.3",
4
+ "version": "2.6.5",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -45,12 +45,12 @@
45
45
  "license": "GPL-3.0",
46
46
  "dependencies": {
47
47
  "@apidevtools/swagger-parser": "10.0.3",
48
- "@budibase/backend-core": "^2.6.3",
49
- "@budibase/client": "^2.6.3",
50
- "@budibase/pro": "2.6.2",
51
- "@budibase/shared-core": "^2.6.3",
52
- "@budibase/string-templates": "^2.6.3",
53
- "@budibase/types": "^2.6.3",
48
+ "@budibase/backend-core": "^2.6.5",
49
+ "@budibase/client": "^2.6.5",
50
+ "@budibase/pro": "2.6.4",
51
+ "@budibase/shared-core": "^2.6.5",
52
+ "@budibase/string-templates": "^2.6.5",
53
+ "@budibase/types": "^2.6.5",
54
54
  "@bull-board/api": "3.7.0",
55
55
  "@bull-board/koa": "3.9.4",
56
56
  "@elastic/elasticsearch": "7.10.0",
@@ -176,5 +176,5 @@
176
176
  "optionalDependencies": {
177
177
  "oracledb": "5.3.0"
178
178
  },
179
- "gitHead": "757ae1836ef21b49d42a8f4472285486b3a24a58"
179
+ "gitHead": "df1d2f33515739050a3f5dee971dfa6c3d711a17"
180
180
  }
@@ -212,6 +212,7 @@ describe("/rows", () => {
212
212
  attachmentNull: attachment,
213
213
  attachmentUndefined: attachment,
214
214
  attachmentEmpty: attachment,
215
+ attachmentEmptyArrayStr: attachment
215
216
  },
216
217
  })
217
218
 
@@ -239,6 +240,7 @@ describe("/rows", () => {
239
240
  attachmentNull: null,
240
241
  attachmentUndefined: undefined,
241
242
  attachmentEmpty: "",
243
+ attachmentEmptyArrayStr: "[]",
242
244
  }
243
245
 
244
246
  const id = (await config.createRow(row))._id
@@ -268,6 +270,7 @@ describe("/rows", () => {
268
270
  expect(saved.attachmentNull).toEqual([])
269
271
  expect(saved.attachmentUndefined).toBe(undefined)
270
272
  expect(saved.attachmentEmpty).toEqual([])
273
+ expect(saved.attachmentEmptyArrayStr).toEqual([])
271
274
  })
272
275
  })
273
276
 
@@ -34,8 +34,6 @@ function parseIntSafe(number?: string) {
34
34
  }
35
35
  }
36
36
 
37
- let inThread = false
38
-
39
37
  const environment = {
40
38
  // important - prefer app port to generic port
41
39
  PORT: process.env.APP_PORT || process.env.PORT,
@@ -95,12 +93,8 @@ const environment = {
95
93
  isProd: () => {
96
94
  return !isDev()
97
95
  },
98
- // used to check if already in a thread, don't thread further
99
- setInThread: () => {
100
- inThread = true
101
- },
102
96
  isInThread: () => {
103
- return inThread
97
+ return process.env.FORKED_PROCESS
104
98
  },
105
99
  }
106
100
 
@@ -39,6 +39,12 @@ export class Thread {
39
39
  const workerOpts: any = {
40
40
  autoStart: true,
41
41
  maxConcurrentWorkers: this.count,
42
+ workerOptions: {
43
+ env: {
44
+ ...process.env,
45
+ FORKED_PROCESS: "1",
46
+ },
47
+ },
42
48
  }
43
49
  if (opts.timeoutMs) {
44
50
  this.timeoutMs = opts.timeoutMs
@@ -25,11 +25,9 @@ function makeVariableKey(queryId: string, variable: string) {
25
25
 
26
26
  export function threadSetup() {
27
27
  // don't run this if not threading
28
- if (env.isTest() || env.DISABLE_THREADING) {
28
+ if (env.isTest() || env.DISABLE_THREADING || !env.isInThread()) {
29
29
  return
30
30
  }
31
- // when thread starts, make sure it is recorded
32
- env.setInThread()
33
31
  db.init()
34
32
  }
35
33
 
@@ -1,5 +1,6 @@
1
1
  // @ts-nocheck
2
2
  import { FieldTypes } from "../../constants"
3
+ import { logging } from "@budibase/backend-core"
3
4
 
4
5
  /**
5
6
  * A map of how we convert various properties in rows to each other based on the row type.
@@ -67,9 +68,23 @@ export const TYPE_TRANSFORM_MAP: any = {
67
68
  },
68
69
  },
69
70
  [FieldTypes.ATTACHMENT]: {
70
- "": [],
71
71
  [null]: [],
72
72
  [undefined]: undefined,
73
+ parse: attachments => {
74
+ if (typeof attachments === "string") {
75
+ if (attachments === "") {
76
+ return []
77
+ }
78
+ let result
79
+ try {
80
+ result = JSON.parse(attachments)
81
+ } catch (e) {
82
+ logging.logAlert("Could not parse attachments", e)
83
+ }
84
+ return result
85
+ }
86
+ return attachments
87
+ },
73
88
  },
74
89
  [FieldTypes.BOOLEAN]: {
75
90
  "": null,