type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Parse JQL query
* Parses and validates JQL queries.
Validation is performed in context of the current user.
This operation can be accessed anonymously.
**[Permissions](#permissions) required:** None.
*/
export async function main(
auth: Jira,
validation: "strict" | "warn" | "none" | undefined,
body: { queries: string[] }
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/jql/parse`
);
for (const [k, v] of [["validation", validation]]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
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 94 days ago
type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Parse JQL query
* Parses and validates JQL queries.
Validation is performed in context of the current user.
This operation can be accessed anonymously.
**[Permissions](#permissions) required:** None.
*/
export async function main(
auth: Jira,
validation: "strict" | "warn" | "none" | undefined,
body: { queries: string[] }
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/jql/parse`
);
for (const [k, v] of [["validation", validation]]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
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 647 days ago