import { LinearAPIClient } from '../linear-client.js';
import {
ListCustomViewsSchema,
CreateCustomViewSchema,
UpdateCustomViewSchema,
GetCustomViewSchema,
DeleteCustomViewSchema,
} from '../schemas/index.js';
/**
* List all custom views with optional filters
*/
export async function listCustomViews(client: LinearAPIClient, args: unknown) {
const params = ListCustomViewsSchema.parse(args);
const views = await client.listCustomViews(params.includeArchived);
return {
content: [
{
type: 'text' as const,
text: JSON.stringify(
{
count: views.length,
views: views,
},
null,
2
),
},
],
};
}
/**
* Create a new custom view
*/
export async function createCustomView(client: LinearAPIClient, args: unknown) {
const params = CreateCustomViewSchema.parse(args);
const view = await client.createCustomView(params);
return {
content: [
{
type: 'text' as const,
text: JSON.stringify(view, null, 2),
},
],
};
}
/**
* Update an existing custom view
*/
export async function updateCustomView(client: LinearAPIClient, args: unknown) {
const params = UpdateCustomViewSchema.parse(args);
const { viewId, ...updateData } = params;
const view = await client.updateCustomView(viewId, updateData);
return {
content: [
{
type: 'text' as const,
text: JSON.stringify(view, null, 2),
},
],
};
}
/**
* Get custom view details by ID
*/
export async function getCustomView(client: LinearAPIClient, args: unknown) {
const params = GetCustomViewSchema.parse(args);
const view = await client.getCustomView(params.viewId);
return {
content: [
{
type: 'text' as const,
text: JSON.stringify(view, null, 2),
},
],
};
}
/**
* Delete a custom view
*/
export async function deleteCustomView(client: LinearAPIClient, args: unknown) {
const params = DeleteCustomViewSchema.parse(args);
const result = await client.deleteCustomView(params.viewId);
return {
content: [
{
type: 'text' as const,
text: JSON.stringify(result, null, 2),
},
],
};
}