Some updates to add in the audit log DB.

This commit is contained in:
mike12345567 2023-02-13 18:16:13 +00:00
parent d0fda67046
commit 46e9bf1443
5 changed files with 25 additions and 4 deletions

View File

@ -68,6 +68,7 @@ export enum DocumentType {
MEM_VIEW = "view",
USER_FLAG = "flag",
AUTOMATION_METADATA = "meta_au",
AUDIT_LOG = "al",
}
export const StaticDatabases = {
@ -88,6 +89,9 @@ export const StaticDatabases = {
install: "install",
},
},
AUDIT_LOGS: {
name: "audit-logs",
},
}
export const APP_PREFIX = DocumentType.APP + SEPARATOR

View File

@ -30,6 +30,13 @@ export function getGlobalDBName(tenantId?: string) {
return baseGlobalDBName(tenantId)
}
export function getAuditLogDBName(tenantId?: string) {
if (!tenantId) {
tenantId = getTenantId()
}
return `${tenantId}${SEPARATOR}${StaticDatabases.AUDIT_LOGS.name}`
}
export function baseGlobalDBName(tenantId: string | undefined | null) {
let dbName
if (!tenantId || tenantId === DEFAULT_TENANT_ID) {
@ -228,6 +235,13 @@ export function getGlobalDB(): Database {
return getDB(baseGlobalDBName(context?.tenantId))
}
export function getAuditLogsDB(): Database {
if (!getTenantId()) {
throw new Error("Audit log DB not found")
}
return getDB(getAuditLogDBName())
}
/**
* Gets the app database based on whatever the request
* contained, dev or prod.

View File

@ -1,7 +1,7 @@
import { Event, AuditedEventFriendlyName } from "../../../sdk"
import { PaginationResponse, PaginationRequest } from "../"
export interface DownloadAuditLogsRequest {
export interface AuditLogSearchParams {
userId?: string[]
appId?: string[]
event?: Event[]
@ -10,9 +10,11 @@ export interface DownloadAuditLogsRequest {
metadataSearch?: string
}
export interface DownloadAuditLogsRequest extends AuditLogSearchParams {}
export interface SearchAuditLogsRequest
extends PaginationRequest,
DownloadAuditLogsRequest {}
AuditLogSearchParams {}
export interface SearchAuditLogsResponse extends PaginationResponse {
data: {

View File

@ -1,8 +1,8 @@
import { Document } from "../document"
import { Event } from "../../sdk"
export interface AuditLogDocument extends Document {
appId: string
export interface AuditLogDoc extends Document {
appId?: string
event: Event
userId: string
timestamp: string

View File

@ -6,3 +6,4 @@ export * from "./quotas"
export * from "./schedule"
export * from "./templates"
export * from "./environmentVariables"
export * from "./auditLogs"