From 30c942c852e17ed03b51c758641e2aaeda239eac Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 14 Jan 2025 10:45:08 +0100 Subject: [PATCH 01/53] Type options --- packages/frontend-core/src/fetch/DataFetch.ts | 27 +++++++++++-------- packages/frontend-core/src/fetch/index.ts | 10 ++++++- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/packages/frontend-core/src/fetch/DataFetch.ts b/packages/frontend-core/src/fetch/DataFetch.ts index b10a8b0a69..ad8a632480 100644 --- a/packages/frontend-core/src/fetch/DataFetch.ts +++ b/packages/frontend-core/src/fetch/DataFetch.ts @@ -51,7 +51,19 @@ export interface DataFetchParams< API: APIClient datasource: TDatasource query: TQuery - options?: {} + options?: Partial> +} + +export interface DataFetchOptions { + // Search config + filter: UISearchFilter | LegacyFilter[] | null + query: TQuery + // Sorting config + sortColumn: string | null + sortOrder: SortOrder + // Pagination config + limit: number + paginate: boolean } /** @@ -73,18 +85,11 @@ export default abstract class DataFetch< supportsSort: boolean supportsPagination: boolean } - options: { + options: DataFetchOptions & { datasource: TDatasource - limit: number - // Search config - filter: UISearchFilter | LegacyFilter[] | null - query: TQuery - // Sorting config - sortColumn: string | null - sortOrder: SortOrder + sortType: SortType | null - // Pagination config - paginate: boolean + // Client side feature customisation clientSideSearching: boolean clientSideSorting: boolean diff --git a/packages/frontend-core/src/fetch/index.ts b/packages/frontend-core/src/fetch/index.ts index d80aa10df6..4b9de01dae 100644 --- a/packages/frontend-core/src/fetch/index.ts +++ b/packages/frontend-core/src/fetch/index.ts @@ -32,7 +32,15 @@ export const DataFetchMap = { } // Constructs a new fetch model for a certain datasource -export const fetchData = ({ API, datasource, options }: any) => { +export const fetchData = ({ + API, + datasource, + options, +}: { + API: APIClient + datasource: TDatasource + options: any +}) => { const Fetch = DataFetchMap[datasource?.type as DataFetchType] || TableFetch const fetch = new Fetch({ API, datasource, ...options }) From c1981aaa29d537e55980837983a1dbfe2c5021f7 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 14 Jan 2025 10:48:50 +0100 Subject: [PATCH 02/53] Rename DataFetch to BaseDataFetch --- packages/frontend-core/src/fetch/CustomFetch.ts | 4 ++-- packages/frontend-core/src/fetch/DataFetch.ts | 2 +- packages/frontend-core/src/fetch/FieldFetch.ts | 4 ++-- packages/frontend-core/src/fetch/GroupUserFetch.ts | 4 ++-- packages/frontend-core/src/fetch/NestedProviderFetch.ts | 4 ++-- packages/frontend-core/src/fetch/QueryFetch.ts | 4 ++-- packages/frontend-core/src/fetch/RelationshipFetch.ts | 4 ++-- packages/frontend-core/src/fetch/TableFetch.ts | 4 ++-- packages/frontend-core/src/fetch/UserFetch.ts | 4 ++-- packages/frontend-core/src/fetch/ViewFetch.ts | 4 ++-- packages/frontend-core/src/fetch/ViewV2Fetch.ts | 4 ++-- 11 files changed, 21 insertions(+), 21 deletions(-) diff --git a/packages/frontend-core/src/fetch/CustomFetch.ts b/packages/frontend-core/src/fetch/CustomFetch.ts index dfd29c4a02..60ce1f50ec 100644 --- a/packages/frontend-core/src/fetch/CustomFetch.ts +++ b/packages/frontend-core/src/fetch/CustomFetch.ts @@ -1,4 +1,4 @@ -import DataFetch from "./DataFetch" +import BaseDataFetch from "./DataFetch" interface CustomDatasource { type: "custom" @@ -7,7 +7,7 @@ interface CustomDatasource { type CustomDefinition = Record -export default class CustomFetch extends DataFetch< +export default class CustomFetch extends BaseDataFetch< CustomDatasource, CustomDefinition > { diff --git a/packages/frontend-core/src/fetch/DataFetch.ts b/packages/frontend-core/src/fetch/DataFetch.ts index ad8a632480..75c454e2ac 100644 --- a/packages/frontend-core/src/fetch/DataFetch.ts +++ b/packages/frontend-core/src/fetch/DataFetch.ts @@ -71,7 +71,7 @@ export interface DataFetchOptions { * internal table or datasource plus. * For other types of datasource, this class is overridden and extended. */ -export default abstract class DataFetch< +export default abstract class BaseDataFetch< TDatasource extends { type: DataFetchType }, TDefinition extends { schema?: Record | null diff --git a/packages/frontend-core/src/fetch/FieldFetch.ts b/packages/frontend-core/src/fetch/FieldFetch.ts index 694443a5dc..5cc903d87e 100644 --- a/packages/frontend-core/src/fetch/FieldFetch.ts +++ b/packages/frontend-core/src/fetch/FieldFetch.ts @@ -1,5 +1,5 @@ import { Row } from "@budibase/types" -import DataFetch from "./DataFetch" +import BaseDataFetch from "./DataFetch" type Types = "field" | "queryarray" | "jsonarray" @@ -18,7 +18,7 @@ function isArrayOfStrings(value: string[] | Row[]): value is string[] { return Array.isArray(value) && !!value[0] && typeof value[0] !== "object" } -export default class FieldFetch extends DataFetch< +export default class FieldFetch extends BaseDataFetch< FieldDatasource, FieldDefinition > { diff --git a/packages/frontend-core/src/fetch/GroupUserFetch.ts b/packages/frontend-core/src/fetch/GroupUserFetch.ts index e07e5331d4..f3fdcf5ebb 100644 --- a/packages/frontend-core/src/fetch/GroupUserFetch.ts +++ b/packages/frontend-core/src/fetch/GroupUserFetch.ts @@ -1,5 +1,5 @@ import { get } from "svelte/store" -import DataFetch, { DataFetchParams } from "./DataFetch" +import BaseDataFetch, { DataFetchParams } from "./DataFetch" import { TableNames } from "../constants" interface GroupUserQuery { @@ -12,7 +12,7 @@ interface GroupUserDatasource { tableId: TableNames.USERS } -export default class GroupUserFetch extends DataFetch< +export default class GroupUserFetch extends BaseDataFetch< GroupUserDatasource, {}, GroupUserQuery diff --git a/packages/frontend-core/src/fetch/NestedProviderFetch.ts b/packages/frontend-core/src/fetch/NestedProviderFetch.ts index af121fcef8..b4274e690f 100644 --- a/packages/frontend-core/src/fetch/NestedProviderFetch.ts +++ b/packages/frontend-core/src/fetch/NestedProviderFetch.ts @@ -1,5 +1,5 @@ import { Row, TableSchema } from "@budibase/types" -import DataFetch from "./DataFetch" +import BaseDataFetch from "./DataFetch" interface NestedProviderDatasource { type: "provider" @@ -14,7 +14,7 @@ interface NestedProviderDefinition { schema?: TableSchema primaryDisplay?: string } -export default class NestedProviderFetch extends DataFetch< +export default class NestedProviderFetch extends BaseDataFetch< NestedProviderDatasource, NestedProviderDefinition > { diff --git a/packages/frontend-core/src/fetch/QueryFetch.ts b/packages/frontend-core/src/fetch/QueryFetch.ts index 09dde86cbd..179deb1a66 100644 --- a/packages/frontend-core/src/fetch/QueryFetch.ts +++ b/packages/frontend-core/src/fetch/QueryFetch.ts @@ -1,4 +1,4 @@ -import DataFetch from "./DataFetch" +import BaseDataFetch from "./DataFetch" import { Helpers } from "@budibase/bbui" import { ExecuteQueryRequest, Query } from "@budibase/types" import { get } from "svelte/store" @@ -17,7 +17,7 @@ interface QueryDatasource { parameters: { name: string; default: string }[] } -export default class QueryFetch extends DataFetch { +export default class QueryFetch extends BaseDataFetch { async determineFeatureFlags() { const definition = await this.getDefinition() const supportsPagination = diff --git a/packages/frontend-core/src/fetch/RelationshipFetch.ts b/packages/frontend-core/src/fetch/RelationshipFetch.ts index 89a85ab0e4..c84c38e77c 100644 --- a/packages/frontend-core/src/fetch/RelationshipFetch.ts +++ b/packages/frontend-core/src/fetch/RelationshipFetch.ts @@ -1,5 +1,5 @@ import { Table } from "@budibase/types" -import DataFetch from "./DataFetch" +import BaseDataFetch from "./DataFetch" interface RelationshipDatasource { type: "link" @@ -9,7 +9,7 @@ interface RelationshipDatasource { fieldName: string } -export default class RelationshipFetch extends DataFetch< +export default class RelationshipFetch extends BaseDataFetch< RelationshipDatasource, Table > { diff --git a/packages/frontend-core/src/fetch/TableFetch.ts b/packages/frontend-core/src/fetch/TableFetch.ts index 67cac6b6a7..c39c9341fc 100644 --- a/packages/frontend-core/src/fetch/TableFetch.ts +++ b/packages/frontend-core/src/fetch/TableFetch.ts @@ -1,5 +1,5 @@ import { get } from "svelte/store" -import DataFetch from "./DataFetch" +import BaseDataFetch from "./DataFetch" import { SortOrder, Table } from "@budibase/types" interface TableDatasource { @@ -7,7 +7,7 @@ interface TableDatasource { tableId: string } -export default class TableFetch extends DataFetch { +export default class TableFetch extends BaseDataFetch { async determineFeatureFlags() { return { supportsSearch: true, diff --git a/packages/frontend-core/src/fetch/UserFetch.ts b/packages/frontend-core/src/fetch/UserFetch.ts index 36aebac506..2632337d64 100644 --- a/packages/frontend-core/src/fetch/UserFetch.ts +++ b/packages/frontend-core/src/fetch/UserFetch.ts @@ -1,5 +1,5 @@ import { get } from "svelte/store" -import DataFetch, { DataFetchParams } from "./DataFetch" +import BaseDataFetch, { DataFetchParams } from "./DataFetch" import { TableNames } from "../constants" import { utils } from "@budibase/shared-core" import { SearchFilters, SearchUsersRequest } from "@budibase/types" @@ -16,7 +16,7 @@ interface UserDatasource { interface UserDefinition {} -export default class UserFetch extends DataFetch< +export default class UserFetch extends BaseDataFetch< UserDatasource, UserDefinition, UserFetchQuery diff --git a/packages/frontend-core/src/fetch/ViewFetch.ts b/packages/frontend-core/src/fetch/ViewFetch.ts index df00b9bbfc..219f17ee2c 100644 --- a/packages/frontend-core/src/fetch/ViewFetch.ts +++ b/packages/frontend-core/src/fetch/ViewFetch.ts @@ -1,5 +1,5 @@ import { Table } from "@budibase/types" -import DataFetch from "./DataFetch" +import BaseDataFetch from "./DataFetch" type ViewV1Datasource = { type: "view" @@ -10,7 +10,7 @@ type ViewV1Datasource = { groupBy: string } -export default class ViewFetch extends DataFetch { +export default class ViewFetch extends BaseDataFetch { async getDefinition() { const { datasource } = this.options diff --git a/packages/frontend-core/src/fetch/ViewV2Fetch.ts b/packages/frontend-core/src/fetch/ViewV2Fetch.ts index aa5fbd60a2..029047c5fb 100644 --- a/packages/frontend-core/src/fetch/ViewV2Fetch.ts +++ b/packages/frontend-core/src/fetch/ViewV2Fetch.ts @@ -1,5 +1,5 @@ import { SortOrder, ViewV2Enriched, ViewV2Type } from "@budibase/types" -import DataFetch from "./DataFetch" +import BaseDataFetch from "./DataFetch" import { get } from "svelte/store" import { helpers } from "@budibase/shared-core" @@ -8,7 +8,7 @@ interface ViewDatasource { id: string } -export default class ViewV2Fetch extends DataFetch< +export default class ViewV2Fetch extends BaseDataFetch< ViewDatasource, ViewV2Enriched > { From 79039a1c30fe4a59a11fc8edaaf5f8aa1bfc5051 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 14 Jan 2025 10:52:08 +0100 Subject: [PATCH 03/53] Use union type --- .../src/components/grid/stores/rows.ts | 5 ++--- packages/frontend-core/src/fetch/index.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/frontend-core/src/components/grid/stores/rows.ts b/packages/frontend-core/src/components/grid/stores/rows.ts index 07fbf02134..159a01a86f 100644 --- a/packages/frontend-core/src/components/grid/stores/rows.ts +++ b/packages/frontend-core/src/components/grid/stores/rows.ts @@ -1,5 +1,5 @@ import { writable, derived, get, Writable, Readable } from "svelte/store" -import { fetchData } from "../../../fetch" +import { DataFetch, fetchData } from "../../../fetch" import { NewRowID, RowPageSize } from "../lib/constants" import { generateRowID, @@ -13,7 +13,6 @@ import { sleep } from "../../../utils/utils" import { FieldType, Row, UIRow } from "@budibase/types" import { getRelatedTableValues } from "../../../utils" import { Store as StoreContext } from "." -import DataFetch from "../../../fetch/DataFetch" interface IndexedUIRow extends UIRow { __idx: number @@ -21,7 +20,7 @@ interface IndexedUIRow extends UIRow { interface RowStore { rows: Writable - fetch: Writable | null> // TODO: type this properly, having a union of all the possible options + fetch: Writable loaded: Writable refreshing: Writable loading: Writable diff --git a/packages/frontend-core/src/fetch/index.ts b/packages/frontend-core/src/fetch/index.ts index 4b9de01dae..1c1d6671e6 100644 --- a/packages/frontend-core/src/fetch/index.ts +++ b/packages/frontend-core/src/fetch/index.ts @@ -31,6 +31,20 @@ export const DataFetchMap = { queryarray: QueryArrayFetch, } +export type DataFetch = + | TableFetch + | ViewFetch + | ViewV2Fetch + | QueryFetch + | RelationshipFetch + | UserFetch + | GroupUserFetch + | CustomFetch + | NestedProviderFetch + | FieldFetch<"field"> + | JSONArrayFetch + | QueryArrayFetch + // Constructs a new fetch model for a certain datasource export const fetchData = ({ API, From bd1a04ff1bcdb49c01b14b9ffa41353bd223f7d8 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 14 Jan 2025 11:01:41 +0100 Subject: [PATCH 04/53] Type UIDatasource --- packages/types/src/ui/stores/grid/datasource.ts | 2 +- packages/types/src/ui/stores/grid/table.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/types/src/ui/stores/grid/datasource.ts b/packages/types/src/ui/stores/grid/datasource.ts index 9927518133..f4210f6725 100644 --- a/packages/types/src/ui/stores/grid/datasource.ts +++ b/packages/types/src/ui/stores/grid/datasource.ts @@ -1,6 +1,6 @@ import { UITable, UIView } from "@budibase/types" -export type UIDatasource = UITable | UIView +export type UIDatasource = UITable | (Omit & { type: "viewV2" }) export interface UIFieldMutation { visible?: boolean diff --git a/packages/types/src/ui/stores/grid/table.ts b/packages/types/src/ui/stores/grid/table.ts index e69f9fd38f..7b6d659e4c 100644 --- a/packages/types/src/ui/stores/grid/table.ts +++ b/packages/types/src/ui/stores/grid/table.ts @@ -8,10 +8,9 @@ import { UISearchFilter, } from "@budibase/types" -export interface UITable extends Omit { +export interface UITable extends Table { name: string id: string - type: string tableId: string primaryDisplay?: string sort?: { From bcbf16a69b6b91c415bb6a4b8e0119d9f06e35a7 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 14 Jan 2025 11:25:26 +0100 Subject: [PATCH 05/53] Typing defititions --- .../src/components/grid/stores/datasource.ts | 34 +++++++++++++------ packages/frontend-core/src/fetch/index.ts | 9 +++++ 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/packages/frontend-core/src/components/grid/stores/datasource.ts b/packages/frontend-core/src/components/grid/stores/datasource.ts index 805ace5a8f..588f373152 100644 --- a/packages/frontend-core/src/components/grid/stores/datasource.ts +++ b/packages/frontend-core/src/components/grid/stores/datasource.ts @@ -1,7 +1,11 @@ // TODO: datasource and defitions are unions of the different implementations. At this point, the datasource does not know what type is being used, and the assignations will cause TS exceptions. Casting it "as any" for now. This should be fixed improving the type usages. import { derived, get, Readable, Writable } from "svelte/store" -import { getDatasourceDefinition, getDatasourceSchema } from "../../../fetch" +import { + DataFetchDefinition, + getDatasourceDefinition, + getDatasourceSchema, +} from "../../../fetch" import { enrichSchemaWithRelColumns, memo } from "../../../utils" import { cloneDeep } from "lodash" import { @@ -18,7 +22,7 @@ import { Store as StoreContext, BaseStoreProps } from "." import { DatasourceActions } from "./datasources" interface DatasourceStore { - definition: Writable + definition: Writable schemaMutations: Writable> subSchemaMutations: Writable>> } @@ -131,11 +135,17 @@ export const deriveStores = (context: StoreContext): DerivedDatasourceStore => { [datasource, definition], ([$datasource, $definition]) => { let type = $datasource?.type + // @ts-expect-error if (type === "provider") { type = ($datasource as any).value?.datasource?.type // TODO: see line 1 } // Handle calculation views - if (type === "viewV2" && $definition?.type === ViewV2Type.CALCULATION) { + if ( + type === "viewV2" && + $definition && + "type" in $definition && + $definition.type === ViewV2Type.CALCULATION + ) { return false } return !!type && ["table", "viewV2", "link"].includes(type) @@ -197,7 +207,7 @@ export const createActions = (context: StoreContext): ActionDatasourceStore => { ) => { // Update local state const originalDefinition = get(definition) - definition.set(newDefinition as UIDatasource) + definition.set(newDefinition) // Update server if (get(config).canSaveSchema) { @@ -225,13 +235,15 @@ export const createActions = (context: StoreContext): ActionDatasourceStore => { // Update primary display newDefinition.primaryDisplay = column - // Sanitise schema to ensure field is required and has no default value - if (!newDefinition.schema[column].constraints) { - newDefinition.schema[column].constraints = {} - } - newDefinition.schema[column].constraints.presence = { allowEmpty: false } - if ("default" in newDefinition.schema[column]) { - delete newDefinition.schema[column].default + if (newDefinition.schema) { + // Sanitise schema to ensure field is required and has no default value + if (!newDefinition.schema[column].constraints) { + newDefinition.schema[column].constraints = {} + } + newDefinition.schema[column].constraints.presence = { allowEmpty: false } + if ("default" in newDefinition.schema[column]) { + delete newDefinition.schema[column].default + } } return await saveDefinition(newDefinition as any) // TODO: see line 1 } diff --git a/packages/frontend-core/src/fetch/index.ts b/packages/frontend-core/src/fetch/index.ts index 1c1d6671e6..dee0c9dbf2 100644 --- a/packages/frontend-core/src/fetch/index.ts +++ b/packages/frontend-core/src/fetch/index.ts @@ -11,6 +11,7 @@ import GroupUserFetch from "./GroupUserFetch" import CustomFetch from "./CustomFetch" import QueryArrayFetch from "./QueryArrayFetch" import { APIClient } from "../api/types" +import { Table, ViewV2Enriched } from "@budibase/types" export type DataFetchType = keyof typeof DataFetchMap @@ -45,6 +46,14 @@ export type DataFetch = | JSONArrayFetch | QueryArrayFetch +export type DataFetchDefinition = + | Table + | ViewV2Enriched + | { + schema?: Record | null + primaryDisplay?: string + } + // Constructs a new fetch model for a certain datasource export const fetchData = ({ API, From 9f5f0d468e7b3c5d2f1769975aca28e6c2dfc47e Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 14 Jan 2025 11:26:37 +0100 Subject: [PATCH 06/53] Remove TODO --- packages/frontend-core/src/components/grid/stores/rows.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/frontend-core/src/components/grid/stores/rows.ts b/packages/frontend-core/src/components/grid/stores/rows.ts index 159a01a86f..7e58808327 100644 --- a/packages/frontend-core/src/components/grid/stores/rows.ts +++ b/packages/frontend-core/src/components/grid/stores/rows.ts @@ -253,7 +253,7 @@ export const createActions = (context: StoreContext): RowActionStore => { // Reset state properties when dataset changes if (!$instanceLoaded || resetRows) { - definition.set($fetch.definition as any) // TODO: datasource and defitions are unions of the different implementations. At this point, the datasource does not know what type is being used, and the assignations will cause TS exceptions. Casting it "as any" for now. This should be fixed improving the type usages. + definition.set($fetch.definition ?? null) } // Reset scroll state when data changes From 4afaa85b846453636c537fa301061255fed49ce7 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 14 Jan 2025 11:46:58 +0100 Subject: [PATCH 07/53] Types --- packages/client/src/{constants.js => constants.ts} | 0 packages/client/src/sdk.ts | 9 +++++++++ 2 files changed, 9 insertions(+) rename packages/client/src/{constants.js => constants.ts} (100%) create mode 100644 packages/client/src/sdk.ts diff --git a/packages/client/src/constants.js b/packages/client/src/constants.ts similarity index 100% rename from packages/client/src/constants.js rename to packages/client/src/constants.ts diff --git a/packages/client/src/sdk.ts b/packages/client/src/sdk.ts new file mode 100644 index 0000000000..8c9413fb37 --- /dev/null +++ b/packages/client/src/sdk.ts @@ -0,0 +1,9 @@ +import { APIClient } from "@budibase/frontend-core" +import type { ActionTypes } from "./constants" + +export interface SDK { + API: APIClient + styleable: unknown + Provider: unknown + ActionTypes: typeof ActionTypes +} From f1680f494197105c5034f404869979a2af77ac96 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 14 Jan 2025 11:47:46 +0100 Subject: [PATCH 08/53] Fix imports --- packages/client/src/stores/components.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/src/stores/components.js b/packages/client/src/stores/components.js index d4afa6c7f1..48ade99321 100644 --- a/packages/client/src/stores/components.js +++ b/packages/client/src/stores/components.js @@ -6,7 +6,7 @@ import { screenStore } from "./screens" import { builderStore } from "./builder" import Router from "../components/Router.svelte" import * as AppComponents from "../components/app/index.js" -import { ScreenslotType } from "../constants.js" +import { ScreenslotType } from "../constants" export const BudibasePrefix = "@budibase/standard-components/" From 85ab9e3ce3335f609c89630e1bb13a777b806677 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 14 Jan 2025 11:51:19 +0100 Subject: [PATCH 09/53] Type and export --- packages/frontend-core/src/fetch/DataFetch.ts | 2 +- packages/frontend-core/src/fetch/index.ts | 1 + packages/frontend-core/src/index.ts | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/frontend-core/src/fetch/DataFetch.ts b/packages/frontend-core/src/fetch/DataFetch.ts index 75c454e2ac..b82cac2d5e 100644 --- a/packages/frontend-core/src/fetch/DataFetch.ts +++ b/packages/frontend-core/src/fetch/DataFetch.ts @@ -435,7 +435,7 @@ export default abstract class BaseDataFetch< * Resets the data set and updates options * @param newOptions any new options */ - async update(newOptions: any) { + async update(newOptions: DataFetchOptions) { // Check if any settings have actually changed let refresh = false for (const [key, value] of Object.entries(newOptions || {})) { diff --git a/packages/frontend-core/src/fetch/index.ts b/packages/frontend-core/src/fetch/index.ts index dee0c9dbf2..2bb6e09000 100644 --- a/packages/frontend-core/src/fetch/index.ts +++ b/packages/frontend-core/src/fetch/index.ts @@ -14,6 +14,7 @@ import { APIClient } from "../api/types" import { Table, ViewV2Enriched } from "@budibase/types" export type DataFetchType = keyof typeof DataFetchMap +export type { DataFetchOptions } from "./DataFetch" export const DataFetchMap = { table: TableFetch, diff --git a/packages/frontend-core/src/index.ts b/packages/frontend-core/src/index.ts index fd5595e04d..11354be49d 100644 --- a/packages/frontend-core/src/index.ts +++ b/packages/frontend-core/src/index.ts @@ -1,7 +1,7 @@ export { createAPIClient } from "./api" export type { APIClient } from "./api" export { fetchData, DataFetchMap } from "./fetch" -export type { DataFetchType } from "./fetch" +export type { DataFetchType, DataFetchOptions } from "./fetch" export * as Constants from "./constants" export * from "./stores" export * from "./utils" From 7d284ae50e062d943c141d2fcf8279b8909dfeaf Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 14 Jan 2025 11:57:20 +0100 Subject: [PATCH 10/53] Type DataProvider --- .../src/components/app/DataProvider.svelte | 40 +++++++++++++------ packages/client/src/{sdk.ts => index.ts} | 5 +++ packages/frontend-core/src/fetch/DataFetch.ts | 2 +- 3 files changed, 34 insertions(+), 13 deletions(-) rename packages/client/src/{sdk.ts => index.ts} (70%) diff --git a/packages/client/src/components/app/DataProvider.svelte b/packages/client/src/components/app/DataProvider.svelte index e6629aa3f3..8b06190727 100644 --- a/packages/client/src/components/app/DataProvider.svelte +++ b/packages/client/src/components/app/DataProvider.svelte @@ -1,8 +1,18 @@ - diff --git a/packages/builder/src/components/common/CodeEditor/index.ts b/packages/builder/src/components/common/CodeEditor/index.ts index 0063cfc789..d2cbe8a23e 100644 --- a/packages/builder/src/components/common/CodeEditor/index.ts +++ b/packages/builder/src/components/common/CodeEditor/index.ts @@ -4,12 +4,13 @@ import { groupBy } from "lodash" import { BindingCompletion, BindingMode, + EditorModesMap, Helper, Snippet, } from "@budibase/types" import { CompletionContext } from "@codemirror/autocomplete" -export const EditorModes = { +export const EditorModes: EditorModesMap = { JS: { name: "javascript", json: false, diff --git a/packages/builder/src/components/common/bindings/BindingPanel.svelte b/packages/builder/src/components/common/bindings/BindingPanel.svelte index 29ddb6a1d0..6b9119f433 100644 --- a/packages/builder/src/components/common/bindings/BindingPanel.svelte +++ b/packages/builder/src/components/common/bindings/BindingPanel.svelte @@ -37,7 +37,9 @@ SidePanel, BindingCompletion, Snippet, + Helper, } from "@budibase/types" + import { CompletionContext } from "@codemirror/autocomplete" const dispatch = createEventDispatcher() @@ -53,8 +55,8 @@ export let placeholder = null export let showTabBar = true - let mode: BindingMode - let sidePanel: SidePanel + let mode: BindingMode | null + let sidePanel: SidePanel | null let initialValueJS = value?.startsWith?.("{{ js ") let jsValue = initialValueJS ? value : null let hbsValue = initialValueJS ? null : value @@ -109,19 +111,19 @@ snippets: Snippet[] | null, useSnippets?: boolean ) => { - const completions = [ + const completions: ((_: CompletionContext) => any)[] = [ jsAutocomplete([ ...bindingCompletions, ...getHelperCompletions(EditorModes.JS), ]), ] - if (useSnippets) { + if (useSnippets && snippets) { completions.push(snippetAutoComplete(snippets)) } return completions } - const getModeOptions = (allowHBS, allowJS) => { + const getModeOptions = (allowHBS: boolean, allowJS: boolean) => { let options = [] if (allowHBS) { options.push(BindingMode.Text) @@ -132,7 +134,12 @@ return options } - const getSidePanelOptions = (bindings, context, useSnippets, mode) => { + const getSidePanelOptions = ( + bindings: EnrichedBinding[], + context: any, + useSnippets: boolean, + mode: BindingMode | null + ) => { let options = [] if (bindings?.length) { options.push(SidePanel.Bindings) @@ -146,32 +153,39 @@ return options } - const debouncedEval = Utils.debounce((expression, context, snippets) => { - try { - expressionError = null - expressionResult = processStringSync( - expression || "", - { - ...context, - snippets, - }, - { - noThrow: false, - } - ) - } catch (err) { - expressionResult = null - expressionError = err - } - evaluating = false - }, 260) + const debouncedEval = Utils.debounce( + (expression: string | null, context: any, snippets: Snippet[]) => { + try { + expressionError = null + expressionResult = processStringSync( + expression || "", + { + ...context, + snippets, + }, + { + noThrow: false, + } + ) + } catch (err: any) { + expressionResult = null + expressionError = err + } + evaluating = false + }, + 260 + ) - const requestEval = (expression, context, snippets) => { + const requestEval = ( + expression: string | null, + context: any, + snippets: Snippet[] | null + ) => { evaluating = true debouncedEval(expression, context, snippets) } - const highlightJSON = json => { + const highlightJSON = (json: object | string) => { return JsonFormatter.format(json, { keyColor: "#e06c75", numberColor: "#e5c07b", @@ -182,7 +196,11 @@ }) } - const enrichBindings = (bindings, context, snippets) => { + const enrichBindings = ( + bindings: EnrichedBinding[], + context: any, + snippets: Snippet[] | null + ) => { // Create a single big array to enrich in one go const bindingStrings = bindings.map(binding => { if (binding.runtimeBinding.startsWith('trim "')) { @@ -193,17 +211,18 @@ return `{{ literal ${binding.runtimeBinding} }}` } }) - const bindingEvauations = processObjectSync(bindingStrings, { + const bindingEvaluations = processObjectSync(bindingStrings, { ...context, snippets, }) // Enrich bindings with evaluations and highlighted HTML return bindings.map((binding, idx) => { - if (!context) { + if (!context || typeof bindingEvaluations !== "object") { return binding } - const value = JSON.stringify(bindingEvauations[idx], null, 2) + const evalObj: Record = bindingEvaluations + const value = JSON.stringify(evalObj[idx], null, 2) return { ...binding, value, @@ -212,29 +231,38 @@ }) } - const updateValue = val => { + const updateValue = (val: any) => { const runtimeExpression = readableToRuntimeBinding(enrichedBindings, val) dispatch("change", val) requestEval(runtimeExpression, context, snippets) } - const onSelectHelper = (helper, js) => { - bindingHelpers.onSelectHelper(js ? jsValue : hbsValue, helper, { js }) + const onSelectHelper = (helper: Helper, js?: boolean) => { + bindingHelpers.onSelectHelper(js ? jsValue : hbsValue, helper, { + js, + dontDecode: undefined, + }) } - const onSelectBinding = (binding, { forceJS } = {}) => { + const onSelectBinding = ( + binding: EnrichedBinding, + { forceJS }: { forceJS?: boolean } = {} + ) => { const js = usingJS || forceJS - bindingHelpers.onSelectBinding(js ? jsValue : hbsValue, binding, { js }) + bindingHelpers.onSelectBinding(js ? jsValue : hbsValue, binding, { + js, + dontDecode: undefined, + }) } - const changeMode = newMode => { + const changeMode = (newMode: BindingMode) => { if (targetMode || newMode === mode) { return } // Get the raw editor value to see if we are abandoning changes let rawValue = editorValue - if (mode === BindingMode.JavaScript) { + if (mode === BindingMode.JavaScript && rawValue) { rawValue = decodeJSBinding(rawValue) } @@ -253,16 +281,16 @@ targetMode = null } - const changeSidePanel = newSidePanel => { + const changeSidePanel = (newSidePanel: SidePanel) => { sidePanel = newSidePanel === sidePanel ? null : newSidePanel } - const onChangeHBSValue = e => { + const onChangeHBSValue = (e: { detail: string }) => { hbsValue = e.detail updateValue(hbsValue) } - const onChangeJSValue = e => { + const onChangeJSValue = (e: { detail: string }) => { jsValue = encodeJSBinding(e.detail) if (!e.detail?.trim()) { // Don't bother saving empty values as JS diff --git a/packages/frontend-core/src/utils/utils.js b/packages/frontend-core/src/utils/utils.js index 55603b0129..f0635fbeac 100644 --- a/packages/frontend-core/src/utils/utils.js +++ b/packages/frontend-core/src/utils/utils.js @@ -43,7 +43,7 @@ export const sequential = fn => { * invocations is enforced. * @param callback an async function to run * @param minDelay the minimum delay between invocations - * @returns {Promise} a debounced version of the callback + * @returns a debounced version of the callback */ export const debounce = (callback, minDelay = 1000) => { let timeout diff --git a/packages/types/src/ui/components/codeEditor.ts b/packages/types/src/ui/components/codeEditor.ts new file mode 100644 index 0000000000..8ea885b667 --- /dev/null +++ b/packages/types/src/ui/components/codeEditor.ts @@ -0,0 +1,19 @@ +type EditorMode = + | { + key: "JS" + name: "javascript" + json: boolean + match: RegExp + } + | { + key: "Handlebars" + name: "handlebars" + base: "text/html" + match: RegExp + } + | { + key: "Text" + name: "text/html" + } + +export type EditorModesMap = { [M in EditorMode as M["key"]]: Omit } diff --git a/packages/types/src/ui/components/index.ts b/packages/types/src/ui/components/index.ts index 6638d36b32..8dc1638f8c 100644 --- a/packages/types/src/ui/components/index.ts +++ b/packages/types/src/ui/components/index.ts @@ -1 +1,2 @@ export * from "./sidepanel" +export * from "./codeEditor" From cf4ce587c4c59fa10903e465c7fa2a8078f61ad0 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 15 Jan 2025 10:24:28 +0100 Subject: [PATCH 15/53] Cleanups --- packages/frontend-core/src/fetch/DataFetch.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/frontend-core/src/fetch/DataFetch.ts b/packages/frontend-core/src/fetch/DataFetch.ts index 14d10db099..62e6c2423d 100644 --- a/packages/frontend-core/src/fetch/DataFetch.ts +++ b/packages/frontend-core/src/fetch/DataFetch.ts @@ -44,17 +44,14 @@ interface DataFetchDerivedStore supportsPagination: boolean } -export interface DataFetchParams< - TDatasource, - TQuery = SearchFilters | undefined -> { +export interface DataFetchParams { API: APIClient datasource: TDatasource query: TQuery options?: Partial> } -export interface DataFetchOptions { +export interface DataFetchOptions { // Search config filter: UISearchFilter | LegacyFilter[] | null query: TQuery @@ -272,6 +269,7 @@ export default abstract class BaseDataFetch< // Build the query let query = this.options.query + if (!query) { query = buildQuery(filter ?? undefined) as TQuery } @@ -435,7 +433,7 @@ export default abstract class BaseDataFetch< * Resets the data set and updates options * @param newOptions any new options */ - async update(newOptions: Partial>) { + async update(newOptions: Partial>) { // Check if any settings have actually changed let refresh = false for (const [key, value] of Object.entries(newOptions || {})) { From a3d73ee6ce7cb159afb368c076f0016b8c1348da Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 15 Jan 2025 10:40:41 +0100 Subject: [PATCH 16/53] Smarter datasource --- .../src/components/app/DataProvider.svelte | 5 ++- packages/frontend-core/src/fetch/index.ts | 37 ++++++++++++++++--- packages/frontend-core/src/index.ts | 6 ++- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/packages/client/src/components/app/DataProvider.svelte b/packages/client/src/components/app/DataProvider.svelte index da7eceeb5c..7b0dcb123b 100644 --- a/packages/client/src/components/app/DataProvider.svelte +++ b/packages/client/src/components/app/DataProvider.svelte @@ -5,6 +5,7 @@ fetchData, QueryUtils, DataFetchOptions, + ProviderDatasource, } from "@budibase/frontend-core" import { LogicalOperator, @@ -15,7 +16,7 @@ } from "@budibase/types" import { SDK, Component } from "../../index" - export let dataSource + export let dataSource: ProviderDatasource export let filter export let sortColumn export let sortOrder @@ -98,7 +99,7 @@ primaryDisplay: ($fetch.definition as any)?.primaryDisplay, } - const createFetch = (datasource: any) => { + const createFetch = (datasource: ProviderDatasource) => { return fetchData({ API, datasource, diff --git a/packages/frontend-core/src/fetch/index.ts b/packages/frontend-core/src/fetch/index.ts index bacea080cb..32c5aa5b21 100644 --- a/packages/frontend-core/src/fetch/index.ts +++ b/packages/frontend-core/src/fetch/index.ts @@ -35,6 +35,23 @@ export const DataFetchMap = { queryarray: QueryArrayFetch, } +export interface DataFetchClassMap { + table: TableFetch + view: ViewFetch + viewV2: ViewV2Fetch + query: QueryFetch + link: RelationshipFetch + user: UserFetch + groupUser: GroupUserFetch + custom: CustomFetch + + // Client specific datasource types + provider: NestedProviderFetch + field: FieldFetch<"field"> + jsonarray: JSONArrayFetch + queryarray: QueryArrayFetch +} + export type DataFetch = | TableFetch | ViewFetch @@ -60,8 +77,11 @@ export type DataFetchDatasource = | CustomDatasource | NestedProviderDatasource | FieldDatasource<"field" | "queryarray" | "jsonarray"> -// | FieldDatasource<"field" | "queryarray" | "jsonarray"> -// | FieldDatasource<"field" | "queryarray" | "jsonarray"> + +export type ProviderDatasource = Exclude< + DataFetchDatasource, + UserDatasource | GroupUserDatasource +> export type DataFetchDefinition = | Table @@ -72,22 +92,27 @@ export type DataFetchDefinition = } // Constructs a new fetch model for a certain datasource -export const fetchData = ({ +export const fetchData = < + T extends DataFetchDatasource, + Type extends T["type"] = T["type"] +>({ API, datasource, options, }: { API: APIClient - datasource: DataFetchDatasource + datasource: T options: any -}) => { +}): Type extends keyof DataFetchClassMap + ? DataFetchClassMap[Type] + : TableFetch => { const Fetch = DataFetchMap[datasource?.type] || TableFetch const fetch = new Fetch({ API, datasource, ...options }) // Initially fetch data but don't bother waiting for the result fetch.getInitialData() - return fetch + return fetch as any } // Creates an empty fetch instance with no datasource configured, so no data diff --git a/packages/frontend-core/src/index.ts b/packages/frontend-core/src/index.ts index 11354be49d..32eb532503 100644 --- a/packages/frontend-core/src/index.ts +++ b/packages/frontend-core/src/index.ts @@ -1,7 +1,11 @@ export { createAPIClient } from "./api" export type { APIClient } from "./api" export { fetchData, DataFetchMap } from "./fetch" -export type { DataFetchType, DataFetchOptions } from "./fetch" +export type { + DataFetchType, + DataFetchOptions, + ProviderDatasource, +} from "./fetch" export * as Constants from "./constants" export * from "./stores" export * from "./utils" From d55e29f9a6a4f5a8216551a2d52249e159331441 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 15 Jan 2025 10:42:37 +0100 Subject: [PATCH 17/53] Move type --- packages/client/src/components/app/DataProvider.svelte | 9 ++++++++- packages/frontend-core/src/fetch/index.ts | 7 ++----- packages/frontend-core/src/index.ts | 4 +++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/client/src/components/app/DataProvider.svelte b/packages/client/src/components/app/DataProvider.svelte index 7b0dcb123b..99831ec65d 100644 --- a/packages/client/src/components/app/DataProvider.svelte +++ b/packages/client/src/components/app/DataProvider.svelte @@ -5,7 +5,9 @@ fetchData, QueryUtils, DataFetchOptions, - ProviderDatasource, + DataFetchDatasource, + UserDatasource, + GroupUserDatasource, } from "@budibase/frontend-core" import { LogicalOperator, @@ -16,6 +18,11 @@ } from "@budibase/types" import { SDK, Component } from "../../index" + type ProviderDatasource = Exclude< + DataFetchDatasource, + UserDatasource | GroupUserDatasource + > + export let dataSource: ProviderDatasource export let filter export let sortColumn diff --git a/packages/frontend-core/src/fetch/index.ts b/packages/frontend-core/src/fetch/index.ts index 32c5aa5b21..93ad79ec32 100644 --- a/packages/frontend-core/src/fetch/index.ts +++ b/packages/frontend-core/src/fetch/index.ts @@ -17,6 +17,8 @@ import { Table, ViewV2Enriched } from "@budibase/types" export type DataFetchType = keyof typeof DataFetchMap export type { DataFetchOptions } from "./DataFetch" +export type { UserDatasource } from "./UserFetch" +export type { GroupUserDatasource } from "./GroupUserFetch" export const DataFetchMap = { table: TableFetch, @@ -78,11 +80,6 @@ export type DataFetchDatasource = | NestedProviderDatasource | FieldDatasource<"field" | "queryarray" | "jsonarray"> -export type ProviderDatasource = Exclude< - DataFetchDatasource, - UserDatasource | GroupUserDatasource -> - export type DataFetchDefinition = | Table | ViewV2Enriched diff --git a/packages/frontend-core/src/index.ts b/packages/frontend-core/src/index.ts index 32eb532503..ba80bb3af6 100644 --- a/packages/frontend-core/src/index.ts +++ b/packages/frontend-core/src/index.ts @@ -4,7 +4,9 @@ export { fetchData, DataFetchMap } from "./fetch" export type { DataFetchType, DataFetchOptions, - ProviderDatasource, + DataFetchDatasource, + UserDatasource, + GroupUserDatasource, } from "./fetch" export * as Constants from "./constants" export * from "./stores" From ea151e2ee5874772aa5c215acbe936b9c02f5097 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 15 Jan 2025 11:38:58 +0100 Subject: [PATCH 18/53] Lint --- packages/client/src/components/app/DataProvider.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/src/components/app/DataProvider.svelte b/packages/client/src/components/app/DataProvider.svelte index 99831ec65d..6f316c6548 100644 --- a/packages/client/src/components/app/DataProvider.svelte +++ b/packages/client/src/components/app/DataProvider.svelte @@ -34,7 +34,7 @@ const { styleable, Provider, ActionTypes, API } = getContext("sdk") const component = getContext("component") - let interval: NodeJS.Timeout + let interval: ReturnType let queryExtensions: Record = {} $: defaultQuery = QueryUtils.buildQuery(filter) From 4a83d0fc1c562d4c71084b5b7b1d7564d7a039a9 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 15 Jan 2025 11:47:33 +0100 Subject: [PATCH 19/53] Type parameters --- .../client/src/components/app/DataProvider.svelte | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/client/src/components/app/DataProvider.svelte b/packages/client/src/components/app/DataProvider.svelte index 6f316c6548..3f03067b81 100644 --- a/packages/client/src/components/app/DataProvider.svelte +++ b/packages/client/src/components/app/DataProvider.svelte @@ -15,6 +15,7 @@ TableSchema, SortOrder, SearchFilters, + UISearchFilter, } from "@budibase/types" import { SDK, Component } from "../../index" @@ -24,12 +25,12 @@ > export let dataSource: ProviderDatasource - export let filter - export let sortColumn - export let sortOrder - export let limit - export let paginate - export let autoRefresh + export let filter: UISearchFilter + export let sortColumn: string + export let sortOrder: SortOrder + export let limit: number + export let paginate: boolean + export let autoRefresh: number const { styleable, Provider, ActionTypes, API } = getContext("sdk") const component = getContext("component") From 72d7443d72394c7f5d5351c696b2cd5660c8cf34 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 15 Jan 2025 12:27:10 +0100 Subject: [PATCH 20/53] Fix types --- .../grid/stores/datasources/table.ts | 5 +++-- .../grid/stores/datasources/viewV2.ts | 19 ++++++++++++++----- packages/frontend-core/src/fetch/index.ts | 7 +++++++ packages/frontend-core/src/index.ts | 3 +++ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/packages/frontend-core/src/components/grid/stores/datasources/table.ts b/packages/frontend-core/src/components/grid/stores/datasources/table.ts index 27fa638596..740ebb4b9f 100644 --- a/packages/frontend-core/src/components/grid/stores/datasources/table.ts +++ b/packages/frontend-core/src/components/grid/stores/datasources/table.ts @@ -8,6 +8,7 @@ import { import { get } from "svelte/store" import { Store as StoreContext } from ".." import { DatasourceTableActions } from "." +import { TableFetch } from "@budibase/frontend-core" const SuppressErrors = true @@ -119,7 +120,7 @@ export const initialise = (context: StoreContext) => { unsubscribers.push( allFilters.subscribe($allFilters => { // Ensure we're updating the correct fetch - const $fetch = get(fetch) + const $fetch = get(fetch) as TableFetch | null if ($fetch?.options?.datasource?.tableId !== $datasource.tableId) { return } @@ -133,7 +134,7 @@ export const initialise = (context: StoreContext) => { unsubscribers.push( sort.subscribe($sort => { // Ensure we're updating the correct fetch - const $fetch = get(fetch) + const $fetch = get(fetch) as TableFetch | null if ($fetch?.options?.datasource?.tableId !== $datasource.tableId) { return } diff --git a/packages/frontend-core/src/components/grid/stores/datasources/viewV2.ts b/packages/frontend-core/src/components/grid/stores/datasources/viewV2.ts index 8b928364e1..b48d011d7e 100644 --- a/packages/frontend-core/src/components/grid/stores/datasources/viewV2.ts +++ b/packages/frontend-core/src/components/grid/stores/datasources/viewV2.ts @@ -4,11 +4,11 @@ import { SaveRowRequest, SortOrder, UIDatasource, - UIView, UpdateViewRequest, } from "@budibase/types" import { Store as StoreContext } from ".." import { DatasourceViewActions } from "." +import { ViewV2Fetch } from "@budibase/frontend-core" const SuppressErrors = true @@ -134,6 +134,9 @@ export const initialise = (context: StoreContext) => { if (!get(config).canSaveSchema) { return } + if (!$definition || !("id" in $definition)) { + return + } if ($definition?.id !== $datasource.id) { return } @@ -184,7 +187,10 @@ export const initialise = (context: StoreContext) => { unsubscribers.push( sort.subscribe(async $sort => { // Ensure we're updating the correct view - const $view = get(definition) as UIView + const $view = get(definition) + if (!$view || !("id" in $view)) { + return + } if ($view?.id !== $datasource.id) { return } @@ -207,7 +213,7 @@ export const initialise = (context: StoreContext) => { // Also update the fetch to ensure the new sort is respected. // Ensure we're updating the correct fetch. - const $fetch = get(fetch) + const $fetch = get(fetch) as ViewV2Fetch | null if ($fetch?.options?.datasource?.id !== $datasource.id) { return } @@ -225,6 +231,9 @@ export const initialise = (context: StoreContext) => { return } const $view = get(definition) + if (!$view || !("id" in $view)) { + return + } if ($view?.id !== $datasource.id) { return } @@ -246,7 +255,7 @@ export const initialise = (context: StoreContext) => { if (!get(config).canSaveSchema) { return } - const $fetch = get(fetch) + const $fetch = get(fetch) as ViewV2Fetch | null if ($fetch?.options?.datasource?.id !== $datasource.id) { return } @@ -262,7 +271,7 @@ export const initialise = (context: StoreContext) => { if (get(config).canSaveSchema) { return } - const $fetch = get(fetch) + const $fetch = get(fetch) as ViewV2Fetch | null if ($fetch?.options?.datasource?.id !== $datasource.id) { return } diff --git a/packages/frontend-core/src/fetch/index.ts b/packages/frontend-core/src/fetch/index.ts index 93ad79ec32..53a33a5be7 100644 --- a/packages/frontend-core/src/fetch/index.ts +++ b/packages/frontend-core/src/fetch/index.ts @@ -16,6 +16,11 @@ import { APIClient } from "../api/types" import { Table, ViewV2Enriched } from "@budibase/types" export type DataFetchType = keyof typeof DataFetchMap + +export type { default as TableFetch } from "./TableFetch" +export type { default as ViewFetch } from "./ViewFetch" +export type { default as ViewV2Fetch } from "./ViewV2Fetch" + export type { DataFetchOptions } from "./DataFetch" export type { UserDatasource } from "./UserFetch" export type { GroupUserDatasource } from "./GroupUserFetch" @@ -86,6 +91,8 @@ export type DataFetchDefinition = | { schema?: Record | null primaryDisplay?: string + rowHeight?: number + type?: string } // Constructs a new fetch model for a certain datasource diff --git a/packages/frontend-core/src/index.ts b/packages/frontend-core/src/index.ts index ba80bb3af6..a2a8287236 100644 --- a/packages/frontend-core/src/index.ts +++ b/packages/frontend-core/src/index.ts @@ -3,6 +3,9 @@ export type { APIClient } from "./api" export { fetchData, DataFetchMap } from "./fetch" export type { DataFetchType, + TableFetch, + ViewFetch, + ViewV2Fetch, DataFetchOptions, DataFetchDatasource, UserDatasource, From 55204871a236cd77e0fd0c0a43fd58b767215b4d Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 15 Jan 2025 12:35:36 +0100 Subject: [PATCH 21/53] Fix types --- packages/frontend-core/src/fetch/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/frontend-core/src/fetch/index.ts b/packages/frontend-core/src/fetch/index.ts index 53a33a5be7..4f353da882 100644 --- a/packages/frontend-core/src/fetch/index.ts +++ b/packages/frontend-core/src/fetch/index.ts @@ -89,10 +89,12 @@ export type DataFetchDefinition = | Table | ViewV2Enriched | { + // These fields are added to allow checking these fields on definition usages without requiring constant castings schema?: Record | null primaryDisplay?: string rowHeight?: number type?: string + name?: string } // Constructs a new fetch model for a certain datasource From 0b909b434a51f9b2336c0bdb20e1d2dd29683271 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 15 Jan 2025 14:34:36 +0000 Subject: [PATCH 22/53] Work on binding drawer typing. --- packages/bbui/src/Label/Label.svelte | 2 +- .../common/CodeEditor/CodeEditor.svelte | 67 ++++++++++++------- .../common/bindings/BindingPanel.svelte | 39 ++++++----- packages/types/src/ui/bindings/binding.ts | 9 +++ .../types/src/ui/components/codeEditor.ts | 43 +++++++----- 5 files changed, 95 insertions(+), 65 deletions(-) diff --git a/packages/bbui/src/Label/Label.svelte b/packages/bbui/src/Label/Label.svelte index 71b0967d99..41e1ccf794 100644 --- a/packages/bbui/src/Label/Label.svelte +++ b/packages/bbui/src/Label/Label.svelte @@ -4,7 +4,7 @@ export let size = "M" export let tooltip = "" - export let muted + export let muted = undefined diff --git a/packages/builder/src/components/common/CodeEditor/CodeEditor.svelte b/packages/builder/src/components/common/CodeEditor/CodeEditor.svelte index f94d26603d..1fa2eb3fae 100644 --- a/packages/builder/src/components/common/CodeEditor/CodeEditor.svelte +++ b/packages/builder/src/components/common/CodeEditor/CodeEditor.svelte @@ -1,4 +1,4 @@ - From ef3ac8883e7725df4bbb861a6e4b41e721af54ad Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 15 Jan 2025 15:18:11 +0000 Subject: [PATCH 24/53] Small TS improvement - make sure result/error is typed correctly. --- .../src/components/common/bindings/BindingPanel.svelte | 10 +++++----- .../common/bindings/EvaluationSidePanel.svelte | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/builder/src/components/common/bindings/BindingPanel.svelte b/packages/builder/src/components/common/bindings/BindingPanel.svelte index 04dc92f920..7c863f4beb 100644 --- a/packages/builder/src/components/common/bindings/BindingPanel.svelte +++ b/packages/builder/src/components/common/bindings/BindingPanel.svelte @@ -31,7 +31,7 @@ import { capitalise } from "@/helpers" import { Utils, JsonFormatter } from "@budibase/frontend-core" import { licensing } from "@/stores/portal" - import { BindingMode, EditorMode, SidePanel } from "@budibase/types" + import { BindingMode, SidePanel } from "@budibase/types" import type { EnrichedBinding, BindingCompletion, @@ -64,8 +64,8 @@ let getCaretPosition: CaretPositionFn | undefined let insertAtPos: InsertAtPositionFn | undefined let targetMode: BindingMode | null = null - let expressionResult: string | undefined | null - let expressionError: string | undefined | null + let expressionResult: string | undefined + let expressionError: string | undefined let evaluating = false $: useSnippets = allowSnippets && !$licensing.isFreePlan @@ -155,7 +155,7 @@ const debouncedEval = Utils.debounce( (expression: string | null, context: any, snippets: Snippet[]) => { try { - expressionError = null + expressionError = undefined expressionResult = processStringSync( expression || "", { @@ -167,7 +167,7 @@ } ) } catch (err: any) { - expressionResult = null + expressionResult = undefined expressionError = err } evaluating = false diff --git a/packages/builder/src/components/common/bindings/EvaluationSidePanel.svelte b/packages/builder/src/components/common/bindings/EvaluationSidePanel.svelte index 10b3f85176..91d986f0f6 100644 --- a/packages/builder/src/components/common/bindings/EvaluationSidePanel.svelte +++ b/packages/builder/src/components/common/bindings/EvaluationSidePanel.svelte @@ -5,8 +5,8 @@ import { fade } from "svelte/transition" import { UserScriptError } from "@budibase/string-templates" - export let expressionResult - export let expressionError + export let expressionResult: string | undefined = undefined + export let expressionError: string | undefined = undefined export let evaluating = false export let expression: string | null = null From fa3c5f1466328aea62f88e644058e81d25d05cd0 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 15 Jan 2025 15:25:55 +0000 Subject: [PATCH 25/53] copyToClipboard typing improvement. --- packages/bbui/src/helpers.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/bbui/src/helpers.d.ts b/packages/bbui/src/helpers.d.ts index bffb75d07f..d4e2a45186 100644 --- a/packages/bbui/src/helpers.d.ts +++ b/packages/bbui/src/helpers.d.ts @@ -1,4 +1,4 @@ declare module "./helpers" { export const cloneDeep: (obj: T) => T - export const copyToClipboard: (value: any) => any + export const copyToClipboard: (value: any) => Promise } From 13915e848894bdc8e1173ad254a18abc92c6fe36 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 15 Jan 2025 15:34:17 +0000 Subject: [PATCH 26/53] Update yarn.lock --- yarn.lock | 187 +++++++++++++++--------------------------------------- 1 file changed, 50 insertions(+), 137 deletions(-) diff --git a/yarn.lock b/yarn.lock index 8996e11ae1..453dc45128 100644 --- a/yarn.lock +++ b/yarn.lock @@ -810,7 +810,7 @@ "@azure/abort-controller" "^2.0.0" tslib "^2.6.2" -"@azure/identity@^4.2.1": +"@azure/identity@4.2.1", "@azure/identity@^4.2.1": version "4.2.1" resolved "https://registry.yarnpkg.com/@azure/identity/-/identity-4.2.1.tgz#22b366201e989b7b41c0e1690e103bd579c31e4c" integrity sha512-U8hsyC9YPcEIzoaObJlRDvp7KiF0MGS7xcWbyJSVvXRkC/HXo1f0oYeBYmEvVgRfacw7GHf6D6yAoh9JHz6A5Q== @@ -2130,6 +2130,28 @@ pouchdb-promise "^6.0.4" through2 "^2.0.0" +"@budibase/pro@npm:@budibase/pro@latest": + version "3.2.44" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-3.2.44.tgz#90367bb2167aafd8c809e000a57d349e5dc4bb78" + integrity sha512-Zv2PBVUZUS6/psOpIRIDlW3jrOHWWPhpQXzCk00kIQJaqjkdcvuTXSedQ70u537sQmLu8JsSWbui9MdfF8ksVw== + dependencies: + "@anthropic-ai/sdk" "^0.27.3" + "@budibase/backend-core" "*" + "@budibase/shared-core" "*" + "@budibase/string-templates" "*" + "@budibase/types" "*" + "@koa/router" "13.1.0" + bull "4.10.1" + dd-trace "5.26.0" + joi "17.6.0" + jsonwebtoken "9.0.2" + lru-cache "^7.14.1" + memorystream "^0.3.1" + node-fetch "2.6.7" + openai "4.59.0" + scim-patch "^0.8.1" + scim2-parse-filter "^0.2.8" + "@bull-board/api@5.10.2": version "5.10.2" resolved "https://registry.yarnpkg.com/@bull-board/api/-/api-5.10.2.tgz#ae8ff6918b23897bf879a6ead3683f964374c4b3" @@ -7020,23 +7042,7 @@ aws4@^1.8.0: resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.13.2.tgz#0aa167216965ac9474ccfa83892cfb6b3e1e52ef" integrity sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw== -axios@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/axios/-/axios-1.1.3.tgz#8274250dada2edf53814ed7db644b9c2866c1e35" - integrity sha512-00tXVRwKx/FZr/IDVFt4C+f9FYairX517WoGCL6dpOntqLkZofjhu43F/Xl44UOpqa+9sLFDrG/XAnFsUYgkDA== - dependencies: - follow-redirects "^1.15.0" - form-data "^4.0.0" - proxy-from-env "^1.1.0" - -axios@^0.21.1: - version "0.21.4" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575" - integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg== - dependencies: - follow-redirects "^1.14.0" - -axios@^1.0.0, axios@^1.1.3, axios@^1.4.0, axios@^1.6.2, axios@^1.6.8: +axios@1.1.3, axios@1.7.7, axios@^0.21.1, axios@^1.0.0, axios@^1.1.3, axios@^1.4.0, axios@^1.6.2, axios@^1.6.8: version "1.7.7" resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.7.tgz#2f554296f9892a72ac8d8e4c5b79c14a91d0a47f" integrity sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q== @@ -10654,7 +10660,7 @@ fn.name@1.x.x: resolved "https://registry.yarnpkg.com/fn.name/-/fn.name-1.1.0.tgz#26cad8017967aea8731bc42961d04a3d5988accc" integrity sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw== -follow-redirects@^1.14.0, follow-redirects@^1.15.0, follow-redirects@^1.15.6: +follow-redirects@^1.15.6: version "1.15.9" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.9.tgz#a604fa10e443bf98ca94228d9eebcc2e8a2c8ee1" integrity sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ== @@ -11269,22 +11275,10 @@ global@~4.4.0: min-document "^2.19.0" process "^0.11.10" -globals@^11.1.0: - version "11.12.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" - integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== - -globals@^13.19.0: - version "13.24.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-13.24.0.tgz#8432a19d78ce0c1e833949c36adb345400bb1171" - integrity sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ== - dependencies: - type-fest "^0.20.2" - -globals@^14.0.0: - version "14.0.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-14.0.0.tgz#898d7413c29babcf6bafe56fcadded858ada724e" - integrity sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ== +globals@15.13.0, globals@^11.1.0, globals@^13.19.0, globals@^14.0.0: + version "15.13.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-15.13.0.tgz#bbec719d69aafef188ecd67954aae76a696010fc" + integrity sha512-49TewVEz0UxZjr1WYYsWpPrhyC/B/pA8Bq0fUmet2n+eR7yn0IvNzNaoBwnK6mdkzcN+se7Ez9zUgULTz2QH4g== globalthis@^1.0.1, globalthis@^1.0.4: version "1.0.4" @@ -11694,12 +11688,7 @@ http-assert@^1.3.0: deep-equal "~1.0.1" http-errors "~1.8.0" -http-cache-semantics@3.8.1: - version "3.8.1" - resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz#39b0e16add9b605bf0a9ef3d9daaf4843b4cacd2" - integrity sha512-5ai2iksyV8ZXmnZhHH4rWPoxxistEexSi5936zIQ1bnNTW5VnA85B6P/VpXiRM017IgRvb2kKo1a//y+0wSp3w== - -http-cache-semantics@^4.0.0, http-cache-semantics@^4.1.0, http-cache-semantics@^4.1.1: +http-cache-semantics@3.8.1, http-cache-semantics@4.1.1, http-cache-semantics@^4.0.0, http-cache-semantics@^4.1.0, http-cache-semantics@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz#abe02fcb2985460bf0323be664436ec3476a6d5a" integrity sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ== @@ -12150,11 +12139,6 @@ is-boolean-object@^1.1.0: call-bind "^1.0.2" has-tostringtag "^1.0.0" -is-buffer@^1.1.5: - version "1.1.6" - resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" - integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== - is-buffer@^2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-2.0.5.tgz#ebc252e400d22ff8d77fa09888821a24a658c191" @@ -12594,6 +12578,11 @@ isobject@^3.0.1: resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" integrity sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg== +isobject@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-4.0.0.tgz#3f1c9155e73b192022a80819bacd0343711697b0" + integrity sha512-S/2fF5wH8SJA/kmwr6HYhK/RI/OkhD84k8ntalo0iJjZikgq1XFvR5M8NPT1x5F7fBwCG3qHfnzeP/Vh/ZxCUA== + isolated-vm@^4.7.2: version "4.7.2" resolved "https://registry.yarnpkg.com/isolated-vm/-/isolated-vm-4.7.2.tgz#5670d5cce1d92004f9b825bec5b0b11fc7501b65" @@ -13473,14 +13462,7 @@ kill-port@^1.6.1: get-them-args "1.3.2" shell-exec "1.0.2" -kind-of@^3.0.2, kind-of@^3.1.0: - version "3.2.2" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" - integrity sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ== - dependencies: - is-buffer "^1.1.5" - -kind-of@^6.0.0, kind-of@^6.0.2, kind-of@^6.0.3: +kind-of@6.0.3, kind-of@^3.0.2, kind-of@^3.1.0, kind-of@^6.0.0, kind-of@^6.0.2, kind-of@^6.0.3: version "6.0.3" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== @@ -14885,7 +14867,7 @@ msgpackr-extract@^3.0.2: "@msgpackr-extract/msgpackr-extract-linux-x64" "3.0.2" "@msgpackr-extract/msgpackr-extract-win32-x64" "3.0.2" -msgpackr@^1.5.2: +msgpackr@1.10.1, msgpackr@^1.5.2: version "1.10.1" resolved "https://registry.yarnpkg.com/msgpackr/-/msgpackr-1.10.1.tgz#51953bb4ce4f3494f0c4af3f484f01cfbb306555" integrity sha512-r5VRLv9qouXuLiIBrLpl2d5ZvPt8svdQTl5/vMvE4nzDMyEX4sgW5yWhuBBj5UmgwOTWj8CIdSXn5sAfsHAWIQ== @@ -15078,27 +15060,13 @@ node-domexception@1.0.0: resolved "https://registry.yarnpkg.com/node-domexception/-/node-domexception-1.0.0.tgz#6888db46a1f71c0b76b3f7555016b63fe64766e5" integrity sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ== -node-fetch@2.6.7, node-fetch@^2.6.0, node-fetch@^2.6.1, node-fetch@^2.6.7: +node-fetch@2.6.7, node-fetch@2.6.9, node-fetch@^2.6.0, node-fetch@^2.6.1, node-fetch@^2.6.7, node-fetch@^2.6.9: version "2.6.7" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== dependencies: whatwg-url "^5.0.0" -node-fetch@2.6.9: - version "2.6.9" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.9.tgz#7c7f744b5cc6eb5fd404e0c7a9fec630a55657e6" - integrity sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg== - dependencies: - whatwg-url "^5.0.0" - -node-fetch@^2.6.9: - version "2.7.0" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" - integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== - dependencies: - whatwg-url "^5.0.0" - node-forge@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3" @@ -16122,15 +16090,7 @@ passport-strategy@1.x.x, passport-strategy@^1.0.0: resolved "https://registry.yarnpkg.com/passport-strategy/-/passport-strategy-1.0.0.tgz#b5539aa8fc225a3d1ad179476ddf236b440f52e4" integrity sha512-CB97UUvDKJde2V0KDWWB3lyf6PC3FaZP7YxZ2G8OAtn9p4HI9j9JLP9qjOGZFvyl8uwNT8qM+hGnz/n16NI7oA== -passport@^0.4.0: - version "0.4.1" - resolved "https://registry.yarnpkg.com/passport/-/passport-0.4.1.tgz#941446a21cb92fc688d97a0861c38ce9f738f270" - integrity sha512-IxXgZZs8d7uFSt3eqNjM9NQ3g3uQCW5avD8mRNoXV99Yig50vjuaez6dQK2qC0kVWPRTujxY0dWgGfT09adjYg== - dependencies: - passport-strategy "1.x.x" - pause "0.0.1" - -passport@^0.6.0: +passport@0.6.0, passport@^0.4.0, passport@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/passport/-/passport-0.6.0.tgz#e869579fab465b5c0b291e841e6cc95c005fac9d" integrity sha512-0fe+p3ZnrWRW74fe8+SvCyf4a3Pb2/h7gFkQ8yTJpAO50gDzlfjZUZTO1k5Eg9kUct22OxHLqDZoKUWRHOh9ug== @@ -17115,13 +17075,6 @@ pseudomap@^1.0.2: resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" integrity sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ== -psl@^1.1.28: - version "1.15.0" - resolved "https://registry.yarnpkg.com/psl/-/psl-1.15.0.tgz#bdace31896f1d97cec6a79e8224898ce93d974c6" - integrity sha512-JZd3gMVBAVQkSs6HdNZo9Sdo0LNcQeMNP3CozBJb3JYC/QUYZTnKxP+f8oWRX4rHP5EurWxqAHTSwUCjlNKa1w== - dependencies: - punycode "^2.3.1" - psl@^1.1.33: version "1.9.0" resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7" @@ -17155,11 +17108,6 @@ punycode@^2.1.0, punycode@^2.1.1, punycode@^2.3.0: resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.0.tgz#f67fa67c94da8f4d0cfff981aee4118064199b8f" integrity sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA== -punycode@^2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" - integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== - pupa@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/pupa/-/pupa-2.1.1.tgz#f5e8fd4afc2c5d97828faa523549ed8744a20d62" @@ -17991,11 +17939,6 @@ sax@1.2.1: resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.1.tgz#7b8e656190b228e81a66aea748480d828cd2d37a" integrity sha512-8I2a3LovHTOpm7NV5yOyO8IHqgVsfK4+UuySrXU8YXkSRX7k6hCV9b3HrkKCr3nMpgj+0bmocaJJWpvp1oc7ZA== -sax@>=0.1.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/sax/-/sax-1.4.1.tgz#44cc8988377f126304d3b3fc1010c733b929ef0f" - integrity sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg== - sax@>=0.6.0: version "1.2.4" resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" @@ -18068,28 +18011,13 @@ semver-diff@^3.1.1: dependencies: semver "^6.3.0" -"semver@2 || 3 || 4 || 5", semver@^5.6.0, semver@^5.7.1: - version "5.7.2" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" - integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== - -semver@7.5.3, semver@^7.0.0, semver@^7.1.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8, semver@^7.5.3: +"semver@2 || 3 || 4 || 5", semver@7.5.3, semver@^5.6.0, semver@^5.7.1, semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0, semver@^6.3.1, semver@^7.0.0, semver@^7.1.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8, semver@^7.5.3, semver@^7.5.4, semver@^7.6.0, semver@^7.6.2: version "7.5.3" resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.3.tgz#161ce8c2c6b4b3bdca6caadc9fa3317a4c4fe88e" integrity sha512-QBlUtyVk/5EeHbi7X0fw6liDZc7BBmEaSYn01fMU1OUYbf6GPsbTtd8WmnqbI20SeycoHSeiybkE/q1Q+qlThQ== dependencies: lru-cache "^6.0.0" -semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0, semver@^6.3.1: - version "6.3.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" - integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== - -semver@^7.5.4, semver@^7.6.0, semver@^7.6.2: - version "7.6.3" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.3.tgz#980f7b5550bc175fb4dc09403085627f9eb33143" - integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A== - seq-queue@^0.0.5: version "0.0.5" resolved "https://registry.yarnpkg.com/seq-queue/-/seq-queue-0.0.5.tgz#d56812e1c017a6e4e7c3e3a37a1da6d78dd3c93e" @@ -19553,7 +19481,7 @@ touch@^3.1.0: dependencies: nopt "~1.0.10" -"tough-cookie@^2.3.3 || ^3.0.1 || ^4.0.0", tough-cookie@^4.0.0, tough-cookie@^4.1.2: +tough-cookie@4.1.3, "tough-cookie@^2.3.3 || ^3.0.1 || ^4.0.0", tough-cookie@^4.0.0, tough-cookie@^4.1.2, tough-cookie@~2.5.0: version "4.1.3" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.1.3.tgz#97b9adb0728b42280aa3d814b6b999b2ff0318bf" integrity sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw== @@ -19563,14 +19491,6 @@ touch@^3.1.0: universalify "^0.2.0" url-parse "^1.5.3" -tough-cookie@~2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" - integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g== - dependencies: - psl "^1.1.28" - punycode "^2.1.1" - tr46@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/tr46/-/tr46-2.1.0.tgz#fa87aa81ca5d5941da8cbf1f9b749dc969a4e240" @@ -20038,6 +19958,14 @@ unpipe@1.0.0: resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" integrity sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ== +unset-value@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-2.0.1.tgz#57bed0c22d26f28d69acde5df9a11b77c74d2df3" + integrity sha512-2hvrBfjUE00PkqN+q0XP6yRAOGrR06uSiUoIQGZkc7GxvQ9H7v8quUPNtZjMg4uux69i8HWpIjLPUKwCuRGyNg== + dependencies: + has-value "^2.0.2" + isobject "^4.0.0" + untildify@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/untildify/-/untildify-4.0.0.tgz#2bc947b953652487e4600949fb091e3ae8cd919b" @@ -20741,14 +20669,7 @@ xml-parse-from-string@^1.0.0: resolved "https://registry.yarnpkg.com/xml-parse-from-string/-/xml-parse-from-string-1.0.1.tgz#a9029e929d3dbcded169f3c6e28238d95a5d5a28" integrity sha512-ErcKwJTF54uRzzNMXq2X5sMIy88zJvfN2DmdoQvy7PAFJ+tPRU6ydWuOKNMyfmOjdyBQTFREi60s0Y0SyI0G0g== -xml2js@0.1.x: - version "0.1.14" - resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.1.14.tgz#5274e67f5a64c5f92974cd85139e0332adc6b90c" - integrity sha512-pbdws4PPPNc1HPluSUKamY4GWMk592K7qwcj6BExbVOhhubub8+pMda/ql68b6L3luZs/OGjGSB5goV7SnmgnA== - dependencies: - sax ">=0.1.1" - -xml2js@0.6.2: +xml2js@0.1.x, xml2js@0.6.2, xml2js@^0.5.0: version "0.6.2" resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.6.2.tgz#dd0b630083aa09c161e25a4d0901e2b2a929b499" integrity sha512-T4rieHaC1EXcES0Kxxj4JWgaUQHDk+qwHcYOCFHfiwKz7tOVPLq7Hjq9dM1WCMhylqMEfP7hMcOIChvotiZegA== @@ -20756,14 +20677,6 @@ xml2js@0.6.2: sax ">=0.6.0" xmlbuilder "~11.0.0" -xml2js@^0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.5.0.tgz#d9440631fbb2ed800203fad106f2724f62c493b7" - integrity sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA== - dependencies: - sax ">=0.6.0" - xmlbuilder "~11.0.0" - xmlbuilder@~11.0.0: version "11.0.1" resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-11.0.1.tgz#be9bae1c8a046e76b31127726347d0ad7002beb3" From 80a67dccc06fa673654133a58d664a97f5824492 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 15 Jan 2025 15:40:18 +0000 Subject: [PATCH 27/53] Typing fixes. --- .../common/bindings/EvaluationSidePanel.svelte | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/builder/src/components/common/bindings/EvaluationSidePanel.svelte b/packages/builder/src/components/common/bindings/EvaluationSidePanel.svelte index 91d986f0f6..6504f5f15b 100644 --- a/packages/builder/src/components/common/bindings/EvaluationSidePanel.svelte +++ b/packages/builder/src/components/common/bindings/EvaluationSidePanel.svelte @@ -5,7 +5,8 @@ import { fade } from "svelte/transition" import { UserScriptError } from "@budibase/string-templates" - export let expressionResult: string | undefined = undefined + export let expressionResult: string | { result: string } | undefined = + undefined export let expressionError: string | undefined = undefined export let evaluating = false export let expression: string | null = null @@ -13,7 +14,11 @@ $: error = expressionError != null $: empty = expression == null || expression?.trim() === "" $: success = !error && !empty - $: highlightedResult = highlight(expressionResult) + $: highlightedResult = highlight( + expressionResult && typeof expressionResult === "object" + ? expressionResult.result + : expressionResult + ) const formatError = (err: any) => { if (err.code === UserScriptError.code) { @@ -22,7 +27,7 @@ return err.toString() } - const highlight = (json: string | null) => { + const highlight = (json?: string | null) => { if (json == null) { return "" } @@ -47,7 +52,10 @@ } const copy = () => { - let clipboardVal = expressionResult.result + let clipboardVal = + expressionResult && typeof expressionResult === "object" + ? expressionResult.result + : expressionResult if (typeof clipboardVal === "object") { clipboardVal = JSON.stringify(clipboardVal, null, 2) } From 1dfedc1ee1d7f5996ca2933441732d1c6d7989eb Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 15 Jan 2025 15:43:15 +0000 Subject: [PATCH 28/53] Linting. --- packages/builder/src/components/common/CodeEditor/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/builder/src/components/common/CodeEditor/index.ts b/packages/builder/src/components/common/CodeEditor/index.ts index d2cbe8a23e..0c974e0bf4 100644 --- a/packages/builder/src/components/common/CodeEditor/index.ts +++ b/packages/builder/src/components/common/CodeEditor/index.ts @@ -3,7 +3,6 @@ import sanitizeHtml from "sanitize-html" import { groupBy } from "lodash" import { BindingCompletion, - BindingMode, EditorModesMap, Helper, Snippet, From afef51166457cb2785c7bdcf3e5e8d92c2525141 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 15 Jan 2025 16:38:34 +0000 Subject: [PATCH 29/53] Removing .result from evaluation side panel. --- .../common/bindings/EvaluationSidePanel.svelte | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/packages/builder/src/components/common/bindings/EvaluationSidePanel.svelte b/packages/builder/src/components/common/bindings/EvaluationSidePanel.svelte index 6504f5f15b..e48b68aef8 100644 --- a/packages/builder/src/components/common/bindings/EvaluationSidePanel.svelte +++ b/packages/builder/src/components/common/bindings/EvaluationSidePanel.svelte @@ -5,7 +5,8 @@ import { fade } from "svelte/transition" import { UserScriptError } from "@budibase/string-templates" - export let expressionResult: string | { result: string } | undefined = + // this can be essentially any primitive response from the JS function + export let expressionResult: string | boolean | object | number | undefined = undefined export let expressionError: string | undefined = undefined export let evaluating = false @@ -14,11 +15,7 @@ $: error = expressionError != null $: empty = expression == null || expression?.trim() === "" $: success = !error && !empty - $: highlightedResult = highlight( - expressionResult && typeof expressionResult === "object" - ? expressionResult.result - : expressionResult - ) + $: highlightedResult = highlight(expressionResult) const formatError = (err: any) => { if (err.code === UserScriptError.code) { @@ -27,7 +24,7 @@ return err.toString() } - const highlight = (json?: string | null) => { + const highlight = (json?: any | null) => { if (json == null) { return "" } @@ -38,7 +35,7 @@ jsonString = JSON.stringify(JSON.parse(json), null, 2) } catch (err) { // Ignore - jsonString = "" + jsonString = json } return JsonFormatter.format(jsonString, { @@ -52,10 +49,7 @@ } const copy = () => { - let clipboardVal = - expressionResult && typeof expressionResult === "object" - ? expressionResult.result - : expressionResult + let clipboardVal = expressionResult if (typeof clipboardVal === "object") { clipboardVal = JSON.stringify(clipboardVal, null, 2) } From 84f1a95a8bf872a183e2a17b3c90ebe2312d326c Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 15 Jan 2025 17:05:32 +0000 Subject: [PATCH 30/53] Implementing JSONValue type for passing binding results around. --- .../common/bindings/EvaluationSidePanel.svelte | 13 ++++++------- packages/frontend-core/src/utils/jsonFormatter.ts | 15 ++++++--------- packages/types/src/core/common.ts | 7 +++++++ packages/types/src/core/index.ts | 1 + 4 files changed, 20 insertions(+), 16 deletions(-) create mode 100644 packages/types/src/core/common.ts diff --git a/packages/builder/src/components/common/bindings/EvaluationSidePanel.svelte b/packages/builder/src/components/common/bindings/EvaluationSidePanel.svelte index e48b68aef8..c8bf5529ad 100644 --- a/packages/builder/src/components/common/bindings/EvaluationSidePanel.svelte +++ b/packages/builder/src/components/common/bindings/EvaluationSidePanel.svelte @@ -4,10 +4,10 @@ import { Helpers } from "@budibase/bbui" import { fade } from "svelte/transition" import { UserScriptError } from "@budibase/string-templates" + import type { JSONValue } from "@budibase/types" // this can be essentially any primitive response from the JS function - export let expressionResult: string | boolean | object | number | undefined = - undefined + export let expressionResult: JSONValue | undefined = undefined export let expressionError: string | undefined = undefined export let evaluating = false export let expression: string | null = null @@ -24,21 +24,20 @@ return err.toString() } + // json can be any primitive type const highlight = (json?: any | null) => { if (json == null) { return "" } // Attempt to parse and then stringify, in case this is valid result - let jsonString: string try { - jsonString = JSON.stringify(JSON.parse(json), null, 2) + json = JSON.stringify(JSON.parse(json), null, 2) } catch (err) { - // Ignore - jsonString = json + // couldn't parse/stringify, just treat it as the raw input } - return JsonFormatter.format(jsonString, { + return JsonFormatter.format(json, { keyColor: "#e06c75", numberColor: "#e5c07b", stringColor: "#98c379", diff --git a/packages/frontend-core/src/utils/jsonFormatter.ts b/packages/frontend-core/src/utils/jsonFormatter.ts index 14a8989fd2..ba9f8fc748 100644 --- a/packages/frontend-core/src/utils/jsonFormatter.ts +++ b/packages/frontend-core/src/utils/jsonFormatter.ts @@ -1,3 +1,5 @@ +import { JSONValue } from "@budibase/types" + export type ColorsOptions = { keyColor?: string numberColor?: string @@ -32,15 +34,10 @@ function escapeHtml(html: string) { }) } -export function format(json: string | object, colorOptions = {}) { +export function format(json: JSONValue, colorOptions: ColorsOptions = {}) { const valueType = typeof json - if (valueType !== "string") { - json = JSON.stringify(json, null, 2) || valueType - } - let jsonString: string = - valueType !== "string" - ? JSON.stringify(json, null, 2) || valueType - : (json as string) + let jsonString = + typeof json === "string" ? json : JSON.stringify(json, null, 2) || valueType let colors = Object.assign({}, defaultColors, colorOptions) jsonString = jsonString .replace(/&/g, "&") @@ -48,7 +45,7 @@ export function format(json: string | object, colorOptions = {}) { .replace(/>/g, ">") return jsonString.replace( /("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+]?\d+)?)/g, - match => { + (match: string) => { let color = colors.numberColor let style = "" if (/^"/.test(match)) { diff --git a/packages/types/src/core/common.ts b/packages/types/src/core/common.ts new file mode 100644 index 0000000000..c61fc3255d --- /dev/null +++ b/packages/types/src/core/common.ts @@ -0,0 +1,7 @@ +export type JSONValue = + | string + | number + | boolean + | null + | { [key: string]: JSONValue } + | JSONValue[] diff --git a/packages/types/src/core/index.ts b/packages/types/src/core/index.ts index 73cc7d35e0..ba9c1b907c 100644 --- a/packages/types/src/core/index.ts +++ b/packages/types/src/core/index.ts @@ -1,2 +1,3 @@ export * from "./installation" export * from "./events" +export * from "./common" From b3ccca051efd6be94d7ad448e76c2103367bca07 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 15 Jan 2025 17:12:17 +0000 Subject: [PATCH 31/53] Fixing build issue. --- .../builder/src/components/common/bindings/BindingPanel.svelte | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/components/common/bindings/BindingPanel.svelte b/packages/builder/src/components/common/bindings/BindingPanel.svelte index 7c863f4beb..98df69bc06 100644 --- a/packages/builder/src/components/common/bindings/BindingPanel.svelte +++ b/packages/builder/src/components/common/bindings/BindingPanel.svelte @@ -39,6 +39,7 @@ Helper, CaretPositionFn, InsertAtPositionFn, + JSONValue, } from "@budibase/types" import type { CompletionContext } from "@codemirror/autocomplete" @@ -184,7 +185,7 @@ debouncedEval(expression, context, snippets) } - const highlightJSON = (json: object | string) => { + const highlightJSON = (json: JSONValue) => { return JsonFormatter.format(json, { keyColor: "#e06c75", numberColor: "#e5c07b", From 482f8aa8200f693010f684e6f3bb22f272f3a0b9 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 16 Jan 2025 10:28:06 +0100 Subject: [PATCH 32/53] Update types --- .../src/components/app/DataProvider.svelte | 15 ++- .../grid/stores/datasources/table.ts | 2 +- .../grid/stores/datasources/viewV2.ts | 2 +- .../frontend-core/src/fetch/CustomFetch.ts | 6 +- packages/frontend-core/src/fetch/DataFetch.ts | 15 +-- .../frontend-core/src/fetch/FieldFetch.ts | 26 +++--- .../frontend-core/src/fetch/GroupUserFetch.ts | 9 +- .../frontend-core/src/fetch/JSONArrayFetch.ts | 3 +- .../src/fetch/NestedProviderFetch.ts | 11 +-- .../src/fetch/QueryArrayFetch.ts | 3 +- .../frontend-core/src/fetch/QueryFetch.ts | 16 +--- .../src/fetch/RelationshipFetch.ts | 10 +- .../frontend-core/src/fetch/TableFetch.ts | 7 +- packages/frontend-core/src/fetch/UserFetch.ts | 15 ++- packages/frontend-core/src/fetch/ViewFetch.ts | 11 +-- .../frontend-core/src/fetch/ViewV2Fetch.ts | 12 +-- packages/frontend-core/src/fetch/index.ts | 50 +++------- packages/frontend-core/src/index.ts | 10 -- .../types/src/ui/dataFetch/datasources.ts | 93 +++++++++++++++++++ packages/types/src/ui/dataFetch/index.ts | 16 ++++ packages/types/src/ui/index.ts | 1 + 21 files changed, 170 insertions(+), 163 deletions(-) create mode 100644 packages/types/src/ui/dataFetch/datasources.ts create mode 100644 packages/types/src/ui/dataFetch/index.ts diff --git a/packages/client/src/components/app/DataProvider.svelte b/packages/client/src/components/app/DataProvider.svelte index 3f03067b81..154f69d4de 100644 --- a/packages/client/src/components/app/DataProvider.svelte +++ b/packages/client/src/components/app/DataProvider.svelte @@ -1,14 +1,7 @@

Date: Fri, 17 Jan 2025 14:15:40 +0000 Subject: [PATCH 52/53] lint --- .../components/automation/SetupPanel/CronBuilder.svelte | 5 ++--- .../backend/DataTable/modals/CreateEditColumn.svelte | 5 +++-- .../data/table/[tableId]/[viewId]/index.svelte | 4 ++-- .../app/[application]/data/table/[tableId]/index.svelte | 5 +++-- .../src/pages/builder/portal/settings/ai/index.svelte | 5 ++--- .../builder/src/pages/builder/portal/settings/index.svelte | 7 +------ 6 files changed, 13 insertions(+), 18 deletions(-) diff --git a/packages/builder/src/components/automation/SetupPanel/CronBuilder.svelte b/packages/builder/src/components/automation/SetupPanel/CronBuilder.svelte index f04c5454ea..1490baa602 100644 --- a/packages/builder/src/components/automation/SetupPanel/CronBuilder.svelte +++ b/packages/builder/src/components/automation/SetupPanel/CronBuilder.svelte @@ -9,7 +9,7 @@ } from "@budibase/bbui" import { onMount, createEventDispatcher } from "svelte" import { flags } from "@/stores/builder" - import { featureFlags, licensing } from "@/stores/portal" + import { licensing } from "@/stores/portal" import { API } from "@/api" import MagicWand from "../../../../assets/MagicWand.svelte" @@ -27,8 +27,7 @@ let loadingAICronExpression = false $: aiEnabled = - ($featureFlags.AI_CUSTOM_CONFIGS && $licensing.customAIConfigsEnabled) || - ($featureFlags.BUDIBASE_AI && $licensing.budibaseAIEnabled) + $licensing.customAIConfigsEnabled || $licensing.budibaseAIEnabled $: { if (cronExpression) { try { diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte index 55ac8474a6..4af1dcc0ee 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte @@ -26,7 +26,7 @@ import { createEventDispatcher, getContext, onMount } from "svelte" import { cloneDeep } from "lodash/fp" import { tables, datasources } from "@/stores/builder" - import { featureFlags } from "@/stores/portal" + import { licensing } from "@/stores/portal" import { TableNames, UNEDITABLE_USER_FIELDS } from "@/constants" import { FIELDS, @@ -100,7 +100,8 @@ let optionsValid = true $: rowGoldenSample = RowUtils.generateGoldenSample($rows) - $: aiEnabled = $featureFlags.BUDIBASE_AI || $featureFlags.AI_CUSTOM_CONFIGS + $: aiEnabled = + $licensing.customAIConfigsEnabled || $licensing.budibaseAiEnabled $: if (primaryDisplay) { editableColumn.constraints.presence = { allowEmpty: false } } diff --git a/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/[viewId]/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/[viewId]/index.svelte index 9ac7ccd715..4d42c0d5d6 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/[viewId]/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/[viewId]/index.svelte @@ -1,6 +1,6 @@ From 4d90751988811729d296a3888a153a41661da39d Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Fri, 17 Jan 2025 14:30:17 +0000 Subject: [PATCH 53/53] Bump version to 3.2.46 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index c02b221ec8..d033c24518 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "3.2.45", + "version": "3.2.46", "npmClient": "yarn", "concurrency": 20, "command": {