//native
type Confluence = {
email: string
apiToken: string
domain: string
}
/**
* Update look and feel settings
* Updates the look and feel settings for the site or for a single space.
If custom settings exist, they are updated. If no custom settings exist,
then a set of custom settings is created.
Note, if a theme is selected for a space, the space look and feel settings
are provided by the theme and cannot be overridden.
**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
'Admin' permission for the space.
*/
export async function main(
auth: Confluence,
spaceKey: string | undefined,
body: {
headings: { color: string }
links: { color: string }
menus: { hoverOrFocus: { backgroundColor: string }; color: string }
header: {
backgroundColor: string
button: { backgroundColor: string; color: string }
primaryNavigation: {
color: string
highlightColor?: string
hoverOrFocus: { backgroundColor: string; color: string }
}
secondaryNavigation: {
color: string
highlightColor?: string
hoverOrFocus: { backgroundColor: string; color: string }
}
search: { backgroundColor: string; color: string }
}
horizontalHeader?: {
backgroundColor: string
button?: { backgroundColor: string; color: string }
primaryNavigation: {
color?: string
highlightColor: string
hoverOrFocus?: { backgroundColor?: string; color?: string }
}
secondaryNavigation?: {
color: string
highlightColor?: string
hoverOrFocus: { backgroundColor: string; color: string }
}
search?: { backgroundColor: string; color: string }
}
content: {
screen?: {
background: string
backgroundAttachment?: string
backgroundBlendMode?: string
backgroundClip?: string
backgroundColor?: string
backgroundImage?: string
backgroundOrigin?: string
backgroundPosition?: string
backgroundRepeat?: string
backgroundSize?: string
layer?: { width?: string; height?: string }
gutterTop?: string
gutterRight?: string
gutterBottom?: string
gutterLeft?: string
}
container?: {
background: string
backgroundAttachment?: string
backgroundBlendMode?: string
backgroundClip?: string
backgroundColor: string
backgroundImage: string
backgroundOrigin?: string
backgroundPosition?: string
backgroundRepeat?: string
backgroundSize: string
padding: string
borderRadius: string
}
header?: {
background: string
backgroundAttachment?: string
backgroundBlendMode?: string
backgroundClip?: string
backgroundColor: string
backgroundImage: string
backgroundOrigin?: string
backgroundPosition?: string
backgroundRepeat?: string
backgroundSize: string
padding: string
borderRadius: string
}
body?: {
background: string
backgroundAttachment?: string
backgroundBlendMode?: string
backgroundClip?: string
backgroundColor: string
backgroundImage: string
backgroundOrigin?: string
backgroundPosition?: string
backgroundRepeat?: string
backgroundSize: string
padding: string
borderRadius: string
}
}
bordersAndDividers: { color: string }
spaceReference?: {}
}
) {
const url = new URL(`https://${auth.domain}/wiki/rest/api/settings/lookandfeel/custom`)
for (const [k, v] of [['spaceKey', spaceKey]]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Basic ' + btoa(`${auth.email}:${auth.apiToken}`)
},
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 235 days ago