@budibase/frontend-core 3.2.28 → 3.2.30
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 +9 -3
- package/src/api/ai.ts +17 -0
- package/src/api/analytics.ts +39 -0
- package/src/api/{app.js → app.ts} +84 -5
- package/src/api/attachments.ts +121 -0
- package/src/api/auditLogs.ts +35 -0
- package/src/api/{auth.js → auth.ts} +44 -7
- package/src/api/automations.ts +158 -0
- package/src/api/backups.ts +50 -0
- package/src/api/{configs.js → configs.ts} +31 -3
- package/src/api/datasources.ts +132 -0
- package/src/api/environmentVariables.ts +58 -0
- package/src/api/events.ts +21 -0
- package/src/api/flags.ts +48 -0
- package/src/api/{groups.js → groups.ts} +73 -17
- package/src/api/{index.js → index.ts} +89 -102
- package/src/api/layouts.ts +35 -0
- package/src/api/licensing.ts +107 -0
- package/src/api/{logs.js → logs.ts} +7 -1
- package/src/api/migrations.ts +19 -0
- package/src/api/{other.js → other.ts} +19 -12
- package/src/api/{permissions.js → permissions.ts} +31 -5
- package/src/api/{plugins.js → plugins.ts} +18 -1
- package/src/api/{queries.js → queries.ts} +39 -14
- package/src/api/relationships.ts +31 -0
- package/src/api/{roles.js → roles.ts} +22 -5
- package/src/api/routes.ts +30 -0
- package/src/api/{rowActions.js → rowActions.ts} +45 -27
- package/src/api/rows.ts +120 -0
- package/src/api/screens.ts +35 -0
- package/src/api/{self.js → self.ts} +20 -4
- package/src/api/tables.ts +192 -0
- package/src/api/templates.ts +57 -0
- package/src/api/types.ts +136 -0
- package/src/api/{user.js → user.ts} +111 -119
- package/src/api/{views.js → views.ts} +18 -7
- package/src/api/{viewsV2.js → viewsV2.ts} +30 -27
- package/src/components/grid/cells/AICell.svelte +1 -0
- package/src/components/grid/cells/LongFormCell.svelte +1 -0
- package/src/components/grid/cells/RelationshipCell.svelte +1 -2
- package/src/components/grid/cells/TextCell.svelte +3 -0
- package/src/components/grid/controls/MigrationModal.svelte +5 -5
- package/src/components/grid/layout/Grid.svelte +5 -8
- package/src/components/grid/lib/constants.js +1 -1
- package/src/components/grid/lib/{events.js → events.ts} +3 -3
- package/src/components/grid/lib/utils.js +2 -0
- package/src/components/grid/lib/utils.ts +32 -0
- package/src/components/grid/stores/bounds.ts +29 -0
- package/src/components/grid/stores/{cache.js → cache.ts} +21 -6
- package/src/components/grid/stores/{clipboard.js → clipboard.ts} +55 -19
- package/src/components/grid/stores/{columns.js → columns.ts} +47 -19
- package/src/components/grid/stores/{conditions.js → conditions.ts} +32 -12
- package/src/components/grid/stores/{config.js → config.ts} +16 -6
- package/src/components/grid/stores/{datasource.js → datasource.ts} +86 -36
- package/src/components/grid/stores/datasources/index.ts +31 -0
- package/src/components/grid/stores/datasources/{nonPlus.js → nonPlus.ts} +21 -11
- package/src/components/grid/stores/datasources/{table.js → table.ts} +39 -21
- package/src/components/grid/stores/datasources/{viewV2.js → viewV2.ts} +74 -28
- package/src/components/grid/stores/{filter.js → filter.ts} +39 -16
- package/src/components/grid/stores/index.ts +143 -0
- package/src/components/grid/stores/{menu.js → menu.ts} +31 -6
- package/src/components/grid/stores/{notifications.js → notifications.ts} +12 -2
- package/src/components/grid/stores/{pagination.js → pagination.ts} +2 -1
- package/src/components/grid/stores/{reorder.js → reorder.ts} +47 -15
- package/src/components/grid/stores/{resize.js → resize.ts} +28 -10
- package/src/components/grid/stores/{rows.js → rows.ts} +167 -53
- package/src/components/grid/stores/{scroll.js → scroll.ts} +28 -5
- package/src/components/grid/stores/{sort.js → sort.ts} +13 -3
- package/src/components/grid/stores/{ui.js → ui.ts} +77 -20
- package/src/components/grid/stores/{users.js → users.ts} +36 -9
- package/src/components/grid/stores/{validation.js → validation.ts} +35 -12
- package/src/components/grid/stores/{viewport.js → viewport.ts} +14 -3
- package/src/{constants.js → constants.ts} +2 -2
- package/src/fetch/QueryFetch.js +2 -2
- package/src/fetch/RelationshipFetch.js +9 -6
- package/src/fetch/TableFetch.js +1 -2
- package/src/fetch/ViewFetch.js +1 -1
- package/src/fetch/ViewV2Fetch.js +1 -2
- package/src/utils/memo.d.ts +10 -0
- package/src/utils/relatedColumns.ts +126 -0
- package/tsconfig.json +14 -0
- package/src/api/ai.js +0 -11
- package/src/api/analytics.js +0 -17
- package/src/api/attachments.js +0 -78
- package/src/api/auditLogs.js +0 -63
- package/src/api/automations.js +0 -111
- package/src/api/backups.js +0 -46
- package/src/api/datasources.js +0 -92
- package/src/api/environmentVariables.js +0 -36
- package/src/api/events.js +0 -13
- package/src/api/flags.js +0 -34
- package/src/api/hosting.js +0 -19
- package/src/api/layouts.js +0 -23
- package/src/api/licensing.js +0 -75
- package/src/api/migrations.js +0 -10
- package/src/api/relationships.js +0 -21
- package/src/api/routes.js +0 -19
- package/src/api/rows.js +0 -117
- package/src/api/screens.js +0 -23
- package/src/api/tables.js +0 -152
- package/src/api/templates.js +0 -35
- package/src/components/grid/stores/bounds.js +0 -16
- package/src/components/grid/stores/index.js +0 -73
- package/src/utils/relatedColumns.js +0 -103
- /package/src/{index.js → index.ts} +0 -0
- /package/src/utils/{index.js → index.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/frontend-core",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.30",
|
|
4
4
|
"description": "Budibase frontend core libraries used in builder and client",
|
|
5
5
|
"author": "Budibase",
|
|
6
6
|
"license": "MPL-2.0",
|
|
7
|
-
"svelte": "src/index.
|
|
7
|
+
"svelte": "./src/index.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"check:types": "yarn svelte-check"
|
|
10
|
+
},
|
|
8
11
|
"dependencies": {
|
|
9
12
|
"@budibase/bbui": "*",
|
|
10
13
|
"@budibase/shared-core": "*",
|
|
@@ -14,5 +17,8 @@
|
|
|
14
17
|
"shortid": "2.2.15",
|
|
15
18
|
"socket.io-client": "^4.7.5"
|
|
16
19
|
},
|
|
17
|
-
"
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"svelte-check": "^4.1.0"
|
|
22
|
+
},
|
|
23
|
+
"gitHead": "674ee960a79856f998b71845c0c86c6955a41f80"
|
|
18
24
|
}
|
package/src/api/ai.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseAPIClient } from "./types"
|
|
2
|
+
|
|
3
|
+
export interface AIEndpoints {
|
|
4
|
+
generateCronExpression: (prompt: string) => Promise<{ message: string }>
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const buildAIEndpoints = (API: BaseAPIClient): AIEndpoints => ({
|
|
8
|
+
/**
|
|
9
|
+
* Generates a cron expression from a prompt
|
|
10
|
+
*/
|
|
11
|
+
generateCronExpression: async prompt => {
|
|
12
|
+
return await API.post({
|
|
13
|
+
url: "/api/ai/cron",
|
|
14
|
+
body: { prompt },
|
|
15
|
+
})
|
|
16
|
+
},
|
|
17
|
+
})
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { BaseAPIClient } from "./types"
|
|
2
|
+
import {
|
|
3
|
+
AnalyticsEnabledResponse,
|
|
4
|
+
AnalyticsPingRequest,
|
|
5
|
+
AnalyticsPingResponse,
|
|
6
|
+
} from "@budibase/types"
|
|
7
|
+
|
|
8
|
+
export interface AnalyticsEndpoints {
|
|
9
|
+
getAnalyticsStatus: () => Promise<AnalyticsEnabledResponse>
|
|
10
|
+
analyticsPing: (
|
|
11
|
+
payload: Omit<AnalyticsPingRequest, "timezone">
|
|
12
|
+
) => Promise<AnalyticsPingResponse>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const buildAnalyticsEndpoints = (
|
|
16
|
+
API: BaseAPIClient
|
|
17
|
+
): AnalyticsEndpoints => ({
|
|
18
|
+
/**
|
|
19
|
+
* Gets the current status of analytics for this environment
|
|
20
|
+
*/
|
|
21
|
+
getAnalyticsStatus: async () => {
|
|
22
|
+
return await API.get({
|
|
23
|
+
url: "/api/bbtel",
|
|
24
|
+
})
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Notifies analytics of a certain environment
|
|
29
|
+
*/
|
|
30
|
+
analyticsPing: async request => {
|
|
31
|
+
return await API.post<AnalyticsPingRequest, AnalyticsPingResponse>({
|
|
32
|
+
url: "/api/bbtel/ping",
|
|
33
|
+
body: {
|
|
34
|
+
...request,
|
|
35
|
+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
36
|
+
},
|
|
37
|
+
})
|
|
38
|
+
},
|
|
39
|
+
})
|
|
@@ -1,6 +1,72 @@
|
|
|
1
1
|
import { sdk } from "@budibase/shared-core"
|
|
2
|
+
import { BaseAPIClient } from "./types"
|
|
3
|
+
import {
|
|
4
|
+
AddAppSampleDataResponse,
|
|
5
|
+
ClearDevLockResponse,
|
|
6
|
+
CreateAppRequest,
|
|
7
|
+
CreateAppResponse,
|
|
8
|
+
DeleteAppResponse,
|
|
9
|
+
DuplicateAppRequest,
|
|
10
|
+
DuplicateAppResponse,
|
|
11
|
+
FetchAppDefinitionResponse,
|
|
12
|
+
FetchAppPackageResponse,
|
|
13
|
+
FetchAppsResponse,
|
|
14
|
+
FetchDeploymentResponse,
|
|
15
|
+
GetDiagnosticsResponse,
|
|
16
|
+
ImportToUpdateAppRequest,
|
|
17
|
+
ImportToUpdateAppResponse,
|
|
18
|
+
PublishAppResponse,
|
|
19
|
+
RevertAppClientResponse,
|
|
20
|
+
RevertAppResponse,
|
|
21
|
+
SetRevertableAppVersionRequest,
|
|
22
|
+
SetRevertableAppVersionResponse,
|
|
23
|
+
SyncAppResponse,
|
|
24
|
+
UnpublishAppResponse,
|
|
25
|
+
UpdateAppClientResponse,
|
|
26
|
+
UpdateAppRequest,
|
|
27
|
+
UpdateAppResponse,
|
|
28
|
+
} from "@budibase/types"
|
|
2
29
|
|
|
3
|
-
export
|
|
30
|
+
export interface AppEndpoints {
|
|
31
|
+
fetchAppPackage: (appId: string) => Promise<FetchAppPackageResponse>
|
|
32
|
+
saveAppMetadata: (
|
|
33
|
+
appId: string,
|
|
34
|
+
metadata: UpdateAppRequest
|
|
35
|
+
) => Promise<UpdateAppResponse>
|
|
36
|
+
unpublishApp: (appId: string) => Promise<UnpublishAppResponse>
|
|
37
|
+
publishAppChanges: (appId: string) => Promise<PublishAppResponse>
|
|
38
|
+
revertAppChanges: (appId: string) => Promise<RevertAppResponse>
|
|
39
|
+
updateAppClientVersion: (appId: string) => Promise<UpdateAppClientResponse>
|
|
40
|
+
revertAppClientVersion: (appId: string) => Promise<RevertAppClientResponse>
|
|
41
|
+
releaseAppLock: (appId: string) => Promise<ClearDevLockResponse>
|
|
42
|
+
getAppDeployments: () => Promise<FetchDeploymentResponse>
|
|
43
|
+
createApp: (app: CreateAppRequest) => Promise<CreateAppResponse>
|
|
44
|
+
deleteApp: (appId: string) => Promise<DeleteAppResponse>
|
|
45
|
+
duplicateApp: (
|
|
46
|
+
appId: string,
|
|
47
|
+
app: DuplicateAppRequest
|
|
48
|
+
) => Promise<DuplicateAppResponse>
|
|
49
|
+
updateAppFromExport: (
|
|
50
|
+
appId: string,
|
|
51
|
+
body: ImportToUpdateAppRequest
|
|
52
|
+
) => Promise<ImportToUpdateAppResponse>
|
|
53
|
+
fetchSystemDebugInfo: () => Promise<GetDiagnosticsResponse>
|
|
54
|
+
syncApp: (appId: string) => Promise<SyncAppResponse>
|
|
55
|
+
getApps: () => Promise<FetchAppsResponse>
|
|
56
|
+
fetchComponentLibDefinitions: (
|
|
57
|
+
appId: string
|
|
58
|
+
) => Promise<FetchAppDefinitionResponse>
|
|
59
|
+
setRevertableVersion: (
|
|
60
|
+
appId: string,
|
|
61
|
+
revertableVersion: string
|
|
62
|
+
) => Promise<SetRevertableAppVersionResponse>
|
|
63
|
+
addSampleData: (appId: string) => Promise<AddAppSampleDataResponse>
|
|
64
|
+
|
|
65
|
+
// Missing request or response types
|
|
66
|
+
importApps: (apps: any) => Promise<any>
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const buildAppEndpoints = (API: BaseAPIClient): AppEndpoints => ({
|
|
4
70
|
/**
|
|
5
71
|
* Fetches screen definition for an app.
|
|
6
72
|
* @param appId the ID of the app to fetch from
|
|
@@ -16,7 +82,7 @@ export const buildAppEndpoints = API => ({
|
|
|
16
82
|
* @param appId the ID of the app to update
|
|
17
83
|
* @param metadata the app metadata to save
|
|
18
84
|
*/
|
|
19
|
-
saveAppMetadata: async (
|
|
85
|
+
saveAppMetadata: async (appId, metadata) => {
|
|
20
86
|
return await API.put({
|
|
21
87
|
url: `/api/applications/${appId}`,
|
|
22
88
|
body: metadata,
|
|
@@ -87,7 +153,7 @@ export const buildAppEndpoints = API => ({
|
|
|
87
153
|
* Duplicate an existing app
|
|
88
154
|
* @param app the app to dupe
|
|
89
155
|
*/
|
|
90
|
-
duplicateApp: async (
|
|
156
|
+
duplicateApp: async (appId, app) => {
|
|
91
157
|
return await API.post({
|
|
92
158
|
url: `/api/applications/${appId}/duplicate`,
|
|
93
159
|
body: app,
|
|
@@ -184,7 +250,7 @@ export const buildAppEndpoints = API => ({
|
|
|
184
250
|
/**
|
|
185
251
|
* Fetches the definitions for component library components. This includes
|
|
186
252
|
* their props and other metadata from components.json.
|
|
187
|
-
* @param
|
|
253
|
+
* @param appId ID of the currently running app
|
|
188
254
|
*/
|
|
189
255
|
fetchComponentLibDefinitions: async appId => {
|
|
190
256
|
return await API.get({
|
|
@@ -192,14 +258,27 @@ export const buildAppEndpoints = API => ({
|
|
|
192
258
|
})
|
|
193
259
|
},
|
|
194
260
|
|
|
261
|
+
/**
|
|
262
|
+
* Adds sample data to an app
|
|
263
|
+
* @param appId the app ID
|
|
264
|
+
*/
|
|
195
265
|
addSampleData: async appId => {
|
|
196
266
|
return await API.post({
|
|
197
267
|
url: `/api/applications/${appId}/sample`,
|
|
198
268
|
})
|
|
199
269
|
},
|
|
200
270
|
|
|
271
|
+
/**
|
|
272
|
+
* Sets the revertable version of an app.
|
|
273
|
+
* Used when manually reverting to older client versions.
|
|
274
|
+
* @param appId the app ID
|
|
275
|
+
* @param revertableVersion the version number
|
|
276
|
+
*/
|
|
201
277
|
setRevertableVersion: async (appId, revertableVersion) => {
|
|
202
|
-
return await API.post
|
|
278
|
+
return await API.post<
|
|
279
|
+
SetRevertableAppVersionRequest,
|
|
280
|
+
SetRevertableAppVersionResponse
|
|
281
|
+
>({
|
|
203
282
|
url: `/api/applications/${appId}/setRevertableVersion`,
|
|
204
283
|
body: {
|
|
205
284
|
revertableVersion,
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DownloadAttachmentResponse,
|
|
3
|
+
GetSignedUploadUrlRequest,
|
|
4
|
+
GetSignedUploadUrlResponse,
|
|
5
|
+
ProcessAttachmentResponse,
|
|
6
|
+
} from "@budibase/types"
|
|
7
|
+
import { BaseAPIClient } from "./types"
|
|
8
|
+
|
|
9
|
+
export interface AttachmentEndpoints {
|
|
10
|
+
downloadAttachment: (
|
|
11
|
+
datasourceId: string,
|
|
12
|
+
rowId: string,
|
|
13
|
+
columnName: string
|
|
14
|
+
) => Promise<DownloadAttachmentResponse>
|
|
15
|
+
getSignedDatasourceURL: (
|
|
16
|
+
datasourceId: string,
|
|
17
|
+
bucket: string,
|
|
18
|
+
key: string
|
|
19
|
+
) => Promise<GetSignedUploadUrlResponse>
|
|
20
|
+
uploadAttachment: (
|
|
21
|
+
tableId: string,
|
|
22
|
+
data: any
|
|
23
|
+
) => Promise<ProcessAttachmentResponse>
|
|
24
|
+
uploadBuilderAttachment: (data: any) => Promise<ProcessAttachmentResponse>
|
|
25
|
+
externalUpload: (
|
|
26
|
+
datasourceId: string,
|
|
27
|
+
bucket: string,
|
|
28
|
+
key: string,
|
|
29
|
+
data: any
|
|
30
|
+
) => Promise<{ publicUrl: string | undefined }>
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const buildAttachmentEndpoints = (
|
|
34
|
+
API: BaseAPIClient
|
|
35
|
+
): AttachmentEndpoints => {
|
|
36
|
+
const endpoints: Pick<AttachmentEndpoints, "getSignedDatasourceURL"> = {
|
|
37
|
+
/**
|
|
38
|
+
* Generates a signed URL to upload a file to an external datasource.
|
|
39
|
+
* @param datasourceId the ID of the datasource to upload to
|
|
40
|
+
* @param bucket the name of the bucket to upload to
|
|
41
|
+
* @param key the name of the file to upload to
|
|
42
|
+
*/
|
|
43
|
+
getSignedDatasourceURL: async (datasourceId, bucket, key) => {
|
|
44
|
+
return await API.post<
|
|
45
|
+
GetSignedUploadUrlRequest,
|
|
46
|
+
GetSignedUploadUrlResponse
|
|
47
|
+
>({
|
|
48
|
+
url: `/api/attachments/${datasourceId}/url`,
|
|
49
|
+
body: { bucket, key },
|
|
50
|
+
})
|
|
51
|
+
},
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
...endpoints,
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Uploads an attachment to the server.
|
|
59
|
+
* @param data the attachment to upload
|
|
60
|
+
* @param tableId the table ID to upload to
|
|
61
|
+
*/
|
|
62
|
+
uploadAttachment: async (tableId, data) => {
|
|
63
|
+
return await API.post({
|
|
64
|
+
url: `/api/attachments/${tableId}/upload`,
|
|
65
|
+
body: data,
|
|
66
|
+
json: false,
|
|
67
|
+
})
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Uploads an attachment to the server as a builder user from the builder.
|
|
72
|
+
* @param data the data to upload
|
|
73
|
+
*/
|
|
74
|
+
uploadBuilderAttachment: async data => {
|
|
75
|
+
return await API.post({
|
|
76
|
+
url: "/api/attachments/process",
|
|
77
|
+
body: data,
|
|
78
|
+
json: false,
|
|
79
|
+
})
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Uploads a file to an external datasource.
|
|
84
|
+
* @param datasourceId the ID of the datasource to upload to
|
|
85
|
+
* @param bucket the name of the bucket to upload to
|
|
86
|
+
* @param key the name of the file to upload to
|
|
87
|
+
* @param data the file to upload
|
|
88
|
+
*/
|
|
89
|
+
externalUpload: async (datasourceId, bucket, key, data) => {
|
|
90
|
+
const { signedUrl, publicUrl } = await endpoints.getSignedDatasourceURL(
|
|
91
|
+
datasourceId,
|
|
92
|
+
bucket,
|
|
93
|
+
key
|
|
94
|
+
)
|
|
95
|
+
if (!signedUrl) {
|
|
96
|
+
return { publicUrl: undefined }
|
|
97
|
+
}
|
|
98
|
+
await API.put({
|
|
99
|
+
url: signedUrl,
|
|
100
|
+
body: data,
|
|
101
|
+
json: false,
|
|
102
|
+
external: true,
|
|
103
|
+
})
|
|
104
|
+
return { publicUrl }
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Download an attachment from a row given its column name.
|
|
109
|
+
* @param datasourceId the ID of the datasource to download from
|
|
110
|
+
* @param rowId the ID of the row to download from
|
|
111
|
+
* @param columnName the column name to download
|
|
112
|
+
*/
|
|
113
|
+
downloadAttachment: async (datasourceId, rowId, columnName) => {
|
|
114
|
+
return await API.get({
|
|
115
|
+
url: `/api/${datasourceId}/rows/${rowId}/attachment/${columnName}`,
|
|
116
|
+
parseResponse: response => response as any,
|
|
117
|
+
suppressErrors: true,
|
|
118
|
+
})
|
|
119
|
+
},
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SearchAuditLogsRequest,
|
|
3
|
+
SearchAuditLogsResponse,
|
|
4
|
+
DefinitionsAuditLogsResponse,
|
|
5
|
+
DownloadAuditLogsRequest,
|
|
6
|
+
} from "@budibase/types"
|
|
7
|
+
import { BaseAPIClient } from "./types"
|
|
8
|
+
|
|
9
|
+
export interface AuditLogEndpoints {
|
|
10
|
+
searchAuditLogs: (
|
|
11
|
+
opts: SearchAuditLogsRequest
|
|
12
|
+
) => Promise<SearchAuditLogsResponse>
|
|
13
|
+
getEventDefinitions: () => Promise<DefinitionsAuditLogsResponse>
|
|
14
|
+
getDownloadUrl: (opts: DownloadAuditLogsRequest) => string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const buildAuditLogEndpoints = (
|
|
18
|
+
API: BaseAPIClient
|
|
19
|
+
): AuditLogEndpoints => ({
|
|
20
|
+
searchAuditLogs: async opts => {
|
|
21
|
+
return await API.post({
|
|
22
|
+
url: `/api/global/auditlogs/search`,
|
|
23
|
+
body: opts,
|
|
24
|
+
})
|
|
25
|
+
},
|
|
26
|
+
getEventDefinitions: async () => {
|
|
27
|
+
return await API.get({
|
|
28
|
+
url: `/api/global/auditlogs/definitions`,
|
|
29
|
+
})
|
|
30
|
+
},
|
|
31
|
+
getDownloadUrl: opts => {
|
|
32
|
+
const query = encodeURIComponent(JSON.stringify(opts))
|
|
33
|
+
return `/api/global/auditlogs/download?query=${query}`
|
|
34
|
+
},
|
|
35
|
+
})
|
|
@@ -1,12 +1,46 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
GetInitInfoResponse,
|
|
3
|
+
LoginRequest,
|
|
4
|
+
LoginResponse,
|
|
5
|
+
LogoutResponse,
|
|
6
|
+
PasswordResetRequest,
|
|
7
|
+
PasswordResetResponse,
|
|
8
|
+
PasswordResetUpdateRequest,
|
|
9
|
+
PasswordResetUpdateResponse,
|
|
10
|
+
SetInitInfoRequest,
|
|
11
|
+
SetInitInfoResponse,
|
|
12
|
+
} from "@budibase/types"
|
|
13
|
+
import { BaseAPIClient } from "./types"
|
|
14
|
+
|
|
15
|
+
export interface AuthEndpoints {
|
|
16
|
+
logIn: (
|
|
17
|
+
tenantId: string,
|
|
18
|
+
username: string,
|
|
19
|
+
password: string
|
|
20
|
+
) => Promise<LoginResponse>
|
|
21
|
+
logOut: () => Promise<LogoutResponse>
|
|
22
|
+
requestForgotPassword: (
|
|
23
|
+
tenantId: string,
|
|
24
|
+
email: string
|
|
25
|
+
) => Promise<PasswordResetResponse>
|
|
26
|
+
resetPassword: (
|
|
27
|
+
tenantId: string,
|
|
28
|
+
password: string,
|
|
29
|
+
resetCode: string
|
|
30
|
+
) => Promise<PasswordResetUpdateResponse>
|
|
31
|
+
setInitInfo: (info: SetInitInfoRequest) => Promise<SetInitInfoResponse>
|
|
32
|
+
getInitInfo: () => Promise<GetInitInfoResponse>
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const buildAuthEndpoints = (API: BaseAPIClient): AuthEndpoints => ({
|
|
2
36
|
/**
|
|
3
37
|
* Performs a login request.
|
|
4
38
|
* @param tenantId the ID of the tenant to log in to
|
|
5
39
|
* @param username the username (email)
|
|
6
40
|
* @param password the password
|
|
7
41
|
*/
|
|
8
|
-
logIn: async (
|
|
9
|
-
return await API.post({
|
|
42
|
+
logIn: async (tenantId, username, password) => {
|
|
43
|
+
return await API.post<LoginRequest, LoginResponse>({
|
|
10
44
|
url: `/api/global/auth/${tenantId}/login`,
|
|
11
45
|
body: {
|
|
12
46
|
username,
|
|
@@ -49,8 +83,8 @@ export const buildAuthEndpoints = API => ({
|
|
|
49
83
|
* @param tenantId the ID of the tenant the user is in
|
|
50
84
|
* @param email the email address of the user
|
|
51
85
|
*/
|
|
52
|
-
requestForgotPassword: async (
|
|
53
|
-
return await API.post({
|
|
86
|
+
requestForgotPassword: async (tenantId, email) => {
|
|
87
|
+
return await API.post<PasswordResetRequest, PasswordResetResponse>({
|
|
54
88
|
url: `/api/global/auth/${tenantId}/reset`,
|
|
55
89
|
body: {
|
|
56
90
|
email,
|
|
@@ -64,8 +98,11 @@ export const buildAuthEndpoints = API => ({
|
|
|
64
98
|
* @param password the new password to set
|
|
65
99
|
* @param resetCode the reset code to authenticate the request
|
|
66
100
|
*/
|
|
67
|
-
resetPassword: async (
|
|
68
|
-
return await API.post
|
|
101
|
+
resetPassword: async (tenantId, password, resetCode) => {
|
|
102
|
+
return await API.post<
|
|
103
|
+
PasswordResetUpdateRequest,
|
|
104
|
+
PasswordResetUpdateResponse
|
|
105
|
+
>({
|
|
69
106
|
url: `/api/global/auth/${tenantId}/reset/update`,
|
|
70
107
|
body: {
|
|
71
108
|
password,
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ClearAutomationLogRequest,
|
|
3
|
+
ClearAutomationLogResponse,
|
|
4
|
+
CreateAutomationRequest,
|
|
5
|
+
CreateAutomationResponse,
|
|
6
|
+
DeleteAutomationResponse,
|
|
7
|
+
FetchAutomationResponse,
|
|
8
|
+
GetAutomationStepDefinitionsResponse,
|
|
9
|
+
SearchAutomationLogsRequest,
|
|
10
|
+
SearchAutomationLogsResponse,
|
|
11
|
+
TestAutomationRequest,
|
|
12
|
+
TestAutomationResponse,
|
|
13
|
+
TriggerAutomationRequest,
|
|
14
|
+
TriggerAutomationResponse,
|
|
15
|
+
UpdateAutomationRequest,
|
|
16
|
+
UpdateAutomationResponse,
|
|
17
|
+
} from "@budibase/types"
|
|
18
|
+
import { BaseAPIClient } from "./types"
|
|
19
|
+
|
|
20
|
+
export interface AutomationEndpoints {
|
|
21
|
+
getAutomations: () => Promise<FetchAutomationResponse>
|
|
22
|
+
createAutomation: (
|
|
23
|
+
automation: CreateAutomationRequest
|
|
24
|
+
) => Promise<CreateAutomationResponse>
|
|
25
|
+
updateAutomation: (
|
|
26
|
+
automation: UpdateAutomationRequest
|
|
27
|
+
) => Promise<UpdateAutomationResponse>
|
|
28
|
+
deleteAutomation: (
|
|
29
|
+
automationId: string,
|
|
30
|
+
automationRev: string
|
|
31
|
+
) => Promise<DeleteAutomationResponse>
|
|
32
|
+
clearAutomationLogErrors: (
|
|
33
|
+
automationId: string,
|
|
34
|
+
appId: string
|
|
35
|
+
) => Promise<ClearAutomationLogResponse>
|
|
36
|
+
triggerAutomation: (
|
|
37
|
+
automationId: string,
|
|
38
|
+
fields: Record<string, any>,
|
|
39
|
+
timeout: number
|
|
40
|
+
) => Promise<TriggerAutomationResponse>
|
|
41
|
+
testAutomation: (
|
|
42
|
+
automationdId: string,
|
|
43
|
+
data: TestAutomationRequest
|
|
44
|
+
) => Promise<TestAutomationResponse>
|
|
45
|
+
getAutomationDefinitions: () => Promise<GetAutomationStepDefinitionsResponse>
|
|
46
|
+
getAutomationLogs: (
|
|
47
|
+
options: SearchAutomationLogsRequest
|
|
48
|
+
) => Promise<SearchAutomationLogsResponse>
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const buildAutomationEndpoints = (
|
|
52
|
+
API: BaseAPIClient
|
|
53
|
+
): AutomationEndpoints => ({
|
|
54
|
+
/**
|
|
55
|
+
* Executes an automation. Must have "App Action" trigger.
|
|
56
|
+
* @param automationId the ID of the automation to trigger
|
|
57
|
+
* @param fields the fields to trigger the automation with
|
|
58
|
+
* @param timeout a timeout override
|
|
59
|
+
*/
|
|
60
|
+
triggerAutomation: async (automationId, fields, timeout) => {
|
|
61
|
+
return await API.post<TriggerAutomationRequest, TriggerAutomationResponse>({
|
|
62
|
+
url: `/api/automations/${automationId}/trigger`,
|
|
63
|
+
body: { fields, timeout },
|
|
64
|
+
})
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Tests an automation with data.
|
|
69
|
+
* @param automationId the ID of the automation to test
|
|
70
|
+
* @param data the test data to run against the automation
|
|
71
|
+
*/
|
|
72
|
+
testAutomation: async (automationId, data) => {
|
|
73
|
+
return await API.post({
|
|
74
|
+
url: `/api/automations/${automationId}/test`,
|
|
75
|
+
body: data,
|
|
76
|
+
})
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Gets a list of all automations.
|
|
81
|
+
*/
|
|
82
|
+
getAutomations: async () => {
|
|
83
|
+
return await API.get({
|
|
84
|
+
url: "/api/automations",
|
|
85
|
+
})
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Gets a list of all the definitions for blocks in automations.
|
|
90
|
+
*/
|
|
91
|
+
getAutomationDefinitions: async () => {
|
|
92
|
+
return await API.get({
|
|
93
|
+
url: "/api/automations/definitions/list",
|
|
94
|
+
})
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Creates an automation.
|
|
99
|
+
* @param automation the automation to create
|
|
100
|
+
*/
|
|
101
|
+
createAutomation: async automation => {
|
|
102
|
+
return await API.post({
|
|
103
|
+
url: "/api/automations",
|
|
104
|
+
body: automation,
|
|
105
|
+
})
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Updates an automation.
|
|
110
|
+
* @param automation the automation to update
|
|
111
|
+
*/
|
|
112
|
+
updateAutomation: async automation => {
|
|
113
|
+
return await API.put({
|
|
114
|
+
url: "/api/automations",
|
|
115
|
+
body: automation,
|
|
116
|
+
})
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Deletes an automation
|
|
121
|
+
* @param automationId the ID of the automation to delete
|
|
122
|
+
* @param automationRev the rev of the automation to delete
|
|
123
|
+
*/
|
|
124
|
+
deleteAutomation: async (automationId, automationRev) => {
|
|
125
|
+
return await API.delete({
|
|
126
|
+
url: `/api/automations/${automationId}/${automationRev}`,
|
|
127
|
+
})
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Get the logs for the app, or by automation ID.
|
|
132
|
+
*/
|
|
133
|
+
getAutomationLogs: async data => {
|
|
134
|
+
return await API.post({
|
|
135
|
+
url: "/api/automations/logs/search",
|
|
136
|
+
body: data,
|
|
137
|
+
})
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Clears automation log errors (which are creating notification) for
|
|
142
|
+
* automation or the app.
|
|
143
|
+
* @param automationId optional - the ID of the automation to clear errors for.
|
|
144
|
+
* @param appId The app ID to clear errors for.
|
|
145
|
+
*/
|
|
146
|
+
clearAutomationLogErrors: async (automationId, appId) => {
|
|
147
|
+
return await API.delete<
|
|
148
|
+
ClearAutomationLogRequest,
|
|
149
|
+
ClearAutomationLogResponse
|
|
150
|
+
>({
|
|
151
|
+
url: "/api/automations/logs",
|
|
152
|
+
body: {
|
|
153
|
+
appId,
|
|
154
|
+
automationId,
|
|
155
|
+
},
|
|
156
|
+
})
|
|
157
|
+
},
|
|
158
|
+
})
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CreateAppBackupResponse,
|
|
3
|
+
ImportAppBackupResponse,
|
|
4
|
+
SearchAppBackupsRequest,
|
|
5
|
+
} from "@budibase/types"
|
|
6
|
+
import { BaseAPIClient } from "./types"
|
|
7
|
+
|
|
8
|
+
export interface BackupEndpoints {
|
|
9
|
+
createManualBackup: (appId: string) => Promise<CreateAppBackupResponse>
|
|
10
|
+
restoreBackup: (
|
|
11
|
+
appId: string,
|
|
12
|
+
backupId: string,
|
|
13
|
+
name?: string
|
|
14
|
+
) => Promise<ImportAppBackupResponse>
|
|
15
|
+
|
|
16
|
+
// Missing request or response types
|
|
17
|
+
searchBackups: (appId: string, opts: SearchAppBackupsRequest) => Promise<any>
|
|
18
|
+
deleteBackup: (
|
|
19
|
+
appId: string,
|
|
20
|
+
backupId: string
|
|
21
|
+
) => Promise<{ message: string }>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const buildBackupEndpoints = (API: BaseAPIClient): BackupEndpoints => ({
|
|
25
|
+
createManualBackup: async appId => {
|
|
26
|
+
return await API.post({
|
|
27
|
+
url: `/api/apps/${appId}/backups`,
|
|
28
|
+
})
|
|
29
|
+
},
|
|
30
|
+
searchBackups: async (appId, opts) => {
|
|
31
|
+
return await API.post({
|
|
32
|
+
url: `/api/apps/${appId}/backups/search`,
|
|
33
|
+
body: opts,
|
|
34
|
+
})
|
|
35
|
+
},
|
|
36
|
+
deleteBackup: async (appId, backupId) => {
|
|
37
|
+
return await API.delete({
|
|
38
|
+
url: `/api/apps/${appId}/backups/${backupId}`,
|
|
39
|
+
})
|
|
40
|
+
},
|
|
41
|
+
restoreBackup: async (appId, backupId, name) => {
|
|
42
|
+
return await API.post({
|
|
43
|
+
url: `/api/apps/${appId}/backups/${backupId}/import`,
|
|
44
|
+
// Name is a legacy thing, but unsure if it is needed for restoring.
|
|
45
|
+
// Leaving this in just in case, but not type casting the body here
|
|
46
|
+
// as we won't normally have it, but it's required in the type.
|
|
47
|
+
body: { name },
|
|
48
|
+
})
|
|
49
|
+
},
|
|
50
|
+
})
|