From 853ba4e20cfce22576b2d93a2293a3c02a5e1515 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 24 Dec 2024 00:50:20 +0100 Subject: [PATCH] More and more types --- .../src/components/grid/stores/datasource.ts | 2 +- .../src/components/grid/stores/datasources/index.ts | 10 +++++----- packages/frontend-core/src/utils/relatedColumns.ts | 12 ++++++------ packages/types/src/ui/stores/grid/table.ts | 5 +++-- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/packages/frontend-core/src/components/grid/stores/datasource.ts b/packages/frontend-core/src/components/grid/stores/datasource.ts index c969e05694..2d013fd23a 100644 --- a/packages/frontend-core/src/components/grid/stores/datasource.ts +++ b/packages/frontend-core/src/components/grid/stores/datasource.ts @@ -203,7 +203,7 @@ export const createActions = (context: StoreContext): ActionDatasourceStore => { // will not be received by the builder websocket because we caused it // ourselves dispatch("updatedatasource", newDefinition) - } catch (error) { + } catch (error: any) { const msg = error?.message || error || "Unknown error" get(notifications).error(`Error saving schema: ${msg}`) diff --git a/packages/frontend-core/src/components/grid/stores/datasources/index.ts b/packages/frontend-core/src/components/grid/stores/datasources/index.ts index 1d1a2103b1..a1ade22317 100644 --- a/packages/frontend-core/src/components/grid/stores/datasources/index.ts +++ b/packages/frontend-core/src/components/grid/stores/datasources/index.ts @@ -10,10 +10,10 @@ export interface DatasourceActions< TSaveDefinitionRequest = UpdateViewRequest | SaveTableRequest > { saveDefinition: (newDefinition: TSaveDefinitionRequest) => Promise - addRow: (row: SaveRowRequest) => Promise - updateRow: (row: SaveRowRequest) => Promise + addRow: (row: SaveRowRequest) => Promise + updateRow: (row: SaveRowRequest) => Promise deleteRows: (rows: (string | Row)[]) => Promise - getRow: (id: string) => Promise - isDatasourceValid: (datasource: UIDatasource) => boolean - canUseColumn: (name: string) => boolean + getRow: (id: string) => Promise + isDatasourceValid: (datasource: UIDatasource) => boolean | void + canUseColumn: (name: string) => boolean | void } diff --git a/packages/frontend-core/src/utils/relatedColumns.ts b/packages/frontend-core/src/utils/relatedColumns.ts index 37859e7ca1..ed4ccf438d 100644 --- a/packages/frontend-core/src/utils/relatedColumns.ts +++ b/packages/frontend-core/src/utils/relatedColumns.ts @@ -7,7 +7,7 @@ import { UIFieldSchema, } from "@budibase/types" -const columnTypeManyTypeOverrides = { +const columnTypeManyTypeOverrides: Partial> = { [FieldType.DATETIME]: FieldType.STRING, [FieldType.BOOLEAN]: FieldType.STRING, [FieldType.SIGNATURE_SINGLE]: FieldType.ATTACHMENTS, @@ -46,7 +46,7 @@ const columnTypeManyParser = { export function enrichSchemaWithRelColumns( schema: Record -): Record { +): Record | undefined { if (!schema) { return } @@ -71,7 +71,7 @@ export function enrichSchemaWithRelColumns( const name = `${field.name}.${relColumn}` result[name] = { ...relField, - type: null, // TODO + type: relField.type as any, // TODO name, related: { field: fieldName, subField: relColumn }, cellRenderType: @@ -102,10 +102,10 @@ export function getRelatedTableValues( if (fromSingle) { result = row[field.related.field]?.[0]?.[field.related.subField] } else { - const parser = columnTypeManyParser[field.type] || (value => value) + const parser = columnTypeManyParser[field.type] || ((value: any) => value) const value = row[field.related.field] - ?.flatMap(r => r[field.related.subField]) - ?.filter(i => i !== undefined && i !== null) + ?.flatMap((r: Row) => r[field.related.subField]) + ?.filter((i: any) => i !== undefined && i !== null) const parsed = parser(value || [], field) result = parsed if ( diff --git a/packages/types/src/ui/stores/grid/table.ts b/packages/types/src/ui/stores/grid/table.ts index d58bc93f8b..8975ef4cfc 100644 --- a/packages/types/src/ui/stores/grid/table.ts +++ b/packages/types/src/ui/stores/grid/table.ts @@ -1,16 +1,17 @@ import { BasicViewFieldMetadata, FieldSchema, + FieldType, RelationSchemaField, } from "@budibase/types" export type UIFieldSchema = FieldSchema & BasicViewFieldMetadata & { related?: { field: string; subField: string } - columns?: Record + columns?: Record cellRenderType?: string } interface UIRelationSchemaField extends RelationSchemaField { - type: string + type: FieldType }