mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-15 02:20:38 +09:00
Add server routes for companies, approvals, costs, and dashboard
New routes: companies, approvals, costs, dashboard, authz. New services: companies, approvals, costs, dashboard, heartbeat, activity-log. Add auth middleware and structured error handling. Expand existing agent and issue routes with richer CRUD operations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
8c830eae70
commit
abadd469bc
29 changed files with 2151 additions and 98 deletions
|
|
@ -1,8 +1,9 @@
|
|||
import { eq, and, desc } from "drizzle-orm";
|
||||
import { and, desc, eq } from "drizzle-orm";
|
||||
import type { Db } from "@paperclip/db";
|
||||
import { activityLog } from "@paperclip/db";
|
||||
|
||||
export interface ActivityFilters {
|
||||
companyId: string;
|
||||
agentId?: string;
|
||||
entityType?: string;
|
||||
entityId?: string;
|
||||
|
|
@ -10,26 +11,20 @@ export interface ActivityFilters {
|
|||
|
||||
export function activityService(db: Db) {
|
||||
return {
|
||||
list: (filters?: ActivityFilters) => {
|
||||
const conditions = [];
|
||||
list: (filters: ActivityFilters) => {
|
||||
const conditions = [eq(activityLog.companyId, filters.companyId)];
|
||||
|
||||
if (filters?.agentId) {
|
||||
if (filters.agentId) {
|
||||
conditions.push(eq(activityLog.agentId, filters.agentId));
|
||||
}
|
||||
if (filters?.entityType) {
|
||||
if (filters.entityType) {
|
||||
conditions.push(eq(activityLog.entityType, filters.entityType));
|
||||
}
|
||||
if (filters?.entityId) {
|
||||
if (filters.entityId) {
|
||||
conditions.push(eq(activityLog.entityId, filters.entityId));
|
||||
}
|
||||
|
||||
const query = db.select().from(activityLog);
|
||||
|
||||
if (conditions.length > 0) {
|
||||
return query.where(and(...conditions)).orderBy(desc(activityLog.createdAt));
|
||||
}
|
||||
|
||||
return query.orderBy(desc(activityLog.createdAt));
|
||||
return db.select().from(activityLog).where(and(...conditions)).orderBy(desc(activityLog.createdAt));
|
||||
},
|
||||
|
||||
create: (data: typeof activityLog.$inferInsert) =>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue