All files / scripts/mcp-client/methods reports.ts

100% Statements 27/27
90% Branches 36/40
100% Functions 5/5
100% Lines 21/21

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69                                  5x 5x 5x   5x 5x               7x 7x   7x 7x               6x 6x   6x 6x             1x 1x 1x 1x             1x 1x 1x 1x    
/**
 * @module mcp-client/methods/reports
 * @description Committee reports, propositions, motions, written questions
 * and interpellations — all the "latest N from this riksmöte" style tools.
 *
 * @author Hack23 AB
 * @license Apache-2.0
 */
 
import type { MCPTransportClient } from '../transport/jsonrpc.js';
 
export async function fetchCommitteeReports(
  transport: MCPTransportClient,
  limit = 10,
  rm: string | null = null,
  organ: string | null = null,
): Promise<unknown[]> {
  const params: Record<string, unknown> = { limit };
  if (rm) params['rm'] = rm;
  if (organ) params['organ'] = organ;
 
  const response = await transport.request('get_betankanden', params);
  return (response['dokument'] ?? response['reports'] ?? []) as unknown[];
}
 
export async function fetchPropositions(
  transport: MCPTransportClient,
  limit = 10,
  rm: string | null = null,
): Promise<unknown[]> {
  const params: Record<string, unknown> = { limit };
  if (rm) params['rm'] = rm;
 
  const response = await transport.request('get_propositioner', params);
  return (response['dokument'] ?? response['propositions'] ?? []) as unknown[];
}
 
export async function fetchMotions(
  transport: MCPTransportClient,
  limit = 10,
  rm: string | null = null,
): Promise<unknown[]> {
  const params: Record<string, unknown> = { limit };
  if (rm) params['rm'] = rm;
 
  const response = await transport.request('get_motioner', params);
  return (response['dokument'] ?? response['motions'] ?? []) as unknown[];
}
 
export async function fetchWrittenQuestions(
  transport: MCPTransportClient,
  params: { limit?: number; rm?: string } = {},
): Promise<unknown[]> {
  const reqParams: Record<string, unknown> = { limit: params.limit ?? 20 };
  Eif (params.rm) reqParams['rm'] = params.rm;
  const response = await transport.request('get_fragor', reqParams);
  return (response['dokument'] ?? response['questions'] ?? []) as unknown[];
}
 
export async function fetchInterpellations(
  transport: MCPTransportClient,
  params: { limit?: number; rm?: string } = {},
): Promise<unknown[]> {
  const reqParams: Record<string, unknown> = { limit: params.limit ?? 15 };
  Eif (params.rm) reqParams['rm'] = params.rm;
  const response = await transport.request('get_interpellationer', reqParams);
  return (response['dokument'] ?? response['interpellations'] ?? []) as unknown[];
}