Browse Source

fix(nocodb): fix hook types

pull/5349/head
Wing-Kam Wong 2 years ago
parent
commit
8c5e86d8f3
  1. 30
      packages/nocodb/src/lib/models/Hook.ts
  2. 8
      packages/nocodb/src/lib/models/HookLog.ts

30
packages/nocodb/src/lib/models/Hook.ts

@ -19,8 +19,8 @@ export default class Hook implements HookType {
description?: string;
env?: string;
type?: string;
event?: 'after' | 'before';
operation?: 'insert' | 'delete' | 'update';
event?: HookType['event'];
operation?: HookType['operation'];
async?: BoolType;
payload?: string;
url?: string;
@ -79,8 +79,8 @@ export default class Hook implements HookType {
static async list(
param: {
fk_model_id: string;
event?: 'after' | 'before';
operation?: 'insert' | 'delete' | 'update';
event?: HookType['event'];
operation?: HookType['operation'];
},
ncMeta = Noco.ncMeta
) {
@ -136,17 +136,6 @@ export default class Hook implements HookType {
'base_id',
]);
if (insertObj.event) {
insertObj.event = insertObj.event.toLowerCase() as 'after' | 'before';
}
if (insertObj.operation) {
insertObj.operation = insertObj.operation.toLowerCase() as
| 'insert'
| 'delete'
| 'update';
}
if (insertObj.notification && typeof insertObj.notification === 'object') {
insertObj.notification = JSON.stringify(insertObj.notification);
}
@ -200,17 +189,6 @@ export default class Hook implements HookType {
'active',
]);
if (updateObj.event) {
updateObj.event = updateObj.event.toLowerCase() as 'after' | 'before';
}
if (updateObj.operation) {
updateObj.operation = updateObj.operation.toLowerCase() as
| 'insert'
| 'delete'
| 'update';
}
if (updateObj.notification && typeof updateObj.notification === 'object') {
updateObj.notification = JSON.stringify(updateObj.notification);
}

8
packages/nocodb/src/lib/models/HookLog.ts

@ -10,8 +10,8 @@ export default class HookLog implements HookLogType {
project_id?: string;
fk_hook_id?: string;
type?: string;
event?: 'after' | 'before';
operation?: 'insert' | 'update' | 'delete';
event?: HookLogType['event'];
operation?: HookLogType['operation'];
test_call?: boolean;
payload?: string;
conditions?: string;
@ -30,8 +30,8 @@ export default class HookLog implements HookLogType {
static async list(
param: {
fk_hook_id: string;
event?: 'after' | 'before';
operation?: 'insert' | 'delete' | 'update';
event?: HookLogType['event'];
operation?: HookLogType['operation'];
},
{
limit = 25,

Loading…
Cancel
Save