type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Search for issues using JQL (GET)
* Searches for issues using [JQL](https://confluence.
*/
export async function main(
auth: Jira,
jql: string | undefined,
startAt: string | undefined,
maxResults: string | undefined,
validateQuery: "strict" | "warn" | "none" | "true" | "false" | undefined,
fields: string | undefined,
expand: string | undefined,
properties: string | undefined,
fieldsByKeys: string | undefined
) {
const url = new URL(`https://${auth.domain}.atlassian.net/rest/api/2/search`);
for (const [k, v] of [
["jql", jql],
["startAt", startAt],
["maxResults", maxResults],
["validateQuery", validateQuery],
["fields", fields],
["expand", expand],
["properties", properties],
["fieldsByKeys", fieldsByKeys],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 38 days ago
type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Search for issues using JQL (GET)
* Searches for issues using [JQL](https://confluence.
*/
export async function main(
auth: Jira,
jql: string | undefined,
startAt: string | undefined,
maxResults: string | undefined,
validateQuery: "strict" | "warn" | "none" | "true" | "false" | undefined,
fields: string | undefined,
expand: string | undefined,
properties: string | undefined,
fieldsByKeys: string | undefined
) {
const url = new URL(`https://${auth.domain}.atlassian.net/rest/api/2/search`);
for (const [k, v] of [
["jql", jql],
["startAt", startAt],
["maxResults", maxResults],
["validateQuery", validateQuery],
["fields", fields],
["expand", expand],
["properties", properties],
["fieldsByKeys", fieldsByKeys],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 590 days ago