@budibase/frontend-core 1.1.30 → 1.1.32-alpha.1
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 +3 -3
- package/src/api/groups.js +40 -0
- package/src/api/index.js +2 -0
- package/src/api/user.js +52 -3
- package/src/constants.js +36 -2
- package/src/utils/lucene.js +15 -3
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/frontend-core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.32-alpha.1",
|
|
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": "
|
|
9
|
+
"@budibase/bbui": "1.1.32-alpha.1",
|
|
10
10
|
"lodash": "^4.17.21",
|
|
11
11
|
"svelte": "^3.46.2"
|
|
12
12
|
},
|
|
13
|
-
"gitHead": "
|
|
13
|
+
"gitHead": "e48766d0ccb12ccaba3de9e34d7ab4a7a23c0cfb"
|
|
14
14
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export const buildGroupsEndpoints = API => ({
|
|
2
|
+
/**
|
|
3
|
+
* Creates a user group.
|
|
4
|
+
* @param user the new group to create
|
|
5
|
+
*/
|
|
6
|
+
saveGroup: async group => {
|
|
7
|
+
return await API.post({
|
|
8
|
+
url: "/api/global/groups",
|
|
9
|
+
body: group,
|
|
10
|
+
})
|
|
11
|
+
},
|
|
12
|
+
/**
|
|
13
|
+
* Gets all of the user groups
|
|
14
|
+
*/
|
|
15
|
+
getGroups: async () => {
|
|
16
|
+
return await API.get({
|
|
17
|
+
url: "/api/global/groups",
|
|
18
|
+
})
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Gets a group by ID
|
|
23
|
+
*/
|
|
24
|
+
getGroup: async id => {
|
|
25
|
+
return await API.get({
|
|
26
|
+
url: `/api/global/groups/${id}`,
|
|
27
|
+
})
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Deletes a user group
|
|
32
|
+
* @param id the id of the config to delete
|
|
33
|
+
* @param rev the revision of the config to delete
|
|
34
|
+
*/
|
|
35
|
+
deleteGroup: async ({ id, rev }) => {
|
|
36
|
+
return await API.delete({
|
|
37
|
+
url: `/api/global/groups/${id}/${rev}`,
|
|
38
|
+
})
|
|
39
|
+
},
|
|
40
|
+
})
|
package/src/api/index.js
CHANGED
|
@@ -23,6 +23,7 @@ import { buildUserEndpoints } from "./user"
|
|
|
23
23
|
import { buildSelfEndpoints } from "./self"
|
|
24
24
|
import { buildViewEndpoints } from "./views"
|
|
25
25
|
import { buildLicensingEndpoints } from "./licensing"
|
|
26
|
+
import { buildGroupsEndpoints } from "./groups"
|
|
26
27
|
|
|
27
28
|
const defaultAPIClientConfig = {
|
|
28
29
|
/**
|
|
@@ -241,5 +242,6 @@ export const createAPIClient = config => {
|
|
|
241
242
|
...buildViewEndpoints(API),
|
|
242
243
|
...buildSelfEndpoints(API),
|
|
243
244
|
...buildLicensingEndpoints(API),
|
|
245
|
+
...buildGroupsEndpoints(API),
|
|
244
246
|
}
|
|
245
247
|
}
|
package/src/api/user.js
CHANGED
|
@@ -13,13 +13,16 @@ export const buildUserEndpoints = API => ({
|
|
|
13
13
|
* @param {string} page The page to retrieve
|
|
14
14
|
* @param {string} search The starts with string to search username/email by.
|
|
15
15
|
*/
|
|
16
|
-
searchUsers: async ({ page,
|
|
16
|
+
searchUsers: async ({ page, email, appId } = {}) => {
|
|
17
17
|
const opts = {}
|
|
18
18
|
if (page) {
|
|
19
19
|
opts.page = page
|
|
20
20
|
}
|
|
21
|
-
if (
|
|
22
|
-
opts.
|
|
21
|
+
if (email) {
|
|
22
|
+
opts.email = email
|
|
23
|
+
}
|
|
24
|
+
if (appId) {
|
|
25
|
+
opts.appId = appId
|
|
23
26
|
}
|
|
24
27
|
return await API.post({
|
|
25
28
|
url: `/api/global/users/search`,
|
|
@@ -80,6 +83,20 @@ export const buildUserEndpoints = API => ({
|
|
|
80
83
|
})
|
|
81
84
|
},
|
|
82
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Creates multiple users.
|
|
88
|
+
* @param users the array of user objects to create
|
|
89
|
+
*/
|
|
90
|
+
createUsers: async ({ users, groups }) => {
|
|
91
|
+
return await API.post({
|
|
92
|
+
url: "/api/global/users/bulkCreate",
|
|
93
|
+
body: {
|
|
94
|
+
users,
|
|
95
|
+
groups,
|
|
96
|
+
},
|
|
97
|
+
})
|
|
98
|
+
},
|
|
99
|
+
|
|
83
100
|
/**
|
|
84
101
|
* Deletes a user from the curernt tenant.
|
|
85
102
|
* @param userId the ID of the user to delete
|
|
@@ -90,6 +107,19 @@ export const buildUserEndpoints = API => ({
|
|
|
90
107
|
})
|
|
91
108
|
},
|
|
92
109
|
|
|
110
|
+
/**
|
|
111
|
+
* Deletes multiple users
|
|
112
|
+
* @param userId the ID of the user to delete
|
|
113
|
+
*/
|
|
114
|
+
deleteUsers: async userIds => {
|
|
115
|
+
return await API.post({
|
|
116
|
+
url: `/api/global/users/bulkDelete`,
|
|
117
|
+
body: {
|
|
118
|
+
userIds,
|
|
119
|
+
},
|
|
120
|
+
})
|
|
121
|
+
},
|
|
122
|
+
|
|
93
123
|
/**
|
|
94
124
|
* Invites a user to the current tenant.
|
|
95
125
|
* @param email the email address to send the invitation to
|
|
@@ -109,6 +139,25 @@ export const buildUserEndpoints = API => ({
|
|
|
109
139
|
})
|
|
110
140
|
},
|
|
111
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Invites multiple users to the current tenant.
|
|
144
|
+
* @param email An array of email addresses
|
|
145
|
+
* @param builder whether the user should be a global builder
|
|
146
|
+
* @param admin whether the user should be a global admin
|
|
147
|
+
*/
|
|
148
|
+
inviteUsers: async ({ emails, builder, admin }) => {
|
|
149
|
+
return await API.post({
|
|
150
|
+
url: "/api/global/users/inviteMultiple",
|
|
151
|
+
body: {
|
|
152
|
+
emails,
|
|
153
|
+
userInfo: {
|
|
154
|
+
admin: admin ? { global: true } : undefined,
|
|
155
|
+
builder: builder ? { global: true } : undefined,
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
})
|
|
159
|
+
},
|
|
160
|
+
|
|
112
161
|
/**
|
|
113
162
|
* Accepts an invite to join the platform and creates a user.
|
|
114
163
|
* @param inviteCode the invite code sent in the email
|
package/src/constants.js
CHANGED
|
@@ -35,7 +35,7 @@ export const OperatorOptions = {
|
|
|
35
35
|
label: "Less than",
|
|
36
36
|
},
|
|
37
37
|
Contains: {
|
|
38
|
-
value: "
|
|
38
|
+
value: "contains",
|
|
39
39
|
label: "Contains",
|
|
40
40
|
},
|
|
41
41
|
NotContains: {
|
|
@@ -60,6 +60,37 @@ export const TableNames = {
|
|
|
60
60
|
USERS: "ta_users",
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
export const BbRoles = [
|
|
64
|
+
{ label: "App User", value: "appUser" },
|
|
65
|
+
{ label: "Developer", value: "developer" },
|
|
66
|
+
{ label: "Admin", value: "admin" },
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
export const BuilderRoleDescriptions = [
|
|
70
|
+
{
|
|
71
|
+
value: "appUser",
|
|
72
|
+
icon: "User",
|
|
73
|
+
label: "App user - Only has access to published apps",
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
value: "developer",
|
|
77
|
+
icon: "Hammer",
|
|
78
|
+
label: "Developer - Access to the app builder",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
value: "admin",
|
|
82
|
+
icon: "Draw",
|
|
83
|
+
label: "Admin - Full access",
|
|
84
|
+
},
|
|
85
|
+
]
|
|
86
|
+
|
|
87
|
+
export const PlanType = {
|
|
88
|
+
FREE: "free",
|
|
89
|
+
TEAM: "team",
|
|
90
|
+
BUSINESS: "business",
|
|
91
|
+
ENTERPRISE: "enterprise",
|
|
92
|
+
}
|
|
93
|
+
|
|
63
94
|
/**
|
|
64
95
|
* API version header attached to all requests.
|
|
65
96
|
* Version changelog:
|
|
@@ -68,6 +99,10 @@ export const TableNames = {
|
|
|
68
99
|
*/
|
|
69
100
|
export const ApiVersion = "1"
|
|
70
101
|
|
|
102
|
+
export const Features = {
|
|
103
|
+
USER_GROUPS: "userGroups",
|
|
104
|
+
}
|
|
105
|
+
|
|
71
106
|
// Role IDs
|
|
72
107
|
export const Roles = {
|
|
73
108
|
ADMIN: "ADMIN",
|
|
@@ -76,7 +111,6 @@ export const Roles = {
|
|
|
76
111
|
PUBLIC: "PUBLIC",
|
|
77
112
|
BUILDER: "BUILDER",
|
|
78
113
|
}
|
|
79
|
-
|
|
80
114
|
/**
|
|
81
115
|
* Maximum minimum range for SQL number values
|
|
82
116
|
*/
|
package/src/utils/lucene.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Helpers } from "@budibase/bbui"
|
|
2
2
|
import { OperatorOptions, SqlNumberTypeRangeMap } from "../constants"
|
|
3
3
|
|
|
4
|
+
const HBS_REGEX = /{{([^{].*?)}}/g
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* Returns the valid operator options for a certain data type
|
|
6
8
|
* @param type the data type
|
|
@@ -98,14 +100,24 @@ export const buildLuceneQuery = filter => {
|
|
|
98
100
|
if (Array.isArray(filter)) {
|
|
99
101
|
filter.forEach(expression => {
|
|
100
102
|
let { operator, field, type, value, externalType } = expression
|
|
103
|
+
const isHbs =
|
|
104
|
+
typeof value === "string" && value.match(HBS_REGEX)?.length > 0
|
|
101
105
|
// Parse all values into correct types
|
|
102
|
-
if (type === "datetime"
|
|
103
|
-
value
|
|
106
|
+
if (type === "datetime") {
|
|
107
|
+
// Ensure date value is a valid date and parse into correct format
|
|
108
|
+
if (!value) {
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
value = new Date(value).toISOString()
|
|
113
|
+
} catch (error) {
|
|
114
|
+
return
|
|
115
|
+
}
|
|
104
116
|
}
|
|
105
117
|
if (type === "number" && !Array.isArray(value)) {
|
|
106
118
|
if (operator === "oneOf") {
|
|
107
119
|
value = value.split(",").map(item => parseFloat(item))
|
|
108
|
-
} else {
|
|
120
|
+
} else if (!isHbs) {
|
|
109
121
|
value = parseFloat(value)
|
|
110
122
|
}
|
|
111
123
|
}
|