Typing emitter
This commit is contained in:
parent
a8264aadc2
commit
47e16dd844
|
@ -7,6 +7,7 @@ import * as internal from "./internal"
|
|||
import * as external from "./external"
|
||||
import { isExternalTableID } from "../../../integrations/utils"
|
||||
import {
|
||||
AutomationEventType,
|
||||
Ctx,
|
||||
DeleteRow,
|
||||
DeleteRowRequest,
|
||||
|
@ -64,15 +65,15 @@ export async function patch(
|
|||
ctx.throw(404, "Row not found")
|
||||
}
|
||||
ctx.status = 200
|
||||
ctx.eventEmitter &&
|
||||
ctx.eventEmitter.emitRow({
|
||||
eventName: `row:update`,
|
||||
appId,
|
||||
row,
|
||||
table,
|
||||
oldRow,
|
||||
user: sdk.users.getUserContextBindings(ctx.user),
|
||||
})
|
||||
|
||||
ctx.eventEmitter?.emitRow({
|
||||
eventName: AutomationEventType.ROW_UPDATE,
|
||||
appId,
|
||||
row,
|
||||
table,
|
||||
oldRow,
|
||||
user: sdk.users.getUserContextBindings(ctx.user),
|
||||
})
|
||||
ctx.message = `${table.name} updated successfully.`
|
||||
ctx.body = row
|
||||
gridSocket?.emitRowUpdate(ctx, row)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { rowEmission, tableEmission } from "./utils"
|
||||
import mainEmitter from "./index"
|
||||
import env from "../environment"
|
||||
import { Table, Row, DocumentType, App } from "@budibase/types"
|
||||
import { Table, Row, DocumentType, App, ContextEmitter } from "@budibase/types"
|
||||
import { context } from "@budibase/backend-core"
|
||||
|
||||
const MAX_AUTOMATIONS_ALLOWED = 5
|
||||
|
||||
class AutomationEmitter {
|
||||
class AutomationEmitter implements ContextEmitter {
|
||||
chainCount: number
|
||||
metadata: { automationChainCount: number }
|
||||
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
import { Context, Request } from "koa"
|
||||
import { User, Role, UserRoles, Account, ConfigType } from "../documents"
|
||||
import {
|
||||
User,
|
||||
Role,
|
||||
UserRoles,
|
||||
Account,
|
||||
ConfigType,
|
||||
Row,
|
||||
Table,
|
||||
AutomationEventType,
|
||||
} from "../documents"
|
||||
import { FeatureFlag, License } from "../sdk"
|
||||
import { Files } from "formidable"
|
||||
|
||||
|
@ -40,6 +49,7 @@ export interface UserCtx<RequestBody = any, ResponseBody = any>
|
|||
extends Ctx<RequestBody, ResponseBody> {
|
||||
user: ContextUser
|
||||
roleId?: string
|
||||
eventEmitter?: ContextEmitter
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,3 +59,12 @@ export interface UserCtx<RequestBody = any, ResponseBody = any>
|
|||
export interface BBContext extends Ctx {
|
||||
user?: ContextUser
|
||||
}
|
||||
|
||||
export interface ContextEmitter {
|
||||
emitRow: (params: {
|
||||
eventName: AutomationEventType
|
||||
appId: string
|
||||
row: Row
|
||||
table?: Table
|
||||
}) => Promise<void>
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue