Browse Source

feat(nocodb): show sample payload based on version

pull/5349/head
Wing-Kam Wong 2 years ago
parent
commit
f4b5574523
  1. 11
      packages/nocodb/src/lib/services/hook.svc.ts

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

@ -3,7 +3,10 @@ import { validatePayload } from '../meta/api/helpers';
import { NcError } from '../meta/helpers/catchError'; import { NcError } from '../meta/helpers/catchError';
import { Hook, HookLog, Model } from '../models'; import { Hook, HookLog, Model } from '../models';
import { invokeWebhook } from '../meta/helpers/webhookHelpers'; import { invokeWebhook } from '../meta/helpers/webhookHelpers';
import populateSamplePayload from '../meta/helpers/populateSamplePayload'; import {
populateSamplePayload,
populateSamplePayloadV2,
} from '../meta/helpers/populateSamplePayload';
import type { HookReqType, HookTestReqType } from 'nocodb-sdk'; import type { HookReqType, HookTestReqType } from 'nocodb-sdk';
function validateHookPayload( function validateHookPayload(
@ -98,8 +101,12 @@ export async function hookTest(param: {
export async function tableSampleData(param: { export async function tableSampleData(param: {
tableId: string; tableId: string;
operation: 'insert' | 'update'; operation: 'insert' | 'update';
version: 'v1' | 'v2';
}) { }) {
const model = await Model.getByIdOrName({ id: param.tableId }); const model = await Model.getByIdOrName({ id: param.tableId });
return await populateSamplePayload(model, false, param.operation); if (param.version === 'v1') {
return await populateSamplePayload(model, false, param.operation);
}
return await populateSamplePayloadV2(model, false, param.operation);
} }

Loading…
Cancel
Save