@budibase/frontend-core 3.34.5 → 3.34.7

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": "3.34.5",
3
+ "version": "3.34.7",
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": "^3.2.4"
25
25
  },
26
- "gitHead": "3cd6b13566b94f609768435eba58baec699ce040"
26
+ "gitHead": "0842f52bf3b8700529e56800ef866175e2850e19"
27
27
  }
package/src/api/ai.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import {
2
+ GenerateAgentInstructionsRequest,
3
+ GenerateAgentInstructionsResponse,
2
4
  GenerateJsRequest,
3
5
  GenerateJsResponse,
4
6
  GenerateTablesRequest,
@@ -38,6 +40,9 @@ const parseSSEEventChunk = (chunk: string): TablesStreamEvent | null => {
38
40
  }
39
41
 
40
42
  export interface AIEndpoints {
43
+ generateAgentInstructions: (
44
+ req: GenerateAgentInstructionsRequest
45
+ ) => Promise<GenerateAgentInstructionsResponse>
41
46
  generateCronExpression: (prompt: string) => Promise<{ message: string }>
42
47
  generateJs: (req: GenerateJsRequest) => Promise<GenerateJsResponse>
43
48
  generateTables: (
@@ -47,6 +52,13 @@ export interface AIEndpoints {
47
52
  }
48
53
 
49
54
  export const buildAIEndpoints = (API: BaseAPIClient): AIEndpoints => ({
55
+ generateAgentInstructions: async req => {
56
+ return await API.post({
57
+ url: "/api/ai/agent-instructions",
58
+ body: req,
59
+ })
60
+ },
61
+
50
62
  /**
51
63
  * Generates a cron expression from a prompt
52
64
  */
@@ -1,4 +1,5 @@
1
1
  import { writable, derived, get, Writable, Readable } from "svelte/store"
2
+ import { sessionBannerStore } from "../../../stores/sessionBanner"
2
3
  import { DataFetch, DataFetchDefinition, fetchData } from "../../../fetch"
3
4
  import { NewRowID, RowPageSize } from "../lib/constants"
4
5
  import {
@@ -10,6 +11,7 @@ import {
10
11
  import { tick } from "svelte"
11
12
  import { Helpers } from "@budibase/bbui"
12
13
  import { sleep } from "../../../utils/utils"
14
+ import { redirectToLoginWithReturnUrl } from "../../../utils/login"
13
15
  import { FieldType, Row, UIRow } from "@budibase/types"
14
16
  import { getRelatedTableValues } from "../../../utils"
15
17
  import { Store as StoreContext } from "."
@@ -265,6 +267,17 @@ export const createActions = (context: StoreContext): RowActionStore => {
265
267
  const fetchStore = newFetch as unknown as Readable<GridFetchSnapshot>
266
268
  unsubscribe = fetchStore.subscribe(async $fetch => {
267
269
  if ($fetch.error) {
270
+ if ($fetch.error.status === 401 || $fetch.error.status === 403) {
271
+ sessionBannerStore.set({
272
+ text: "Session not authenticated",
273
+ variant: "session-not-authenticated",
274
+ action: {
275
+ label: "Log in",
276
+ onClick: () => redirectToLoginWithReturnUrl(),
277
+ },
278
+ })
279
+ }
280
+
268
281
  // Present a helpful error to the user
269
282
  let message = "An unknown error occurred"
270
283
  if ($fetch.error.status === 403) {
package/src/constants.ts CHANGED
@@ -86,6 +86,7 @@ export const PlanType = {
86
86
  TEAM: "team",
87
87
  PRO: "pro",
88
88
  BUSINESS: "business",
89
+ BUSINESS_PLUS: "business_plus",
89
90
  PREMIUM: "premium",
90
91
  PREMIUM_PLUS: "premium_plus",
91
92
  PREMIUM_PLUS_TRIAL: "premium_plus_trial",
@@ -1,3 +1,4 @@
1
1
  export { createLocalStorageStore } from "./localStorage"
2
2
  export { createSessionStorageStore } from "./sessionStorage"
3
3
  export { gridClipboard } from "./gridClipboard"
4
+ export { sessionBannerStore } from "./sessionBanner"
@@ -0,0 +1,17 @@
1
+ import { writable } from "svelte/store"
2
+
3
+ interface SessionBannerAction {
4
+ label: string
5
+ onClick: () => void
6
+ }
7
+
8
+ interface SessionBanner {
9
+ text: string
10
+ variant?: "session-not-authenticated"
11
+ background?: string
12
+ textColor?: string
13
+ textSize?: number
14
+ action?: SessionBannerAction
15
+ }
16
+
17
+ export const sessionBannerStore = writable<SessionBanner | null>(null)
@@ -1,7 +1,17 @@
1
1
  import { MAX_SESSIONS_PER_USER } from "@budibase/shared-core"
2
+ import * as Constants from "../constants"
3
+ import * as CookieUtils from "./cookies"
2
4
 
3
5
  const SESSIONS_INVALIDATED_KEY = "bb-sessions-invalidated"
4
6
 
7
+ export function redirectToLoginWithReturnUrl(returnUrl?: string) {
8
+ const resolvedReturnUrl =
9
+ returnUrl ??
10
+ `${window.location.pathname}${window.location.search}${window.location.hash}`
11
+ CookieUtils.setCookie(Constants.Cookies.ReturnUrl, resolvedReturnUrl)
12
+ window.location.href = "/builder/auth/login"
13
+ }
14
+
5
15
  // export function checkIfSessionsInvalidatedAndNotify() {
6
16
  export function popNumSessionsInvalidated() {
7
17
  const invalidatedCount = parseInt(