Some DB type updates (typing dump function) and adding in main audit log event publishers.
This commit is contained in:
parent
59afdc94d4
commit
b48acd8cf4
|
@ -0,0 +1,26 @@
|
||||||
|
import {
|
||||||
|
Event,
|
||||||
|
AuditLogSearchParams,
|
||||||
|
AuditLogFilterEvent,
|
||||||
|
AuditLogDownloadEvent,
|
||||||
|
} from "@budibase/types"
|
||||||
|
import { publishEvent } from "../events"
|
||||||
|
|
||||||
|
async function filtered(search: AuditLogSearchParams) {
|
||||||
|
const properties: AuditLogFilterEvent = {
|
||||||
|
filters: search,
|
||||||
|
}
|
||||||
|
await publishEvent(Event.AUDIT_LOG_FILTER, properties)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function download(search: AuditLogSearchParams) {
|
||||||
|
const properties: AuditLogDownloadEvent = {
|
||||||
|
filters: search,
|
||||||
|
}
|
||||||
|
await publishEvent(Event.AUDIT_LOG_DOWNLOAD, properties)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
filtered,
|
||||||
|
download,
|
||||||
|
}
|
|
@ -21,3 +21,4 @@ export { default as group } from "./group"
|
||||||
export { default as plugin } from "./plugin"
|
export { default as plugin } from "./plugin"
|
||||||
export { default as backup } from "./backup"
|
export { default as backup } from "./backup"
|
||||||
export { default as environmentVariable } from "./environmentVariable"
|
export { default as environmentVariable } from "./environmentVariable"
|
||||||
|
export { default as auditLog } from "./auditLog"
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
import { Event, AuditedEventFriendlyName } from "../../../sdk"
|
import { Event, AuditedEventFriendlyName } from "../../../sdk"
|
||||||
import { PaginationResponse, PaginationRequest } from "../"
|
import {
|
||||||
|
PaginationResponse,
|
||||||
|
PaginationRequest,
|
||||||
|
BasicPaginationRequest,
|
||||||
|
} from "../"
|
||||||
import { User, App } from "../../../"
|
import { User, App } from "../../../"
|
||||||
|
|
||||||
export interface AuditLogSearchParams {
|
export interface AuditLogSearchParams {
|
||||||
|
@ -9,12 +13,13 @@ export interface AuditLogSearchParams {
|
||||||
startDate?: string
|
startDate?: string
|
||||||
endDate?: string
|
endDate?: string
|
||||||
fullSearch?: string
|
fullSearch?: string
|
||||||
|
bookmark?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DownloadAuditLogsRequest extends AuditLogSearchParams {}
|
export interface DownloadAuditLogsRequest extends AuditLogSearchParams {}
|
||||||
|
|
||||||
export interface SearchAuditLogsRequest
|
export interface SearchAuditLogsRequest
|
||||||
extends PaginationRequest,
|
extends BasicPaginationRequest,
|
||||||
AuditLogSearchParams {}
|
AuditLogSearchParams {}
|
||||||
|
|
||||||
export enum AuditLogResourceStatus {
|
export enum AuditLogResourceStatus {
|
||||||
|
|
|
@ -8,9 +8,12 @@ export enum SortType {
|
||||||
number = "number",
|
number = "number",
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PaginationRequest {
|
export interface BasicPaginationRequest {
|
||||||
limit?: number
|
|
||||||
bookmark?: string
|
bookmark?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PaginationRequest extends BasicPaginationRequest {
|
||||||
|
limit?: number
|
||||||
sort?: {
|
sort?: {
|
||||||
order: SortOrder
|
order: SortOrder
|
||||||
column: string
|
column: string
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import Nano from "@budibase/nano"
|
import Nano from "@budibase/nano"
|
||||||
import { AllDocsResponse, AnyDocument, Document } from "../"
|
import { AllDocsResponse, AnyDocument, Document } from "../"
|
||||||
|
import { Writable } from "stream"
|
||||||
|
|
||||||
export type PouchOptions = {
|
export type PouchOptions = {
|
||||||
inMemory?: boolean
|
inMemory?: boolean
|
||||||
|
@ -63,6 +64,18 @@ export const isDocument = (doc: any): doc is Document => {
|
||||||
return typeof doc === "object" && doc._id && doc._rev
|
return typeof doc === "object" && doc._id && doc._rev
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DatabaseDumpOpts {
|
||||||
|
filter?: (doc: AnyDocument) => boolean
|
||||||
|
batch_size?: number
|
||||||
|
batch_limit?: number
|
||||||
|
style?: "main_only" | "all_docs"
|
||||||
|
timeout?: number
|
||||||
|
doc_ids?: string[]
|
||||||
|
query_params?: any
|
||||||
|
view?: string
|
||||||
|
selector?: any
|
||||||
|
}
|
||||||
|
|
||||||
export interface Database {
|
export interface Database {
|
||||||
name: string
|
name: string
|
||||||
|
|
||||||
|
@ -87,7 +100,7 @@ export interface Database {
|
||||||
compact(): Promise<Nano.OkResponse | void>
|
compact(): Promise<Nano.OkResponse | void>
|
||||||
// these are all PouchDB related functions that are rarely used - in future
|
// these are all PouchDB related functions that are rarely used - in future
|
||||||
// should be replaced by better typed/non-pouch implemented methods
|
// should be replaced by better typed/non-pouch implemented methods
|
||||||
dump(...args: any[]): Promise<any>
|
dump(stream: Writable, opts?: DatabaseDumpOpts): Promise<any>
|
||||||
load(...args: any[]): Promise<any>
|
load(...args: any[]): Promise<any>
|
||||||
createIndex(...args: any[]): Promise<any>
|
createIndex(...args: any[]): Promise<any>
|
||||||
deleteIndex(...args: any[]): Promise<any>
|
deleteIndex(...args: any[]): Promise<any>
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
import { BaseEvent } from "./event"
|
||||||
|
import { AuditLogSearchParams } from "../../api"
|
||||||
|
|
||||||
|
export interface AuditLogFilterEvent extends BaseEvent {
|
||||||
|
filters: AuditLogSearchParams
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AuditLogDownloadEvent extends BaseEvent {
|
||||||
|
filters: AuditLogSearchParams
|
||||||
|
}
|
|
@ -180,6 +180,10 @@ export enum Event {
|
||||||
ENVIRONMENT_VARIABLE_CREATED = "environment_variable:created",
|
ENVIRONMENT_VARIABLE_CREATED = "environment_variable:created",
|
||||||
ENVIRONMENT_VARIABLE_DELETED = "environment_variable:deleted",
|
ENVIRONMENT_VARIABLE_DELETED = "environment_variable:deleted",
|
||||||
ENVIRONMENT_VARIABLE_UPGRADE_PANEL_OPENED = "environment_variable:upgrade_panel_opened",
|
ENVIRONMENT_VARIABLE_UPGRADE_PANEL_OPENED = "environment_variable:upgrade_panel_opened",
|
||||||
|
|
||||||
|
// AUDIT LOG
|
||||||
|
AUDIT_LOG_FILTER = "audit_log:filter",
|
||||||
|
AUDIT_LOG_DOWNLOAD = "audit_log:download",
|
||||||
}
|
}
|
||||||
|
|
||||||
// all events that are not audited have been added to this record as undefined, this means
|
// all events that are not audited have been added to this record as undefined, this means
|
||||||
|
@ -356,6 +360,10 @@ export const AuditedEventFriendlyName: Record<Event, string | undefined> = {
|
||||||
[Event.INSTALLATION_VERSION_UPGRADED]: undefined,
|
[Event.INSTALLATION_VERSION_UPGRADED]: undefined,
|
||||||
[Event.INSTALLATION_VERSION_DOWNGRADED]: undefined,
|
[Event.INSTALLATION_VERSION_DOWNGRADED]: undefined,
|
||||||
[Event.INSTALLATION_FIRST_STARTUP]: undefined,
|
[Event.INSTALLATION_FIRST_STARTUP]: undefined,
|
||||||
|
|
||||||
|
// AUDIT LOG - NOT AUDITED
|
||||||
|
[Event.AUDIT_LOG_FILTER]: undefined,
|
||||||
|
[Event.AUDIT_LOG_DOWNLOAD]: undefined,
|
||||||
}
|
}
|
||||||
|
|
||||||
// properties added at the final stage of the event pipeline
|
// properties added at the final stage of the event pipeline
|
||||||
|
|
|
@ -22,3 +22,4 @@ export * from "./userGroup"
|
||||||
export * from "./plugin"
|
export * from "./plugin"
|
||||||
export * from "./backup"
|
export * from "./backup"
|
||||||
export * from "./environmentVariable"
|
export * from "./environmentVariable"
|
||||||
|
export * from "./auditLog"
|
||||||
|
|
Loading…
Reference in New Issue