Edits history of script submission #17288 for ' Create connector (miro)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Miro = {
      token: string;
    };
    /**
     * Create connector
     * Adds a connector to a board.Required scope boards:write Rate limiting Level 2
     */
    export async function main(
      auth: Miro,
      board_id: string,
      body: {
        startItem: {
          id?: string;
          position?: { x?: string; y?: string };
          snapTo?: "auto" | "top" | "right" | "bottom" | "left";
        };
        endItem: {
          id?: string;
          position?: { x?: string; y?: string };
          snapTo?: "auto" | "top" | "right" | "bottom" | "left";
        };
        shape?: "straight" | "elbowed" | "curved";
        captions?: {
          content: string;
          position?: string;
          textAlignVertical?: "top" | "bottom" | "middle";
        }[];
        style?: {
          color?: string;
          endStrokeCap?:
            | "none"
            | "stealth"
            | "rounded_stealth"
            | "diamond"
            | "filled_diamond"
            | "oval"
            | "filled_oval"
            | "arrow"
            | "triangle"
            | "filled_triangle"
            | "erd_one"
            | "erd_many"
            | "erd_only_one"
            | "erd_zero_or_one"
            | "erd_one_or_many"
            | "erd_zero_or_many"
            | "unknown";
          fontSize?: string;
          startStrokeCap?:
            | "none"
            | "stealth"
            | "rounded_stealth"
            | "diamond"
            | "filled_diamond"
            | "oval"
            | "filled_oval"
            | "arrow"
            | "triangle"
            | "filled_triangle"
            | "erd_one"
            | "erd_many"
            | "erd_only_one"
            | "erd_zero_or_one"
            | "erd_one_or_many"
            | "erd_zero_or_many"
            | "unknown";
          strokeColor?: string;
          strokeStyle?: "normal" | "dotted" | "dashed";
          strokeWidth?: string;
          textOrientation?: "horizontal" | "aligned";
        };
      },
    ) {
      const url = new URL(`https://api.miro.com//v2/boards/${board_id}/connectors`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 235 days ago