@budibase/frontend-core 3.20.0 → 3.20.2
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 +2 -2
- package/src/api/app.ts +9 -3
- package/src/utils/validation/yup/app.ts +30 -20
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/frontend-core",
|
|
3
|
-
"version": "3.20.
|
|
3
|
+
"version": "3.20.2",
|
|
4
4
|
"description": "Budibase frontend core libraries used in builder and client",
|
|
5
5
|
"author": "Budibase",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
"shortid": "2.2.15",
|
|
18
18
|
"socket.io-client": "^4.7.5"
|
|
19
19
|
},
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "3582592cff6b755c0e6f5cf7d04f32be18d7a9a8"
|
|
21
21
|
}
|
package/src/api/app.ts
CHANGED
|
@@ -52,7 +52,8 @@ export interface AppEndpoints {
|
|
|
52
52
|
) => Promise<DuplicateWorkspaceResponse>
|
|
53
53
|
updateAppFromExport: (
|
|
54
54
|
appId: string,
|
|
55
|
-
body: ImportToUpdateWorkspaceRequest
|
|
55
|
+
body: ImportToUpdateWorkspaceRequest,
|
|
56
|
+
appExport: File
|
|
56
57
|
) => Promise<ImportToUpdateWorkspaceResponse>
|
|
57
58
|
fetchSystemDebugInfo: () => Promise<GetDiagnosticsResponse>
|
|
58
59
|
getApps: () => Promise<FetchWorkspacesResponse>
|
|
@@ -175,11 +176,16 @@ export const buildAppEndpoints = (API: BaseAPIClient): AppEndpoints => ({
|
|
|
175
176
|
* converted to development ID.
|
|
176
177
|
* @param body a FormData body with a file and password.
|
|
177
178
|
*/
|
|
178
|
-
updateAppFromExport: async (appId, body) => {
|
|
179
|
+
updateAppFromExport: async (appId, body, appExport) => {
|
|
179
180
|
const devId = sdk.applications.getDevAppID(appId)
|
|
181
|
+
const formData = new FormData()
|
|
182
|
+
formData.append("appExport", appExport)
|
|
183
|
+
for (const [key, field] of Object.entries(body)) {
|
|
184
|
+
formData.append(key, field)
|
|
185
|
+
}
|
|
180
186
|
return await API.post({
|
|
181
187
|
url: `/api/applications/${devId}/import`,
|
|
182
|
-
body,
|
|
188
|
+
body: formData,
|
|
183
189
|
json: false,
|
|
184
190
|
})
|
|
185
191
|
},
|
|
@@ -3,11 +3,18 @@ import { mixed, string } from "yup"
|
|
|
3
3
|
import { ValidationStore } from "."
|
|
4
4
|
import { APP_NAME_REGEX, APP_URL_REGEX } from "../../../constants"
|
|
5
5
|
|
|
6
|
+
interface ValidationContext {
|
|
7
|
+
workspaces: Workspace[]
|
|
8
|
+
currentWorkspace?: Workspace
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const defaultContext = {
|
|
12
|
+
workspaces: [],
|
|
13
|
+
}
|
|
14
|
+
|
|
6
15
|
export const name = (
|
|
7
16
|
validation: ValidationStore,
|
|
8
|
-
{
|
|
9
|
-
apps: [],
|
|
10
|
-
}
|
|
17
|
+
{ workspaces, currentWorkspace }: ValidationContext = defaultContext
|
|
11
18
|
) => {
|
|
12
19
|
validation.addValidator(
|
|
13
20
|
"name",
|
|
@@ -26,12 +33,15 @@ export const name = (
|
|
|
26
33
|
// exit early, above validator will fail
|
|
27
34
|
return true
|
|
28
35
|
}
|
|
29
|
-
return !
|
|
30
|
-
.filter(
|
|
31
|
-
return
|
|
36
|
+
return !workspaces
|
|
37
|
+
.filter(workspace => {
|
|
38
|
+
return workspace.appId !== currentWorkspace?.appId
|
|
32
39
|
})
|
|
33
|
-
.map(
|
|
34
|
-
.some(
|
|
40
|
+
.map(workspace => workspace.name)
|
|
41
|
+
.some(
|
|
42
|
+
workspaceName =>
|
|
43
|
+
workspaceName.toLowerCase() === value.toLowerCase()
|
|
44
|
+
)
|
|
35
45
|
}
|
|
36
46
|
)
|
|
37
47
|
)
|
|
@@ -39,9 +49,7 @@ export const name = (
|
|
|
39
49
|
|
|
40
50
|
export const url = (
|
|
41
51
|
validation: ValidationStore,
|
|
42
|
-
{
|
|
43
|
-
apps: [],
|
|
44
|
-
}
|
|
52
|
+
{ workspaces, currentWorkspace }: ValidationContext = defaultContext
|
|
45
53
|
) => {
|
|
46
54
|
validation.addValidator(
|
|
47
55
|
"url",
|
|
@@ -57,17 +65,19 @@ export const url = (
|
|
|
57
65
|
if (!value) {
|
|
58
66
|
return true
|
|
59
67
|
}
|
|
60
|
-
if (
|
|
61
|
-
// filter out the current
|
|
62
|
-
|
|
68
|
+
if (currentWorkspace) {
|
|
69
|
+
// filter out the current workspace if present
|
|
70
|
+
workspaces = workspaces.filter(
|
|
71
|
+
workspace => workspace.appId !== currentWorkspace.appId
|
|
72
|
+
)
|
|
63
73
|
}
|
|
64
|
-
return !
|
|
65
|
-
.map(
|
|
66
|
-
.some(
|
|
74
|
+
return !workspaces
|
|
75
|
+
.map(workspace => workspace.url)
|
|
76
|
+
.some(workspaceUrl => {
|
|
67
77
|
const url =
|
|
68
|
-
|
|
69
|
-
?
|
|
70
|
-
:
|
|
78
|
+
workspaceUrl?.[0] === "/"
|
|
79
|
+
? workspaceUrl.substring(1, workspaceUrl.length)
|
|
80
|
+
: workspaceUrl
|
|
71
81
|
return url?.toLowerCase() === value.toLowerCase()
|
|
72
82
|
})
|
|
73
83
|
}
|