More typings
This commit is contained in:
parent
e3a811d1a6
commit
577df882ae
|
@ -19,7 +19,7 @@ import { DatasourceActions } from "./datasources"
|
||||||
interface DatasourceStore {
|
interface DatasourceStore {
|
||||||
definition: Writable<UIDatasource>
|
definition: Writable<UIDatasource>
|
||||||
schemaMutations: Writable<Record<string, UIFieldMutation>>
|
schemaMutations: Writable<Record<string, UIFieldMutation>>
|
||||||
subSchemaMutations: Writable<Record<string, UIFieldMutation>>
|
subSchemaMutations: Writable<Record<string, Record<string, UIFieldMutation>>>
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DerivedDatasourceStore {
|
interface DerivedDatasourceStore {
|
||||||
|
@ -197,7 +197,7 @@ export const createActions = (context: StoreContext): ActionDatasourceStore => {
|
||||||
// Update server
|
// Update server
|
||||||
if (get(config).canSaveSchema) {
|
if (get(config).canSaveSchema) {
|
||||||
try {
|
try {
|
||||||
await getAPI()?.actions.saveDefinition(newDefinition)
|
await getAPI()?.actions.saveDefinition(newDefinition as never)
|
||||||
|
|
||||||
// Broadcast change so external state can be updated, as this change
|
// Broadcast change so external state can be updated, as this change
|
||||||
// will not be received by the builder websocket because we caused it
|
// 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 $definition = get(definition)
|
||||||
const $schemaMutations = get(schemaMutations)
|
const $schemaMutations = get(schemaMutations)
|
||||||
const $subSchemaMutations = get(subSchemaMutations)
|
const $subSchemaMutations = get(subSchemaMutations)
|
||||||
const $schema = get(schema)
|
const $schema = get(schema) || {}
|
||||||
let newSchema = {}
|
let newSchema: Record<string, UIFieldSchema> = {}
|
||||||
|
|
||||||
// Build new updated datasource schema
|
// Build new updated datasource schema
|
||||||
Object.keys($schema).forEach(column => {
|
Object.keys($schema).forEach(column => {
|
||||||
newSchema[column] = {
|
newSchema[column] = {
|
||||||
...$schema[column],
|
...$schema[column],
|
||||||
...$schemaMutations[column],
|
...$schemaMutations[column],
|
||||||
}
|
} as UIFieldSchema // TODO
|
||||||
if ($subSchemaMutations[column]) {
|
if ($subSchemaMutations[column]) {
|
||||||
newSchema[column].columns ??= {}
|
newSchema[column].columns ??= {}
|
||||||
for (const fieldName of Object.keys($subSchemaMutations[column])) {
|
for (const fieldName of Object.keys($subSchemaMutations[column])) {
|
||||||
|
|
|
@ -12,7 +12,7 @@ export interface DatasourceActions<
|
||||||
saveDefinition: (newDefinition: TSaveDefinitionRequest) => Promise<void>
|
saveDefinition: (newDefinition: TSaveDefinitionRequest) => Promise<void>
|
||||||
addRow: (row: SaveRowRequest) => Promise<Row | void>
|
addRow: (row: SaveRowRequest) => Promise<Row | void>
|
||||||
updateRow: (row: SaveRowRequest) => Promise<Row | void>
|
updateRow: (row: SaveRowRequest) => Promise<Row | void>
|
||||||
deleteRows: (rows: (string | Row)[]) => Promise<void>
|
deleteRows: (rows: Row[]) => Promise<void>
|
||||||
getRow: (id: string) => Promise<Row | void>
|
getRow: (id: string) => Promise<Row | void>
|
||||||
isDatasourceValid: (datasource: UIDatasource) => boolean | void
|
isDatasourceValid: (datasource: UIDatasource) => boolean | void
|
||||||
canUseColumn: (name: string) => boolean | void
|
canUseColumn: (name: string) => boolean | void
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { DatasourceActions } from "."
|
||||||
|
|
||||||
interface NonPlusActions {
|
interface NonPlusActions {
|
||||||
nonPlus: {
|
nonPlus: {
|
||||||
actions: DatasourceActions<never>
|
actions: DatasourceActions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ export const createActions = (context: StoreContext): TableActions => {
|
||||||
return await API.saveRow(row, SuppressErrors)
|
return await API.saveRow(row, SuppressErrors)
|
||||||
}
|
}
|
||||||
|
|
||||||
const deleteRows = async (rows: (string | Row)[]) => {
|
const deleteRows = async (rows: Row[]) => {
|
||||||
await API.deleteRows(get(datasource).tableId, rows)
|
await API.deleteRows(get(datasource).tableId, rows)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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)
|
await API.deleteRows(get(datasource).id, rows)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue