|
|
@ -18,12 +18,12 @@ import slash from 'slash'; |
|
|
|
|
|
|
|
|
|
|
|
export async function dataList(req: Request, res: Response) { |
|
|
|
export async function dataList(req: Request, res: Response) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const view = await View.getByUUID(req.params.publicDataUuid); |
|
|
|
const view = await View.getByUUID(req.params.sharedViewUuid); |
|
|
|
|
|
|
|
|
|
|
|
if (!view) NcError.notFound('Not found'); |
|
|
|
if (!view) NcError.notFound('Not found'); |
|
|
|
if (view.type !== ViewTypes.GRID) NcError.notFound('Not found'); |
|
|
|
if (view.type !== ViewTypes.GRID) NcError.notFound('Not found'); |
|
|
|
|
|
|
|
|
|
|
|
if (view.password && view.password !== req.body?.password) { |
|
|
|
if (view.password && view.password !== req.headers?.['xc-password']) { |
|
|
|
return NcError.forbidden(ErrorMessages.INVALID_SHARED_VIEW_PASSWORD); |
|
|
|
return NcError.forbidden(ErrorMessages.INVALID_SHARED_VIEW_PASSWORD); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -39,37 +39,22 @@ export async function dataList(req: Request, res: Response) { |
|
|
|
dbDriver: NcConnectionMgrv2.get(base) |
|
|
|
dbDriver: NcConnectionMgrv2.get(base) |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const key = `${model.title}List`; |
|
|
|
const listArgs: any = { ...req.query }; |
|
|
|
const requestObj = { |
|
|
|
try { |
|
|
|
[key]: await baseModel.defaultResolverReq(req.query) |
|
|
|
listArgs.filterArr = JSON.parse(listArgs.filterArrJson); |
|
|
|
}; |
|
|
|
} catch (e) {} |
|
|
|
|
|
|
|
try { |
|
|
|
const data = ( |
|
|
|
listArgs.sortArr = JSON.parse(listArgs.sortArrJson); |
|
|
|
await nocoExecute( |
|
|
|
} catch (e) {} |
|
|
|
requestObj, |
|
|
|
|
|
|
|
{ |
|
|
|
const data = await nocoExecute( |
|
|
|
[key]: async args => { |
|
|
|
await baseModel.defaultResolverReq(req.query), |
|
|
|
return await baseModel.list(args); |
|
|
|
await baseModel.list(listArgs), |
|
|
|
} |
|
|
|
{}, |
|
|
|
}, |
|
|
|
listArgs |
|
|
|
{}, |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
nested: { |
|
|
|
|
|
|
|
[key]: { |
|
|
|
|
|
|
|
...req.query, |
|
|
|
|
|
|
|
sortArr: req.body?.sorts, |
|
|
|
|
|
|
|
filterArr: req.body?.filters |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
)?.[key]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const count = await baseModel.count({ |
|
|
|
const count = await baseModel.count(listArgs); |
|
|
|
...req.query, |
|
|
|
|
|
|
|
filterArr: req.body?.filters |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res.json({ |
|
|
|
res.json({ |
|
|
|
data: new PagedResponseImpl(data, { ...req.query, count }) |
|
|
|
data: new PagedResponseImpl(data, { ...req.query, count }) |
|
|
@ -85,12 +70,12 @@ async function dataInsert( |
|
|
|
res: Response, |
|
|
|
res: Response, |
|
|
|
next |
|
|
|
next |
|
|
|
) { |
|
|
|
) { |
|
|
|
const view = await View.getByUUID(req.params.publicDataUuid); |
|
|
|
const view = await View.getByUUID(req.params.sharedViewUuid); |
|
|
|
|
|
|
|
|
|
|
|
if (!view) return next(new Error('Not found')); |
|
|
|
if (!view) return next(new Error('Not found')); |
|
|
|
if (view.type !== ViewTypes.FORM) return next(new Error('Not found')); |
|
|
|
if (view.type !== ViewTypes.FORM) return next(new Error('Not found')); |
|
|
|
|
|
|
|
|
|
|
|
if (view.password && view.password !== req.body?.password) { |
|
|
|
if (view.password && view.password !== req.headers?.['xc-password']) { |
|
|
|
return res.status(403).json(ErrorMessages.INVALID_SHARED_VIEW_PASSWORD); |
|
|
|
return res.status(403).json(ErrorMessages.INVALID_SHARED_VIEW_PASSWORD); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -169,12 +154,12 @@ async function dataInsert( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function relDataList(req, res) { |
|
|
|
async function relDataList(req, res) { |
|
|
|
const view = await View.getByUUID(req.params.publicDataUuid); |
|
|
|
const view = await View.getByUUID(req.params.sharedViewUuid); |
|
|
|
|
|
|
|
|
|
|
|
if (!view) NcError.notFound('Not found'); |
|
|
|
if (!view) NcError.notFound('Not found'); |
|
|
|
if (view.type !== ViewTypes.FORM) NcError.notFound('Not found'); |
|
|
|
if (view.type !== ViewTypes.FORM) NcError.notFound('Not found'); |
|
|
|
|
|
|
|
|
|
|
|
if (view.password && view.password !== req.body?.password) { |
|
|
|
if (view.password && view.password !== req.headers?.['xc-password']) { |
|
|
|
NcError.forbidden(ErrorMessages.INVALID_SHARED_VIEW_PASSWORD); |
|
|
|
NcError.forbidden(ErrorMessages.INVALID_SHARED_VIEW_PASSWORD); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -215,12 +200,12 @@ async function relDataList(req, res) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export async function publicMmList(req: Request, res: Response) { |
|
|
|
export async function publicMmList(req: Request, res: Response) { |
|
|
|
const view = await View.getByUUID(req.params.publicDataUuid); |
|
|
|
const view = await View.getByUUID(req.params.sharedViewUuid); |
|
|
|
|
|
|
|
|
|
|
|
if (!view) NcError.notFound('Not found'); |
|
|
|
if (!view) NcError.notFound('Not found'); |
|
|
|
if (view.type !== ViewTypes.GRID) NcError.notFound('Not found'); |
|
|
|
if (view.type !== ViewTypes.GRID) NcError.notFound('Not found'); |
|
|
|
|
|
|
|
|
|
|
|
if (view.password && view.password !== req.body?.password) { |
|
|
|
if (view.password && view.password !== req.headers?.['xc-password']) { |
|
|
|
NcError.forbidden(ErrorMessages.INVALID_SHARED_VIEW_PASSWORD); |
|
|
|
NcError.forbidden(ErrorMessages.INVALID_SHARED_VIEW_PASSWORD); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -271,12 +256,12 @@ export async function publicMmList(req: Request, res: Response) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export async function publicHmList(req: Request, res: Response) { |
|
|
|
export async function publicHmList(req: Request, res: Response) { |
|
|
|
const view = await View.getByUUID(req.params.publicDataUuid); |
|
|
|
const view = await View.getByUUID(req.params.sharedViewUuid); |
|
|
|
|
|
|
|
|
|
|
|
if (!view) NcError.notFound('Not found'); |
|
|
|
if (!view) NcError.notFound('Not found'); |
|
|
|
if (view.type !== ViewTypes.GRID) NcError.notFound('Not found'); |
|
|
|
if (view.type !== ViewTypes.GRID) NcError.notFound('Not found'); |
|
|
|
|
|
|
|
|
|
|
|
if (view.password && view.password !== req.body?.password) { |
|
|
|
if (view.password && view.password !== req.headers?.['xc-password']) { |
|
|
|
NcError.forbidden(ErrorMessages.INVALID_SHARED_VIEW_PASSWORD); |
|
|
|
NcError.forbidden(ErrorMessages.INVALID_SHARED_VIEW_PASSWORD); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -330,13 +315,16 @@ export async function publicHmList(req: Request, res: Response) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const router = Router({ mergeParams: true }); |
|
|
|
const router = Router({ mergeParams: true }); |
|
|
|
router.post('/public/data/:publicDataUuid/list', catchError(dataList)); |
|
|
|
router.get( |
|
|
|
|
|
|
|
'/api/v1/db/public/shared-view/:sharedViewUuid/rows', |
|
|
|
|
|
|
|
catchError(dataList) |
|
|
|
|
|
|
|
); |
|
|
|
router.post( |
|
|
|
router.post( |
|
|
|
'/public/data/:publicDataUuid/nested/:columnId', |
|
|
|
'/api/v1/db/public/shared-view/:sharedViewUuid/nested/:columnId', |
|
|
|
catchError(relDataList) |
|
|
|
catchError(relDataList) |
|
|
|
); |
|
|
|
); |
|
|
|
router.post( |
|
|
|
router.post( |
|
|
|
'/public/data/:publicDataUuid/create', |
|
|
|
'/api/v1/db/public/shared-view/:sharedViewUuid/create', |
|
|
|
multer({ |
|
|
|
multer({ |
|
|
|
storage: multer.diskStorage({}) |
|
|
|
storage: multer.diskStorage({}) |
|
|
|
}).any(), |
|
|
|
}).any(), |
|
|
@ -344,11 +332,11 @@ router.post( |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
router.get( |
|
|
|
router.get( |
|
|
|
'/public/data/:publicDataUuid/:rowId/mm/:colId', |
|
|
|
'/api/v1/db/public/shared-view/:sharedViewUuid/:rowId/mm/:colId', |
|
|
|
catchError(publicMmList) |
|
|
|
catchError(publicMmList) |
|
|
|
); |
|
|
|
); |
|
|
|
router.get( |
|
|
|
router.get( |
|
|
|
'/public/data/:publicDataUuid/:rowId/hm/:colId', |
|
|
|
'/api/v1/db/public/shared-view/:sharedViewUuid/:rowId/hm/:colId', |
|
|
|
catchError(publicHmList) |
|
|
|
catchError(publicHmList) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|