# All files / src/trpc/routers coordination.ts

9.09% Statements 1/11
100% Branches 0/0
20% Functions 1/5
9.09% Lines 1/11

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

    11x

     /**
     * Coordination Router — merge queue operations
     */

    import { z } from 'zod';
    import type { ProcedureBuilder } from '../trpc.js';
    import { requireCoordinationManager } from './_helpers.js';

    export function coordinationProcedures(publicProcedure: ProcedureBuilder) {
      return {
        queueMerge: publicProcedure
          .input(z.object({ taskId: z.string().min(1) }))
          .mutation(async ({ ctx, input }) => {
            const coordinationManager = requireCoordinationManager(ctx);
            await coordinationManager.queueMerge(input.taskId);
            return { success: true };
          }),

        processMerges: publicProcedure
          .input(z.object({
            targetBranch: z.string().default('main'),
          }))
          .mutation(async ({ ctx, input }) => {
            const coordinationManager = requireCoordinationManager(ctx);
            const results = await coordinationManager.processMerges(input.targetBranch);
            return { results };
          }),

        getMergeQueueStatus: publicProcedure
          .query(async ({ ctx }) => {
            const coordinationManager = requireCoordinationManager(ctx);
            return coordinationManager.getQueueState();
          }),

        getNextMergeable: publicProcedure
          .query(async ({ ctx }) => {
            const coordinationManager = requireCoordinationManager(ctx);
            return coordinationManager.getNextMergeable();
          }),
      };
    }