Proper typing for emitTable
This commit is contained in:
parent
342d70b326
commit
637c13c1af
|
@ -16,6 +16,7 @@ import {
|
||||||
BulkImportResponse,
|
BulkImportResponse,
|
||||||
CsvToJsonRequest,
|
CsvToJsonRequest,
|
||||||
CsvToJsonResponse,
|
CsvToJsonResponse,
|
||||||
|
EventType,
|
||||||
FetchTablesResponse,
|
FetchTablesResponse,
|
||||||
FieldType,
|
FieldType,
|
||||||
MigrateRequest,
|
MigrateRequest,
|
||||||
|
@ -129,8 +130,7 @@ export async function save(ctx: UserCtx<SaveTableRequest, SaveTableResponse>) {
|
||||||
}
|
}
|
||||||
ctx.status = 200
|
ctx.status = 200
|
||||||
ctx.message = `Table ${table.name} saved successfully.`
|
ctx.message = `Table ${table.name} saved successfully.`
|
||||||
ctx.eventEmitter &&
|
ctx.eventEmitter?.emitTable(EventType.TABLE_SAVE, appId, { ...savedTable })
|
||||||
ctx.eventEmitter.emitTable(`table:save`, appId, { ...savedTable })
|
|
||||||
ctx.body = savedTable
|
ctx.body = savedTable
|
||||||
|
|
||||||
savedTable = await processTable(savedTable)
|
savedTable = await processTable(savedTable)
|
||||||
|
@ -143,8 +143,8 @@ export async function destroy(ctx: UserCtx) {
|
||||||
await sdk.rowActions.deleteAll(tableId)
|
await sdk.rowActions.deleteAll(tableId)
|
||||||
const deletedTable = await pickApi({ tableId }).destroy(ctx)
|
const deletedTable = await pickApi({ tableId }).destroy(ctx)
|
||||||
await events.table.deleted(deletedTable)
|
await events.table.deleted(deletedTable)
|
||||||
ctx.eventEmitter &&
|
|
||||||
ctx.eventEmitter.emitTable(`table:delete`, appId, deletedTable)
|
ctx.eventEmitter?.emitTable(EventType.TABLE_DELETE, appId, deletedTable)
|
||||||
ctx.status = 200
|
ctx.status = 200
|
||||||
ctx.table = deletedTable
|
ctx.table = deletedTable
|
||||||
ctx.body = { message: `Table ${tableId} deleted.` }
|
ctx.body = { message: `Table ${tableId} deleted.` }
|
||||||
|
|
|
@ -83,4 +83,9 @@ export interface ContextEmitter {
|
||||||
row: Row
|
row: Row
|
||||||
user: UserBindings
|
user: UserBindings
|
||||||
}): void
|
}): void
|
||||||
|
emitTable(
|
||||||
|
eventName: EventType.TABLE_SAVE | EventType.TABLE_DELETE,
|
||||||
|
appId: string,
|
||||||
|
table?: Table
|
||||||
|
): void
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue