@budibase/frontend-core 1.0.218 → 1.0.219-alpha.0

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/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@budibase/frontend-core",
3
- "version": "1.0.218",
3
+ "version": "1.0.219-alpha.0",
4
4
  "description": "Budibase frontend core libraries used in builder and client",
5
5
  "author": "Budibase",
6
6
  "license": "MPL-2.0",
7
7
  "svelte": "src/index.js",
8
8
  "dependencies": {
9
- "@budibase/bbui": "^1.0.218",
9
+ "@budibase/bbui": "^1.0.219-alpha.0",
10
10
  "lodash": "^4.17.21",
11
11
  "svelte": "^3.46.2"
12
12
  },
13
- "gitHead": "b6a5feadb6b472ec3f13952c6e17b412c6b2f87f"
13
+ "gitHead": "7918452c522610c27c020342aac2edbcdf00f18c"
14
14
  }
@@ -73,4 +73,39 @@ export const buildAutomationEndpoints = API => ({
73
73
  url: `/api/automations/${automationId}/${automationRev}`,
74
74
  })
75
75
  },
76
+
77
+ /**
78
+ * Get the logs for the app, or by automation ID.
79
+ * @param automationId The ID of the automation to get logs for.
80
+ * @param startDate An ISO date string to state the start of the date range.
81
+ * @param status The status, error or success.
82
+ * @param page The page to retrieve.
83
+ */
84
+ getAutomationLogs: async ({ automationId, startDate, status, page }) => {
85
+ return await API.post({
86
+ url: "/api/automations/logs/search",
87
+ body: {
88
+ automationId,
89
+ startDate,
90
+ status,
91
+ page,
92
+ },
93
+ })
94
+ },
95
+
96
+ /**
97
+ * Clears automation log errors (which are creating notification) for
98
+ * automation or the app.
99
+ * @param automationId optional - the ID of the automation to clear errors for.
100
+ * @param appId The app ID to clear errors for.
101
+ */
102
+ clearAutomationLogErrors: async ({ automationId, appId }) => {
103
+ return await API.delete({
104
+ url: "/api/automations/logs",
105
+ body: {
106
+ appId,
107
+ automationId,
108
+ },
109
+ })
110
+ },
76
111
  })
package/src/api/other.js CHANGED
@@ -61,6 +61,7 @@ export const buildOtherEndpoints = API => ({
61
61
  checkBetaAccess: async email => {
62
62
  return await API.get({
63
63
  url: `/api/beta/access?email=${email}`,
64
+ external: true,
64
65
  })
65
66
  },
66
67
  })
package/src/api/rows.js CHANGED
@@ -65,12 +65,15 @@ export const buildRowEndpoints = API => ({
65
65
  * Exports rows.
66
66
  * @param tableId the table ID to export the rows from
67
67
  * @param rows the array of rows to export
68
+ * @param format the format to export (csv or json)
69
+ * @param columns which columns to export (all if undefined)
68
70
  */
69
- exportRows: async ({ tableId, rows, format }) => {
71
+ exportRows: async ({ tableId, rows, format, columns }) => {
70
72
  return await API.post({
71
73
  url: `/api/${tableId}/rows/exportRows?format=${format}`,
72
74
  body: {
73
75
  rows,
76
+ columns,
74
77
  },
75
78
  parseResponse: async response => {
76
79
  return await response.text()
package/src/api/user.js CHANGED
@@ -8,6 +8,34 @@ export const buildUserEndpoints = API => ({
8
8
  })
9
9
  },
10
10
 
11
+ /**
12
+ * Gets a list of users in the current tenant.
13
+ * @param {string} page The page to retrieve
14
+ * @param {string} search The starts with string to search username/email by.
15
+ */
16
+ searchUsers: async ({ page, search } = {}) => {
17
+ const opts = {}
18
+ if (page) {
19
+ opts.page = page
20
+ }
21
+ if (search) {
22
+ opts.search = search
23
+ }
24
+ return await API.post({
25
+ url: `/api/global/users/search`,
26
+ body: opts,
27
+ })
28
+ },
29
+
30
+ /**
31
+ * Get a single user by ID.
32
+ */
33
+ getUser: async userId => {
34
+ return await API.get({
35
+ url: `/api/global/users/${userId}`,
36
+ })
37
+ },
38
+
11
39
  /**
12
40
  * Creates a user for an app.
13
41
  * @param user the user to create
package/src/constants.js CHANGED
@@ -42,6 +42,10 @@ export const OperatorOptions = {
42
42
  value: "notEqual",
43
43
  label: "Does Not Contain",
44
44
  },
45
+ In: {
46
+ value: "oneOf",
47
+ label: "Is in",
48
+ },
45
49
  }
46
50
 
47
51
  // Cookie names
@@ -63,3 +67,25 @@ export const TableNames = {
63
67
  * - Coerce types for search endpoint
64
68
  */
65
69
  export const ApiVersion = "1"
70
+
71
+ /**
72
+ * Maximum minimum range for SQL number values
73
+ */
74
+ export const SqlNumberTypeRangeMap = {
75
+ integer: {
76
+ max: 2147483647,
77
+ min: -2147483648,
78
+ },
79
+ int: {
80
+ max: 2147483647,
81
+ min: -2147483648,
82
+ },
83
+ smallint: {
84
+ max: 32767,
85
+ min: -32768,
86
+ },
87
+ mediumint: {
88
+ max: 8388607,
89
+ min: -8388608,
90
+ },
91
+ }
@@ -1,5 +1,5 @@
1
1
  import { Helpers } from "@budibase/bbui"
2
- import { OperatorOptions } from "../constants"
2
+ import { OperatorOptions, SqlNumberTypeRangeMap } from "../constants"
3
3
 
4
4
  /**
5
5
  * Returns the valid operator options for a certain data type
@@ -14,6 +14,7 @@ export const getValidOperatorsForType = type => {
14
14
  Op.Like,
15
15
  Op.Empty,
16
16
  Op.NotEmpty,
17
+ Op.In,
17
18
  ]
18
19
  const numOps = [
19
20
  Op.Equals,
@@ -22,6 +23,7 @@ export const getValidOperatorsForType = type => {
22
23
  Op.LessThan,
23
24
  Op.Empty,
24
25
  Op.NotEmpty,
26
+ Op.In,
25
27
  ]
26
28
  if (type === "string") {
27
29
  return stringOps
@@ -91,31 +93,34 @@ export const buildLuceneQuery = filter => {
91
93
  notEmpty: {},
92
94
  contains: {},
93
95
  notContains: {},
96
+ oneOf: {},
94
97
  }
95
98
  if (Array.isArray(filter)) {
96
99
  filter.forEach(expression => {
97
- let { operator, field, type, value } = expression
100
+ let { operator, field, type, value, externalType } = expression
98
101
  // Parse all values into correct types
99
102
  if (type === "datetime" && value) {
100
103
  value = new Date(value).toISOString()
101
104
  }
102
- if (type === "number") {
103
- value = parseFloat(value)
105
+ if (type === "number" && !Array.isArray(value)) {
106
+ if (operator === "oneOf") {
107
+ value = value.split(",").map(item => parseFloat(item))
108
+ } else {
109
+ value = parseFloat(value)
110
+ }
104
111
  }
105
112
  if (type === "boolean") {
106
113
  value = `${value}`?.toLowerCase() === "true"
107
114
  }
108
115
  if (operator.startsWith("range")) {
116
+ const minint =
117
+ SqlNumberTypeRangeMap[externalType]?.min || Number.MIN_SAFE_INTEGER
118
+ const maxint =
119
+ SqlNumberTypeRangeMap[externalType]?.max || Number.MAX_SAFE_INTEGER
109
120
  if (!query.range[field]) {
110
121
  query.range[field] = {
111
- low:
112
- type === "number"
113
- ? Number.MIN_SAFE_INTEGER
114
- : "0000-00-00T00:00:00.000Z",
115
- high:
116
- type === "number"
117
- ? Number.MAX_SAFE_INTEGER
118
- : "9999-00-00T00:00:00.000Z",
122
+ low: type === "number" ? minint : "0000-00-00T00:00:00.000Z",
123
+ high: type === "number" ? maxint : "9999-00-00T00:00:00.000Z",
119
124
  }
120
125
  }
121
126
  if (operator === "rangeLow" && value != null && value !== "") {
@@ -141,7 +146,6 @@ export const buildLuceneQuery = filter => {
141
146
  }
142
147
  })
143
148
  }
144
-
145
149
  return query
146
150
  }
147
151
 
@@ -213,6 +217,17 @@ export const runLuceneQuery = (docs, query) => {
213
217
  return docValue == null || docValue === ""
214
218
  })
215
219
 
220
+ // Process an includes match (fails if the value is not included)
221
+ const oneOf = match("oneOf", (docValue, testValue) => {
222
+ if (typeof testValue === "string") {
223
+ testValue = testValue.split(",")
224
+ if (typeof docValue === "number") {
225
+ testValue = testValue.map(item => parseFloat(item))
226
+ }
227
+ }
228
+ return !testValue?.includes(docValue)
229
+ })
230
+
216
231
  // Match a document against all criteria
217
232
  const docMatch = doc => {
218
233
  return (
@@ -222,7 +237,8 @@ export const runLuceneQuery = (docs, query) => {
222
237
  equalMatch(doc) &&
223
238
  notEqualMatch(doc) &&
224
239
  emptyMatch(doc) &&
225
- notEmptyMatch(doc)
240
+ notEmptyMatch(doc) &&
241
+ oneOf(doc)
226
242
  )
227
243
  }
228
244