@budibase/frontend-core 2.21.9 → 2.22.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
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/frontend-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.22.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": "2.
|
|
10
|
-
"@budibase/shared-core": "2.
|
|
9
|
+
"@budibase/bbui": "2.22.1",
|
|
10
|
+
"@budibase/shared-core": "2.22.1",
|
|
11
11
|
"dayjs": "^1.10.8",
|
|
12
12
|
"lodash": "4.17.21",
|
|
13
13
|
"socket.io-client": "^4.6.1"
|
|
14
14
|
},
|
|
15
|
-
"gitHead": "
|
|
15
|
+
"gitHead": "b91392adfadf5e27c40a78102046cb3e51a7a792"
|
|
16
16
|
}
|
package/src/api/app.js
CHANGED
|
@@ -83,6 +83,18 @@ export const buildAppEndpoints = API => ({
|
|
|
83
83
|
})
|
|
84
84
|
},
|
|
85
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Duplicate an existing app
|
|
88
|
+
* @param app the app to dupe
|
|
89
|
+
*/
|
|
90
|
+
duplicateApp: async (app, appId) => {
|
|
91
|
+
return await API.post({
|
|
92
|
+
url: `/api/applications/${appId}/duplicate`,
|
|
93
|
+
body: app,
|
|
94
|
+
json: false,
|
|
95
|
+
})
|
|
96
|
+
},
|
|
97
|
+
|
|
86
98
|
/**
|
|
87
99
|
* Update an application using an export - the body
|
|
88
100
|
* should be of type FormData, with a "file" and a "password" if encrypted.
|
package/src/utils/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export * as JSONUtils from "./json"
|
|
|
3
3
|
export * as CookieUtils from "./cookies"
|
|
4
4
|
export * as RoleUtils from "./roles"
|
|
5
5
|
export * as Utils from "./utils"
|
|
6
|
+
export * as RowUtils from "./rows"
|
|
6
7
|
export { memo, derivedMemo } from "./memo"
|
|
7
8
|
export { createWebsocket } from "./websocket"
|
|
8
9
|
export * from "./download"
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Util to check is a given value is "better" than another. "Betterness" is
|
|
3
|
+
* defined as presence and length.
|
|
4
|
+
*/
|
|
5
|
+
const isBetterSample = (newValue, oldValue) => {
|
|
6
|
+
// Prefer non-null values
|
|
7
|
+
if (oldValue == null && newValue != null) {
|
|
8
|
+
return true
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Don't change type
|
|
12
|
+
const oldType = typeof oldValue
|
|
13
|
+
const newType = typeof newValue
|
|
14
|
+
if (oldType !== newType) {
|
|
15
|
+
return false
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Prefer longer values
|
|
19
|
+
if (newType === "string" && newValue.length > oldValue.length) {
|
|
20
|
+
return true
|
|
21
|
+
}
|
|
22
|
+
if (
|
|
23
|
+
newType === "object" &&
|
|
24
|
+
Object.keys(newValue).length > Object.keys(oldValue).length
|
|
25
|
+
) {
|
|
26
|
+
return true
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return false
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Generates a best-case example object of the provided samples.
|
|
34
|
+
* The generated sample does not necessarily exist - it simply is a sample that
|
|
35
|
+
* contains "good" examples for every property of all the samples.
|
|
36
|
+
* The generate sample will have a value for all keys across all samples.
|
|
37
|
+
*/
|
|
38
|
+
export const generateGoldenSample = samples => {
|
|
39
|
+
let goldenSample = {}
|
|
40
|
+
samples?.slice(0, 100).forEach(sample => {
|
|
41
|
+
Object.keys(sample).forEach(key => {
|
|
42
|
+
if (isBetterSample(sample[key], goldenSample[key])) {
|
|
43
|
+
goldenSample[key] = sample[key]
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
return goldenSample
|
|
48
|
+
}
|