//native
type Vercel = {
token: string;
};
/**
* List deployments
* List deployments under the authenticated user or team. If a deployment hasn't finished uploading (is incomplete), the `url` property will have a value of `null`.
*/
export async function main(
auth: Vercel,
app: string | undefined,
from: string | undefined,
limit: string | undefined,
projectId: string | undefined,
target: string | undefined,
to: string | undefined,
users: string | undefined,
since: string | undefined,
until: string | undefined,
state: string | undefined,
rollbackCandidate: string | undefined,
teamId: string | undefined,
slug: string | undefined,
) {
const url = new URL(`https://api.vercel.com/v6/deployments`);
for (const [k, v] of [
["app", app],
["from", from],
["limit", limit],
["projectId", projectId],
["target", target],
["to", to],
["users", users],
["since", since],
["until", until],
["state", state],
["rollbackCandidate", rollbackCandidate],
["teamId", teamId],
["slug", slug],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago