# All files / src/schemas/ep mep.ts

100% Statements 9/9
100% Branches 0/0
100% Functions 0/0
100% Lines 9/9

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
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157

    58x

    58x

    58x

    58x

    58x

    58x

    58x

    58x

    58x

     /**
     * MEP-related Zod validation schemas.
     *
     * @module schemas/ep/mep
     */

    import { z } from 'zod';
    import { CountryCodeSchema, MepIdSchema } from './common.js';

    /**
     * Get MEPs input schema
     */
    export const GetMEPsSchema = z.object({
      country: CountryCodeSchema.optional(),
      group: z.string()
        .min(1)
        .max(50)
        .optional()
        .describe('Political group identifier'),
      committee: z.string()
        .min(1)
        .max(100)
        .optional()
        .describe('Committee identifier'),
      active: z.boolean()
        .default(true)
        .describe('Filter by active status'),
      limit: z.number()
        .int()
        .min(1)
        .max(100)
        .default(50)
        .describe('Maximum results to return'),
      offset: z.number()
        .int()
        .min(0)
        .default(0)
        .describe('Pagination offset')
    });

    /**
     * Get MEP details input schema
     */
    export const GetMEPDetailsSchema = z.object({
      id: MepIdSchema
        .describe('MEP identifier')
    });

    /**
     * MEP output schema
     */
    export const MEPSchema = z.object({
      id: z.string(),
      name: z.string(),
      country: z.string(),
      politicalGroup: z.string(),
      committees: z.array(z.string()),
      email: z.email({ message: 'Invalid email format' }).optional(),
      active: z.boolean(),
      termStart: z.string(),
      termEnd: z.string().optional()
    });

    /**
     * Voting statistics schema
     * @internal - Used internally within MEPDetailsSchema
     */
    const VotingStatisticsSchema = z.object({
      totalVotes: z.number().int().min(0),
      votesFor: z.number().int().min(0),
      votesAgainst: z.number().int().min(0),
      abstentions: z.number().int().min(0),
      attendanceRate: z.number().min(0).max(100)
    });

    /**
     * MEP details output schema
     */
    export const MEPDetailsSchema = MEPSchema.extend({
      biography: z.string().optional(),
      phone: z.string().optional(),
      address: z.string().optional(),
      website: z.url({ message: 'Invalid URL format' }).optional(),
      twitter: z.string().optional(),
      facebook: z.string().optional(),
      votingStatistics: VotingStatisticsSchema.optional(),
      roles: z.array(z.string()).optional()
    });

    /**
     * Get current MEPs input schema
     */
    export const GetCurrentMEPsSchema = z.object({
      limit: z.number()
        .int()
        .min(1)
        .max(100)
        .default(50)
        .describe('Maximum results to return'),
      offset: z.number()
        .int()
        .min(0)
        .default(0)
        .describe('Pagination offset')
    });

    /**
     * Get incoming MEPs input schema
     */
    export const GetIncomingMEPsSchema = z.object({
      limit: z.number()
        .int()
        .min(1)
        .max(100)
        .default(50)
        .describe('Maximum results to return'),
      offset: z.number()
        .int()
        .min(0)
        .default(0)
        .describe('Pagination offset')
    });

    /**
     * Get outgoing MEPs input schema
     */
    export const GetOutgoingMEPsSchema = z.object({
      limit: z.number()
        .int()
        .min(1)
        .max(100)
        .default(50)
        .describe('Maximum results to return'),
      offset: z.number()
        .int()
        .min(0)
        .default(0)
        .describe('Pagination offset')
    });

    /**
     * Get homonym MEPs input schema
     */
    export const GetHomonymMEPsSchema = z.object({
      limit: z.number()
        .int()
        .min(1)
        .max(100)
        .default(50)
        .describe('Maximum results to return'),
      offset: z.number()
        .int()
        .min(0)
        .default(0)
        .describe('Pagination offset')
    });