From 20a226a0a5b0c174d3e7734de374d4880d1560b0 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 13 Jan 2025 11:30:04 +0100 Subject: [PATCH] Initial typings --- packages/client/src/api/patches.ts | 9 +++++---- packages/frontend-core/src/api/index.ts | 2 ++ packages/frontend-core/src/index.ts | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/client/src/api/patches.ts b/packages/client/src/api/patches.ts index 722167e16d..77061968d7 100644 --- a/packages/client/src/api/patches.ts +++ b/packages/client/src/api/patches.ts @@ -1,19 +1,20 @@ -import { Constants } from "@budibase/frontend-core" +import { Constants, APIClient } from "@budibase/frontend-core" import { FieldTypes } from "../constants" +import { Row, Table } from "@budibase/types" -export const patchAPI = API => { +export const patchAPI = (API: APIClient) => { /** * Enriches rows which contain certain field types so that they can * be properly displayed. * The ability to create these bindings has been removed, but they will still * exist in client apps to support backwards compatibility. */ - const enrichRows = async (rows, tableId) => { + const enrichRows = async (rows: Row[], tableId: string) => { if (!Array.isArray(rows)) { return [] } if (rows.length) { - const tables = {} + const tables: Record = {} for (let row of rows) { // Fall back to passed in tableId if row doesn't have it specified let rowTableId = row.tableId || tableId diff --git a/packages/frontend-core/src/api/index.ts b/packages/frontend-core/src/api/index.ts index 6efc90023a..485e4d8b5a 100644 --- a/packages/frontend-core/src/api/index.ts +++ b/packages/frontend-core/src/api/index.ts @@ -46,6 +46,8 @@ import { buildLogsEndpoints } from "./logs" import { buildMigrationEndpoints } from "./migrations" import { buildRowActionEndpoints } from "./rowActions" +export type { APIClient } from "./types" + /** * Random identifier to uniquely identify a session in a tab. This is * used to determine the originator of calls to the API, which is in diff --git a/packages/frontend-core/src/index.ts b/packages/frontend-core/src/index.ts index c0baa63ab6..fd5595e04d 100644 --- a/packages/frontend-core/src/index.ts +++ b/packages/frontend-core/src/index.ts @@ -1,4 +1,5 @@ export { createAPIClient } from "./api" +export type { APIClient } from "./api" export { fetchData, DataFetchMap } from "./fetch" export type { DataFetchType } from "./fetch" export * as Constants from "./constants"