From 9ede7b43c823511b9f74867a12056cb7e4c77dfb Mon Sep 17 00:00:00 2001 From: Thomas Draier Date: Fri, 9 Aug 2024 17:26:25 +0200 Subject: [PATCH] fix --- front/pages/api/w/[wId]/vaults/[vId]/categories.ts | 2 +- .../w/[wId]/vaults/[vId]/data_source_views/index.ts | 12 +++++++----- .../api/w/[wId]/vaults/[vId]/data_sources/index.ts | 10 ++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/front/pages/api/w/[wId]/vaults/[vId]/categories.ts b/front/pages/api/w/[wId]/vaults/[vId]/categories.ts index a3efe49725a5..71cf2aed33aa 100644 --- a/front/pages/api/w/[wId]/vaults/[vId]/categories.ts +++ b/front/pages/api/w/[wId]/vaults/[vId]/categories.ts @@ -8,7 +8,7 @@ import { apiError } from "@app/logger/withlogging"; import { getDataSourceViewsInfo } from "@app/pages/api/w/[wId]/vaults/[vId]/data_source_views"; import { getDataSourceInfos } from "@app/pages/api/w/[wId]/vaults/[vId]/data_sources"; -type VaultCategoryInfo = { +export type VaultCategoryInfo = { category: ResourceCategory; usage: number; count: number; diff --git a/front/pages/api/w/[wId]/vaults/[vId]/data_source_views/index.ts b/front/pages/api/w/[wId]/vaults/[vId]/data_source_views/index.ts index a6c4bfd11b33..5a3bf853fd5e 100644 --- a/front/pages/api/w/[wId]/vaults/[vId]/data_source_views/index.ts +++ b/front/pages/api/w/[wId]/vaults/[vId]/data_source_views/index.ts @@ -12,8 +12,8 @@ import { DataSourceViewResource } from "@app/lib/resources/data_source_view_reso import { VaultResource } from "@app/lib/resources/vault_resource"; import { apiError } from "@app/logger/withlogging"; -export type GetVaultDataSourcesResponseBody = { - dataSources: ResourceInfo[]; +export type GetVaultDataSourceViewsResponseBody = { + dataSourceViews: ResourceInfo[]; }; export const getDataSourceCategory = ( @@ -38,7 +38,7 @@ export const getDataSourceViewsInfo = async ( return dataSourceViews.map((view) => { return { - ...view.dataSource?.toJSON(), + ...(view.dataSource as DataSourceResource).toJSON(), ...view.toJSON(), usage: 0, category: getDataSourceCategory(view.dataSource as DataSourceResource), @@ -48,7 +48,9 @@ export const getDataSourceViewsInfo = async ( async function handler( req: NextApiRequest, - res: NextApiResponse>, + res: NextApiResponse< + WithAPIErrorResponse + >, auth: Authenticator ): Promise { const owner = auth.workspace(); @@ -87,7 +89,7 @@ async function handler( const all = await getDataSourceViewsInfo(auth, vault); res.status(200).json({ - dataSources: all.filter( + dataSourceViews: all.filter( (dataSourceInfo) => !category || dataSourceInfo.category === category ), }); diff --git a/front/pages/api/w/[wId]/vaults/[vId]/data_sources/index.ts b/front/pages/api/w/[wId]/vaults/[vId]/data_sources/index.ts index fae9abff3e6e..4b0ac7b642ba 100644 --- a/front/pages/api/w/[wId]/vaults/[vId]/data_sources/index.ts +++ b/front/pages/api/w/[wId]/vaults/[vId]/data_sources/index.ts @@ -11,8 +11,8 @@ import { DataSourceResource } from "@app/lib/resources/data_source_resource"; import { VaultResource } from "@app/lib/resources/vault_resource"; import { apiError } from "@app/logger/withlogging"; -export type GetVaultDataSourceViewsResponseBody = { - dataSourceViews: ResourceInfo[]; +export type GetVaultDataSourcesResponseBody = { + dataSources: ResourceInfo[]; }; export const getDataSourceCategory = ( @@ -45,9 +45,7 @@ export const getDataSourceInfos = async ( async function handler( req: NextApiRequest, - res: NextApiResponse< - WithAPIErrorResponse - >, + res: NextApiResponse>, auth: Authenticator ): Promise { const owner = auth.workspace(); @@ -86,7 +84,7 @@ async function handler( const all = await getDataSourceInfos(auth, vault); res.status(200).json({ - dataSourceViews: all.filter( + dataSources: all.filter( (dataSourceInfo) => !category || dataSourceInfo.category === category ), });