import { LinearAPIClient } from '../linear-client.js';
import {
ListProjectsSchema,
CreateProjectSchema,
UpdateProjectSchema,
GetProjectSchema,
ArchiveProjectSchema,
UnarchiveProjectSchema,
} from '../schemas/index.js';
/**
* List all projects with optional filters
*/
export async function listProjects(client: LinearAPIClient, args: unknown) {
const params = ListProjectsSchema.parse(args);
const projects = await client.listProjects(params.teamId, params.includeArchived);
return {
content: [
{
type: 'text' as const,
text: JSON.stringify(
{
count: projects.length,
projects: projects,
},
null,
2
),
},
],
};
}
/**
* Create a new project
*/
export async function createProject(client: LinearAPIClient, args: unknown) {
const params = CreateProjectSchema.parse(args);
const project = await client.createProject(params);
return {
content: [
{
type: 'text' as const,
text: JSON.stringify(project, null, 2),
},
],
};
}
/**
* Update an existing project
*/
export async function updateProject(client: LinearAPIClient, args: unknown) {
const params = UpdateProjectSchema.parse(args);
const { projectId, ...updateData } = params;
const project = await client.updateProject(projectId, updateData);
return {
content: [
{
type: 'text' as const,
text: JSON.stringify(project, null, 2),
},
],
};
}
/**
* Get project details by ID
*/
export async function getProject(client: LinearAPIClient, args: unknown) {
const params = GetProjectSchema.parse(args);
const project = await client.getProject(params.projectId);
return {
content: [
{
type: 'text' as const,
text: JSON.stringify(project, null, 2),
},
],
};
}
/**
* Archive a project
*/
export async function archiveProject(client: LinearAPIClient, args: unknown) {
const params = ArchiveProjectSchema.parse(args);
const result = await client.archiveProject(params.projectId);
return {
content: [
{
type: 'text' as const,
text: JSON.stringify(result, null, 2),
},
],
};
}
/**
* Unarchive a project
*/
export async function unarchiveProject(client: LinearAPIClient, args: unknown) {
const params = UnarchiveProjectSchema.parse(args);
const result = await client.unarchiveProject(params.projectId);
return {
content: [
{
type: 'text' as const,
text: JSON.stringify(result, null, 2),
},
],
};
}