Add logActionAudit and query endpoint

This commit is contained in:
Owen
2025-10-19 21:53:00 -07:00
parent dce84b9b09
commit 1f50bc3752
12 changed files with 488 additions and 108 deletions

View File

@@ -225,6 +225,28 @@ export const actionAuditLog = sqliteTable("actionAuditLog", {
index("idx_actionAuditLog_org_timestamp").on(table.orgId, table.timestamp)
]));
export const identityAuditLog = sqliteTable("identityAuditLog", {
id: integer("id").primaryKey({ autoIncrement: true }),
timestamp: integer("timestamp").notNull(), // this is EPOCH time in seconds
orgId: text("orgId")
.notNull()
.references(() => orgs.orgId, { onDelete: "cascade" }),
actorType: text("actorType").notNull(),
actor: text("actor").notNull(),
actorId: text("actorId").notNull(),
resourceId: integer("resourceId"),
ip: text("ip").notNull(),
type: text("type").notNull(),
action: text("action").notNull(),
location: text("location"),
path: text("path"),
userAgent: text("userAgent"),
metadata: text("details")
}, (table) => ([
index("idx_actionAuditLog_timestamp").on(table.timestamp),
index("idx_actionAuditLog_org_timestamp").on(table.orgId, table.timestamp)
]));
export type Limit = InferSelectModel<typeof limits>;
export type Account = InferSelectModel<typeof account>;
export type Certificate = InferSelectModel<typeof certificates>;