Updating events to include a proper friendly map of audited events.
This commit is contained in:
parent
6d83ea9bec
commit
2afd3e1580
|
@ -19,6 +19,7 @@ const created = async (app: App, timestamp?: string | number) => {
|
||||||
const properties: AppCreatedEvent = {
|
const properties: AppCreatedEvent = {
|
||||||
appId: app.appId,
|
appId: app.appId,
|
||||||
version: app.version,
|
version: app.version,
|
||||||
|
name: app.name,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.APP_CREATED, properties, timestamp)
|
await publishEvent(Event.APP_CREATED, properties, timestamp)
|
||||||
}
|
}
|
||||||
|
@ -27,6 +28,7 @@ async function updated(app: App) {
|
||||||
const properties: AppUpdatedEvent = {
|
const properties: AppUpdatedEvent = {
|
||||||
appId: app.appId,
|
appId: app.appId,
|
||||||
version: app.version,
|
version: app.version,
|
||||||
|
name: app.name,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.APP_UPDATED, properties)
|
await publishEvent(Event.APP_UPDATED, properties)
|
||||||
}
|
}
|
||||||
|
@ -34,6 +36,7 @@ async function updated(app: App) {
|
||||||
async function deleted(app: App) {
|
async function deleted(app: App) {
|
||||||
const properties: AppDeletedEvent = {
|
const properties: AppDeletedEvent = {
|
||||||
appId: app.appId,
|
appId: app.appId,
|
||||||
|
name: app.name,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.APP_DELETED, properties)
|
await publishEvent(Event.APP_DELETED, properties)
|
||||||
}
|
}
|
||||||
|
@ -41,6 +44,7 @@ async function deleted(app: App) {
|
||||||
async function published(app: App, timestamp?: string | number) {
|
async function published(app: App, timestamp?: string | number) {
|
||||||
const properties: AppPublishedEvent = {
|
const properties: AppPublishedEvent = {
|
||||||
appId: app.appId,
|
appId: app.appId,
|
||||||
|
name: app.name,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.APP_PUBLISHED, properties, timestamp)
|
await publishEvent(Event.APP_PUBLISHED, properties, timestamp)
|
||||||
}
|
}
|
||||||
|
@ -48,6 +52,7 @@ async function published(app: App, timestamp?: string | number) {
|
||||||
async function unpublished(app: App) {
|
async function unpublished(app: App) {
|
||||||
const properties: AppUnpublishedEvent = {
|
const properties: AppUnpublishedEvent = {
|
||||||
appId: app.appId,
|
appId: app.appId,
|
||||||
|
name: app.name,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.APP_UNPUBLISHED, properties)
|
await publishEvent(Event.APP_UNPUBLISHED, properties)
|
||||||
}
|
}
|
||||||
|
@ -55,6 +60,7 @@ async function unpublished(app: App) {
|
||||||
async function fileImported(app: App) {
|
async function fileImported(app: App) {
|
||||||
const properties: AppFileImportedEvent = {
|
const properties: AppFileImportedEvent = {
|
||||||
appId: app.appId,
|
appId: app.appId,
|
||||||
|
name: app.name,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.APP_FILE_IMPORTED, properties)
|
await publishEvent(Event.APP_FILE_IMPORTED, properties)
|
||||||
}
|
}
|
||||||
|
@ -63,6 +69,7 @@ async function templateImported(app: App, templateKey: string) {
|
||||||
const properties: AppTemplateImportedEvent = {
|
const properties: AppTemplateImportedEvent = {
|
||||||
appId: app.appId,
|
appId: app.appId,
|
||||||
templateKey,
|
templateKey,
|
||||||
|
name: app.name,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.APP_TEMPLATE_IMPORTED, properties)
|
await publishEvent(Event.APP_TEMPLATE_IMPORTED, properties)
|
||||||
}
|
}
|
||||||
|
@ -76,6 +83,7 @@ async function versionUpdated(
|
||||||
appId: app.appId,
|
appId: app.appId,
|
||||||
currentVersion,
|
currentVersion,
|
||||||
updatedToVersion,
|
updatedToVersion,
|
||||||
|
name: app.name,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.APP_VERSION_UPDATED, properties)
|
await publishEvent(Event.APP_VERSION_UPDATED, properties)
|
||||||
}
|
}
|
||||||
|
@ -89,6 +97,7 @@ async function versionReverted(
|
||||||
appId: app.appId,
|
appId: app.appId,
|
||||||
currentVersion,
|
currentVersion,
|
||||||
revertedToVersion,
|
revertedToVersion,
|
||||||
|
name: app.name,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.APP_VERSION_REVERTED, properties)
|
await publishEvent(Event.APP_VERSION_REVERTED, properties)
|
||||||
}
|
}
|
||||||
|
@ -96,6 +105,7 @@ async function versionReverted(
|
||||||
async function reverted(app: App) {
|
async function reverted(app: App) {
|
||||||
const properties: AppRevertedEvent = {
|
const properties: AppRevertedEvent = {
|
||||||
appId: app.appId,
|
appId: app.appId,
|
||||||
|
name: app.name,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.APP_REVERTED, properties)
|
await publishEvent(Event.APP_REVERTED, properties)
|
||||||
}
|
}
|
||||||
|
@ -103,6 +113,7 @@ async function reverted(app: App) {
|
||||||
async function exported(app: App) {
|
async function exported(app: App) {
|
||||||
const properties: AppExportedEvent = {
|
const properties: AppExportedEvent = {
|
||||||
appId: app.appId,
|
appId: app.appId,
|
||||||
|
name: app.name,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.APP_EXPORTED, properties)
|
await publishEvent(Event.APP_EXPORTED, properties)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,19 +12,21 @@ import {
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { identification } from ".."
|
import { identification } from ".."
|
||||||
|
|
||||||
async function login(source: LoginSource) {
|
async function login(source: LoginSource, email: string) {
|
||||||
const identity = await identification.getCurrentIdentity()
|
const identity = await identification.getCurrentIdentity()
|
||||||
const properties: LoginEvent = {
|
const properties: LoginEvent = {
|
||||||
userId: identity.id,
|
userId: identity.id,
|
||||||
source,
|
source,
|
||||||
|
email,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.AUTH_LOGIN, properties)
|
await publishEvent(Event.AUTH_LOGIN, properties)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function logout() {
|
async function logout(email: string) {
|
||||||
const identity = await identification.getCurrentIdentity()
|
const identity = await identification.getCurrentIdentity()
|
||||||
const properties: LogoutEvent = {
|
const properties: LogoutEvent = {
|
||||||
userId: identity.id,
|
userId: identity.id,
|
||||||
|
email,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.AUTH_LOGOUT, properties)
|
await publishEvent(Event.AUTH_LOGOUT, properties)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ async function appBackupRestored(backup: AppBackup) {
|
||||||
appId: backup.appId,
|
appId: backup.appId,
|
||||||
restoreId: backup._id!,
|
restoreId: backup._id!,
|
||||||
backupCreatedAt: backup.timestamp,
|
backupCreatedAt: backup.timestamp,
|
||||||
|
name: backup.name as string,
|
||||||
}
|
}
|
||||||
|
|
||||||
await publishEvent(Event.APP_BACKUP_RESTORED, properties)
|
await publishEvent(Event.APP_BACKUP_RESTORED, properties)
|
||||||
|
@ -22,13 +23,15 @@ async function appBackupTriggered(
|
||||||
appId: string,
|
appId: string,
|
||||||
backupId: string,
|
backupId: string,
|
||||||
type: AppBackupType,
|
type: AppBackupType,
|
||||||
trigger: AppBackupTrigger
|
trigger: AppBackupTrigger,
|
||||||
|
name: string
|
||||||
) {
|
) {
|
||||||
const properties: AppBackupTriggeredEvent = {
|
const properties: AppBackupTriggeredEvent = {
|
||||||
appId: appId,
|
appId: appId,
|
||||||
backupId,
|
backupId,
|
||||||
type,
|
type,
|
||||||
trigger,
|
trigger,
|
||||||
|
name,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.APP_BACKUP_TRIGGERED, properties)
|
await publishEvent(Event.APP_BACKUP_TRIGGERED, properties)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,14 @@ import {
|
||||||
GroupUsersAddedEvent,
|
GroupUsersAddedEvent,
|
||||||
GroupUsersDeletedEvent,
|
GroupUsersDeletedEvent,
|
||||||
GroupAddedOnboardingEvent,
|
GroupAddedOnboardingEvent,
|
||||||
|
GroupPermissionsEditedEvent,
|
||||||
UserGroupRoles,
|
UserGroupRoles,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
|
|
||||||
async function created(group: UserGroup, timestamp?: number) {
|
async function created(group: UserGroup, timestamp?: number) {
|
||||||
const properties: GroupCreatedEvent = {
|
const properties: GroupCreatedEvent = {
|
||||||
groupId: group._id as string,
|
groupId: group._id as string,
|
||||||
|
name: group.name,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.USER_GROUP_CREATED, properties, timestamp)
|
await publishEvent(Event.USER_GROUP_CREATED, properties, timestamp)
|
||||||
}
|
}
|
||||||
|
@ -21,6 +23,7 @@ async function created(group: UserGroup, timestamp?: number) {
|
||||||
async function updated(group: UserGroup) {
|
async function updated(group: UserGroup) {
|
||||||
const properties: GroupUpdatedEvent = {
|
const properties: GroupUpdatedEvent = {
|
||||||
groupId: group._id as string,
|
groupId: group._id as string,
|
||||||
|
name: group.name,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.USER_GROUP_UPDATED, properties)
|
await publishEvent(Event.USER_GROUP_UPDATED, properties)
|
||||||
}
|
}
|
||||||
|
@ -28,6 +31,7 @@ async function updated(group: UserGroup) {
|
||||||
async function deleted(group: UserGroup) {
|
async function deleted(group: UserGroup) {
|
||||||
const properties: GroupDeletedEvent = {
|
const properties: GroupDeletedEvent = {
|
||||||
groupId: group._id as string,
|
groupId: group._id as string,
|
||||||
|
name: group.name,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.USER_GROUP_DELETED, properties)
|
await publishEvent(Event.USER_GROUP_DELETED, properties)
|
||||||
}
|
}
|
||||||
|
@ -36,6 +40,7 @@ async function usersAdded(count: number, group: UserGroup) {
|
||||||
const properties: GroupUsersAddedEvent = {
|
const properties: GroupUsersAddedEvent = {
|
||||||
count,
|
count,
|
||||||
groupId: group._id as string,
|
groupId: group._id as string,
|
||||||
|
name: group.name,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.USER_GROUP_USERS_ADDED, properties)
|
await publishEvent(Event.USER_GROUP_USERS_ADDED, properties)
|
||||||
}
|
}
|
||||||
|
@ -44,6 +49,7 @@ async function usersDeleted(count: number, group: UserGroup) {
|
||||||
const properties: GroupUsersDeletedEvent = {
|
const properties: GroupUsersDeletedEvent = {
|
||||||
count,
|
count,
|
||||||
groupId: group._id as string,
|
groupId: group._id as string,
|
||||||
|
name: group.name,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.USER_GROUP_USERS_REMOVED, properties)
|
await publishEvent(Event.USER_GROUP_USERS_REMOVED, properties)
|
||||||
}
|
}
|
||||||
|
@ -56,9 +62,11 @@ async function createdOnboarding(groupId: string) {
|
||||||
await publishEvent(Event.USER_GROUP_ONBOARDING, properties)
|
await publishEvent(Event.USER_GROUP_ONBOARDING, properties)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function permissionsEdited(roles: UserGroupRoles) {
|
async function permissionsEdited(group: UserGroup) {
|
||||||
const properties: UserGroupRoles = {
|
const properties: GroupPermissionsEditedEvent = {
|
||||||
...roles,
|
permissions: group.roles!,
|
||||||
|
name: group.name,
|
||||||
|
groupId: group._id as string,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.USER_GROUP_PERMISSIONS_EDITED, properties)
|
await publishEvent(Event.USER_GROUP_PERMISSIONS_EDITED, properties)
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import {
|
||||||
async function created(user: User, timestamp?: number) {
|
async function created(user: User, timestamp?: number) {
|
||||||
const properties: UserCreatedEvent = {
|
const properties: UserCreatedEvent = {
|
||||||
userId: user._id as string,
|
userId: user._id as string,
|
||||||
|
email: user.email,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.USER_CREATED, properties, timestamp)
|
await publishEvent(Event.USER_CREATED, properties, timestamp)
|
||||||
}
|
}
|
||||||
|
@ -26,6 +27,7 @@ async function created(user: User, timestamp?: number) {
|
||||||
async function updated(user: User) {
|
async function updated(user: User) {
|
||||||
const properties: UserUpdatedEvent = {
|
const properties: UserUpdatedEvent = {
|
||||||
userId: user._id as string,
|
userId: user._id as string,
|
||||||
|
email: user.email,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.USER_UPDATED, properties)
|
await publishEvent(Event.USER_UPDATED, properties)
|
||||||
}
|
}
|
||||||
|
@ -33,6 +35,7 @@ async function updated(user: User) {
|
||||||
async function deleted(user: User) {
|
async function deleted(user: User) {
|
||||||
const properties: UserDeletedEvent = {
|
const properties: UserDeletedEvent = {
|
||||||
userId: user._id as string,
|
userId: user._id as string,
|
||||||
|
email: user.email,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.USER_DELETED, properties)
|
await publishEvent(Event.USER_DELETED, properties)
|
||||||
}
|
}
|
||||||
|
@ -40,6 +43,7 @@ async function deleted(user: User) {
|
||||||
export async function onboardingComplete(user: User) {
|
export async function onboardingComplete(user: User) {
|
||||||
const properties: UserOnboardingEvent = {
|
const properties: UserOnboardingEvent = {
|
||||||
userId: user._id as string,
|
userId: user._id as string,
|
||||||
|
email: user.email,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.USER_ONBOARDING_COMPLETE, properties)
|
await publishEvent(Event.USER_ONBOARDING_COMPLETE, properties)
|
||||||
}
|
}
|
||||||
|
@ -49,6 +53,7 @@ export async function onboardingComplete(user: User) {
|
||||||
async function permissionAdminAssigned(user: User, timestamp?: number) {
|
async function permissionAdminAssigned(user: User, timestamp?: number) {
|
||||||
const properties: UserPermissionAssignedEvent = {
|
const properties: UserPermissionAssignedEvent = {
|
||||||
userId: user._id as string,
|
userId: user._id as string,
|
||||||
|
email: user.email,
|
||||||
}
|
}
|
||||||
await publishEvent(
|
await publishEvent(
|
||||||
Event.USER_PERMISSION_ADMIN_ASSIGNED,
|
Event.USER_PERMISSION_ADMIN_ASSIGNED,
|
||||||
|
@ -60,6 +65,7 @@ async function permissionAdminAssigned(user: User, timestamp?: number) {
|
||||||
async function permissionAdminRemoved(user: User) {
|
async function permissionAdminRemoved(user: User) {
|
||||||
const properties: UserPermissionRemovedEvent = {
|
const properties: UserPermissionRemovedEvent = {
|
||||||
userId: user._id as string,
|
userId: user._id as string,
|
||||||
|
email: user.email,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.USER_PERMISSION_ADMIN_REMOVED, properties)
|
await publishEvent(Event.USER_PERMISSION_ADMIN_REMOVED, properties)
|
||||||
}
|
}
|
||||||
|
@ -67,6 +73,7 @@ async function permissionAdminRemoved(user: User) {
|
||||||
async function permissionBuilderAssigned(user: User, timestamp?: number) {
|
async function permissionBuilderAssigned(user: User, timestamp?: number) {
|
||||||
const properties: UserPermissionAssignedEvent = {
|
const properties: UserPermissionAssignedEvent = {
|
||||||
userId: user._id as string,
|
userId: user._id as string,
|
||||||
|
email: user.email,
|
||||||
}
|
}
|
||||||
await publishEvent(
|
await publishEvent(
|
||||||
Event.USER_PERMISSION_BUILDER_ASSIGNED,
|
Event.USER_PERMISSION_BUILDER_ASSIGNED,
|
||||||
|
@ -78,20 +85,22 @@ async function permissionBuilderAssigned(user: User, timestamp?: number) {
|
||||||
async function permissionBuilderRemoved(user: User) {
|
async function permissionBuilderRemoved(user: User) {
|
||||||
const properties: UserPermissionRemovedEvent = {
|
const properties: UserPermissionRemovedEvent = {
|
||||||
userId: user._id as string,
|
userId: user._id as string,
|
||||||
|
email: user.email,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.USER_PERMISSION_BUILDER_REMOVED, properties)
|
await publishEvent(Event.USER_PERMISSION_BUILDER_REMOVED, properties)
|
||||||
}
|
}
|
||||||
|
|
||||||
// INVITE
|
// INVITE
|
||||||
|
|
||||||
async function invited() {
|
async function invited(email: string) {
|
||||||
const properties: UserInvitedEvent = {}
|
const properties: UserInvitedEvent = { email }
|
||||||
await publishEvent(Event.USER_INVITED, properties)
|
await publishEvent(Event.USER_INVITED, properties)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function inviteAccepted(user: User) {
|
async function inviteAccepted(user: User) {
|
||||||
const properties: UserInviteAcceptedEvent = {
|
const properties: UserInviteAcceptedEvent = {
|
||||||
userId: user._id as string,
|
userId: user._id as string,
|
||||||
|
email: user.email,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.USER_INVITED_ACCEPTED, properties)
|
await publishEvent(Event.USER_INVITED_ACCEPTED, properties)
|
||||||
}
|
}
|
||||||
|
@ -101,6 +110,7 @@ async function inviteAccepted(user: User) {
|
||||||
async function passwordForceReset(user: User) {
|
async function passwordForceReset(user: User) {
|
||||||
const properties: UserPasswordForceResetEvent = {
|
const properties: UserPasswordForceResetEvent = {
|
||||||
userId: user._id as string,
|
userId: user._id as string,
|
||||||
|
email: user.email,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.USER_PASSWORD_FORCE_RESET, properties)
|
await publishEvent(Event.USER_PASSWORD_FORCE_RESET, properties)
|
||||||
}
|
}
|
||||||
|
@ -108,6 +118,7 @@ async function passwordForceReset(user: User) {
|
||||||
async function passwordUpdated(user: User) {
|
async function passwordUpdated(user: User) {
|
||||||
const properties: UserPasswordUpdatedEvent = {
|
const properties: UserPasswordUpdatedEvent = {
|
||||||
userId: user._id as string,
|
userId: user._id as string,
|
||||||
|
email: user.email,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.USER_PASSWORD_UPDATED, properties)
|
await publishEvent(Event.USER_PASSWORD_UPDATED, properties)
|
||||||
}
|
}
|
||||||
|
@ -115,6 +126,7 @@ async function passwordUpdated(user: User) {
|
||||||
async function passwordResetRequested(user: User) {
|
async function passwordResetRequested(user: User) {
|
||||||
const properties: UserPasswordResetRequestedEvent = {
|
const properties: UserPasswordResetRequestedEvent = {
|
||||||
userId: user._id as string,
|
userId: user._id as string,
|
||||||
|
email: user.email,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.USER_PASSWORD_RESET_REQUESTED, properties)
|
await publishEvent(Event.USER_PASSWORD_RESET_REQUESTED, properties)
|
||||||
}
|
}
|
||||||
|
@ -122,6 +134,7 @@ async function passwordResetRequested(user: User) {
|
||||||
async function passwordReset(user: User) {
|
async function passwordReset(user: User) {
|
||||||
const properties: UserPasswordResetEvent = {
|
const properties: UserPasswordResetEvent = {
|
||||||
userId: user._id as string,
|
userId: user._id as string,
|
||||||
|
email: user.email,
|
||||||
}
|
}
|
||||||
await publishEvent(Event.USER_PASSWORD_RESET, properties)
|
await publishEvent(Event.USER_PASSWORD_RESET, properties)
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,6 +227,7 @@ export async function getBuildersCount() {
|
||||||
*/
|
*/
|
||||||
export async function platformLogout(opts: PlatformLogoutOpts) {
|
export async function platformLogout(opts: PlatformLogoutOpts) {
|
||||||
const ctx = opts.ctx
|
const ctx = opts.ctx
|
||||||
|
const email = ctx.user?.email!
|
||||||
const userId = opts.userId
|
const userId = opts.userId
|
||||||
const keepActiveSession = opts.keepActiveSession
|
const keepActiveSession = opts.keepActiveSession
|
||||||
|
|
||||||
|
@ -247,7 +248,7 @@ export async function platformLogout(opts: PlatformLogoutOpts) {
|
||||||
|
|
||||||
const sessionIds = sessions.map(({ sessionId }) => sessionId)
|
const sessionIds = sessions.map(({ sessionId }) => sessionId)
|
||||||
await invalidateSessions(userId, { sessionIds, reason: "logout" })
|
await invalidateSessions(userId, { sessionIds, reason: "logout" })
|
||||||
await events.auth.logout()
|
await events.auth.logout(email)
|
||||||
await userCache.invalidateUser(userId)
|
await userCache.invalidateUser(userId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,50 +3,61 @@ import { BaseEvent } from "./event"
|
||||||
export interface AppCreatedEvent extends BaseEvent {
|
export interface AppCreatedEvent extends BaseEvent {
|
||||||
appId: string
|
appId: string
|
||||||
version: string
|
version: string
|
||||||
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AppUpdatedEvent extends BaseEvent {
|
export interface AppUpdatedEvent extends BaseEvent {
|
||||||
appId: string
|
appId: string
|
||||||
version: string
|
version: string
|
||||||
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AppDeletedEvent extends BaseEvent {
|
export interface AppDeletedEvent extends BaseEvent {
|
||||||
appId: string
|
appId: string
|
||||||
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AppPublishedEvent extends BaseEvent {
|
export interface AppPublishedEvent extends BaseEvent {
|
||||||
appId: string
|
appId: string
|
||||||
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AppUnpublishedEvent extends BaseEvent {
|
export interface AppUnpublishedEvent extends BaseEvent {
|
||||||
appId: string
|
appId: string
|
||||||
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AppFileImportedEvent extends BaseEvent {
|
export interface AppFileImportedEvent extends BaseEvent {
|
||||||
appId: string
|
appId: string
|
||||||
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AppTemplateImportedEvent extends BaseEvent {
|
export interface AppTemplateImportedEvent extends BaseEvent {
|
||||||
appId: string
|
appId: string
|
||||||
templateKey: string
|
templateKey: string
|
||||||
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AppVersionUpdatedEvent extends BaseEvent {
|
export interface AppVersionUpdatedEvent extends BaseEvent {
|
||||||
appId: string
|
appId: string
|
||||||
currentVersion: string
|
currentVersion: string
|
||||||
updatedToVersion: string
|
updatedToVersion: string
|
||||||
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AppVersionRevertedEvent extends BaseEvent {
|
export interface AppVersionRevertedEvent extends BaseEvent {
|
||||||
appId: string
|
appId: string
|
||||||
currentVersion: string
|
currentVersion: string
|
||||||
revertedToVersion: string
|
revertedToVersion: string
|
||||||
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AppRevertedEvent extends BaseEvent {
|
export interface AppRevertedEvent extends BaseEvent {
|
||||||
appId: string
|
appId: string
|
||||||
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AppExportedEvent extends BaseEvent {
|
export interface AppExportedEvent extends BaseEvent {
|
||||||
appId: string
|
appId: string
|
||||||
|
name: string
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,10 +7,12 @@ export type SSOType = ConfigType.OIDC | ConfigType.GOOGLE
|
||||||
export interface LoginEvent extends BaseEvent {
|
export interface LoginEvent extends BaseEvent {
|
||||||
userId: string
|
userId: string
|
||||||
source: LoginSource
|
source: LoginSource
|
||||||
|
email: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LogoutEvent extends BaseEvent {
|
export interface LogoutEvent extends BaseEvent {
|
||||||
userId: string
|
userId: string
|
||||||
|
email: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SSOCreatedEvent extends BaseEvent {
|
export interface SSOCreatedEvent extends BaseEvent {
|
||||||
|
|
|
@ -5,6 +5,7 @@ export interface AppBackupRestoreEvent extends BaseEvent {
|
||||||
appId: string
|
appId: string
|
||||||
restoreId: string
|
restoreId: string
|
||||||
backupCreatedAt: string
|
backupCreatedAt: string
|
||||||
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AppBackupTriggeredEvent extends BaseEvent {
|
export interface AppBackupTriggeredEvent extends BaseEvent {
|
||||||
|
@ -12,4 +13,5 @@ export interface AppBackupTriggeredEvent extends BaseEvent {
|
||||||
appId: string
|
appId: string
|
||||||
trigger: AppBackupTrigger
|
trigger: AppBackupTrigger
|
||||||
type: AppBackupType
|
type: AppBackupType
|
||||||
|
name: string
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,8 +182,102 @@ export enum Event {
|
||||||
ENVIRONMENT_VARIABLE_UPGRADE_PANEL_OPENED = "environment_variable:upgrade_panel_opened",
|
ENVIRONMENT_VARIABLE_UPGRADE_PANEL_OPENED = "environment_variable:upgrade_panel_opened",
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AuditedEventFriendlyName = {
|
export class AuditedEventFriendlyName {
|
||||||
[Event.USER_CREATED]: "user created",
|
// USER
|
||||||
|
static USER_CREATED = "User {{ email }} created"
|
||||||
|
static USER_UPDATED = "User {{ email }} updated"
|
||||||
|
static USER_DELETED = "User {{ email }} deleted"
|
||||||
|
static USER_PERMISSION_ADMIN_ASSIGNED = "User {{ email }} admin role assigned"
|
||||||
|
static USER_PERMISSION_ADMIN_REMOVED = "User {{ email }} admin role removed"
|
||||||
|
static USER_PERMISSION_BUILDER_ASSIGNED =
|
||||||
|
"User {{ email }} builder role assigned"
|
||||||
|
static USER_PERMISSION_BUILDER_REMOVED =
|
||||||
|
"User {{ email }} builder role removed"
|
||||||
|
static USER_INVITED = "User {{ email }} invited"
|
||||||
|
static USER_INVITED_ACCEPTED = "User {{ email }} accepted invite"
|
||||||
|
static USER_PASSWORD_UPDATED = "User {{ email }} password updated"
|
||||||
|
static USER_PASSWORD_RESET_REQUESTED =
|
||||||
|
"User {{ email }} password reset requested"
|
||||||
|
static USER_PASSWORD_RESET = "User {{ email }} password reset"
|
||||||
|
static USER_GROUP_CREATED = "User group {{ name }} created"
|
||||||
|
static USER_GROUP_UPDATED = "User group {{ name }} updated"
|
||||||
|
static USER_GROUP_DELETED = "User group {{ name }} deleted"
|
||||||
|
static USER_GROUP_USERS_ADDED =
|
||||||
|
"User group {{ name }} {{ count }} users added"
|
||||||
|
static USER_GROUP_USERS_REMOVED =
|
||||||
|
"User group {{ name }} {{ count }} users removed"
|
||||||
|
static USER_GROUP_PERMISSIONS_EDITED =
|
||||||
|
"User group {{ name }} permissions edited"
|
||||||
|
|
||||||
|
// EMAIL
|
||||||
|
static EMAIL_SMTP_CREATED = "Email configuration created"
|
||||||
|
static EMAIL_SMTP_UPDATED = "Email configuration updated"
|
||||||
|
|
||||||
|
// AUTH
|
||||||
|
static AUTH_SSO_CREATED = "SSO configuration created"
|
||||||
|
static AUTH_SSO_UPDATED = "SSO configuration updated"
|
||||||
|
static AUTH_SSO_ACTIVATED = "SSO configuration activated"
|
||||||
|
static AUTH_SSO_DEACTIVATED = "SSO configuration deactivated"
|
||||||
|
static AUTH_LOGIN = "User {{ email }} logged in"
|
||||||
|
static AUTH_LOGOUT = "User {{ email }} logged out"
|
||||||
|
|
||||||
|
// ORG
|
||||||
|
static ORG_NAME_UPDATED = "Organisation name updated"
|
||||||
|
static ORG_LOGO_UPDATED = "Organisation logo updated"
|
||||||
|
static ORG_PLATFORM_URL_UPDATED = "Organisation platform URL updated"
|
||||||
|
|
||||||
|
// APP
|
||||||
|
static APP_CREATED = "App {{ name }} created"
|
||||||
|
static APP_UPDATED = "App {{ name }} updated"
|
||||||
|
static APP_DELETED = "App {{ name }} deleted"
|
||||||
|
static APP_PUBLISHED = "App {{ name }} published"
|
||||||
|
static APP_UNPUBLISHED = "App {{ name }} unpublished"
|
||||||
|
static APP_TEMPLATE_IMPORTED = "App {{ name }} template imported"
|
||||||
|
static APP_FILE_IMPORTED = "App {{ name }} file imported"
|
||||||
|
static APP_VERSION_UPDATED = "App {{ name }} version updated"
|
||||||
|
static APP_VERSION_REVERTED = "App {{ name }} version reverted"
|
||||||
|
static APP_REVERTED = "App {{ name }} reverted"
|
||||||
|
static APP_EXPORTED = "App {{ name }} exported"
|
||||||
|
static APP_BACKUP_RESTORED = "App backup {{ name }} restored"
|
||||||
|
static APP_BACKUP_TRIGGERED = "App backup {{ name }} triggered"
|
||||||
|
|
||||||
|
// DATASOURCE
|
||||||
|
static DATASOURCE_CREATED = "Datasource created"
|
||||||
|
static DATASOURCE_UPDATED = "Datasource updated"
|
||||||
|
static DATASOURCE_DELETED = "Datasource deleted"
|
||||||
|
|
||||||
|
// QUERY
|
||||||
|
static QUERY_CREATED = "Query created"
|
||||||
|
static QUERY_UPDATED = "Query updated"
|
||||||
|
static QUERY_DELETED = "Query deleted"
|
||||||
|
static QUERY_IMPORT = "Query import"
|
||||||
|
|
||||||
|
// TABLE
|
||||||
|
static TABLE_CREATED = "Table created"
|
||||||
|
static TABLE_UPDATED = "Table updated"
|
||||||
|
static TABLE_DELETED = "Table deleted"
|
||||||
|
static TABLE_EXPORTED = "Table exported"
|
||||||
|
static TABLE_IMPORTED = "Table imported"
|
||||||
|
static TABLE_DATA_IMPORTED = "Data imported to table"
|
||||||
|
|
||||||
|
// ROWS
|
||||||
|
static ROWS_CREATED = "Rows created"
|
||||||
|
static ROWS_IMPORTED = "Rows imported"
|
||||||
|
|
||||||
|
// AUTOMATION
|
||||||
|
static AUTOMATION_CREATED = "Automation created"
|
||||||
|
static AUTOMATION_DELETED = "Automation deleted"
|
||||||
|
|
||||||
|
// SCREEN
|
||||||
|
static SCREEN_CREATED = "Screen created"
|
||||||
|
static SCREEN_DELETED = "Screen deleted"
|
||||||
|
|
||||||
|
// COMPONENT
|
||||||
|
static COMPONENT_CREATED = "Component created"
|
||||||
|
static COMPONENT_DELETED = "Component deleted"
|
||||||
|
|
||||||
|
static ENVIRONMENT_VARIABLE_CREATED = "Environment variable created"
|
||||||
|
static ENVIRONMENT_VARIABLE_DELETED = "Environment variable deleted"
|
||||||
}
|
}
|
||||||
|
|
||||||
// properties added at the final stage of the event pipeline
|
// properties added at the final stage of the event pipeline
|
||||||
|
|
|
@ -2,47 +2,60 @@ import { BaseEvent } from "./event"
|
||||||
|
|
||||||
export interface UserCreatedEvent extends BaseEvent {
|
export interface UserCreatedEvent extends BaseEvent {
|
||||||
userId: string
|
userId: string
|
||||||
|
email: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserUpdatedEvent extends BaseEvent {
|
export interface UserUpdatedEvent extends BaseEvent {
|
||||||
userId: string
|
userId: string
|
||||||
|
email: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserDeletedEvent extends BaseEvent {
|
export interface UserDeletedEvent extends BaseEvent {
|
||||||
userId: string
|
userId: string
|
||||||
|
email: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserOnboardingEvent extends BaseEvent {
|
export interface UserOnboardingEvent extends BaseEvent {
|
||||||
userId: string
|
userId: string
|
||||||
step?: string
|
step?: string
|
||||||
|
email: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserPermissionAssignedEvent extends BaseEvent {
|
export interface UserPermissionAssignedEvent extends BaseEvent {
|
||||||
userId: string
|
userId: string
|
||||||
|
email: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserPermissionRemovedEvent extends BaseEvent {
|
export interface UserPermissionRemovedEvent extends BaseEvent {
|
||||||
userId: string
|
userId: string
|
||||||
|
email: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserInvitedEvent extends BaseEvent {}
|
export interface UserInvitedEvent extends BaseEvent {
|
||||||
|
email: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface UserInviteAcceptedEvent extends BaseEvent {
|
export interface UserInviteAcceptedEvent extends BaseEvent {
|
||||||
userId: string
|
userId: string
|
||||||
|
email: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserPasswordForceResetEvent extends BaseEvent {
|
export interface UserPasswordForceResetEvent extends BaseEvent {
|
||||||
userId: string
|
userId: string
|
||||||
|
email: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserPasswordUpdatedEvent extends BaseEvent {
|
export interface UserPasswordUpdatedEvent extends BaseEvent {
|
||||||
userId: string
|
userId: string
|
||||||
|
email: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserPasswordResetRequestedEvent extends BaseEvent {
|
export interface UserPasswordResetRequestedEvent extends BaseEvent {
|
||||||
userId: string
|
userId: string
|
||||||
|
email: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserPasswordResetEvent extends BaseEvent {
|
export interface UserPasswordResetEvent extends BaseEvent {
|
||||||
userId: string
|
userId: string
|
||||||
|
email: string
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,27 +2,38 @@ import { BaseEvent } from "./event"
|
||||||
|
|
||||||
export interface GroupCreatedEvent extends BaseEvent {
|
export interface GroupCreatedEvent extends BaseEvent {
|
||||||
groupId: string
|
groupId: string
|
||||||
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GroupUpdatedEvent extends BaseEvent {
|
export interface GroupUpdatedEvent extends BaseEvent {
|
||||||
groupId: string
|
groupId: string
|
||||||
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GroupDeletedEvent extends BaseEvent {
|
export interface GroupDeletedEvent extends BaseEvent {
|
||||||
groupId: string
|
groupId: string
|
||||||
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GroupUsersAddedEvent extends BaseEvent {
|
export interface GroupUsersAddedEvent extends BaseEvent {
|
||||||
count: number
|
count: number
|
||||||
groupId: string
|
groupId: string
|
||||||
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GroupUsersDeletedEvent extends BaseEvent {
|
export interface GroupUsersDeletedEvent extends BaseEvent {
|
||||||
count: number
|
count: number
|
||||||
groupId: string
|
groupId: string
|
||||||
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GroupAddedOnboardingEvent extends BaseEvent {
|
export interface GroupAddedOnboardingEvent extends BaseEvent {
|
||||||
groupId: string
|
groupId: string
|
||||||
onboarding: boolean
|
onboarding: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface GroupPermissionsEditedEvent extends BaseEvent {
|
||||||
|
permissions: Record<string, string>
|
||||||
|
name: string
|
||||||
|
groupId: string
|
||||||
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ export const authenticate = async (ctx: any, next: any) => {
|
||||||
async (err: any, user: User, info: any) => {
|
async (err: any, user: User, info: any) => {
|
||||||
await authInternal(ctx, user, err, info)
|
await authInternal(ctx, user, err, info)
|
||||||
await context.identity.doInUserContext(user, async () => {
|
await context.identity.doInUserContext(user, async () => {
|
||||||
await events.auth.login("local")
|
await events.auth.login("local", user.email)
|
||||||
})
|
})
|
||||||
ctx.status = 200
|
ctx.status = 200
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ export const googleAuth = async (ctx: any, next: any) => {
|
||||||
async (err: any, user: User, info: any) => {
|
async (err: any, user: User, info: any) => {
|
||||||
await authInternal(ctx, user, err, info)
|
await authInternal(ctx, user, err, info)
|
||||||
await context.identity.doInUserContext(user, async () => {
|
await context.identity.doInUserContext(user, async () => {
|
||||||
await events.auth.login("google-internal")
|
await events.auth.login("google-internal", user.email)
|
||||||
})
|
})
|
||||||
ctx.redirect("/")
|
ctx.redirect("/")
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ export const oidcAuth = async (ctx: any, next: any) => {
|
||||||
async (err: any, user: any, info: any) => {
|
async (err: any, user: any, info: any) => {
|
||||||
await authInternal(ctx, user, err, info)
|
await authInternal(ctx, user, err, info)
|
||||||
await context.identity.doInUserContext(user, async () => {
|
await context.identity.doInUserContext(user, async () => {
|
||||||
await events.auth.login("oidc")
|
await events.auth.login("oidc", user.email)
|
||||||
})
|
})
|
||||||
ctx.redirect("/")
|
ctx.redirect("/")
|
||||||
}
|
}
|
||||||
|
|
|
@ -623,7 +623,7 @@ export const invite = async (
|
||||||
}
|
}
|
||||||
await sendEmail(user.email, EmailTemplatePurpose.INVITATION, opts)
|
await sendEmail(user.email, EmailTemplatePurpose.INVITATION, opts)
|
||||||
response.successful.push({ email: user.email })
|
response.successful.push({ email: user.email })
|
||||||
await events.user.invited()
|
await events.user.invited(user.email)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`Failed to send email invitation email=${user.email}`, e)
|
console.error(`Failed to send email invitation email=${user.email}`, e)
|
||||||
response.unsuccessful.push({
|
response.unsuccessful.push({
|
||||||
|
|
Loading…
Reference in New Issue