97 lines
1.8 KiB
TypeScript
97 lines
1.8 KiB
TypeScript
import { apiRequest, type ApiSession } from './client'
|
|
|
|
export type BackendProject = {
|
|
ID?: number
|
|
id?: number
|
|
Name?: string
|
|
name?: string
|
|
Description?: string
|
|
description?: string
|
|
}
|
|
|
|
export type BackendWorkspaceProject = {
|
|
id: number
|
|
name: string
|
|
description: string
|
|
initials: string
|
|
unreadCount: number
|
|
}
|
|
|
|
export type BackendChannel = {
|
|
id: string
|
|
projectID: number
|
|
type: string
|
|
title: string
|
|
icon: string
|
|
count?: number
|
|
url?: string
|
|
sortOrder: number
|
|
}
|
|
|
|
export type BackendInboxMessage = {
|
|
id: string
|
|
source: string
|
|
title: string
|
|
summary: string
|
|
status: string
|
|
tag: string
|
|
time: string
|
|
}
|
|
|
|
export type BackendTask = {
|
|
id: string
|
|
title: string
|
|
summary: string
|
|
completed: boolean
|
|
owner: string
|
|
due: string
|
|
tag: string
|
|
}
|
|
|
|
export type BackendAISession = {
|
|
id: string
|
|
title: string
|
|
summary: string
|
|
updatedAt: string
|
|
references: string[]
|
|
}
|
|
|
|
export type BackendNoteSource = {
|
|
id: string
|
|
kind: string
|
|
title: string
|
|
updatedAt: string
|
|
tag: string
|
|
source: string
|
|
}
|
|
|
|
export type BackendCronPlan = {
|
|
id: string
|
|
title: string
|
|
schedule: string
|
|
nextRun: string
|
|
enabled: boolean
|
|
lastResult: string
|
|
owner: string
|
|
}
|
|
|
|
export type BackendProjectWorkspace = {
|
|
project: BackendWorkspaceProject
|
|
channels: BackendChannel[]
|
|
tags: string[]
|
|
recentSessions: BackendAISession[]
|
|
inbox: BackendInboxMessage[]
|
|
tasks: BackendTask[]
|
|
aiSessions: BackendAISession[]
|
|
notesSources: BackendNoteSource[]
|
|
cronPlans: BackendCronPlan[]
|
|
}
|
|
|
|
export async function fetchProjects(session: ApiSession) {
|
|
return apiRequest<BackendProject[]>('/api/projects', { token: session.token })
|
|
}
|
|
|
|
export async function fetchProjectWorkspace(session: ApiSession, projectID: string | number) {
|
|
return apiRequest<BackendProjectWorkspace>(`/api/projects/${projectID}/workspace`, { token: session.token })
|
|
}
|