Schema additions for issues #37-41: New models: - Domain (#37): Life domains (work, marriage, homelab, etc.) - Idea (#38): Brain dumps with pgvector embeddings - Relationship (#39): Generic entity linking (blocks, depends_on) - Agent (#40): ClawdBot agent tracking with metrics - AgentSession (#40): Conversation session tracking - WidgetDefinition (#41): HUD widget registry - UserLayout (#41): Per-user dashboard configuration Updated models: - Task, Event, Project: Added domainId foreign key - User, Workspace: Added new relations New enums: - IdeaStatus: CAPTURED, PROCESSING, ACTIONABLE, ARCHIVED, DISCARDED - RelationshipType: BLOCKS, BLOCKED_BY, DEPENDS_ON, etc. - AgentStatus: IDLE, WORKING, WAITING, ERROR, TERMINATED - EntityType: Added IDEA, DOMAIN Migration: 20260129182803_add_domains_ideas_agents_widgets
91 lines
2.3 KiB
TypeScript
91 lines
2.3 KiB
TypeScript
/**
|
|
* Event API Client
|
|
* Handles event-related API requests
|
|
*/
|
|
|
|
import type { Event } from "@mosaic/shared";
|
|
import { apiGet, type ApiResponse } from "./client";
|
|
|
|
export interface EventFilters {
|
|
startDate?: Date;
|
|
endDate?: Date;
|
|
workspaceId?: string;
|
|
}
|
|
|
|
/**
|
|
* Fetch events with optional filters
|
|
*/
|
|
export async function fetchEvents(filters?: EventFilters): Promise<Event[]> {
|
|
const params = new URLSearchParams();
|
|
|
|
if (filters?.startDate) {
|
|
params.append("startDate", filters.startDate.toISOString());
|
|
}
|
|
if (filters?.endDate) {
|
|
params.append("endDate", filters.endDate.toISOString());
|
|
}
|
|
if (filters?.workspaceId) {
|
|
params.append("workspaceId", filters.workspaceId);
|
|
}
|
|
|
|
const queryString = params.toString();
|
|
const endpoint = queryString ? `/api/events?${queryString}` : "/api/events";
|
|
|
|
const response = await apiGet<ApiResponse<Event[]>>(endpoint);
|
|
return response.data;
|
|
}
|
|
|
|
/**
|
|
* Mock events for development (until backend endpoints are ready)
|
|
*/
|
|
export const mockEvents: Event[] = [
|
|
{
|
|
id: "event-1",
|
|
title: "Team standup",
|
|
description: "Daily sync meeting",
|
|
startTime: new Date("2026-01-29T10:00:00"),
|
|
endTime: new Date("2026-01-29T10:30:00"),
|
|
allDay: false,
|
|
location: "Zoom",
|
|
recurrence: null,
|
|
creatorId: "user-1",
|
|
workspaceId: "workspace-1",
|
|
projectId: null,
|
|
metadata: {},
|
|
createdAt: new Date("2026-01-28"),
|
|
updatedAt: new Date("2026-01-28"),
|
|
},
|
|
{
|
|
id: "event-2",
|
|
title: "Project review",
|
|
description: "Quarterly project review session",
|
|
startTime: new Date("2026-01-30T14:00:00"),
|
|
endTime: new Date("2026-01-30T15:30:00"),
|
|
allDay: false,
|
|
location: "Conference Room A",
|
|
recurrence: null,
|
|
creatorId: "user-1",
|
|
workspaceId: "workspace-1",
|
|
projectId: null,
|
|
metadata: {},
|
|
createdAt: new Date("2026-01-28"),
|
|
updatedAt: new Date("2026-01-28"),
|
|
},
|
|
{
|
|
id: "event-3",
|
|
title: "Focus time",
|
|
description: "Dedicated time for deep work",
|
|
startTime: new Date("2026-01-31T09:00:00"),
|
|
endTime: new Date("2026-01-31T12:00:00"),
|
|
allDay: false,
|
|
location: null,
|
|
recurrence: null,
|
|
creatorId: "user-1",
|
|
workspaceId: "workspace-1",
|
|
projectId: null,
|
|
metadata: {},
|
|
createdAt: new Date("2026-01-28"),
|
|
updatedAt: new Date("2026-01-28"),
|
|
},
|
|
];
|