From 2ad7e738138513c88b8820c56d76af02a45e8120 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 14 Jan 2025 12:58:53 +0100 Subject: [PATCH] More types --- .../src/components/app/DataProvider.svelte | 23 +++++++++++-------- packages/client/src/index.ts | 5 ++-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/packages/client/src/components/app/DataProvider.svelte b/packages/client/src/components/app/DataProvider.svelte index 8b06190727..da7eceeb5c 100644 --- a/packages/client/src/components/app/DataProvider.svelte +++ b/packages/client/src/components/app/DataProvider.svelte @@ -11,6 +11,7 @@ EmptyFilterOption, TableSchema, SortOrder, + SearchFilters, } from "@budibase/types" import { SDK, Component } from "../../index" @@ -26,7 +27,7 @@ const component = getContext("component") let interval: NodeJS.Timeout - let queryExtensions = {} + let queryExtensions: Record = {} $: defaultQuery = QueryUtils.buildQuery(filter) @@ -79,6 +80,7 @@ }, }, ] + $: dataContext = { rows: $fetch.rows, info: $fetch.info, @@ -91,14 +93,12 @@ id: $component?.id, state: { query: $fetch.query, - sortColumn: $fetch.sortColumn, - sortOrder: $fetch.sortOrder, }, limit, - primaryDisplay: $fetch.definition?.primaryDisplay, + primaryDisplay: ($fetch.definition as any)?.primaryDisplay, } - const createFetch = datasource => { + const createFetch = (datasource: any) => { return fetchData({ API, datasource, @@ -125,7 +125,7 @@ return cloned } - const addQueryExtension = (key: string, extension) => { + const addQueryExtension = (key: string, extension: any) => { if (!key || !extension) { return } @@ -141,11 +141,14 @@ queryExtensions = newQueryExtensions } - const extendQuery = (defaultQuery, extensions) => { + const extendQuery = ( + defaultQuery: SearchFilters, + extensions: Record + ): SearchFilters => { if (!Object.keys(extensions).length) { return defaultQuery } - const extended = { + const extended: SearchFilters = { [LogicalOperator.AND]: { conditions: [ ...(defaultQuery ? [defaultQuery] : []), @@ -156,9 +159,9 @@ } // If there are no conditions applied at all, clear the request. - return extended[LogicalOperator.AND]?.conditions?.length > 0 + return (extended[LogicalOperator.AND]?.conditions?.length ?? 0) > 0 ? extended - : null + : {} } const setUpAutoRefresh = (autoRefresh: number) => { diff --git a/packages/client/src/index.ts b/packages/client/src/index.ts index 2a66d0c995..2bcb476b30 100644 --- a/packages/client/src/index.ts +++ b/packages/client/src/index.ts @@ -4,11 +4,12 @@ import { Readable } from "svelte/store" export interface SDK { API: APIClient - styleable: unknown - Provider: unknown + styleable: any + Provider: any ActionTypes: typeof ActionTypes } export type Component = Readable<{ id: string + styles: any }>