Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tdraier committed Aug 9, 2024
1 parent e4c878f commit 9ede7b4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion front/pages/api/w/[wId]/vaults/[vId]/categories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 7 additions & 5 deletions front/pages/api/w/[wId]/vaults/[vId]/data_source_views/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand All @@ -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),
Expand All @@ -48,7 +48,9 @@ export const getDataSourceViewsInfo = async (

async function handler(
req: NextApiRequest,
res: NextApiResponse<WithAPIErrorResponse<GetVaultDataSourcesResponseBody>>,
res: NextApiResponse<
WithAPIErrorResponse<GetVaultDataSourceViewsResponseBody>
>,
auth: Authenticator
): Promise<void> {
const owner = auth.workspace();
Expand Down Expand Up @@ -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
),
});
Expand Down
10 changes: 4 additions & 6 deletions front/pages/api/w/[wId]/vaults/[vId]/data_sources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down Expand Up @@ -45,9 +45,7 @@ export const getDataSourceInfos = async (

async function handler(
req: NextApiRequest,
res: NextApiResponse<
WithAPIErrorResponse<GetVaultDataSourceViewsResponseBody>
>,
res: NextApiResponse<WithAPIErrorResponse<GetVaultDataSourcesResponseBody>>,
auth: Authenticator
): Promise<void> {
const owner = auth.workspace();
Expand Down Expand Up @@ -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
),
});
Expand Down

0 comments on commit 9ede7b4

Please sign in to comment.