type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Get precomputations (apps)
* Returns the list of a function's precomputations along with information about when they were created, updated, and last used. Each precomputation has a `value` \- the JQL fragment to replace the custom function clause with.
**[Permissions](#permissions) required:** This API is only accessible to apps and apps can only inspect their own functions.
*/
export async function main(
auth: Jira,
functionKey: string | undefined,
startAt: string | undefined,
maxResults: string | undefined,
orderBy: string | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/jql/function/computation`
);
for (const [k, v] of [
["functionKey", functionKey],
["startAt", startAt],
["maxResults", maxResults],
["orderBy", orderBy],
]) {
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 396 days ago
type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Get precomputations (apps)
* Returns the list of a function's precomputations along with information about when they were created, updated, and last used. Each precomputation has a `value` \- the JQL fragment to replace the custom function clause with.
**[Permissions](#permissions) required:** This API is only accessible to apps and apps can only inspect their own functions.
*/
export async function main(
auth: Jira,
functionKey: string | undefined,
startAt: string | undefined,
maxResults: string | undefined,
orderBy: string | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/jql/function/computation`
);
for (const [k, v] of [
["functionKey", functionKey],
["startAt", startAt],
["maxResults", maxResults],
["orderBy", orderBy],
]) {
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 948 days ago