semantic update
This commit is contained in:
@@ -58,6 +58,8 @@ async function createUser(userData) {
|
||||
// [DEF:getRoles:Function]
|
||||
/**
|
||||
* @purpose Fetches all available system roles.
|
||||
* @pre User must be authenticated with Admin privileges.
|
||||
* @post Returns an array of role objects.
|
||||
* @returns {Promise<Array>}
|
||||
* @relation CALLS -> backend.src.api.routes.admin.list_roles
|
||||
*/
|
||||
@@ -77,6 +79,8 @@ async function getRoles() {
|
||||
// [DEF:getADGroupMappings:Function]
|
||||
/**
|
||||
* @purpose Fetches mappings between AD groups and local roles.
|
||||
* @pre User must be authenticated with Admin privileges.
|
||||
* @post Returns an array of AD group mapping objects.
|
||||
* @returns {Promise<Array>}
|
||||
*/
|
||||
async function getADGroupMappings() {
|
||||
@@ -95,6 +99,8 @@ async function getADGroupMappings() {
|
||||
// [DEF:createADGroupMapping:Function]
|
||||
/**
|
||||
* @purpose Creates or updates an AD group to Role mapping.
|
||||
* @pre User must be authenticated with Admin privileges.
|
||||
* @post New or updated mapping created in auth.db.
|
||||
* @param {Object} mappingData - Mapping details (ad_group, role_id).
|
||||
* @returns {Promise<Object>}
|
||||
*/
|
||||
@@ -114,6 +120,8 @@ async function createADGroupMapping(mappingData) {
|
||||
// [DEF:updateUser:Function]
|
||||
/**
|
||||
* @purpose Updates an existing user.
|
||||
* @pre User must be authenticated with Admin privileges.
|
||||
* @post User record updated in auth.db.
|
||||
* @param {string} userId - Target user ID.
|
||||
* @param {Object} userData - Updated user data.
|
||||
* @returns {Promise<Object>}
|
||||
@@ -134,6 +142,8 @@ async function updateUser(userId, userData) {
|
||||
// [DEF:deleteUser:Function]
|
||||
/**
|
||||
* @purpose Deletes a user.
|
||||
* @pre User must be authenticated with Admin privileges.
|
||||
* @post User record removed from auth.db.
|
||||
* @param {string} userId - Target user ID.
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@@ -152,6 +162,8 @@ async function deleteUser(userId) {
|
||||
// [DEF:createRole:Function]
|
||||
/**
|
||||
* @purpose Creates a new role.
|
||||
* @pre User must be authenticated with Admin privileges.
|
||||
* @post New role created in auth.db.
|
||||
* @param {Object} roleData - Role details (name, description, permissions).
|
||||
* @returns {Promise<Object>}
|
||||
*/
|
||||
@@ -224,6 +236,45 @@ async function getPermissions() {
|
||||
}
|
||||
// [/DEF:getPermissions:Function]
|
||||
|
||||
// [DEF:getLoggingConfig:Function]
|
||||
/**
|
||||
* @purpose Fetches current logging configuration.
|
||||
* @returns {Promise<Object>} - Logging config with level, task_log_level, enable_belief_state.
|
||||
* @relation CALLS -> backend.src.api.routes.settings.get_logging_config
|
||||
*/
|
||||
async function getLoggingConfig() {
|
||||
console.log('[getLoggingConfig][Entry]');
|
||||
try {
|
||||
const config = await api.requestApi('/settings/logging', 'GET');
|
||||
console.log('[getLoggingConfig][Coherence:OK]');
|
||||
return config;
|
||||
} catch (e) {
|
||||
console.error('[getLoggingConfig][Coherence:Failed]', e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
// [/DEF:getLoggingConfig:Function]
|
||||
|
||||
// [DEF:updateLoggingConfig:Function]
|
||||
/**
|
||||
* @purpose Updates logging configuration.
|
||||
* @param {Object} configData - Logging config (level, task_log_level, enable_belief_state).
|
||||
* @returns {Promise<Object>}
|
||||
* @relation CALLS -> backend.src.api.routes.settings.update_logging_config
|
||||
*/
|
||||
async function updateLoggingConfig(configData) {
|
||||
console.log('[updateLoggingConfig][Entry]');
|
||||
try {
|
||||
const config = await api.requestApi('/settings/logging', 'PATCH', configData);
|
||||
console.log('[updateLoggingConfig][Coherence:OK]');
|
||||
return config;
|
||||
} catch (e) {
|
||||
console.error('[updateLoggingConfig][Coherence:Failed]', e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
// [/DEF:updateLoggingConfig:Function]
|
||||
|
||||
export const adminService = {
|
||||
getUsers,
|
||||
createUser,
|
||||
@@ -235,7 +286,9 @@ export const adminService = {
|
||||
deleteRole,
|
||||
getPermissions,
|
||||
getADGroupMappings,
|
||||
createADGroupMapping
|
||||
createADGroupMapping,
|
||||
getLoggingConfig,
|
||||
updateLoggingConfig
|
||||
};
|
||||
|
||||
// [/DEF:adminService:Module]
|
||||
@@ -1,5 +1,6 @@
|
||||
// [DEF:GitServiceClient:Module]
|
||||
/**
|
||||
* @TIER: STANDARD
|
||||
* @SEMANTICS: git, service, api, client
|
||||
* @PURPOSE: API client for Git operations, managing the communication between frontend and backend.
|
||||
* @LAYER: Service
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// [DEF:storageService:Module]
|
||||
/**
|
||||
* @TIER: STANDARD
|
||||
* @purpose Frontend API client for file storage management.
|
||||
* @layer Service
|
||||
* @relation DEPENDS_ON -> backend.api.storage
|
||||
@@ -8,6 +9,25 @@
|
||||
|
||||
const API_BASE = '/api/storage';
|
||||
|
||||
// [DEF:getStorageAuthHeaders:Function]
|
||||
/**
|
||||
* @purpose Returns headers with Authorization for storage API calls.
|
||||
* @returns {Object} Headers object with Authorization if token exists.
|
||||
* @NOTE Unlike api.js getAuthHeaders, this doesn't set Content-Type
|
||||
* to allow FormData to set its own multipart boundary.
|
||||
*/
|
||||
function getStorageAuthHeaders() {
|
||||
const headers = {};
|
||||
if (typeof window !== 'undefined') {
|
||||
const token = localStorage.getItem('auth_token');
|
||||
if (token) {
|
||||
headers['Authorization'] = `Bearer ${token}`;
|
||||
}
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
// [/DEF:getStorageAuthHeaders:Function]
|
||||
|
||||
// [DEF:listFiles:Function]
|
||||
/**
|
||||
* @purpose Fetches the list of files for a given category and subpath.
|
||||
@@ -25,7 +45,9 @@ export async function listFiles(category, path) {
|
||||
if (path) {
|
||||
params.append('path', path);
|
||||
}
|
||||
const response = await fetch(`${API_BASE}/files?${params.toString()}`);
|
||||
const response = await fetch(`${API_BASE}/files?${params.toString()}`, {
|
||||
headers: getStorageAuthHeaders()
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch files: ${response.statusText}`);
|
||||
}
|
||||
@@ -53,6 +75,7 @@ export async function uploadFile(file, category, path) {
|
||||
|
||||
const response = await fetch(`${API_BASE}/upload`, {
|
||||
method: 'POST',
|
||||
headers: getStorageAuthHeaders(),
|
||||
body: formData
|
||||
});
|
||||
|
||||
@@ -75,7 +98,8 @@ export async function uploadFile(file, category, path) {
|
||||
*/
|
||||
export async function deleteFile(category, path) {
|
||||
const response = await fetch(`${API_BASE}/files/${category}/${path}`, {
|
||||
method: 'DELETE'
|
||||
method: 'DELETE',
|
||||
headers: getStorageAuthHeaders()
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
@@ -93,6 +117,8 @@ export async function deleteFile(category, path) {
|
||||
* @returns {string}
|
||||
* @PRE category and path must identify an existing file.
|
||||
* @POST Returns a valid API URL for file download.
|
||||
* @NOTE Downloads use browser navigation, so auth is handled via cookies
|
||||
* or the backend must allow unauthenticated downloads for valid paths.
|
||||
*/
|
||||
export function downloadFileUrl(category, path) {
|
||||
return `${API_BASE}/download/${category}/${path}`;
|
||||
|
||||
Reference in New Issue
Block a user