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; description?: string;
env?: string; env?: string;
type?: string; type?: string;
event?: 'after' | 'before'; event?: HookType['event'];
operation?: 'insert' | 'delete' | 'update'; operation?: HookType['operation'];
async?: BoolType; async?: BoolType;
payload?: string; payload?: string;
url?: string; url?: string;
@ -79,8 +79,8 @@ export default class Hook implements HookType {
static async list( static async list(
param: { param: {
fk_model_id: string; fk_model_id: string;
event?: 'after' | 'before'; event?: HookType['event'];
operation?: 'insert' | 'delete' | 'update'; operation?: HookType['operation'];
}, },
ncMeta = Noco.ncMeta ncMeta = Noco.ncMeta
) { ) {
@ -136,17 +136,6 @@ export default class Hook implements HookType {
'base_id', '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') { if (insertObj.notification && typeof insertObj.notification === 'object') {
insertObj.notification = JSON.stringify(insertObj.notification); insertObj.notification = JSON.stringify(insertObj.notification);
} }
@ -200,17 +189,6 @@ export default class Hook implements HookType {
'active', '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') { if (updateObj.notification && typeof updateObj.notification === 'object') {
updateObj.notification = JSON.stringify(updateObj.notification); 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; project_id?: string;
fk_hook_id?: string; fk_hook_id?: string;
type?: string; type?: string;
event?: 'after' | 'before'; event?: HookLogType['event'];
operation?: 'insert' | 'update' | 'delete'; operation?: HookLogType['operation'];
test_call?: boolean; test_call?: boolean;
payload?: string; payload?: string;
conditions?: string; conditions?: string;
@ -30,8 +30,8 @@ export default class HookLog implements HookLogType {
static async list( static async list(
param: { param: {
fk_hook_id: string; fk_hook_id: string;
event?: 'after' | 'before'; event?: HookLogType['event'];
operation?: 'insert' | 'delete' | 'update'; operation?: HookLogType['operation'];
}, },
{ {
limit = 25, limit = 25,

Loading…
Cancel
Save