Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions src/linear/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ import type {
LinearIssue,
LinearLabel,
LinearReaction,
LinearTeam,
LinearUpdateIssueInput,
LinearUser,
LinearWorkflowState,
} from './types.js';

const LINEAR_API_URL = 'https://api.linear.app/graphql';
Expand Down Expand Up @@ -580,6 +582,74 @@ export const linearClient = {
};
},

// ===== Discovery =====

async getTeams(): Promise<LinearTeam[]> {
logger.debug('Fetching Linear teams');
const data = await linearGraphQL<{ teams: { nodes: unknown[] } }>(
`query GetTeams {
teams {
nodes {
${TEAM_FIELDS}
}
}
}`,
);
return (data.teams.nodes as RawIssue['team'][]).map(mapTeam);
},

async getTeamWorkflowStates(teamId: string): Promise<LinearWorkflowState[]> {
logger.debug('Fetching Linear team workflow states', { teamId });
const data = await linearGraphQL<{
team: { states: { nodes: unknown[] } };
}>(
`query GetTeamWorkflowStates($id: String!) {
team(id: $id) {
states {
nodes {
${STATE_FIELDS}
}
}
}
}`,
{ id: teamId },
);
return (
data.team.states.nodes as Array<{
id?: string;
name?: string;
type?: string;
color?: string;
}>
).map(mapState);
},

async getTeamLabels(teamId: string): Promise<LinearLabel[]> {
logger.debug('Fetching Linear team labels', { teamId });
const data = await linearGraphQL<{
team: { labels: { nodes: unknown[] } };
}>(
`query GetTeamLabels($id: String!) {
team(id: $id) {
labels {
nodes {
${LABEL_FIELDS}
}
}
}
}`,
{ id: teamId },
);
return (
data.team.labels.nodes as Array<{
id?: string;
name?: string;
color?: string;
description?: string | null;
}>
).map(mapLabel);
},

// ===== User =====

async getMe(): Promise<LinearUser> {
Expand Down
Loading
Loading