@budibase/frontend-core 3.42.0 → 3.44.0

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@budibase/frontend-core",
3
- "version": "v3.42.0",
3
+ "version": "v3.44.0",
4
4
  "description": "Budibase frontend core libraries used in builder and client",
5
5
  "author": "Budibase",
6
6
  "license": "MPL-2.0",
@@ -23,5 +23,5 @@
23
23
  "devDependencies": {
24
24
  "vitest": "^4.1.0"
25
25
  },
26
- "gitHead": "180c04c6852aa7acf0402d53dc909eab764d0251"
26
+ "gitHead": "3b4b472084bfed7fdf0b083c5a7390ce0a3eebda"
27
27
  }
package/src/api/agents.ts CHANGED
@@ -13,12 +13,8 @@ import {
13
13
  FetchAgentsResponse,
14
14
  ProvisionAgentSlackChannelRequest,
15
15
  ProvisionAgentSlackChannelResponse,
16
- ProvisionAgentTelegramChannelRequest,
17
- ProvisionAgentTelegramChannelResponse,
18
16
  ProvisionAgentMSTeamsChannelRequest,
19
17
  ProvisionAgentMSTeamsChannelResponse,
20
- SyncAgentDiscordCommandsRequest,
21
- SyncAgentDiscordCommandsResponse,
22
18
  SyncAgentKnowledgeSourcesRequest,
23
19
  SyncAgentKnowledgeSourcesResponse,
24
20
  ToggleAgentDeploymentRequest,
@@ -31,12 +27,14 @@ import {
31
27
  CreateAgentOperationRequest,
32
28
  UpdateAgentOperationRequest,
33
29
  AgentOperationMutationResponse,
30
+ CreateAgentSlackAppRequest,
31
+ CreateAgentSlackAppResponse,
34
32
  } from "@budibase/types"
35
33
 
36
34
  import { BaseAPIClient } from "./types"
37
35
 
38
36
  export interface AgentEndpoints {
39
- fetchTools: (aiconfigId?: string) => Promise<ToolMetadata[]>
37
+ fetchTools: () => Promise<ToolMetadata[]>
40
38
  fetchAgents: () => Promise<FetchAgentsResponse>
41
39
  fetchAgentKnowledge: (
42
40
  agentId: string
@@ -58,26 +56,20 @@ export interface AgentEndpoints {
58
56
  ) => Promise<AgentOperationMutationResponse>
59
57
  duplicateAgent: (agentId: string) => Promise<DuplicateAgentResponse>
60
58
  deleteAgent: (agentId: string) => Promise<{ deleted: true }>
61
- syncAgentDiscordCommands: (
62
- agentId: string,
63
- body?: SyncAgentDiscordCommandsRequest
64
- ) => Promise<SyncAgentDiscordCommandsResponse>
65
59
  provisionAgentMSTeamsChannel: (
66
60
  agentId: string,
67
61
  body?: ProvisionAgentMSTeamsChannelRequest
68
62
  ) => Promise<ProvisionAgentMSTeamsChannelResponse>
63
+ downloadAgentMSTeamsPackage: (agentId: string) => Promise<Response>
69
64
  provisionAgentSlackChannel: (
70
65
  agentId: string,
71
66
  body?: ProvisionAgentSlackChannelRequest
72
67
  ) => Promise<ProvisionAgentSlackChannelResponse>
73
- provisionAgentTelegramChannel: (
74
- agentId: string,
75
- body?: ProvisionAgentTelegramChannelRequest
76
- ) => Promise<ProvisionAgentTelegramChannelResponse>
77
- toggleAgentDiscordDeployment: (
68
+ downloadAgentSlackManifest: (agentId: string) => Promise<string>
69
+ createAgentSlackApp: (
78
70
  agentId: string,
79
- enabled: boolean
80
- ) => Promise<ToggleAgentDeploymentResponse>
71
+ body?: CreateAgentSlackAppRequest
72
+ ) => Promise<CreateAgentSlackAppResponse>
81
73
  toggleAgentMSTeamsDeployment: (
82
74
  agentId: string,
83
75
  enabled: boolean
@@ -86,10 +78,6 @@ export interface AgentEndpoints {
86
78
  agentId: string,
87
79
  enabled: boolean
88
80
  ) => Promise<ToggleAgentDeploymentResponse>
89
- toggleAgentTelegramDeployment: (
90
- agentId: string,
91
- enabled: boolean
92
- ) => Promise<ToggleAgentDeploymentResponse>
93
81
  uploadOperationFile: (
94
82
  agentId: string,
95
83
  operationId: string,
@@ -147,12 +135,9 @@ export interface AgentEndpoints {
147
135
  }
148
136
 
149
137
  export const buildAgentEndpoints = (API: BaseAPIClient): AgentEndpoints => ({
150
- fetchTools: async (aiconfigId?: string) => {
151
- const query = aiconfigId
152
- ? `?aiconfigId=${encodeURIComponent(aiconfigId)}`
153
- : ""
138
+ fetchTools: async () => {
154
139
  return await API.get({
155
- url: `/api/agent/tools${query}`,
140
+ url: "/api/agent/tools",
156
141
  })
157
142
  },
158
143
  fetchAgents: async () => {
@@ -213,16 +198,6 @@ export const buildAgentEndpoints = (API: BaseAPIClient): AgentEndpoints => ({
213
198
  })
214
199
  },
215
200
 
216
- syncAgentDiscordCommands: async (agentId: string, body) => {
217
- return await API.post<
218
- SyncAgentDiscordCommandsRequest | undefined,
219
- SyncAgentDiscordCommandsResponse
220
- >({
221
- url: `/api/agent/${agentId}/discord/sync`,
222
- body,
223
- })
224
- },
225
-
226
201
  provisionAgentMSTeamsChannel: async (agentId: string, body) => {
227
202
  return await API.post<
228
203
  ProvisionAgentMSTeamsChannelRequest | undefined,
@@ -233,6 +208,13 @@ export const buildAgentEndpoints = (API: BaseAPIClient): AgentEndpoints => ({
233
208
  })
234
209
  },
235
210
 
211
+ downloadAgentMSTeamsPackage: async (agentId: string) => {
212
+ return await API.get<Response>({
213
+ url: `/api/agent/${agentId}/ms-teams/package`,
214
+ parseResponse: response => response,
215
+ })
216
+ },
217
+
236
218
  provisionAgentSlackChannel: async (agentId: string, body) => {
237
219
  return await API.post<
238
220
  ProvisionAgentSlackChannelRequest | undefined,
@@ -243,23 +225,20 @@ export const buildAgentEndpoints = (API: BaseAPIClient): AgentEndpoints => ({
243
225
  })
244
226
  },
245
227
 
246
- provisionAgentTelegramChannel: async (agentId: string, body) => {
247
- return await API.post<
248
- ProvisionAgentTelegramChannelRequest | undefined,
249
- ProvisionAgentTelegramChannelResponse
250
- >({
251
- url: `/api/agent/${agentId}/telegram/provision`,
252
- body,
228
+ downloadAgentSlackManifest: async (agentId: string) => {
229
+ return await API.get<string>({
230
+ url: `/api/agent/${agentId}/slack/manifest`,
231
+ parseResponse: async response => await response.text(),
253
232
  })
254
233
  },
255
234
 
256
- toggleAgentDiscordDeployment: async (agentId: string, enabled: boolean) => {
235
+ createAgentSlackApp: async (agentId: string, body) => {
257
236
  return await API.post<
258
- ToggleAgentDeploymentRequest,
259
- ToggleAgentDeploymentResponse
237
+ CreateAgentSlackAppRequest | undefined,
238
+ CreateAgentSlackAppResponse
260
239
  >({
261
- url: `/api/agent/${agentId}/discord/toggle`,
262
- body: { enabled },
240
+ url: `/api/agent/${agentId}/slack/app/create`,
241
+ body,
263
242
  })
264
243
  },
265
244
 
@@ -283,16 +262,6 @@ export const buildAgentEndpoints = (API: BaseAPIClient): AgentEndpoints => ({
283
262
  })
284
263
  },
285
264
 
286
- toggleAgentTelegramDeployment: async (agentId: string, enabled: boolean) => {
287
- return await API.post<
288
- ToggleAgentDeploymentRequest,
289
- ToggleAgentDeploymentResponse
290
- >({
291
- url: `/api/agent/${agentId}/telegram/toggle`,
292
- body: { enabled },
293
- })
294
- },
295
-
296
265
  uploadOperationFile: async (
297
266
  agentId: string,
298
267
  operationId: string,
package/src/api/ai.ts CHANGED
@@ -5,6 +5,8 @@ import {
5
5
  GenerateJsResponse,
6
6
  GenerateTablesRequest,
7
7
  GenerateTablesResponse,
8
+ SaveSlackAppConfigRequest,
9
+ SlackAppConfigResponse,
8
10
  } from "@budibase/types"
9
11
  import { BaseAPIClient } from "./types"
10
12
 
@@ -49,6 +51,11 @@ export interface AIEndpoints {
49
51
  req: GenerateTablesRequest,
50
52
  onProgress?: (message: string) => void
51
53
  ) => Promise<GenerateTablesResponse>
54
+ fetchSlackAppConfig: () => Promise<SlackAppConfigResponse>
55
+ saveSlackAppConfig: (
56
+ req: SaveSlackAppConfigRequest
57
+ ) => Promise<SlackAppConfigResponse>
58
+ deleteSlackAppConfig: () => Promise<SlackAppConfigResponse>
52
59
  }
53
60
 
54
61
  export const buildAIEndpoints = (API: BaseAPIClient): AIEndpoints => ({
@@ -129,4 +136,23 @@ export const buildAIEndpoints = (API: BaseAPIClient): AIEndpoints => ({
129
136
  },
130
137
  })
131
138
  },
139
+
140
+ fetchSlackAppConfig: async () => {
141
+ return await API.get({
142
+ url: "/api/ai/slack/app-config",
143
+ })
144
+ },
145
+
146
+ saveSlackAppConfig: async req => {
147
+ return await API.put({
148
+ url: "/api/ai/slack/app-config",
149
+ body: req,
150
+ })
151
+ },
152
+
153
+ deleteSlackAppConfig: async () => {
154
+ return await API.delete({
155
+ url: "/api/ai/slack/app-config",
156
+ })
157
+ },
132
158
  })
@@ -16,13 +16,27 @@ export interface MSTeamsChannel {
16
16
  teamName: string
17
17
  }
18
18
 
19
+ // Cursor is an opaque provider token - callers only act on hasNext and echo
20
+ // the cursor back verbatim.
21
+ export interface PagedChannels<T> {
22
+ channels: T[]
23
+ hasNext: boolean
24
+ cursor?: string
25
+ }
26
+
19
27
  export interface ChatLinksEndpoints {
20
28
  fetchChatIdentityLinks: (
21
29
  provider?: ChatIdentityLinkProvider,
22
30
  agentId?: string
23
31
  ) => Promise<ChatIdentityLink[]>
24
- fetchSlackChannels: (agentId: string) => Promise<SlackChannel[]>
25
- fetchMSTeamsChannels: (agentId: string) => Promise<MSTeamsChannel[]>
32
+ fetchSlackChannels: (
33
+ agentId: string,
34
+ cursor?: string
35
+ ) => Promise<PagedChannels<SlackChannel>>
36
+ fetchMSTeamsChannels: (
37
+ agentId: string,
38
+ cursor?: string
39
+ ) => Promise<PagedChannels<MSTeamsChannel>>
26
40
  }
27
41
 
28
42
  export const buildChatLinksEndpoints = (
@@ -36,12 +50,18 @@ export const buildChatLinksEndpoints = (
36
50
  const query = params ? `?${params}` : ""
37
51
  return await API.get({ url: `/api/chat-links${query}` })
38
52
  },
39
- fetchSlackChannels: async agentId => {
40
- const query = new URLSearchParams({ agentId }).toString()
53
+ fetchSlackChannels: async (agentId, cursor) => {
54
+ const query = new URLSearchParams({
55
+ agentId,
56
+ ...(cursor ? { cursor } : {}),
57
+ }).toString()
41
58
  return await API.get({ url: `/api/slack-channels?${query}` })
42
59
  },
43
- fetchMSTeamsChannels: async agentId => {
44
- const query = new URLSearchParams({ agentId }).toString()
60
+ fetchMSTeamsChannels: async (agentId, cursor) => {
61
+ const query = new URLSearchParams({
62
+ agentId,
63
+ ...(cursor ? { cursor } : {}),
64
+ }).toString()
45
65
  return await API.get({ url: `/api/teams-channels?${query}` })
46
66
  },
47
67
  })
@@ -10,7 +10,10 @@ export interface EscalationEndpoints {
10
10
  fetchEscalationContext: (
11
11
  escalationId: string
12
12
  ) => Promise<EscalationContextDoc>
13
- fetchEscalationResult: (escalationId: string) => Promise<EscalationResult>
13
+ fetchEscalationResult: (
14
+ escalationId: string,
15
+ signal?: AbortSignal
16
+ ) => Promise<EscalationResult>
14
17
  resolveEscalation: (
15
18
  escalationId: string,
16
19
  response: EscalationResponse
@@ -26,9 +29,10 @@ export const buildEscalationEndpoints = (
26
29
  })
27
30
  },
28
31
 
29
- fetchEscalationResult: async escalationId => {
32
+ fetchEscalationResult: async (escalationId, signal) => {
30
33
  return await API.get({
31
34
  url: `/api/escalations/${escalationId}/result`,
35
+ signal,
32
36
  })
33
37
  },
34
38
 
package/src/api/index.ts CHANGED
@@ -51,13 +51,13 @@ import { buildAgentEndpoints } from "./agents"
51
51
  import { buildAgentTestEndpoints } from "./agentTests"
52
52
  import { buildAgentLogEndpoints } from "./agentLogs"
53
53
  import { buildAgentRequestEndpoints } from "./agentRequests"
54
- import { buildChatAppEndpoints } from "./chatApps"
55
54
  import { buildEscalationEndpoints } from "./escalations"
56
55
  import { buildChatLinksEndpoints } from "./chatLinks"
57
56
  import { buildFeatureFlagEndpoints } from "./features"
58
57
  import { buildNavigationEndpoints } from "./navigation"
59
58
  import { buildWorkspaceAppEndpoints } from "./workspaceApps"
60
59
  import { buildResourceEndpoints } from "./resource"
60
+ import { buildRestTemplateEndpoints } from "./restTemplates"
61
61
  import { buildDeploymentEndpoints } from "./deploy"
62
62
  import { buildWorkspaceFavouriteEndpoints } from "./workspaceFavourites"
63
63
  import { buildWorkspaceHomeEndpoints } from "./workspaceHome"
@@ -145,8 +145,16 @@ export const createAPIClient = (config: APIClientConfig = {}): APIClient => {
145
145
  const makeApiCall = async <RequestT = null, ResponseT = void>(
146
146
  callConfig: APICallConfig<RequestT, ResponseT>
147
147
  ): Promise<ResponseT> => {
148
- let { json, method, external, body, url, parseResponse, suppressErrors } =
149
- callConfig
148
+ let {
149
+ json,
150
+ method,
151
+ external,
152
+ body,
153
+ url,
154
+ parseResponse,
155
+ suppressErrors,
156
+ signal,
157
+ } = callConfig
150
158
 
151
159
  // Ensure we don't do JSON processing if sending a GET request
152
160
  json = json && method !== HTTPMethod.GET
@@ -182,9 +190,13 @@ export const createAPIClient = (config: APIClientConfig = {}): APIClient => {
182
190
  headers,
183
191
  body: requestBody,
184
192
  credentials: "same-origin",
193
+ signal,
185
194
  })
186
195
  } catch (error) {
187
196
  delete cache[url]
197
+ if (signal?.aborted) {
198
+ throw error
199
+ }
188
200
  throw makeError("Failed to send request", url, method)
189
201
  }
190
202
 
@@ -260,7 +272,7 @@ export const createAPIClient = (config: APIClientConfig = {}): APIClient => {
260
272
  const handler = cacheRequest ? makeCachedApiCall : makeApiCall
261
273
  return await handler(callConfig)
262
274
  } catch (error) {
263
- if (config?.onError) {
275
+ if (config?.onError && !params.signal?.aborted) {
264
276
  config.onError(error as APIError)
265
277
  }
266
278
  throw error
@@ -309,6 +321,7 @@ export const createAPIClient = (config: APIClientConfig = {}): APIClient => {
309
321
  ...buildScreenEndpoints(API),
310
322
  ...buildTableEndpoints(API),
311
323
  ...buildTemplateEndpoints(API),
324
+ ...buildRestTemplateEndpoints(API),
312
325
  ...buildUserEndpoints(API),
313
326
  ...buildViewEndpoints(API),
314
327
  ...buildSelfEndpoints(API),
@@ -325,7 +338,6 @@ export const createAPIClient = (config: APIClientConfig = {}): APIClient => {
325
338
  ...buildAgentTestEndpoints(API),
326
339
  ...buildAgentLogEndpoints(API),
327
340
  ...buildAgentRequestEndpoints(API),
328
- ...buildChatAppEndpoints(API),
329
341
  ...buildEscalationEndpoints(API),
330
342
  ...buildChatLinksEndpoints(API),
331
343
  ...buildFeatureFlagEndpoints(API),
@@ -0,0 +1,74 @@
1
+ import type {
2
+ CustomRestTemplateId,
3
+ DeleteCustomRestTemplateResponse,
4
+ FetchCustomRestTemplatesResponse,
5
+ UpdateCustomRestTemplateResponse,
6
+ UploadCustomRestTemplateResponse,
7
+ } from "@budibase/types"
8
+ import type { BaseAPIClient } from "./types"
9
+
10
+ interface UploadCustomRestTemplateParams {
11
+ name: string
12
+ description: string
13
+ file: File
14
+ }
15
+
16
+ interface UpdateCustomRestTemplateParams {
17
+ restTemplateId: CustomRestTemplateId
18
+ name: string
19
+ description: string
20
+ }
21
+
22
+ export interface RestTemplateEndpoints {
23
+ getCustomRestTemplates: () => Promise<FetchCustomRestTemplatesResponse>
24
+ uploadCustomRestTemplate: (
25
+ params: UploadCustomRestTemplateParams
26
+ ) => Promise<UploadCustomRestTemplateResponse>
27
+ updateCustomRestTemplate: (
28
+ params: UpdateCustomRestTemplateParams
29
+ ) => Promise<UpdateCustomRestTemplateResponse>
30
+ deleteCustomRestTemplate: (
31
+ restTemplateId: CustomRestTemplateId
32
+ ) => Promise<DeleteCustomRestTemplateResponse>
33
+ }
34
+
35
+ export const buildRestTemplateEndpoints = (
36
+ API: BaseAPIClient
37
+ ): RestTemplateEndpoints => ({
38
+ getCustomRestTemplates: async () => {
39
+ return await API.get({
40
+ url: "/api/rest-templates",
41
+ })
42
+ },
43
+
44
+ uploadCustomRestTemplate: async ({ name, description, file }) => {
45
+ const body = new FormData()
46
+ body.append("name", name)
47
+ body.append("description", description)
48
+ body.append("file", file)
49
+
50
+ return await API.post<FormData, UploadCustomRestTemplateResponse>({
51
+ url: "/api/rest-templates",
52
+ body,
53
+ json: false,
54
+ })
55
+ },
56
+
57
+ updateCustomRestTemplate: async ({ restTemplateId, name, description }) => {
58
+ const body = new FormData()
59
+ body.append("name", name)
60
+ body.append("description", description)
61
+
62
+ return await API.put<FormData, UpdateCustomRestTemplateResponse>({
63
+ url: `/api/rest-templates/${encodeURIComponent(restTemplateId)}`,
64
+ body,
65
+ json: false,
66
+ })
67
+ },
68
+
69
+ deleteCustomRestTemplate: async restTemplateId => {
70
+ return await API.delete({
71
+ url: `/api/rest-templates/${encodeURIComponent(restTemplateId)}`,
72
+ })
73
+ },
74
+ })
package/src/api/types.ts CHANGED
@@ -39,12 +39,12 @@ import { AgentEndpoints } from "./agents"
39
39
  import { AgentTestEndpoints } from "./agentTests"
40
40
  import { AgentLogEndpoints } from "./agentLogs"
41
41
  import { AgentRequestEndpoints } from "./agentRequests"
42
- import { ChatAppEndpoints } from "./chatApps"
43
42
  import { ChatLinksEndpoints } from "./chatLinks"
44
43
  import { EscalationEndpoints } from "./escalations"
45
44
  import { NavigationEndpoints } from "./navigation"
46
45
  import { WorkspaceAppEndpoints } from "./workspaceApps"
47
46
  import { ResourceEndpoints } from "./resource"
47
+ import { RestTemplateEndpoints } from "./restTemplates"
48
48
  import { DeploymentEndpoints } from "./deploy"
49
49
  import { WorkspaceFavouriteEndpoints } from "./workspaceFavourites"
50
50
  import { WorkspaceHomeEndpoints } from "./workspaceHome"
@@ -79,6 +79,7 @@ export type APICallConfig<RequestT, ResponseT> = {
79
79
  suppressErrors: boolean
80
80
  cache: boolean
81
81
  body?: RequestT
82
+ signal?: AbortSignal
82
83
  parseResponse?: (response: Response) => Promise<ResponseT> | ResponseT
83
84
  }
84
85
 
@@ -127,7 +128,6 @@ export type APIClient = BaseAPIClient &
127
128
  AgentTestEndpoints &
128
129
  AgentLogEndpoints &
129
130
  AgentRequestEndpoints &
130
- ChatAppEndpoints &
131
131
  ChatLinksEndpoints &
132
132
  EscalationEndpoints &
133
133
  AnalyticsEndpoints &
@@ -159,6 +159,7 @@ export type APIClient = BaseAPIClient &
159
159
  SelfEndpoints &
160
160
  TableEndpoints &
161
161
  TemplateEndpoints &
162
+ RestTemplateEndpoints &
162
163
  UserEndpoints &
163
164
  FeatureFlagEndpoints &
164
165
  ViewEndpoints & {