diff --git a/packages/frontend-core/src/components/grid/stores/datasource.ts b/packages/frontend-core/src/components/grid/stores/datasource.ts index 472f598299..6b4fb8dc52 100644 --- a/packages/frontend-core/src/components/grid/stores/datasource.ts +++ b/packages/frontend-core/src/components/grid/stores/datasource.ts @@ -19,7 +19,7 @@ import { DatasourceActions } from "./datasources" interface DatasourceStore { definition: Writable schemaMutations: Writable> - subSchemaMutations: Writable> + subSchemaMutations: Writable>> } interface DerivedDatasourceStore { @@ -197,7 +197,7 @@ export const createActions = (context: StoreContext): ActionDatasourceStore => { // Update server if (get(config).canSaveSchema) { try { - await getAPI()?.actions.saveDefinition(newDefinition) + await getAPI()?.actions.saveDefinition(newDefinition as never) // Broadcast change so external state can be updated, as this change // will not be received by the builder websocket because we caused it @@ -277,15 +277,15 @@ export const createActions = (context: StoreContext): ActionDatasourceStore => { const $definition = get(definition) const $schemaMutations = get(schemaMutations) const $subSchemaMutations = get(subSchemaMutations) - const $schema = get(schema) - let newSchema = {} + const $schema = get(schema) || {} + let newSchema: Record = {} // Build new updated datasource schema Object.keys($schema).forEach(column => { newSchema[column] = { ...$schema[column], ...$schemaMutations[column], - } + } as UIFieldSchema // TODO if ($subSchemaMutations[column]) { newSchema[column].columns ??= {} for (const fieldName of Object.keys($subSchemaMutations[column])) { 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 a1ade22317..4c3ffc7a74 100644 --- a/packages/frontend-core/src/components/grid/stores/datasources/index.ts +++ b/packages/frontend-core/src/components/grid/stores/datasources/index.ts @@ -12,7 +12,7 @@ export interface DatasourceActions< saveDefinition: (newDefinition: TSaveDefinitionRequest) => Promise addRow: (row: SaveRowRequest) => Promise updateRow: (row: SaveRowRequest) => Promise - deleteRows: (rows: (string | Row)[]) => Promise + deleteRows: (rows: Row[]) => Promise getRow: (id: string) => Promise isDatasourceValid: (datasource: UIDatasource) => boolean | void canUseColumn: (name: string) => boolean | void diff --git a/packages/frontend-core/src/components/grid/stores/datasources/nonPlus.ts b/packages/frontend-core/src/components/grid/stores/datasources/nonPlus.ts index 2ea5a05a0e..65fc6d8696 100644 --- a/packages/frontend-core/src/components/grid/stores/datasources/nonPlus.ts +++ b/packages/frontend-core/src/components/grid/stores/datasources/nonPlus.ts @@ -5,7 +5,7 @@ import { DatasourceActions } from "." interface NonPlusActions { nonPlus: { - actions: DatasourceActions + actions: DatasourceActions } } 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 9f1a490306..5f3d27159e 100644 --- a/packages/frontend-core/src/components/grid/stores/datasources/table.ts +++ b/packages/frontend-core/src/components/grid/stores/datasources/table.ts @@ -34,7 +34,7 @@ export const createActions = (context: StoreContext): TableActions => { return await API.saveRow(row, SuppressErrors) } - const deleteRows = async (rows: (string | Row)[]) => { + const deleteRows = async (rows: Row[]) => { await API.deleteRows(get(datasource).tableId, rows) } 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 70a83b4594..edafd94d6f 100644 --- a/packages/frontend-core/src/components/grid/stores/datasources/viewV2.ts +++ b/packages/frontend-core/src/components/grid/stores/datasources/viewV2.ts @@ -39,7 +39,7 @@ export const createActions = (context: StoreContext): ViewActions => { } } - const deleteRows = async (rows: (string | Row)[]) => { + const deleteRows = async (rows: Row[]) => { await API.deleteRows(get(datasource).id, rows) }