diff --git a/packages/nocodb/src/lib/services/attachmentService.ts b/packages/nocodb/src/lib/services/attachmentService.ts index d65134e75b..f43c1d847f 100644 --- a/packages/nocodb/src/lib/services/attachmentService.ts +++ b/packages/nocodb/src/lib/services/attachmentService.ts @@ -11,6 +11,7 @@ export async function upload(param: { // todo: proper type files: unknown[]; }) { + // TODO: add getAjvValidatorMw const filePath = sanitizeUrlPath(param.path?.toString()?.split('/') || ['']); const destPath = path.join('nc', 'uploads', ...filePath); @@ -59,6 +60,7 @@ export async function uploadViaURL(param: { size?: string | number; }[]; }) { + // TODO: add getAjvValidatorMw const filePath = sanitizeUrlPath(param?.path?.toString()?.split('/') || ['']); const destPath = path.join('nc', 'uploads', ...filePath); diff --git a/packages/nocodb/src/lib/services/viewColumnService.ts b/packages/nocodb/src/lib/services/viewColumnService.ts index 73d2041d46..464fdd5b48 100644 --- a/packages/nocodb/src/lib/services/viewColumnService.ts +++ b/packages/nocodb/src/lib/services/viewColumnService.ts @@ -1,5 +1,7 @@ import { T } from 'nc-help'; +import { validatePayload } from '../meta/api/helpers'; import { View } from '../models'; +import type { ViewColumnReqType } from 'nocodb-sdk'; export async function columnList(param: { viewId: string }) { return await View.getColumns(param.viewId); @@ -7,9 +9,11 @@ export async function columnList(param: { viewId: string }) { export async function columnAdd(param: { viewId: string; columnId: string; - // todo: add proper type for grid column in swagger - column: any; + column: ViewColumnReqType; }) { + + validatePayload('swagger.json#/components/schemas/ViewColumnReq', param.column); + const viewColumn = await View.insertOrUpdateColumn( param.viewId, param.columnId, diff --git a/packages/nocodb/src/lib/services/viewService.ts b/packages/nocodb/src/lib/services/viewService.ts index f328d5bab8..c2a0be37a3 100644 --- a/packages/nocodb/src/lib/services/viewService.ts +++ b/packages/nocodb/src/lib/services/viewService.ts @@ -1,4 +1,5 @@ -import { SharedViewType, ViewType } from 'nocodb-sdk'; +import { SharedViewReqType, ViewReqType } from 'nocodb-sdk'; +import { validatePayload } from '../meta/api/helpers'; import { Model, View } from '../models'; import { T } from 'nc-help'; import { xcVisibilityMetaGet } from './modelVisibilityService'; @@ -33,8 +34,8 @@ export async function shareView(param: { viewId: string }) { return await View.share(param.viewId); } -// todo: type correctly -export async function viewUpdate(param: { viewId: string; view: ViewType }) { +export async function viewUpdate(param: { viewId: string; view: ViewReqType }) { + validatePayload('swagger.json#/components/schemas/ViewReq', param.view); const result = await View.update(param.viewId, param.view); T.emit('evt', { evt_type: 'vtable:updated', show_as: result.type }); return result; @@ -48,9 +49,9 @@ export async function viewDelete(param: { viewId: string }) { export async function shareViewUpdate(param: { viewId: string; - // todo: type correctly - sharedView: SharedViewType; + sharedView: SharedViewReqType; }) { + validatePayload('swagger.json#/components/schemas/SharedViewReq', param.sharedView); T.emit('evt', { evt_type: 'sharedView:updated' }); return await View.update(param.viewId, param.sharedView); }