From 999b93d0a9b48c13131d2b39482df79f0c3825fa Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 11 Apr 2022 12:48:59 +0800 Subject: [PATCH] fix: pass fn names manually to ncMetaAclMw instead of using minified ones Signed-off-by: Wing-Kam Wong --- .../src/lib/noco/meta/api/apiTokenApis.ts | 12 +++++-- .../src/lib/noco/meta/api/attachmentApis.ts | 2 +- .../nocodb/src/lib/noco/meta/api/auditApis.ts | 11 +++--- .../src/lib/noco/meta/api/columnApis.ts | 14 +++++--- .../meta/api/dataApis/bulkDataAliasApis.ts | 10 +++--- .../noco/meta/api/dataApis/dataAliasApis.ts | 12 +++---- .../lib/noco/meta/api/dataApis/dataApis.ts | 24 ++++++------- .../lib/noco/meta/api/dataApis/oldDataApis.ts | 22 +++++++++--- .../src/lib/noco/meta/api/exportApis.ts | 2 +- .../src/lib/noco/meta/api/filterApis.ts | 24 +++++++++---- .../src/lib/noco/meta/api/formViewApis.ts | 14 +++++--- .../lib/noco/meta/api/formViewColumnApis.ts | 5 ++- .../src/lib/noco/meta/api/galleryViewApis.ts | 15 ++++++-- .../src/lib/noco/meta/api/gridViewApis.ts | 5 ++- .../lib/noco/meta/api/gridViewColumnApis.ts | 10 ++++-- .../nocodb/src/lib/noco/meta/api/hookApis.ts | 10 +++--- .../src/lib/noco/meta/api/hookFilterApis.ts | 24 +++++++++---- .../src/lib/noco/meta/api/metaDiffApis.ts | 7 ++-- .../src/lib/noco/meta/api/pluginApis.ts | 10 +++--- .../src/lib/noco/meta/api/projectApis.ts | 16 ++++++--- .../src/lib/noco/meta/api/projectUserApis.ts | 11 +++--- .../src/lib/noco/meta/api/sharedBaseApis.ts | 11 +++--- .../nocodb/src/lib/noco/meta/api/sortApis.ts | 16 ++++++--- .../nocodb/src/lib/noco/meta/api/tableApis.ts | 21 +++++++---- .../src/lib/noco/meta/api/userApi/userApis.ts | 6 ++-- .../nocodb/src/lib/noco/meta/api/utilApis.ts | 2 +- .../nocodb/src/lib/noco/meta/api/viewApis.ts | 35 +++++++++++++------ .../src/lib/noco/meta/api/viewColumnApis.ts | 4 +-- .../src/lib/noco/meta/helpers/ncMetaAclMw.ts | 2 +- 29 files changed, 241 insertions(+), 116 deletions(-) diff --git a/packages/nocodb/src/lib/noco/meta/api/apiTokenApis.ts b/packages/nocodb/src/lib/noco/meta/api/apiTokenApis.ts index 360d0c2402..5043225c24 100644 --- a/packages/nocodb/src/lib/noco/meta/api/apiTokenApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/apiTokenApis.ts @@ -17,11 +17,17 @@ export async function apiTokenDelete(req: Request, res: Response) { const router = Router({ mergeParams: true }); -router.get('/projects/:projectId/apiTokens', ncMetaAclMw(apiTokenList)); -router.post('/projects/:projectId/apiTokens', ncMetaAclMw(apiTokenCreate)); +router.get( + '/projects/:projectId/apiTokens', + ncMetaAclMw(apiTokenList, 'apiTokenList') +); +router.post( + '/projects/:projectId/apiTokens', + ncMetaAclMw(apiTokenCreate, 'apiTokenCreate') +); router.delete( '/projects/:projectId/apiTokens/:token', - ncMetaAclMw(apiTokenDelete) + ncMetaAclMw(apiTokenDelete, 'apiTokenDelete') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/attachmentApis.ts b/packages/nocodb/src/lib/noco/meta/api/attachmentApis.ts index 9debc6f4a6..b5604a2e21 100644 --- a/packages/nocodb/src/lib/noco/meta/api/attachmentApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/attachmentApis.ts @@ -87,7 +87,7 @@ router.post( multer({ storage: multer.diskStorage({}) }).any(), - ncMetaAclMw(upload) + ncMetaAclMw(upload, 'upload') ); router.get('/download/:projectId/:viewId/:fileName', catchError(fileRead)); diff --git a/packages/nocodb/src/lib/noco/meta/api/auditApis.ts b/packages/nocodb/src/lib/noco/meta/api/auditApis.ts index 62a59fe246..2ec433fd0c 100644 --- a/packages/nocodb/src/lib/noco/meta/api/auditApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/auditApis.ts @@ -58,9 +58,12 @@ export async function commentsCount(req: Request, res) { } const router = Router({ mergeParams: true }); -router.get('/audits/comments', ncMetaAclMw(commentList)); +router.get('/audits/comments', ncMetaAclMw(commentList, 'commentList')); router.post('/audits/rowUpdate', ncMetaAclMw(auditRowUpdate, 'auditRowUpdate')); -router.post('/audits/comments', ncMetaAclMw(commentRow)); -router.get('/audits/comments/count', ncMetaAclMw(commentsCount)); -router.get('/project/:projectId/audits', ncMetaAclMw(auditList)); +router.post('/audits/comments', ncMetaAclMw(commentRow, 'commentRow')); +router.get( + '/audits/comments/count', + ncMetaAclMw(commentsCount, 'commentsCount') +); +router.get('/project/:projectId/audits', ncMetaAclMw(auditList, 'auditList')); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/columnApis.ts b/packages/nocodb/src/lib/noco/meta/api/columnApis.ts index bee441428b..91b18ce1a5 100644 --- a/packages/nocodb/src/lib/noco/meta/api/columnApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/columnApis.ts @@ -900,11 +900,17 @@ const deleteHmOrBtRelation = async ( }; const router = Router({ mergeParams: true }); -router.post('/tables/:tableId/columns/', ncMetaAclMw(columnAdd)); -router.put('/tables/:tableId/columns/:columnId', ncMetaAclMw(columnUpdate)); -router.delete('/tables/:tableId/columns/:columnId', ncMetaAclMw(columnDelete)); +router.post('/tables/:tableId/columns/', ncMetaAclMw(columnAdd, 'columnAdd')); +router.put( + '/tables/:tableId/columns/:columnId', + ncMetaAclMw(columnUpdate, 'columnUpdate') +); +router.delete( + '/tables/:tableId/columns/:columnId', + ncMetaAclMw(columnDelete, 'columnDelete') +); router.post( '/tables/:tableId/columns/:columnId/primary', - ncMetaAclMw(columnSetAsPrimary) + ncMetaAclMw(columnSetAsPrimary, 'columnSetAsPrimary') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/bulkDataAliasApis.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/bulkDataAliasApis.ts index 5ac4f237e8..da81a2df3e 100644 --- a/packages/nocodb/src/lib/noco/meta/api/dataApis/bulkDataAliasApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/bulkDataAliasApis.ts @@ -92,23 +92,23 @@ const router = Router({ mergeParams: true }); router.post( '/bulkData/:orgs/:projectName/:tableAlias', - ncMetaAclMw(bulkDataInsert) + ncMetaAclMw(bulkDataInsert, 'bulkDataInsert') ); router.patch( '/bulkData/:orgs/:projectName/:tableAlias', - ncMetaAclMw(bulkDataUpdate) + ncMetaAclMw(bulkDataUpdate, 'bulkDataUpdate') ); router.patch( '/bulkData/:orgs/:projectName/:tableAlias/all', - ncMetaAclMw(bulkDataUpdateAll) + ncMetaAclMw(bulkDataUpdateAll, 'bulkDataUpdateAll') ); router.delete( '/bulkData/:orgs/:projectName/:tableAlias', - ncMetaAclMw(bulkDataDelete) + ncMetaAclMw(bulkDataDelete, 'bulkDataDelete') ); router.delete( '/bulkData/:orgs/:projectName/:tableAlias/all', - ncMetaAclMw(bulkDataDeleteAll) + ncMetaAclMw(bulkDataDeleteAll, 'bulkDataDeleteAll') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasApis.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasApis.ts index d301c05a7d..92b16f9341 100644 --- a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataAliasApis.ts @@ -125,27 +125,27 @@ async function dataRead(req: Request, res: Response) { const router = Router({ mergeParams: true }); -router.get('/data/:orgs/:projectName/:tableName', ncMetaAclMw(dataList)); +router.get('/data/:orgs/:projectName/:tableName', ncMetaAclMw(dataList, 'dataList')); router.get( '/data/:orgs/:projectName/:tableName/views/:viewName', - ncMetaAclMw(dataList) + ncMetaAclMw(dataList, 'dataList') ); router.post( '/data/:orgs/:projectName/:tableName/views/:viewName', - ncMetaAclMw(dataInsert) + ncMetaAclMw(dataInsert, 'dataInsert') ); router.put( '/data/:orgs/:projectName/:tableName/views/:viewName/:rowId', - ncMetaAclMw(dataUpdate) + ncMetaAclMw(dataUpdate, 'dataUpdate') ); router.get( '/data/:orgs/:projectName/:tableName/views/:viewName/:rowId', - ncMetaAclMw(dataRead) + ncMetaAclMw(dataRead, 'dataRead') ); router.delete( '/data/:orgs/:projectName/:tableName/views/:viewName/:rowId', - ncMetaAclMw(dataDelete) + ncMetaAclMw(dataDelete, 'dataDelete') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataApis.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataApis.ts index e298aded0c..edefdf35d2 100644 --- a/packages/nocodb/src/lib/noco/meta/api/dataApis/dataApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/dataApis.ts @@ -563,34 +563,34 @@ const router = Router({ mergeParams: true }); // ncMetaAclMw(dataDeleteNew) // ); -router.get('/data/:viewId/', ncMetaAclMw(dataList)); -router.post('/data/:viewId/', ncMetaAclMw(dataInsert)); -router.get('/data/:viewId/:rowId', ncMetaAclMw(dataRead)); -router.put('/data/:viewId/:rowId', ncMetaAclMw(dataUpdate)); -router.delete('/data/:viewId/:rowId', ncMetaAclMw(dataDelete)); +router.get('/data/:viewId/', ncMetaAclMw(dataList, 'dataList')); +router.post('/data/:viewId/', ncMetaAclMw(dataInsert, 'dataInsert')); +router.get('/data/:viewId/:rowId', ncMetaAclMw(dataRead, 'dataRead')); +router.put('/data/:viewId/:rowId', ncMetaAclMw(dataUpdate, 'dataUpdate')); +router.delete('/data/:viewId/:rowId', ncMetaAclMw(dataDelete, 'dataDelete')); -router.get('/data/:viewId/:rowId/mm/:colId', ncMetaAclMw(mmList)); -router.get('/data/:viewId/:rowId/hm/:colId', ncMetaAclMw(hmList)); +router.get('/data/:viewId/:rowId/mm/:colId', ncMetaAclMw(mmList, 'mmList')); +router.get('/data/:viewId/:rowId/hm/:colId', ncMetaAclMw(hmList, 'hmList')); router.get( '/data/:viewId/:rowId/mm/:colId/exclude', - ncMetaAclMw(mmExcludedList) + ncMetaAclMw(mmExcludedList, 'mmExcludedList') ); router.get( '/data/:viewId/:rowId/hm/:colId/exclude', - ncMetaAclMw(hmExcludedList) + ncMetaAclMw(hmExcludedList, 'hmExcludedList') ); router.get( '/data/:viewId/:rowId/bt/:colId/exclude', - ncMetaAclMw(btExcludedList) + ncMetaAclMw(btExcludedList, 'btExcludedList') ); router.post( '/data/:viewId/:rowId/:relationType/:colId/:childId', - ncMetaAclMw(relationDataAdd) + ncMetaAclMw(relationDataAdd, 'relationDataAdd') ); router.delete( '/data/:viewId/:rowId/:relationType/:colId/:childId', - ncMetaAclMw(relationDataDelete) + ncMetaAclMw(relationDataDelete, 'relationDataDelete') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/oldDataApis.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/oldDataApis.ts index 564f867206..14d9b68654 100644 --- a/packages/nocodb/src/lib/noco/meta/api/dataApis/oldDataApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/oldDataApis.ts @@ -125,14 +125,26 @@ async function dataRead(req: Request, res: Response) { const router = Router({ mergeParams: true }); -router.get('/nc/:projectId/api/v2/:tableName', ncMetaAclMw(dataList)); +router.get( + '/nc/:projectId/api/v2/:tableName', + ncMetaAclMw(dataList, 'dataList') +); -router.post('/nc/:projectId/api/v2/:tableName', ncMetaAclMw(dataInsert)); -router.get('/nc/:projectId/api/v2/:tableName/:rowId', ncMetaAclMw(dataRead)); -router.put('/nc/:projectId/api/v2/:tableName/:rowId', ncMetaAclMw(dataUpdate)); +router.post( + '/nc/:projectId/api/v2/:tableName', + ncMetaAclMw(dataInsert, 'dataInsert') +); +router.get( + '/nc/:projectId/api/v2/:tableName/:rowId', + ncMetaAclMw(dataRead, 'dataRead') +); +router.put( + '/nc/:projectId/api/v2/:tableName/:rowId', + ncMetaAclMw(dataUpdate, 'dataUpdate') +); router.delete( '/nc/:projectId/api/v2/:tableName/:rowId', - ncMetaAclMw(dataDelete) + ncMetaAclMw(dataDelete, 'dataDelete') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/exportApis.ts b/packages/nocodb/src/lib/noco/meta/api/exportApis.ts index 33cca96cd9..d995aefa25 100644 --- a/packages/nocodb/src/lib/noco/meta/api/exportApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/exportApis.ts @@ -173,5 +173,5 @@ async function serializeCellValue({ } const router = Router({ mergeParams: true }); -router.get('/data/:viewId/export/csv', ncMetaAclMw(exportCsv)); +router.get('/data/:viewId/export/csv', ncMetaAclMw(exportCsv, 'exportCsv')); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/filterApis.ts b/packages/nocodb/src/lib/noco/meta/api/filterApis.ts index 39890c9471..a67484f015 100644 --- a/packages/nocodb/src/lib/noco/meta/api/filterApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/filterApis.ts @@ -106,13 +106,25 @@ export async function filterDelete(req: Request, res: Response, next) { } const router = Router({ mergeParams: true }); -router.get('/views/:viewId/filters/', ncMetaAclMw(filterList)); -router.post('/views/:viewId/filters/', ncMetaAclMw(filterCreate)); -router.get('/views/:viewId/filters/:filterId', ncMetaAclMw(filterGet)); -router.put('/views/:viewId/filters/:filterId', ncMetaAclMw(filterUpdate)); -router.delete('/views/:viewId/filters/:filterId', ncMetaAclMw(filterDelete)); +router.get('/views/:viewId/filters/', ncMetaAclMw(filterList, 'filterList')); +router.post( + '/views/:viewId/filters/', + ncMetaAclMw(filterCreate, 'filterCreate') +); +router.get( + '/views/:viewId/filters/:filterId', + ncMetaAclMw(filterGet, 'filterGet') +); +router.put( + '/views/:viewId/filters/:filterId', + ncMetaAclMw(filterUpdate, 'filterUpdate') +); +router.delete( + '/views/:viewId/filters/:filterId', + ncMetaAclMw(filterDelete, 'filterDelete') +); router.get( '/views/:viewId/filters/:filterParentId/children', - ncMetaAclMw(filterChildrenRead) + ncMetaAclMw(filterChildrenRead, 'filterChildrenRead') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/formViewApis.ts b/packages/nocodb/src/lib/noco/meta/api/formViewApis.ts index 2aa7055155..f379b5b7a6 100644 --- a/packages/nocodb/src/lib/noco/meta/api/formViewApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/formViewApis.ts @@ -39,8 +39,14 @@ export async function formViewUpdate(req, res) { export async function formViewDelete(req: Request, res: Response, next) {} const router = Router({ mergeParams: true }); -router.post('/tables/:tableId/forms', ncMetaAclMw(formViewCreate)); -router.get('/forms/:formViewId', ncMetaAclMw(formViewGet)); -router.put('/forms/:formViewId', ncMetaAclMw(formViewUpdate)); -router.delete('/forms/:formViewId', ncMetaAclMw(formViewDelete)); +router.post( + '/tables/:tableId/forms', + ncMetaAclMw(formViewCreate, 'formViewCreate') +); +router.get('/forms/:formViewId', ncMetaAclMw(formViewGet, 'formViewGet')); +router.put('/forms/:formViewId', ncMetaAclMw(formViewUpdate, 'formViewUpdate')); +router.delete( + '/forms/:formViewId', + ncMetaAclMw(formViewDelete, 'formViewDelete') +); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/formViewColumnApis.ts b/packages/nocodb/src/lib/noco/meta/api/formViewColumnApis.ts index 06537da9b7..891ad603fb 100644 --- a/packages/nocodb/src/lib/noco/meta/api/formViewColumnApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/formViewColumnApis.ts @@ -9,5 +9,8 @@ export async function columnUpdate(req: Request, res: Response) { } const router = Router({ mergeParams: true }); -router.put('/formColumns/:formViewColumnId', ncMetaAclMw(columnUpdate)); +router.put( + '/formColumns/:formViewColumnId', + ncMetaAclMw(columnUpdate, 'columnUpdate') +); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/galleryViewApis.ts b/packages/nocodb/src/lib/noco/meta/api/galleryViewApis.ts index a7be5b7d75..5c662ff0b4 100644 --- a/packages/nocodb/src/lib/noco/meta/api/galleryViewApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/galleryViewApis.ts @@ -46,9 +46,18 @@ export async function galleyViewDelete(req: Request, res: Response, next) {} const router = Router({ mergeParams: true }); // router.get('/', galleyViewList); -router.post('/tables/:tableId/galleries', ncMetaAclMw(galleryViewCreate)); +router.post( + '/tables/:tableId/galleries', + ncMetaAclMw(galleryViewCreate, 'galleryViewCreate') +); // router.get('/:galleryViewId', galleyViewGet); -router.put('/galleries/:galleryViewId', ncMetaAclMw(galleryViewUpdate)); -router.get('/galleries/:galleryViewId', ncMetaAclMw(galleryViewGet)); +router.put( + '/galleries/:galleryViewId', + ncMetaAclMw(galleryViewUpdate, 'galleryViewUpdate') +); +router.get( + '/galleries/:galleryViewId', + ncMetaAclMw(galleryViewGet, 'galleryViewGet') +); // router.delete('/:galleryViewId', galleyViewDelete); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/gridViewApis.ts b/packages/nocodb/src/lib/noco/meta/api/gridViewApis.ts index 47cc17e2fb..119b825245 100644 --- a/packages/nocodb/src/lib/noco/meta/api/gridViewApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/gridViewApis.ts @@ -25,5 +25,8 @@ export async function gridViewCreate(req: Request, res) { } const router = Router({ mergeParams: true }); -router.post('/tables/:tableId/grids/', ncMetaAclMw(gridViewCreate)); +router.post( + '/tables/:tableId/grids/', + ncMetaAclMw(gridViewCreate, 'gridViewCreate') +); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/gridViewColumnApis.ts b/packages/nocodb/src/lib/noco/meta/api/gridViewColumnApis.ts index 69bacd8d91..6ef54970d8 100644 --- a/packages/nocodb/src/lib/noco/meta/api/gridViewColumnApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/gridViewColumnApis.ts @@ -13,6 +13,12 @@ export async function gridColumnUpdate(req: Request, res: Response) { } const router = Router({ mergeParams: true }); -router.get('/grid/:gridViewId/gridColumns', ncMetaAclMw(columnList)); -router.put('/gridColumns/:gridViewColumnId', ncMetaAclMw(gridColumnUpdate)); +router.get( + '/grid/:gridViewId/gridColumns', + ncMetaAclMw(columnList, 'columnList') +); +router.put( + '/gridColumns/:gridViewColumnId', + ncMetaAclMw(gridColumnUpdate, 'gridColumnUpdate') +); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/hookApis.ts b/packages/nocodb/src/lib/noco/meta/api/hookApis.ts index b83111c553..f116b33cd5 100644 --- a/packages/nocodb/src/lib/noco/meta/api/hookApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/hookApis.ts @@ -75,11 +75,11 @@ export async function tableSampleData(req: Request, res: Response) { } const router = Router({ mergeParams: true }); -router.get('/tables/:tableId/hooks', ncMetaAclMw(hookList)); -router.post('/tables/:tableId/hooks/test', ncMetaAclMw(hookTest)); -router.post('/tables/:tableId/hooks', ncMetaAclMw(hookCreate)); -router.delete('/hooks/:hookId', ncMetaAclMw(hookDelete)); -router.put('/hooks/:hookId', ncMetaAclMw(hookUpdate)); +router.get('/tables/:tableId/hooks', ncMetaAclMw(hookList, 'hookList')); +router.post('/tables/:tableId/hooks/test', ncMetaAclMw(hookTest, 'hookTest')); +router.post('/tables/:tableId/hooks', ncMetaAclMw(hookCreate, 'hookCreate')); +router.delete('/hooks/:hookId', ncMetaAclMw(hookDelete, 'hookDelete')); +router.put('/hooks/:hookId', ncMetaAclMw(hookUpdate, 'hookUpdate')); router.get( '/tables/:tableId/hooks/samplePayload/:operation', catchError(tableSampleData) diff --git a/packages/nocodb/src/lib/noco/meta/api/hookFilterApis.ts b/packages/nocodb/src/lib/noco/meta/api/hookFilterApis.ts index 4e62527739..73573324f9 100644 --- a/packages/nocodb/src/lib/noco/meta/api/hookFilterApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/hookFilterApis.ts @@ -108,13 +108,25 @@ export async function filterDelete(req: Request, res: Response, next) { } const router = Router({ mergeParams: true }); -router.get('/hooks/:hookId/filters/', ncMetaAclMw(filterList)); -router.post('/hooks/:hookId/filters/', ncMetaAclMw(filterCreate)); -router.get('/hooks/:hookId/filters/:filterId', ncMetaAclMw(filterGet)); -router.put('/hooks/:hookId/filters/:filterId', ncMetaAclMw(filterUpdate)); -router.delete('/hooks/:hookId/filters/:filterId', ncMetaAclMw(filterDelete)); +router.get('/hooks/:hookId/filters/', ncMetaAclMw(filterList, 'filterList')); +router.post( + '/hooks/:hookId/filters/', + ncMetaAclMw(filterCreate, 'filterCreate') +); +router.get( + '/hooks/:hookId/filters/:filterId', + ncMetaAclMw(filterGet, 'filterGet') +); +router.put( + '/hooks/:hookId/filters/:filterId', + ncMetaAclMw(filterUpdate, 'filterUpdate') +); +router.delete( + '/hooks/:hookId/filters/:filterId', + ncMetaAclMw(filterDelete, 'filterDelete') +); router.get( '/hooks/:hookId/filters/:filterParentId/children', - ncMetaAclMw(filterChildrenRead) + ncMetaAclMw(filterChildrenRead, 'filterChildrenRead') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts b/packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts index c474075338..6b9f2ead4a 100644 --- a/packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/metaDiffApis.ts @@ -826,6 +826,9 @@ export async function extractAndGenerateManyToManyRelations( } const router = Router(); -router.get('/projects/:projectId/metaDiff', ncMetaAclMw(metaDiff)); -router.post('/projects/:projectId/metaDiff', ncMetaAclMw(metaDiffSync)); +router.get('/projects/:projectId/metaDiff', ncMetaAclMw(metaDiff, 'metaDiff')); +router.post( + '/projects/:projectId/metaDiff', + ncMetaAclMw(metaDiffSync, 'metaDiffSync') +); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/pluginApis.ts b/packages/nocodb/src/lib/noco/meta/api/pluginApis.ts index 18455285aa..2b3fd1657a 100644 --- a/packages/nocodb/src/lib/noco/meta/api/pluginApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/pluginApis.ts @@ -34,9 +34,9 @@ export async function isPluginActive(req: Request, res: Response) { } const router = Router({ mergeParams: true }); -router.get('/plugins', ncMetaAclMw(pluginList)); -router.post('/plugins/test', ncMetaAclMw(pluginTest)); -router.get('/plugins/:pluginId', ncMetaAclMw(pluginRead)); -router.put('/plugins/:pluginId', ncMetaAclMw(pluginUpdate)); -router.get('/plugins/:pluginTitle/status', ncMetaAclMw(isPluginActive)); +router.get('/plugins', ncMetaAclMw(pluginList, 'pluginList')); +router.post('/plugins/test', ncMetaAclMw(pluginTest, 'pluginTest')); +router.get('/plugins/:pluginId', ncMetaAclMw(pluginRead, 'pluginRead')); +router.put('/plugins/:pluginId', ncMetaAclMw(pluginUpdate, 'pluginUpdate')); +router.get('/plugins/:pluginTitle/status', ncMetaAclMw(isPluginActive, 'isPluginActive')); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/projectApis.ts b/packages/nocodb/src/lib/noco/meta/api/projectApis.ts index 09cdeeb1be..5323efd884 100644 --- a/packages/nocodb/src/lib/noco/meta/api/projectApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/projectApis.ts @@ -391,9 +391,15 @@ export async function projectInfoGet(req, res) { } export default router => { - router.get('/projects/:projectId/info', ncMetaAclMw(projectInfoGet)); - router.get('/projects/:projectId', ncMetaAclMw(projectGet)); - router.delete('/projects/:projectId', ncMetaAclMw(projectDelete)); - router.post('/projects', ncMetaAclMw(projectCreate)); - router.get('/projects', ncMetaAclMw(projectList)); + router.get( + '/projects/:projectId/info', + ncMetaAclMw(projectInfoGet, 'projectInfoGet') + ); + router.get('/projects/:projectId', ncMetaAclMw(projectGet, 'projectGet')); + router.delete( + '/projects/:projectId', + ncMetaAclMw(projectDelete, 'projectDelete') + ); + router.post('/projects', ncMetaAclMw(projectCreate, 'projectCreate')); + router.get('/projects', ncMetaAclMw(projectList, 'projectList')); }; diff --git a/packages/nocodb/src/lib/noco/meta/api/projectUserApis.ts b/packages/nocodb/src/lib/noco/meta/api/projectUserApis.ts index ce132be1ca..62c5f0b3ff 100644 --- a/packages/nocodb/src/lib/noco/meta/api/projectUserApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/projectUserApis.ts @@ -249,14 +249,17 @@ async function resendInvite(req, res, next): Promise { } const router = Router({ mergeParams: true }); -router.get('/projects/:projectId/users', ncMetaAclMw(userList)); -router.post('/projects/:projectId/users', ncMetaAclMw(userInvite)); +router.get('/projects/:projectId/users', ncMetaAclMw(userList, 'userList')); +router.post( + '/projects/:projectId/users', + ncMetaAclMw(userInvite, 'userInvite') +); router.put( '/projects/:projectId/users/:userId', - ncMetaAclMw(projectUserUpdate) + ncMetaAclMw(projectUserUpdate, 'projectUserUpdate') ); router.delete( '/projects/:projectId/users/:userId', - ncMetaAclMw(projectUserDelete) + ncMetaAclMw(projectUserDelete, 'projectUserDelete') ); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/sharedBaseApis.ts b/packages/nocodb/src/lib/noco/meta/api/sharedBaseApis.ts index ee5aa59427..df588e1ac6 100644 --- a/packages/nocodb/src/lib/noco/meta/api/sharedBaseApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/sharedBaseApis.ts @@ -99,18 +99,21 @@ async function publicSharedBaseGet(req, res): Promise { } const router = Router({ mergeParams: true }); -router.get('/projects/:projectId/sharedBase', ncMetaAclMw(getSharedBaseLink)); +router.get( + '/projects/:projectId/sharedBase', + ncMetaAclMw(getSharedBaseLink, 'getSharedBaseLink') +); router.post( '/projects/:projectId/sharedBase', - ncMetaAclMw(createSharedBaseLink) + ncMetaAclMw(createSharedBaseLink, 'createSharedBaseLink') ); router.put( '/projects/:projectId/sharedBase', - ncMetaAclMw(updateSharedBaseLink) + ncMetaAclMw(updateSharedBaseLink, 'updateSharedBaseLink') ); router.delete( '/projects/:projectId/sharedBase', - ncMetaAclMw(disableSharedBaseLink) + ncMetaAclMw(disableSharedBaseLink, 'disableSharedBaseLink') ); router.get('/public/sharedBase/:uuid', catchError(publicSharedBaseGet)); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/sortApis.ts b/packages/nocodb/src/lib/noco/meta/api/sortApis.ts index 9022b42b83..4ab4cfe0f0 100644 --- a/packages/nocodb/src/lib/noco/meta/api/sortApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/sortApis.ts @@ -51,9 +51,15 @@ export async function sortDelete(req: Request, res: Response, next) { } const router = Router({ mergeParams: true }); -router.get('/views/:viewId/sorts/', ncMetaAclMw(sortList)); -router.post('/views/:viewId/sorts/', ncMetaAclMw(sortCreate)); -router.get('/views/:viewId/sorts/:sortId', ncMetaAclMw(sortGet)); -router.put('/views/:viewId/sorts/:sortId', ncMetaAclMw(sortUpdate)); -router.delete('/views/:viewId/sorts/:sortId', ncMetaAclMw(sortDelete)); +router.get('/views/:viewId/sorts/', ncMetaAclMw(sortList, 'sortList')); +router.post('/views/:viewId/sorts/', ncMetaAclMw(sortCreate, 'sortCreate')); +router.get('/views/:viewId/sorts/:sortId', ncMetaAclMw(sortGet, 'sortGet')); +router.put( + '/views/:viewId/sorts/:sortId', + ncMetaAclMw(sortUpdate, 'sortUpdate') +); +router.delete( + '/views/:viewId/sorts/:sortId', + ncMetaAclMw(sortDelete, 'sortDelete') +); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/tableApis.ts b/packages/nocodb/src/lib/noco/meta/api/tableApis.ts index 8167fdaacb..58ee9686fa 100644 --- a/packages/nocodb/src/lib/noco/meta/api/tableApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/tableApis.ts @@ -222,10 +222,19 @@ export async function tableDelete(req: Request, res: Response, next) { } const router = Router({ mergeParams: true }); -router.get('/projects/:projectId/:baseId/tables', ncMetaAclMw(tableList)); -router.post('/projects/:projectId/:baseId/tables', ncMetaAclMw(tableCreate)); -router.get('/tables/:tableId', ncMetaAclMw(tableGet)); -router.put('/tables/:tableId', ncMetaAclMw(tableUpdate)); -router.delete('/tables/:tableId', ncMetaAclMw(tableDelete)); -router.post('/tables/:tableId/reorder', ncMetaAclMw(tableReorder)); +router.get( + '/projects/:projectId/:baseId/tables', + ncMetaAclMw(tableList, 'tableList') +); +router.post( + '/projects/:projectId/:baseId/tables', + ncMetaAclMw(tableCreate, 'tableCreate') +); +router.get('/tables/:tableId', ncMetaAclMw(tableGet, 'tableGet')); +router.put('/tables/:tableId', ncMetaAclMw(tableUpdate, 'tableUpdate')); +router.delete('/tables/:tableId', ncMetaAclMw(tableDelete, 'tableDelete')); +router.post( + '/tables/:tableId/reorder', + ncMetaAclMw(tableReorder, 'tableReorder') +); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/userApi/userApis.ts b/packages/nocodb/src/lib/noco/meta/api/userApi/userApis.ts index b840760fd0..d4bb10773c 100644 --- a/packages/nocodb/src/lib/noco/meta/api/userApi/userApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/userApi/userApis.ts @@ -401,7 +401,9 @@ const mapRoutes = router => { router.post('/auth/token/validate/:tokenId', catchError(tokenValidate)); router.post('/auth/password/reset/:tokenId', catchError(passwordReset)); router.post('/auth/email/validate/:tokenId', catchError(emailVerification)); - - router.post('/user/password/change', ncMetaAclMw(passwordChange)); + router.post( + '/user/password/change', + ncMetaAclMw(passwordChange, 'passwordChange') + ); }; export { mapRoutes as userApis }; diff --git a/packages/nocodb/src/lib/noco/meta/api/utilApis.ts b/packages/nocodb/src/lib/noco/meta/api/utilApis.ts index f49621e733..12243fac73 100644 --- a/packages/nocodb/src/lib/noco/meta/api/utilApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/utilApis.ts @@ -44,6 +44,6 @@ export async function appInfo(_req: Request, res: Response) { } export default router => { - router.post('/testConnection', ncMetaAclMw(testConnection)); + router.post('/testConnection', ncMetaAclMw(testConnection, 'testConnection')); router.get('/appInfo', catchError(appInfo)); }; diff --git a/packages/nocodb/src/lib/noco/meta/api/viewApis.ts b/packages/nocodb/src/lib/noco/meta/api/viewApis.ts index 7504cd470b..f61633cd8a 100644 --- a/packages/nocodb/src/lib/noco/meta/api/viewApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/viewApis.ts @@ -101,15 +101,30 @@ async function shareViewList(req: Request, res) { } const router = Router({ mergeParams: true }); -router.get('/tables/:tableId/views', ncMetaAclMw(viewList)); -router.put('/views/:viewId', ncMetaAclMw(viewUpdate)); -router.delete('/views/:viewId', ncMetaAclMw(viewDelete)); -router.post('/views/:viewId/showAll', ncMetaAclMw(showAllColumns)); -router.post('/views/:viewId/hideAll', ncMetaAclMw(hideAllColumns)); - -router.get('/tables/:tableId/share', ncMetaAclMw(shareViewList)); -router.post('/views/:viewId/share', ncMetaAclMw(shareView)); -router.put('/views/:viewId/share', ncMetaAclMw(shareViewPasswordUpdate)); -router.delete('/views/:viewId/share', ncMetaAclMw(shareViewDelete)); +router.get('/tables/:tableId/views', ncMetaAclMw(viewList, 'viewList')); +router.put('/views/:viewId', ncMetaAclMw(viewUpdate, 'viewUpdate')); +router.delete('/views/:viewId', ncMetaAclMw(viewDelete, 'viewDelete')); +router.post( + '/views/:viewId/showAll', + ncMetaAclMw(showAllColumns, 'showAllColumns') +); +router.post( + '/views/:viewId/hideAll', + ncMetaAclMw(hideAllColumns, 'hideAllColumns') +); + +router.get( + '/tables/:tableId/share', + ncMetaAclMw(shareViewList, 'shareViewList') +); +router.post('/views/:viewId/share', ncMetaAclMw(shareView, 'shareView')); +router.put( + '/views/:viewId/share', + ncMetaAclMw(shareViewPasswordUpdate, 'shareViewPasswordUpdate') +); +router.delete( + '/views/:viewId/share', + ncMetaAclMw(shareViewDelete, 'shareViewDelete') +); export default router; diff --git a/packages/nocodb/src/lib/noco/meta/api/viewColumnApis.ts b/packages/nocodb/src/lib/noco/meta/api/viewColumnApis.ts index b8a6a3119e..dc15c5669e 100644 --- a/packages/nocodb/src/lib/noco/meta/api/viewColumnApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/viewColumnApis.ts @@ -31,8 +31,8 @@ export async function columnUpdate(req: Request, res: Response) { } const router = Router({ mergeParams: true }); -router.get('/views/:viewId/columns/', ncMetaAclMw(columnList)); -router.post('/views/:viewId/columns/', ncMetaAclMw(columnAdd)); +router.get('/views/:viewId/columns/', ncMetaAclMw(columnList, 'columnList')); +router.post('/views/:viewId/columns/', ncMetaAclMw(columnAdd, 'columnAdd')); router.put( '/views/:viewId/columns/:columnId', ncMetaAclMw(columnUpdate, 'viewColumnUpdate') diff --git a/packages/nocodb/src/lib/noco/meta/helpers/ncMetaAclMw.ts b/packages/nocodb/src/lib/noco/meta/helpers/ncMetaAclMw.ts index 27f199c570..90e7687750 100644 --- a/packages/nocodb/src/lib/noco/meta/helpers/ncMetaAclMw.ts +++ b/packages/nocodb/src/lib/noco/meta/helpers/ncMetaAclMw.ts @@ -2,7 +2,7 @@ import projectAcl from '../../../utils/projectAcl'; import { NextFunction, Request, Response } from 'express'; import catchError, { NcError } from './catchError'; import extractProjectIdAndAuthenticate from './extractProjectIdAndAuthenticate'; -export default function(handlerFn, permissionName = handlerFn.name) { +export default function(handlerFn, permissionName) { return [ extractProjectIdAndAuthenticate, catchError(function authMiddleware(req, _res, next) {