type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Create workflow
* Creates a workflow.
*/
export async function main(
auth: Jira,
body: {
description?: string;
name: string;
statuses: { id: string; properties?: { [k: string]: string } }[];
transitions: {
description?: string;
from?: string[];
name: string;
properties?: { [k: string]: string };
rules?: {
conditions?: {
conditions?: {}[];
configuration?: { [k: string]: { [k: string]: unknown } };
operator?: "AND" | "OR";
type?: string;
};
postFunctions?: {
configuration?: { [k: string]: { [k: string]: unknown } };
type: string;
}[];
validators?: {
configuration?: { [k: string]: { [k: string]: unknown } };
type: string;
}[];
};
screen?: { id: string };
to: string;
type: "global" | "initial" | "directed";
}[];
}
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/workflow`
);
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 396 days ago
type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Create workflow
* Creates a workflow.
*/
export async function main(
auth: Jira,
body: {
description?: string;
name: string;
statuses: { id: string; properties?: { [k: string]: string } }[];
transitions: {
description?: string;
from?: string[];
name: string;
properties?: { [k: string]: string };
rules?: {
conditions?: {
conditions?: {}[];
configuration?: { [k: string]: { [k: string]: unknown } };
operator?: "AND" | "OR";
type?: string;
};
postFunctions?: {
configuration?: { [k: string]: { [k: string]: unknown } };
type: string;
}[];
validators?: {
configuration?: { [k: string]: { [k: string]: unknown } };
type: string;
}[];
};
screen?: { id: string };
to: string;
type: "global" | "initial" | "directed";
}[];
}
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/workflow`
);
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 948 days ago