//native
type Miro = {
token: string;
};
/**
* Create items in bulk
* Adds different types of items to a board.
*/
export async function main(
auth: Miro,
board_id: string,
body: {
type:
| "app_card"
| "text"
| "shape"
| "sticky_note"
| "image"
| "document"
| "card"
| "frame"
| "embed";
data?:
| {
description?: string;
fields?: {
fillColor?: string;
iconShape?: "round" | "square";
iconUrl?: string;
textColor?: string;
tooltip?: string;
value?: string;
}[];
owned?: false | true;
status?: "disconnected" | "connected" | "disabled";
title?: string;
}
| {
assigneeId?: string;
description?: string;
dueDate?: string;
title?: string;
}
| { title?: string; url: string }
| { mode?: "inline" | "modal"; previewUrl?: string; url: string }
| { title?: string; url: string }
| {
content?: string;
shape?:
| "rectangle"
| "round_rectangle"
| "circle"
| "triangle"
| "rhombus"
| "parallelogram"
| "trapezoid"
| "pentagon"
| "hexagon"
| "octagon"
| "wedge_round_rectangle_callout"
| "star"
| "flow_chart_predefined_process"
| "cloud"
| "cross"
| "can"
| "right_arrow"
| "left_arrow"
| "left_right_arrow"
| "left_brace"
| "right_brace";
}
| { content?: string; shape?: "square" | "rectangle" }
| { content: string };
style?:
| { fillColor?: string }
| { cardTheme?: string }
| {
borderColor?: string;
borderOpacity?: string;
borderStyle?: "normal" | "dotted" | "dashed";
borderWidth?: string;
color?: string;
fillColor?: string;
fillOpacity?: string;
fontFamily?:
| "arial"
| "abril_fatface"
| "bangers"
| "eb_garamond"
| "georgia"
| "graduate"
| "gravitas_one"
| "fredoka_one"
| "nixie_one"
| "open_sans"
| "permanent_marker"
| "pt_sans"
| "pt_sans_narrow"
| "pt_serif"
| "rammetto_one"
| "roboto"
| "roboto_condensed"
| "roboto_slab"
| "caveat"
| "times_new_roman"
| "titan_one"
| "lemon_tuesday"
| "roboto_mono"
| "noto_sans"
| "plex_sans"
| "plex_serif"
| "plex_mono"
| "spoof"
| "tiempos_text"
| "formular";
fontSize?: string;
textAlign?: "left" | "right" | "center";
textAlignVertical?: "top" | "middle" | "bottom";
}
| {
fillColor?:
| "gray"
| "light_yellow"
| "yellow"
| "orange"
| "light_green"
| "green"
| "dark_green"
| "cyan"
| "light_pink"
| "pink"
| "violet"
| "red"
| "light_blue"
| "blue"
| "dark_blue"
| "black";
textAlign?: "left" | "right" | "center";
textAlignVertical?: "top" | "middle" | "bottom";
}
| {
color?: string;
fillColor?: string;
fillOpacity?: string;
fontFamily?:
| "arial"
| "abril_fatface"
| "bangers"
| "eb_garamond"
| "georgia"
| "graduate"
| "gravitas_one"
| "fredoka_one"
| "nixie_one"
| "open_sans"
| "permanent_marker"
| "pt_sans"
| "pt_sans_narrow"
| "pt_serif"
| "rammetto_one"
| "roboto"
| "roboto_condensed"
| "roboto_slab"
| "caveat"
| "times_new_roman"
| "titan_one"
| "lemon_tuesday"
| "roboto_mono"
| "noto_sans"
| "plex_sans"
| "plex_serif"
| "plex_mono"
| "spoof"
| "tiempos_text"
| "formular";
fontSize?: string;
textAlign?: "left" | "right" | "center";
};
position?: { x?: number; y?: number };
geometry?: { height?: number; rotation?: number; width?: number };
parent?: { id?: string };
}[],
) {
const url = new URL(`https://api.miro.com//v2/boards/${board_id}/items/bulk`);
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