More types

This commit is contained in:
Adria Navarro 2024-12-24 01:24:52 +01:00
parent 853ba4e20c
commit e3a811d1a6
3 changed files with 13 additions and 11 deletions

View File

@ -18,13 +18,13 @@ import { DatasourceActions } from "./datasources"
interface DatasourceStore {
definition: Writable<UIDatasource>
schemaMutations: Writable<Record<string, {}>>
subSchemaMutations: Writable<Record<string, {}>>
schemaMutations: Writable<Record<string, UIFieldMutation>>
subSchemaMutations: Writable<Record<string, UIFieldMutation>>
}
interface DerivedDatasourceStore {
schema: Readable<Record<string, FieldSchema>>
enrichedSchema: Readable<Record<string, UIFieldSchema>>
schema: Readable<Record<string, FieldSchema> | null>
enrichedSchema: Readable<Record<string, UIFieldSchema> | null>
hasBudibaseIdentifiers: Readable<boolean>
}
@ -100,9 +100,9 @@ export const deriveStores = (context: StoreContext): DerivedDatasourceStore => {
const schemaWithRelatedColumns = enrichSchemaWithRelColumns($schema)
const enrichedSchema: Record<string, UIFieldSchema> = {}
Object.keys(schemaWithRelatedColumns).forEach(field => {
Object.keys(schemaWithRelatedColumns || {}).forEach(field => {
enrichedSchema[field] = {
...schemaWithRelatedColumns[field],
...schemaWithRelatedColumns?.[field],
...$schemaOverrides?.[field],
...$schemaMutations[field],
}
@ -197,7 +197,7 @@ export const createActions = (context: StoreContext): ActionDatasourceStore => {
// Update server
if (get(config).canSaveSchema) {
try {
await getAPI()?.actions.saveDefinition(newDefinition as any)
await getAPI()?.actions.saveDefinition(newDefinition)
// Broadcast change so external state can be updated, as this change
// will not be received by the builder websocket because we caused it

View File

@ -102,12 +102,14 @@ export function getRelatedTableValues(
if (fromSingle) {
result = row[field.related.field]?.[0]?.[field.related.subField]
} else {
const parser = columnTypeManyParser[field.type] || ((value: any) => value)
const parser =
columnTypeManyParser[field.type as keyof typeof columnTypeManyParser] ||
((value: any) => value)
const value = row[field.related.field]
?.flatMap((r: Row) => r[field.related.subField])
?.filter((i: any) => i !== undefined && i !== null)
const parsed = parser(value || [], field)
result = parsed
const parsed = parser(value || [], field as any)
result = parsed as any
if (
[
FieldType.STRING,

View File

@ -7,7 +7,7 @@ import {
export type UIFieldSchema = FieldSchema &
BasicViewFieldMetadata & {
related?: { field: string; subField: string }
related: { field: string; subField: string }
columns?: Record<string, UIRelationSchemaField>
cellRenderType?: string
}