Skip to content

Commit

Permalink
Merge branch 'master' into fix/automation-query-rows-table-with-spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
mike12345567 authored Jan 13, 2025
2 parents ffcf24b + 7d3bd3a commit 757d99a
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 11 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { Constants } from "@budibase/frontend-core"
import { Constants, APIClient } from "@budibase/frontend-core"
import { FieldTypes } from "../constants"
import { Row, Table } from "@budibase/types"

export const patchAPI = API => {
export const patchAPI = (API: APIClient) => {
/**
* Enriches rows which contain certain field types so that they can
* be properly displayed.
* The ability to create these bindings has been removed, but they will still
* exist in client apps to support backwards compatibility.
*/
const enrichRows = async (rows, tableId) => {
const enrichRows = async (rows: Row[], tableId: string) => {
if (!Array.isArray(rows)) {
return []
}
if (rows.length) {
const tables = {}
const tables: Record<string, Table> = {}
for (let row of rows) {
// Fall back to passed in tableId if row doesn't have it specified
let rowTableId = row.tableId || tableId
Expand Down Expand Up @@ -54,7 +55,7 @@ export const patchAPI = API => {
const fetchSelf = API.fetchSelf
API.fetchSelf = async () => {
const user = await fetchSelf()
if (user && user._id) {
if (user && "_id" in user && user._id) {
if (user.roleId === "PUBLIC") {
// Don't try to enrich a public user as it will 403
return user
Expand Down Expand Up @@ -90,13 +91,14 @@ export const patchAPI = API => {
return await enrichRows(rows, tableId)
}

// Wipe any HBS formulae from table definitions, as these interfere with
// Wipe any HBS formulas from table definitions, as these interfere with
// handlebars enrichment
const fetchTableDefinition = API.fetchTableDefinition
API.fetchTableDefinition = async tableId => {
const definition = await fetchTableDefinition(tableId)
Object.keys(definition?.schema || {}).forEach(field => {
if (definition.schema[field]?.type === "formula") {
// @ts-expect-error TODO check what use case removing that would break
delete definition.schema[field].formula
}
})
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/components/Block.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script>
import { getContext, onDestroy, onMount, setContext } from "svelte"
import { builderStore } from "stores/builder.js"
import { blockStore } from "stores/blocks.js"
import { blockStore } from "stores/blocks"
const component = getContext("component")
const { styleable } = getContext("sdk")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Block from "components/Block.svelte"
import BlockComponent from "components/BlockComponent.svelte"
import { makePropSafe as safe } from "@budibase/string-templates"
import { enrichSearchColumns, enrichFilter } from "utils/blocks.js"
import { enrichSearchColumns, enrichFilter } from "utils/blocks"
import { get } from "svelte/store"
export let title
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import Block from "components/Block.svelte"
import BlockComponent from "components/BlockComponent.svelte"
import { makePropSafe as safe } from "@budibase/string-templates"
import { enrichSearchColumns, enrichFilter } from "utils/blocks.js"
import { enrichSearchColumns, enrichFilter } from "utils/blocks"
import { Utils } from "@budibase/frontend-core"
export let title
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/utils/blocks.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { makePropSafe as safe } from "@budibase/string-templates"
import { API } from "../api/index.js"
import { API } from "../api"
import { UILogicalOperator } from "@budibase/types"
import { Constants } from "@budibase/frontend-core"

Expand Down
2 changes: 2 additions & 0 deletions packages/frontend-core/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ import { buildLogsEndpoints } from "./logs"
import { buildMigrationEndpoints } from "./migrations"
import { buildRowActionEndpoints } from "./rowActions"

export type { APIClient } from "./types"

/**
* Random identifier to uniquely identify a session in a tab. This is
* used to determine the originator of calls to the API, which is in
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend-core/src/api/self.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface SelfEndpoints {
generateAPIKey: () => Promise<string | undefined>
fetchDeveloperInfo: () => Promise<FetchAPIKeyResponse>
fetchBuilderSelf: () => Promise<GetGlobalSelfResponse>
fetchSelf: () => Promise<AppSelfResponse>
fetchSelf: () => Promise<AppSelfResponse | null>
}

export const buildSelfEndpoints = (API: BaseAPIClient): SelfEndpoints => ({
Expand Down
1 change: 1 addition & 0 deletions packages/frontend-core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { createAPIClient } from "./api"
export type { APIClient } from "./api"
export { fetchData, DataFetchMap } from "./fetch"
export type { DataFetchType } from "./fetch"
export * as Constants from "./constants"
Expand Down

0 comments on commit 757d99a

Please sign in to comment.