Browse Source

feat(nocodb): add hookLogList

pull/5349/head
Wing-Kam Wong 2 years ago
parent
commit
a11516c4a9
  1. 22
      packages/nocodb/src/lib/controllers/hook.ctl.ts
  2. 6
      packages/nocodb/src/lib/services/hook.svc.ts

22
packages/nocodb/src/lib/controllers/hook.ctl.ts

@ -4,7 +4,7 @@ import { PagedResponseImpl } from '../meta/helpers/PagedResponse';
import ncMetaAclMw from '../meta/helpers/ncMetaAclMw';
import { metaApiMetrics } from '../meta/helpers/apiMetrics';
import { hookService } from '../services';
import type { HookListType, HookType } from 'nocodb-sdk';
import type { HookListType, HookLogListType, HookType } from 'nocodb-sdk';
import type { Request, Response } from 'express';
export async function hookList(
@ -63,12 +63,25 @@ export async function tableSampleData(req: Request, res: Response) {
);
}
export async function hookLogList(
req: Request<any, any, any>,
res: Response<HookLogListType>
) {
res.json(
new PagedResponseImpl(
await hookService.hookLogList({ tableId: req.params.hookId })
)
);
}
const router = Router({ mergeParams: true });
router.get(
'/api/v1/db/meta/tables/:tableId/hooks',
metaApiMetrics,
ncMetaAclMw(hookList, 'hookList')
);
router.post(
'/api/v1/db/meta/tables/:tableId/hooks/test',
metaApiMetrics,
@ -94,4 +107,11 @@ router.get(
metaApiMetrics,
catchError(tableSampleData)
);
router.get(
'/api/v1/db/meta/hooks/:hookId/logs',
metaApiMetrics,
ncMetaAclMw(hookLogList, 'hookLogList')
);
export default router;

6
packages/nocodb/src/lib/services/hook.svc.ts

@ -1,7 +1,7 @@
import { T } from 'nc-help';
import { validatePayload } from '../meta/api/helpers';
import { NcError } from '../meta/helpers/catchError';
import { Hook, Model } from '../models';
import { Hook, HookLog, Model } from '../models';
import { invokeWebhook } from '../meta/helpers/webhookHelpers';
import populateSamplePayload from '../meta/helpers/populateSamplePayload';
import type { HookReqType, HookTestReqType } from 'nocodb-sdk';
@ -26,6 +26,10 @@ export async function hookList(param: { tableId: string }) {
return await Hook.list({ fk_model_id: param.tableId });
}
export async function hookLogList(param: { hookId: string }) {
return await HookLog.list({ fk_hook_id: param.hookId });
}
export async function hookCreate(param: {
tableId: string;
hook: HookReqType;

Loading…
Cancel
Save