@budibase/frontend-core 3.2.29 → 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
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HTTPMethod,
|
|
3
|
+
APICallParams,
|
|
4
|
+
APIClientConfig,
|
|
5
|
+
APIClient,
|
|
6
|
+
APICallConfig,
|
|
7
|
+
BaseAPIClient,
|
|
8
|
+
Headers,
|
|
9
|
+
APIError,
|
|
10
|
+
} from "./types"
|
|
1
11
|
import { Helpers } from "@budibase/bbui"
|
|
2
12
|
import { Header } from "@budibase/shared-core"
|
|
3
13
|
import { ApiVersion } from "../constants"
|
|
@@ -10,7 +20,6 @@ import { buildAutomationEndpoints } from "./automations"
|
|
|
10
20
|
import { buildConfigEndpoints } from "./configs"
|
|
11
21
|
import { buildDatasourceEndpoints } from "./datasources"
|
|
12
22
|
import { buildFlagEndpoints } from "./flags"
|
|
13
|
-
import { buildHostingEndpoints } from "./hosting"
|
|
14
23
|
import { buildLayoutEndpoints } from "./layouts"
|
|
15
24
|
import { buildOtherEndpoints } from "./other"
|
|
16
25
|
import { buildPermissionsEndpoints } from "./permissions"
|
|
@@ -29,10 +38,10 @@ import { buildViewV2Endpoints } from "./viewsV2"
|
|
|
29
38
|
import { buildLicensingEndpoints } from "./licensing"
|
|
30
39
|
import { buildGroupsEndpoints } from "./groups"
|
|
31
40
|
import { buildPluginEndpoints } from "./plugins"
|
|
32
|
-
import {
|
|
41
|
+
import { buildBackupEndpoints } from "./backups"
|
|
33
42
|
import { buildEnvironmentVariableEndpoints } from "./environmentVariables"
|
|
34
43
|
import { buildEventEndpoints } from "./events"
|
|
35
|
-
import {
|
|
44
|
+
import { buildAuditLogEndpoints } from "./auditLogs"
|
|
36
45
|
import { buildLogsEndpoints } from "./logs"
|
|
37
46
|
import { buildMigrationEndpoints } from "./migrations"
|
|
38
47
|
import { buildRowActionEndpoints } from "./rowActions"
|
|
@@ -45,55 +54,21 @@ import { buildRowActionEndpoints } from "./rowActions"
|
|
|
45
54
|
*/
|
|
46
55
|
export const APISessionID = Helpers.uuid()
|
|
47
56
|
|
|
48
|
-
const defaultAPIClientConfig = {
|
|
49
|
-
/**
|
|
50
|
-
* Certain definitions can't change at runtime for client apps, such as the
|
|
51
|
-
* schema of tables. The endpoints that are cacheable can be cached by passing
|
|
52
|
-
* in this flag. It's disabled by default to avoid bugs with stale data.
|
|
53
|
-
*/
|
|
54
|
-
enableCaching: false,
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* A function can be passed in to attach headers to all outgoing requests.
|
|
58
|
-
* This function is passed in the headers object, which should be directly
|
|
59
|
-
* mutated. No return value is required.
|
|
60
|
-
*/
|
|
61
|
-
attachHeaders: null,
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* A function can be passed in which will be invoked any time an API error
|
|
65
|
-
* occurs. An error is defined as a status code >= 400. This function is
|
|
66
|
-
* invoked before the actual JS error is thrown up the stack.
|
|
67
|
-
*/
|
|
68
|
-
onError: null,
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* A function can be passed to be called when an API call returns info about a migration running for a specific app
|
|
72
|
-
*/
|
|
73
|
-
onMigrationDetected: null,
|
|
74
|
-
}
|
|
75
|
-
|
|
76
57
|
/**
|
|
77
58
|
* Constructs an API client with the provided configuration.
|
|
78
|
-
* @param config the API client configuration
|
|
79
|
-
* @return {object} the API client
|
|
80
59
|
*/
|
|
81
|
-
export const createAPIClient = config => {
|
|
82
|
-
|
|
83
|
-
...defaultAPIClientConfig,
|
|
84
|
-
...config,
|
|
85
|
-
}
|
|
86
|
-
let cache = {}
|
|
60
|
+
export const createAPIClient = (config: APIClientConfig = {}): APIClient => {
|
|
61
|
+
let cache: Record<string, any> = {}
|
|
87
62
|
|
|
88
63
|
// Generates an error object from an API response
|
|
89
64
|
const makeErrorFromResponse = async (
|
|
90
|
-
response,
|
|
91
|
-
method,
|
|
65
|
+
response: Response,
|
|
66
|
+
method: HTTPMethod,
|
|
92
67
|
suppressErrors = false
|
|
93
|
-
) => {
|
|
68
|
+
): Promise<APIError> => {
|
|
94
69
|
// Try to read a message from the error
|
|
95
70
|
let message = response.statusText
|
|
96
|
-
let json = null
|
|
71
|
+
let json: any = null
|
|
97
72
|
try {
|
|
98
73
|
json = await response.json()
|
|
99
74
|
if (json?.message) {
|
|
@@ -116,32 +91,34 @@ export const createAPIClient = config => {
|
|
|
116
91
|
}
|
|
117
92
|
|
|
118
93
|
// Generates an error object from a string
|
|
119
|
-
const makeError = (
|
|
94
|
+
const makeError = (
|
|
95
|
+
message: string,
|
|
96
|
+
url?: string,
|
|
97
|
+
method?: HTTPMethod
|
|
98
|
+
): APIError => {
|
|
120
99
|
return {
|
|
121
100
|
message,
|
|
122
101
|
json: null,
|
|
123
102
|
status: 400,
|
|
124
|
-
url:
|
|
125
|
-
method:
|
|
103
|
+
url: url,
|
|
104
|
+
method: method,
|
|
126
105
|
handled: true,
|
|
106
|
+
suppressErrors: false,
|
|
127
107
|
}
|
|
128
108
|
}
|
|
129
109
|
|
|
130
110
|
// Performs an API call to the server.
|
|
131
|
-
const makeApiCall = async (
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
body,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
parseResponse,
|
|
138
|
-
suppressErrors = false,
|
|
139
|
-
}) => {
|
|
111
|
+
const makeApiCall = async <RequestT = null, ResponseT = void>(
|
|
112
|
+
callConfig: APICallConfig<RequestT, ResponseT>
|
|
113
|
+
): Promise<ResponseT> => {
|
|
114
|
+
let { json, method, external, body, url, parseResponse, suppressErrors } =
|
|
115
|
+
callConfig
|
|
116
|
+
|
|
140
117
|
// Ensure we don't do JSON processing if sending a GET request
|
|
141
|
-
json = json && method !==
|
|
118
|
+
json = json && method !== HTTPMethod.GET
|
|
142
119
|
|
|
143
120
|
// Build headers
|
|
144
|
-
let headers = { Accept: "application/json" }
|
|
121
|
+
let headers: Headers = { Accept: "application/json" }
|
|
145
122
|
headers[Header.SESSION_ID] = APISessionID
|
|
146
123
|
if (!external) {
|
|
147
124
|
headers[Header.API_VER] = ApiVersion
|
|
@@ -154,17 +131,17 @@ export const createAPIClient = config => {
|
|
|
154
131
|
}
|
|
155
132
|
|
|
156
133
|
// Build request body
|
|
157
|
-
let requestBody = body
|
|
134
|
+
let requestBody: any = body
|
|
158
135
|
if (json) {
|
|
159
136
|
try {
|
|
160
137
|
requestBody = JSON.stringify(body)
|
|
161
138
|
} catch (error) {
|
|
162
|
-
throw makeError("Invalid JSON body",
|
|
139
|
+
throw makeError("Invalid JSON body", url, method)
|
|
163
140
|
}
|
|
164
141
|
}
|
|
165
142
|
|
|
166
143
|
// Make request
|
|
167
|
-
let response
|
|
144
|
+
let response: Response
|
|
168
145
|
try {
|
|
169
146
|
response = await fetch(url, {
|
|
170
147
|
method,
|
|
@@ -174,21 +151,23 @@ export const createAPIClient = config => {
|
|
|
174
151
|
})
|
|
175
152
|
} catch (error) {
|
|
176
153
|
delete cache[url]
|
|
177
|
-
throw makeError("Failed to send request",
|
|
154
|
+
throw makeError("Failed to send request", url, method)
|
|
178
155
|
}
|
|
179
156
|
|
|
180
157
|
// Handle response
|
|
181
158
|
if (response.status >= 200 && response.status < 400) {
|
|
182
159
|
handleMigrations(response)
|
|
183
160
|
try {
|
|
184
|
-
if (
|
|
161
|
+
if (response.status === 204) {
|
|
162
|
+
return undefined as ResponseT
|
|
163
|
+
} else if (parseResponse) {
|
|
185
164
|
return await parseResponse(response)
|
|
186
165
|
} else {
|
|
187
|
-
return await response.json()
|
|
166
|
+
return (await response.json()) as ResponseT
|
|
188
167
|
}
|
|
189
168
|
} catch (error) {
|
|
190
169
|
delete cache[url]
|
|
191
|
-
|
|
170
|
+
throw `Failed to parse response: ${error}`
|
|
192
171
|
}
|
|
193
172
|
} else {
|
|
194
173
|
delete cache[url]
|
|
@@ -196,7 +175,7 @@ export const createAPIClient = config => {
|
|
|
196
175
|
}
|
|
197
176
|
}
|
|
198
177
|
|
|
199
|
-
const handleMigrations = response => {
|
|
178
|
+
const handleMigrations = (response: Response) => {
|
|
200
179
|
if (!config.onMigrationDetected) {
|
|
201
180
|
return
|
|
202
181
|
}
|
|
@@ -210,48 +189,57 @@ export const createAPIClient = config => {
|
|
|
210
189
|
// Performs an API call to the server and caches the response.
|
|
211
190
|
// Future invocation for this URL will return the cached result instead of
|
|
212
191
|
// hitting the server again.
|
|
213
|
-
const makeCachedApiCall = async
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
192
|
+
const makeCachedApiCall = async <RequestT = null, ResponseT = void>(
|
|
193
|
+
callConfig: APICallConfig<RequestT, ResponseT>
|
|
194
|
+
): Promise<ResponseT> => {
|
|
195
|
+
const identifier = callConfig.url
|
|
218
196
|
if (!cache[identifier]) {
|
|
219
|
-
cache[identifier] = makeApiCall(
|
|
197
|
+
cache[identifier] = makeApiCall(callConfig)
|
|
220
198
|
cache[identifier] = await cache[identifier]
|
|
221
199
|
}
|
|
222
|
-
return await cache[identifier]
|
|
200
|
+
return (await cache[identifier]) as ResponseT
|
|
223
201
|
}
|
|
224
202
|
|
|
225
203
|
// Constructs an API call function for a particular HTTP method
|
|
226
|
-
const requestApiCall =
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
204
|
+
const requestApiCall =
|
|
205
|
+
(method: HTTPMethod) =>
|
|
206
|
+
async <RequestT = null, ResponseT = void>(
|
|
207
|
+
params: APICallParams<RequestT, ResponseT>
|
|
208
|
+
): Promise<ResponseT> => {
|
|
209
|
+
try {
|
|
210
|
+
let callConfig: APICallConfig<RequestT, ResponseT> = {
|
|
211
|
+
json: true,
|
|
212
|
+
external: false,
|
|
213
|
+
suppressErrors: false,
|
|
214
|
+
cache: false,
|
|
215
|
+
method,
|
|
216
|
+
...params,
|
|
217
|
+
}
|
|
218
|
+
let { url, cache, external } = callConfig
|
|
219
|
+
if (!external) {
|
|
220
|
+
callConfig.url = `/${url}`.replace("//", "/")
|
|
221
|
+
}
|
|
236
222
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
223
|
+
// Cache the request if possible and desired
|
|
224
|
+
const cacheRequest = cache && config?.enableCaching
|
|
225
|
+
const handler = cacheRequest ? makeCachedApiCall : makeApiCall
|
|
226
|
+
return await handler(callConfig)
|
|
227
|
+
} catch (error) {
|
|
228
|
+
if (config?.onError) {
|
|
229
|
+
config.onError(error)
|
|
230
|
+
}
|
|
231
|
+
throw error
|
|
242
232
|
}
|
|
243
|
-
throw error
|
|
244
233
|
}
|
|
245
|
-
}
|
|
246
234
|
|
|
247
235
|
// Build the underlying core API methods
|
|
248
|
-
let API = {
|
|
249
|
-
post: requestApiCall(
|
|
250
|
-
get: requestApiCall(
|
|
251
|
-
patch: requestApiCall(
|
|
252
|
-
delete: requestApiCall(
|
|
253
|
-
put: requestApiCall(
|
|
254
|
-
error: message => {
|
|
236
|
+
let API: BaseAPIClient = {
|
|
237
|
+
post: requestApiCall(HTTPMethod.POST),
|
|
238
|
+
get: requestApiCall(HTTPMethod.GET),
|
|
239
|
+
patch: requestApiCall(HTTPMethod.PATCH),
|
|
240
|
+
delete: requestApiCall(HTTPMethod.DELETE),
|
|
241
|
+
put: requestApiCall(HTTPMethod.PUT),
|
|
242
|
+
error: (message: string) => {
|
|
255
243
|
throw makeError(message)
|
|
256
244
|
},
|
|
257
245
|
invalidateCache: () => {
|
|
@@ -260,9 +248,9 @@ export const createAPIClient = config => {
|
|
|
260
248
|
|
|
261
249
|
// Generic utility to extract the current app ID. Assumes that any client
|
|
262
250
|
// that exists in an app context will be attaching our app ID header.
|
|
263
|
-
getAppID: () => {
|
|
264
|
-
let headers = {}
|
|
265
|
-
config?.attachHeaders(headers)
|
|
251
|
+
getAppID: (): string => {
|
|
252
|
+
let headers: Headers = {}
|
|
253
|
+
config?.attachHeaders?.(headers)
|
|
266
254
|
return headers?.[Header.APP_ID]
|
|
267
255
|
},
|
|
268
256
|
}
|
|
@@ -279,7 +267,6 @@ export const createAPIClient = config => {
|
|
|
279
267
|
...buildConfigEndpoints(API),
|
|
280
268
|
...buildDatasourceEndpoints(API),
|
|
281
269
|
...buildFlagEndpoints(API),
|
|
282
|
-
...buildHostingEndpoints(API),
|
|
283
270
|
...buildLayoutEndpoints(API),
|
|
284
271
|
...buildOtherEndpoints(API),
|
|
285
272
|
...buildPermissionsEndpoints(API),
|
|
@@ -297,10 +284,10 @@ export const createAPIClient = config => {
|
|
|
297
284
|
...buildLicensingEndpoints(API),
|
|
298
285
|
...buildGroupsEndpoints(API),
|
|
299
286
|
...buildPluginEndpoints(API),
|
|
300
|
-
...
|
|
287
|
+
...buildBackupEndpoints(API),
|
|
301
288
|
...buildEnvironmentVariableEndpoints(API),
|
|
302
289
|
...buildEventEndpoints(API),
|
|
303
|
-
...
|
|
290
|
+
...buildAuditLogEndpoints(API),
|
|
304
291
|
...buildLogsEndpoints(API),
|
|
305
292
|
...buildMigrationEndpoints(API),
|
|
306
293
|
viewV2: buildViewV2Endpoints(API),
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DeleteLayoutResponse,
|
|
3
|
+
SaveLayoutRequest,
|
|
4
|
+
SaveLayoutResponse,
|
|
5
|
+
} from "@budibase/types"
|
|
6
|
+
import { BaseAPIClient } from "./types"
|
|
7
|
+
|
|
8
|
+
export interface LayoutEndpoints {
|
|
9
|
+
saveLayout: (layout: SaveLayoutRequest) => Promise<SaveLayoutResponse>
|
|
10
|
+
deleteLayout: (id: string, rev: string) => Promise<DeleteLayoutResponse>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const buildLayoutEndpoints = (API: BaseAPIClient): LayoutEndpoints => ({
|
|
14
|
+
/**
|
|
15
|
+
* Saves a layout.
|
|
16
|
+
* @param layout the layout to save
|
|
17
|
+
*/
|
|
18
|
+
saveLayout: async layout => {
|
|
19
|
+
return await API.post({
|
|
20
|
+
url: "/api/layouts",
|
|
21
|
+
body: layout,
|
|
22
|
+
})
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Deletes a layout.
|
|
27
|
+
* @param layoutId the ID of the layout to delete
|
|
28
|
+
* @param layoutRev the rev of the layout to delete
|
|
29
|
+
*/
|
|
30
|
+
deleteLayout: async (id: string, rev: string) => {
|
|
31
|
+
return await API.delete({
|
|
32
|
+
url: `/api/layouts/${id}/${rev}`,
|
|
33
|
+
})
|
|
34
|
+
},
|
|
35
|
+
})
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ActivateLicenseKeyRequest,
|
|
3
|
+
ActivateLicenseKeyResponse,
|
|
4
|
+
ActivateOfflineLicenseTokenRequest,
|
|
5
|
+
ActivateOfflineLicenseTokenResponse,
|
|
6
|
+
GetLicenseKeyResponse,
|
|
7
|
+
GetOfflineIdentifierResponse,
|
|
8
|
+
GetOfflineLicenseTokenResponse,
|
|
9
|
+
QuotaUsage,
|
|
10
|
+
RefreshOfflineLicenseResponse,
|
|
11
|
+
} from "@budibase/types"
|
|
12
|
+
import { BaseAPIClient } from "./types"
|
|
13
|
+
|
|
14
|
+
export interface LicensingEndpoints {
|
|
15
|
+
activateLicenseKey: (
|
|
16
|
+
licenseKey: string
|
|
17
|
+
) => Promise<ActivateLicenseKeyResponse>
|
|
18
|
+
deleteLicenseKey: () => Promise<void>
|
|
19
|
+
getLicenseKey: () => Promise<GetLicenseKeyResponse | void>
|
|
20
|
+
activateOfflineLicense: (
|
|
21
|
+
offlineLicenseToken: string
|
|
22
|
+
) => Promise<ActivateOfflineLicenseTokenResponse>
|
|
23
|
+
deleteOfflineLicense: () => Promise<void>
|
|
24
|
+
getOfflineLicense: () => Promise<GetOfflineLicenseTokenResponse | void>
|
|
25
|
+
getOfflineLicenseIdentifier: () => Promise<GetOfflineIdentifierResponse>
|
|
26
|
+
refreshLicense: () => Promise<RefreshOfflineLicenseResponse>
|
|
27
|
+
getQuotaUsage: () => Promise<QuotaUsage>
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const buildLicensingEndpoints = (
|
|
31
|
+
API: BaseAPIClient
|
|
32
|
+
): LicensingEndpoints => ({
|
|
33
|
+
// LICENSE KEY
|
|
34
|
+
activateLicenseKey: async licenseKey => {
|
|
35
|
+
return API.post<ActivateLicenseKeyRequest, ActivateLicenseKeyResponse>({
|
|
36
|
+
url: `/api/global/license/key`,
|
|
37
|
+
body: { licenseKey },
|
|
38
|
+
})
|
|
39
|
+
},
|
|
40
|
+
deleteLicenseKey: async () => {
|
|
41
|
+
return API.delete({
|
|
42
|
+
url: `/api/global/license/key`,
|
|
43
|
+
})
|
|
44
|
+
},
|
|
45
|
+
getLicenseKey: async () => {
|
|
46
|
+
try {
|
|
47
|
+
return await API.get({
|
|
48
|
+
url: "/api/global/license/key",
|
|
49
|
+
})
|
|
50
|
+
} catch (e: any) {
|
|
51
|
+
if (e.status !== 404) {
|
|
52
|
+
throw e
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
// OFFLINE LICENSE
|
|
58
|
+
activateOfflineLicense: async offlineLicenseToken => {
|
|
59
|
+
return API.post<
|
|
60
|
+
ActivateOfflineLicenseTokenRequest,
|
|
61
|
+
ActivateOfflineLicenseTokenResponse
|
|
62
|
+
>({
|
|
63
|
+
url: "/api/global/license/offline",
|
|
64
|
+
body: {
|
|
65
|
+
offlineLicenseToken,
|
|
66
|
+
},
|
|
67
|
+
})
|
|
68
|
+
},
|
|
69
|
+
deleteOfflineLicense: async () => {
|
|
70
|
+
return API.delete({
|
|
71
|
+
url: "/api/global/license/offline",
|
|
72
|
+
})
|
|
73
|
+
},
|
|
74
|
+
getOfflineLicense: async () => {
|
|
75
|
+
try {
|
|
76
|
+
return await API.get({
|
|
77
|
+
url: "/api/global/license/offline",
|
|
78
|
+
})
|
|
79
|
+
} catch (e: any) {
|
|
80
|
+
if (e.status !== 404) {
|
|
81
|
+
throw e
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
getOfflineLicenseIdentifier: async () => {
|
|
86
|
+
return await API.get({
|
|
87
|
+
url: "/api/global/license/offline/identifier",
|
|
88
|
+
})
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Refreshes the license cache
|
|
93
|
+
*/
|
|
94
|
+
refreshLicense: async () => {
|
|
95
|
+
return API.post({
|
|
96
|
+
url: "/api/global/license/refresh",
|
|
97
|
+
})
|
|
98
|
+
},
|
|
99
|
+
/**
|
|
100
|
+
* Retrieve the usage information for the tenant
|
|
101
|
+
*/
|
|
102
|
+
getQuotaUsage: async () => {
|
|
103
|
+
return API.get({
|
|
104
|
+
url: "/api/global/license/usage",
|
|
105
|
+
})
|
|
106
|
+
},
|
|
107
|
+
})
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { BaseAPIClient } from "./types"
|
|
2
|
+
|
|
3
|
+
export interface LogEndpoints {
|
|
4
|
+
getSystemLogs: () => Promise<any>
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const buildLogsEndpoints = (API: BaseAPIClient): LogEndpoints => ({
|
|
2
8
|
/**
|
|
3
9
|
* Gets a stream for the system logs.
|
|
4
10
|
*/
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { GetOldMigrationStatus } from "@budibase/types"
|
|
2
|
+
import { BaseAPIClient } from "./types"
|
|
3
|
+
|
|
4
|
+
export interface MigrationEndpoints {
|
|
5
|
+
getMigrationStatus: () => Promise<GetOldMigrationStatus>
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const buildMigrationEndpoints = (
|
|
9
|
+
API: BaseAPIClient
|
|
10
|
+
): MigrationEndpoints => ({
|
|
11
|
+
/**
|
|
12
|
+
* Gets the info about the current app migration
|
|
13
|
+
*/
|
|
14
|
+
getMigrationStatus: async () => {
|
|
15
|
+
return await API.get({
|
|
16
|
+
url: "/api/migrations/status",
|
|
17
|
+
})
|
|
18
|
+
},
|
|
19
|
+
})
|
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
FetchBuiltinPermissionsResponse,
|
|
3
|
+
FetchIntegrationsResponse,
|
|
4
|
+
GetEnvironmentResponse,
|
|
5
|
+
GetVersionResponse,
|
|
6
|
+
SystemStatusResponse,
|
|
7
|
+
} from "@budibase/types"
|
|
8
|
+
import { BaseAPIClient } from "./types"
|
|
9
|
+
|
|
10
|
+
export interface OtherEndpoints {
|
|
11
|
+
getSystemStatus: () => Promise<SystemStatusResponse>
|
|
12
|
+
getBudibaseVersion: () => Promise<string>
|
|
13
|
+
getIntegrations: () => Promise<FetchIntegrationsResponse>
|
|
14
|
+
getBasePermissions: () => Promise<FetchBuiltinPermissionsResponse>
|
|
15
|
+
getEnvironment: () => Promise<GetEnvironmentResponse>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const buildOtherEndpoints = (API: BaseAPIClient): OtherEndpoints => ({
|
|
2
19
|
/**
|
|
3
20
|
* Gets the current environment details.
|
|
4
21
|
*/
|
|
@@ -31,7 +48,7 @@ export const buildOtherEndpoints = API => ({
|
|
|
31
48
|
*/
|
|
32
49
|
getBudibaseVersion: async () => {
|
|
33
50
|
return (
|
|
34
|
-
await API.get({
|
|
51
|
+
await API.get<GetVersionResponse>({
|
|
35
52
|
url: "/api/dev/version",
|
|
36
53
|
})
|
|
37
54
|
).version
|
|
@@ -45,14 +62,4 @@ export const buildOtherEndpoints = API => ({
|
|
|
45
62
|
url: "/api/permission/builtin",
|
|
46
63
|
})
|
|
47
64
|
},
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Check if they are part of the budibase beta program.
|
|
51
|
-
*/
|
|
52
|
-
checkBetaAccess: async email => {
|
|
53
|
-
return await API.get({
|
|
54
|
-
url: `/api/beta/access?email=${email}`,
|
|
55
|
-
external: true,
|
|
56
|
-
})
|
|
57
|
-
},
|
|
58
65
|
})
|
|
@@ -1,4 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
AddPermissionResponse,
|
|
3
|
+
GetDependantResourcesResponse,
|
|
4
|
+
GetResourcePermsResponse,
|
|
5
|
+
PermissionLevel,
|
|
6
|
+
RemovePermissionResponse,
|
|
7
|
+
} from "@budibase/types"
|
|
8
|
+
import { BaseAPIClient } from "./types"
|
|
9
|
+
|
|
10
|
+
export interface PermissionEndpoints {
|
|
11
|
+
getPermissionForResource: (
|
|
12
|
+
resourceId: string
|
|
13
|
+
) => Promise<GetResourcePermsResponse>
|
|
14
|
+
updatePermissionForResource: (
|
|
15
|
+
resourceId: string,
|
|
16
|
+
roleId: string,
|
|
17
|
+
level: PermissionLevel
|
|
18
|
+
) => Promise<AddPermissionResponse>
|
|
19
|
+
removePermissionFromResource: (
|
|
20
|
+
resourceId: string,
|
|
21
|
+
roleId: string,
|
|
22
|
+
level: PermissionLevel
|
|
23
|
+
) => Promise<RemovePermissionResponse>
|
|
24
|
+
getDependants: (resourceId: string) => Promise<GetDependantResourcesResponse>
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const buildPermissionsEndpoints = (
|
|
28
|
+
API: BaseAPIClient
|
|
29
|
+
): PermissionEndpoints => ({
|
|
2
30
|
/**
|
|
3
31
|
* Gets the permission required to access a specific resource
|
|
4
32
|
* @param resourceId the resource ID to check
|
|
@@ -14,9 +42,8 @@ export const buildPermissionsEndpoints = API => ({
|
|
|
14
42
|
* @param resourceId the ID of the resource to update
|
|
15
43
|
* @param roleId the ID of the role to update the permissions of
|
|
16
44
|
* @param level the level to assign the role for this resource
|
|
17
|
-
* @return {Promise<*>}
|
|
18
45
|
*/
|
|
19
|
-
updatePermissionForResource: async (
|
|
46
|
+
updatePermissionForResource: async (resourceId, roleId, level) => {
|
|
20
47
|
return await API.post({
|
|
21
48
|
url: `/api/permission/${roleId}/${resourceId}/${level}`,
|
|
22
49
|
})
|
|
@@ -27,9 +54,8 @@ export const buildPermissionsEndpoints = API => ({
|
|
|
27
54
|
* @param resourceId the ID of the resource to update
|
|
28
55
|
* @param roleId the ID of the role to update the permissions of
|
|
29
56
|
* @param level the level to remove the role for this resource
|
|
30
|
-
* @return {Promise<*>}
|
|
31
57
|
*/
|
|
32
|
-
removePermissionFromResource: async (
|
|
58
|
+
removePermissionFromResource: async (resourceId, roleId, level) => {
|
|
33
59
|
return await API.delete({
|
|
34
60
|
url: `/api/permission/${roleId}/${resourceId}/${level}`,
|
|
35
61
|
})
|
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
CreatePluginRequest,
|
|
3
|
+
CreatePluginResponse,
|
|
4
|
+
DeletePluginResponse,
|
|
5
|
+
FetchPluginResponse,
|
|
6
|
+
UploadPluginRequest,
|
|
7
|
+
UploadPluginResponse,
|
|
8
|
+
} from "@budibase/types"
|
|
9
|
+
import { BaseAPIClient } from "./types"
|
|
10
|
+
|
|
11
|
+
export interface PluginEndpoins {
|
|
12
|
+
uploadPlugin: (data: UploadPluginRequest) => Promise<UploadPluginResponse>
|
|
13
|
+
createPlugin: (data: CreatePluginRequest) => Promise<CreatePluginResponse>
|
|
14
|
+
getPlugins: () => Promise<FetchPluginResponse>
|
|
15
|
+
deletePlugin: (pluginId: string) => Promise<DeletePluginResponse>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const buildPluginEndpoints = (API: BaseAPIClient): PluginEndpoins => ({
|
|
2
19
|
/**
|
|
3
20
|
* Uploads a plugin tarball bundle
|
|
4
21
|
* @param data the plugin tarball bundle to upload
|