/home/techb158/trello.abdallabala.com/public
Edit: /home/techb158/trello.abdallabala.com/public/client-utils.js (1591B)
export const DEFAULT_API_BASE = window.COSMIC_API_BASE || window.location.origin;
export const DEFAULT_APP_KEY = window.COSMIC_TRELLO_API_KEY || 'replace_with_power_up_api_key';
export const DEFAULT_APP_NAME = window.COSMIC_APP_NAME || 'COSMIC AI-Risk Management';
export function powerUpOptions() {
return {
appKey: DEFAULT_APP_KEY,
appName: DEFAULT_APP_NAME
};
}
export function getApiBase(t) {
return t.get('board', 'shared', 'cosmicSettings')
.then((settings) => settings?.apiBaseUrl || DEFAULT_API_BASE)
.catch(() => DEFAULT_API_BASE);
}
export async function apiFetch(t, path, options = {}) {
const base = await getApiBase(t);
const response = await fetch(`${base}${path}`, {
headers: { 'Content-Type': 'application/json', ...(options.headers || {}) },
...options
});
if (!response.ok) {
const message = await response.text();
throw new Error(message || `Request failed: ${response.status}`);
}
return response.json();
}
export function statusClass(status) {
return ['low', 'medium', 'high', 'critical'].includes(status) ? status : '';
}
export function escapeHtml(value) {
return String(value ?? '')
.replaceAll('&', '&')
.replaceAll('<', '<')
.replaceAll('>', '>')
.replaceAll('"', '"')
.replaceAll("'", ''');
}
export async function canWriteCard(t) {
try {
return await t.memberCanWriteToModel('card');
} catch {
return false;
}
}
export async function canWriteBoard(t) {
try {
return await t.memberCanWriteToModel('board');
} catch {
return false;
}
}