@budibase/frontend-core 1.0.220-alpha.2 → 1.0.221
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/attachments.js +0 -1
- package/src/api/index.js +7 -1
- package/src/constants.js +9 -0
- package/src/utils/index.js +1 -0
- package/src/utils/roles.js +22 -0
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/frontend-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.221",
|
|
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.
|
|
9
|
+
"@budibase/bbui": "^1.0.221",
|
|
10
10
|
"lodash": "^4.17.21",
|
|
11
11
|
"svelte": "^3.46.2"
|
|
12
12
|
},
|
|
13
|
-
"gitHead": "
|
|
13
|
+
"gitHead": "4e1904bba3bbec3d6f36827ecd012827b5e76cd8"
|
|
14
14
|
}
|
package/src/api/attachments.js
CHANGED
|
@@ -48,7 +48,6 @@ export const buildAttachmentEndpoints = API => {
|
|
|
48
48
|
* @param data the file to upload
|
|
49
49
|
*/
|
|
50
50
|
externalUpload: async ({ datasourceId, bucket, key, data }) => {
|
|
51
|
-
console.log(API)
|
|
52
51
|
const { signedUrl, publicUrl } = await getSignedDatasourceURL({
|
|
53
52
|
datasourceId,
|
|
54
53
|
bucket,
|
package/src/api/index.js
CHANGED
|
@@ -57,6 +57,7 @@ export const createAPIClient = config => {
|
|
|
57
57
|
...defaultAPIClientConfig,
|
|
58
58
|
...config,
|
|
59
59
|
}
|
|
60
|
+
let cache = {}
|
|
60
61
|
|
|
61
62
|
// Generates an error object from an API response
|
|
62
63
|
const makeErrorFromResponse = async (response, method) => {
|
|
@@ -139,6 +140,7 @@ export const createAPIClient = config => {
|
|
|
139
140
|
credentials: "same-origin",
|
|
140
141
|
})
|
|
141
142
|
} catch (error) {
|
|
143
|
+
delete cache[url]
|
|
142
144
|
throw makeError("Failed to send request", { url, method })
|
|
143
145
|
}
|
|
144
146
|
|
|
@@ -151,9 +153,11 @@ export const createAPIClient = config => {
|
|
|
151
153
|
return await response.json()
|
|
152
154
|
}
|
|
153
155
|
} catch (error) {
|
|
156
|
+
delete cache[url]
|
|
154
157
|
return null
|
|
155
158
|
}
|
|
156
159
|
} else {
|
|
160
|
+
delete cache[url]
|
|
157
161
|
throw await makeErrorFromResponse(response, method)
|
|
158
162
|
}
|
|
159
163
|
}
|
|
@@ -161,7 +165,6 @@ export const createAPIClient = config => {
|
|
|
161
165
|
// Performs an API call to the server and caches the response.
|
|
162
166
|
// Future invocation for this URL will return the cached result instead of
|
|
163
167
|
// hitting the server again.
|
|
164
|
-
let cache = {}
|
|
165
168
|
const makeCachedApiCall = async params => {
|
|
166
169
|
const identifier = params.url
|
|
167
170
|
if (!identifier) {
|
|
@@ -206,6 +209,9 @@ export const createAPIClient = config => {
|
|
|
206
209
|
error: message => {
|
|
207
210
|
throw makeError(message)
|
|
208
211
|
},
|
|
212
|
+
invalidateCache: () => {
|
|
213
|
+
cache = {}
|
|
214
|
+
},
|
|
209
215
|
}
|
|
210
216
|
|
|
211
217
|
// Attach all endpoints
|
package/src/constants.js
CHANGED
|
@@ -68,6 +68,15 @@ export const TableNames = {
|
|
|
68
68
|
*/
|
|
69
69
|
export const ApiVersion = "1"
|
|
70
70
|
|
|
71
|
+
// Role IDs
|
|
72
|
+
export const Roles = {
|
|
73
|
+
ADMIN: "ADMIN",
|
|
74
|
+
POWER: "POWER",
|
|
75
|
+
BASIC: "BASIC",
|
|
76
|
+
PUBLIC: "PUBLIC",
|
|
77
|
+
BUILDER: "BUILDER",
|
|
78
|
+
}
|
|
79
|
+
|
|
71
80
|
/**
|
|
72
81
|
* Maximum minimum range for SQL number values
|
|
73
82
|
*/
|
package/src/utils/index.js
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Roles } from "../constants"
|
|
2
|
+
|
|
3
|
+
const RolePriorities = {
|
|
4
|
+
[Roles.ADMIN]: 4,
|
|
5
|
+
[Roles.POWER]: 3,
|
|
6
|
+
[Roles.BASIC]: 2,
|
|
7
|
+
[Roles.PUBLIC]: 1,
|
|
8
|
+
}
|
|
9
|
+
const RoleColours = {
|
|
10
|
+
[Roles.ADMIN]: "var(--spectrum-global-color-static-seafoam-400)",
|
|
11
|
+
[Roles.POWER]: "var(--spectrum-global-color-static-purple-400)",
|
|
12
|
+
[Roles.BASIC]: "var(--spectrum-global-color-static-magenta-400)",
|
|
13
|
+
[Roles.PUBLIC]: "var(--spectrum-global-color-static-yellow-400)",
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const getRolePriority = roleId => {
|
|
17
|
+
return RolePriorities[roleId] ?? 0
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const getRoleColour = roleId => {
|
|
21
|
+
return RoleColours[roleId] ?? "rgb(20, 115, 230)"
|
|
22
|
+
}
|