Small view API typing update.

This commit is contained in:
mike12345567 2024-12-04 15:02:16 +00:00
parent a7a2a56044
commit aa2d6779cd
2 changed files with 8 additions and 4 deletions

View File

@ -4,7 +4,6 @@ import {
Ctx, Ctx,
RequiredKeys, RequiredKeys,
UpdateViewRequest, UpdateViewRequest,
ViewResponse,
ViewResponseEnriched, ViewResponseEnriched,
ViewV2, ViewV2,
BasicViewFieldMetadata, BasicViewFieldMetadata,
@ -15,6 +14,9 @@ import {
ViewFetchResponseEnriched, ViewFetchResponseEnriched,
CountDistinctCalculationFieldMetadata, CountDistinctCalculationFieldMetadata,
CountCalculationFieldMetadata, CountCalculationFieldMetadata,
CreateViewResponse,
UpdateViewResponse,
DeleteViewResponse,
} from "@budibase/types" } from "@budibase/types"
import { builderSocket, gridSocket } from "../../../websockets" import { builderSocket, gridSocket } from "../../../websockets"
import { helpers } from "@budibase/shared-core" import { helpers } from "@budibase/shared-core"
@ -132,7 +134,7 @@ export async function fetch(ctx: Ctx<void, ViewFetchResponseEnriched>) {
} }
} }
export async function create(ctx: Ctx<CreateViewRequest, ViewResponse>) { export async function create(ctx: Ctx<CreateViewRequest, CreateViewResponse>) {
const view = ctx.request.body const view = ctx.request.body
const { tableId } = view const { tableId } = view
@ -159,7 +161,7 @@ export async function create(ctx: Ctx<CreateViewRequest, ViewResponse>) {
gridSocket?.emitViewUpdate(ctx, result) gridSocket?.emitViewUpdate(ctx, result)
} }
export async function update(ctx: Ctx<UpdateViewRequest, ViewResponse>) { export async function update(ctx: Ctx<UpdateViewRequest, UpdateViewResponse>) {
const view = ctx.request.body const view = ctx.request.body
if (view.version !== 2) { if (view.version !== 2) {
@ -196,7 +198,7 @@ export async function update(ctx: Ctx<UpdateViewRequest, ViewResponse>) {
gridSocket?.emitViewUpdate(ctx, result) gridSocket?.emitViewUpdate(ctx, result)
} }
export async function remove(ctx: Ctx) { export async function remove(ctx: Ctx<void, void>) {
const { viewId } = ctx.params const { viewId } = ctx.params
const view = await sdk.views.remove(viewId) const view = await sdk.views.remove(viewId)

View File

@ -14,5 +14,7 @@ export interface ViewFetchResponseEnriched {
} }
export interface CreateViewRequest extends Omit<ViewV2, "version" | "id"> {} export interface CreateViewRequest extends Omit<ViewV2, "version" | "id"> {}
export interface CreateViewResponse extends ViewResponse {}
export interface UpdateViewRequest extends ViewV2 {} export interface UpdateViewRequest extends ViewV2 {}
export interface UpdateViewResponse extends ViewResponse {}