📚 The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
chore: Improve code style, add comments
Smaug67392776b991432c
diff --git a/frontend/app/composables/ModalBus.ts b/frontend/app/composables/ModalBus.tsindex 89191cf8..d1eeaf33 100644--- a/frontend/app/composables/ModalBus.ts+++ b/frontend/app/composables/ModalBus.ts@@ -1,11 +1,17 @@-// Modal bus for managing modal state+/**+ * Modal management composable+ * Handles stacked modal state and body scroll locking+ */const modals = ref<Modal[]>([]);+/** Open a new modal (adds to stack) */function add(modal: Modal) {document.body.classList.add('modal-open');modals.value.push(modal);}++/** Close a modal and trigger its onClose callback */function close(modal: Modal) {const index = modals.value.indexOf(modal);if (index !== -1) {@@ -18,11 +24,7 @@ function close(modal: Modal) {}export function useModal() {- return {- add,- close,- modals,- };+ return { add, close, modals };}interface ModalOptions {@@ -33,13 +35,5 @@ interface ModalOptions {}export class Modal {- constructor(- public component: object,- public options: ModalOptions = {- onClose: () => {},- size: 'medium',- noPadding: false,- props: {},- },- ) {}+ constructor(public component: object, public options: ModalOptions = { size: 'medium' }) {}}diff --git a/frontend/app/composables/Sidebar.ts b/frontend/app/composables/Sidebar.tsindex 37093436..120f6109 100644--- a/frontend/app/composables/Sidebar.ts+++ b/frontend/app/composables/Sidebar.ts@@ -1,15 +1,22 @@+/**+ * Sidebar state management+ * Controls sidebar visibility, width, and content filtering+ */+const isOpened = ref(false);const hasSidebar = ref(false);-const paneWidth = ref(isMobile() ? 350 : 390); // initial width of pane 1+const paneWidth = ref(isMobile() ? 350 : 390);const isResizing = ref(false);const workspaceId = ref<string | undefined>(undefined);const active_id = ref<string | null>(null);const toggleSidebar = () => (isOpened.value = !isOpened.value);+/** Filter tree items based on selected workspace and preferences */const filtered = computed(() => {const { tree } = useSidebarTree();const found = tree.value.find(i => i.id === workspaceId.value);+if (found) return found.childrens || [];if (workspaceId.value === 'shared') return tree.value.filter(i => i.data && i.data.shared);if (!usePreferences().get('displayUncategorizedRessources').value) return tree.value.filter(i => i.data && i.data.role != 4); // hide uncategorizeddiff --git a/frontend/app/composables/TreeStructure.ts b/frontend/app/composables/TreeStructure.tsindex 6e19e726..4b73a177 100644--- a/frontend/app/composables/TreeStructure.ts+++ b/frontend/app/composables/TreeStructure.ts@@ -1,5 +1,10 @@+/**+ * Tree Structure utilities+ * Provides hierarchical data management for nodes (categories, documents, etc.)+ */import type { Node } from '~/stores';+/** Base node interface for tree structures */export interface ANode<id = string | number> {id: id;label: string;@@ -7,6 +12,7 @@ export interface ANode<id = string | number> {childrens?: ANode[];}+/** Extended node with routing and display properties */export interface Item<T = Node> extends ANode {id: string;route: string;@@ -17,6 +23,10 @@ export interface Item<T = Node> extends ANode {icon?: string;}+/**+ * Manages a flat list of items and provides tree operations+ * Uses Maps for O(1) lookups by ID and parent ID+ */export class TreeStructure {public readonly items: Item[];diff --git a/frontend/app/composables/collapseStates.ts b/frontend/app/composables/collapseStates.tsindex 791ec5db..aabad8f6 100644--- a/frontend/app/composables/collapseStates.ts+++ b/frontend/app/composables/collapseStates.ts@@ -1,8 +1,10 @@-import { reactive } from 'vue';+/**+ * Collapse state management+ * Persists sidebar item expand/collapse states to localStorage+ */const STORAGE_KEY = 'collapse-states';-// Initial loadfunction loadCollapseStates(): Record<string, boolean> {try {const raw = localStorage.getItem(STORAGE_KEY);@@ -12,33 +14,38 @@ function loadCollapseStates(): Record<string, boolean> {}}-// Global reactive state+// Global reactive state (shared across components)const states = reactive<Record<string, boolean>>(loadCollapseStates());function saveStates() {localStorage.setItem(STORAGE_KEY, JSON.stringify(states));}+/** Get collapse state for an item (defaults to expanded) */export function getCollapseState(id: string): boolean {- if (!(id in states)) states[id] = true; // default: expanded+ if (!(id in states)) states[id] = true;return states[id] ?? true;}+/** Set collapse state for an item */export function setCollapseState(id: string, value: boolean) {states[id] = value;saveStates();}+/** Toggle collapse state for an item */export function toggleCollapseState(id: string) {states[id] = !getCollapseState(id);saveStates();}+/** Collapse all items */export function collapseAllStates() {Object.keys(states).forEach(key => (states[key] = false));saveStates();}+/** Access the raw reactive states object */export function useCollapseStates() {return states;}diff --git a/frontend/app/composables/colors.ts b/frontend/app/composables/colors.tsnew file mode 100644index 00000000..3516cbdf--- /dev/null+++ b/frontend/app/composables/colors.ts@@ -0,0 +1,22 @@+/** Get theme color name by index (-2 = primary, -1 = none, 0+ = color index) */+export function getAppColor(index: number = 0, defaultPrimary?: boolean): string {+ if ((defaultPrimary && index < 0) || index == -2) return 'primary';+ if (index == -1) return '';+ return appColors[index % appColors.length] || 'primary';+}++/** Apply a theme color to CSS custom properties */+export function setAppColor(color: string | number) {+ if (typeof color === 'number') {+ color = getAppColor(color);+ }+ if (color === 'primary') color = 'default';+ document.documentElement.style.setProperty('--primary', `var(--${color})`);+ document.documentElement.style.setProperty('--primary-dark', `var(--${color}-dark)`);+ document.documentElement.style.setProperty('--primary-bg', `var(--${color}-bg)`);+ document.documentElement.style.setProperty('--primary-border', `var(--${color}-border)`);++ const colorMode = useColorMode();+ usePreferences().set('darkMode', colorMode.value === 'dark');+ document.body.style.colorScheme = colorMode.preference;+}diff --git a/frontend/app/composables/constants.ts b/frontend/app/composables/constants.tsindex 28f5890d..5f71ad08 100644--- a/frontend/app/composables/constants.ts+++ b/frontend/app/composables/constants.ts@@ -1,3 +1,12 @@+/**+ * Application constants+ * Centralized configuration options for documents, nodes, and UI settings+ */++// Theme color palette+export const appColors = ['blue', 'red', 'green', 'yellow', 'purple', 'pink', 'teal', 'grey'];++// Document display themesexport const DOCUMENT_THEMES = [{ label: 'Alexandrie', id: 'alexandrie' },{ label: 'Latex style', id: 'latex' },@@ -5,21 +14,26 @@ export const DOCUMENT_THEMES = [{ label: 'Modern', id: 'modern' },];+// Document visibility options (1 = Private, 3 = Published)export const DOCUMENT_ACCESSIBILITIES: ANode[] = [{ id: 1, label: 'Private' },{ id: 3, label: 'Published' },];++// Sharing access levels (0 = View only, 2 = Can edit)export const DOCUMENT_GENERAL_ACCESS: ANode[] = [{ id: 0, label: 'Viewer' },{ id: 2, label: 'Editor' },];+// Document width presetsexport const DOCUMENT_SIZES = [{ label: 'Small', id: 0 },{ label: 'Medium', id: 1 },{ label: 'Large', id: 2 },];+// Editor font optionsexport const EDITOR_FONTS = [{ label: 'JetBrains Mono', id: 'JetBrains Mono' },{ label: 'monospace', id: 'monospace' },@@ -29,11 +43,13 @@ export const EDITOR_FONTS = [{ label: 'Times New Roman', id: 'Times New Roman' },];+// Node role options (1 = Workspace, 2 = Category)export const CATEGORY_ROLES = [{ id: 1, label: 'Workspace' },{ id: 2, label: 'Category' },];+// Permission levels for sharingexport const NODE_PERMISSIONS = [{ label: 'Viewer', id: 1 },{ label: 'Editor', id: 2 },diff --git a/frontend/app/composables/date.ts b/frontend/app/composables/date.tsindex 1f56aef4..62b563c9 100644--- a/frontend/app/composables/date.ts+++ b/frontend/app/composables/date.ts@@ -1,5 +1,21 @@const locale = 'en-US';+/** Format a timestamp to a readable date string (e.g., "15 Dec 2024") */+export function formatDate(timestamp: number | undefined): string {+ const date = new Date(timestamp || 0);+ return `${date.getDate()} ${date.toLocaleString('default', { month: 'short' })} ${date.getFullYear()}`;+}++/** Format a timestamp to a numeric date string (e.g., "12/15/2024") */+export function numericDate(timestamp: number): string {+ return new Date(timestamp).toLocaleDateString(locale, {+ year: 'numeric',+ month: '2-digit',+ day: '2-digit',+ });+}++/** Format a timestamp to a relative time string (e.g., "2h ago") */export const relativeTime = (timestamp: number) => {const diff = Date.now() - timestamp;const minutes = Math.floor(diff / 60000);diff --git a/frontend/app/composables/useNodesTree.ts b/frontend/app/composables/useNodesTree.tsindex 99e03d7a..d9395ba4 100644--- a/frontend/app/composables/useNodesTree.ts+++ b/frontend/app/composables/useNodesTree.ts@@ -1,16 +1,9 @@-import { resolveIcon } from '~/helpers/node';+import { resolveIcon, resolveNodeLink } from '~/helpers/node';import type { Node } from '~/stores';let nodes: ComputedRef<Item<Node>[]> | Ref<Item<Node>[]> = ref([]);const structure = computed(() => new TreeStructure(nodes.value));-const resolveLink = (item: Node) => {- if (item.role === 1 || item.role === 2) return `/dashboard/categories/${item.id}`;- if (item.role === 3) return `/dashboard/docs/${item.id}`;- if (item.role === 4) return `/dashboard/cdn/${item.id}/preview`;- return '/dashboard';-};-/* Do operations in the tree and return the final tree */const tree = computed(() => {return structure.value.generateTree();@@ -35,7 +28,7 @@ function useSidebarTree() {id: node.id,parent_id: node.role !== 1 ? node.parent_id || '' : '',label: node.name,- route: resolveLink(node),+ route: resolveNodeLink(node),icon: ref(resolveIcon(node)).value,data: node,show: ref(getCollapseState(node.id)),diff --git a/frontend/app/composables/useNotifications.ts b/frontend/app/composables/useNotifications.tsindex 3453fb00..828148d2 100644--- a/frontend/app/composables/useNotifications.ts+++ b/frontend/app/composables/useNotifications.ts@@ -1,3 +1,8 @@+/**+ * Notification system composable+ * Manages toast-style notifications with auto-dismiss+ */+export interface Notification {id: number;title: string;@@ -8,21 +13,19 @@ export interface Notification {const notifications = ref<Notification[]>([]);+/** Add a notification (auto-dismisses after timeout, default 3s) */function add(notification: Omit<Notification, 'id'>) {const id = Math.floor(Math.random() * 100000);- notifications.value.push({ id: id, ...notification });+ notifications.value.push({ id, ...notification });setTimeout(() => remove(id), notification.timeout || 3000);}++/** Remove a notification by ID */function remove(id: number) {- const index = notifications.value.findIndex(n => n.id == id);- if (index == -1) return;- notifications.value.splice(index, 1);+ const index = notifications.value.findIndex(n => n.id === id);+ if (index !== -1) notifications.value.splice(index, 1);}export function useNotifications() {- return {- add,- remove,- notifications,- };+ return { add, remove, notifications };}diff --git a/frontend/app/composables/usePasswordField.ts b/frontend/app/composables/usePasswordField.tsnew file mode 100644index 00000000..ead323ed--- /dev/null+++ b/frontend/app/composables/usePasswordField.ts@@ -0,0 +1,11 @@+/**+ * Password field composable+ * Reusable logic for password visibility toggle in forms+ */++export function usePasswordField() {+ const showPassword = ref(false);+ const togglePassword = () => (showPassword.value = !showPassword.value);++ return { showPassword, togglePassword };+}diff --git a/frontend/app/composables/user.ts b/frontend/app/composables/user.tsindex 3b5d8cad..0c7d93e7 100644--- a/frontend/app/composables/user.ts+++ b/frontend/app/composables/user.ts@@ -1,3 +1,9 @@+/**+ * User authentication actions+ * Provides logout functions with notification feedback+ */++/** Logout current session */function logoutUser() {const store = useUserStore();store@@ -10,6 +16,7 @@ function logoutUser() {.catch(e => useNotifications().add({ type: 'error', title: 'Error', message: e }));}+/** Logout all sessions (including other devices) */function logoutUserAll() {const store = useUserStore();storediff --git a/frontend/app/composables/utils.ts b/frontend/app/composables/utils.tsindex f6186109..910b801a 100644--- a/frontend/app/composables/utils.ts+++ b/frontend/app/composables/utils.ts@@ -1,57 +1,27 @@+/**+ * Core application utilities+ * Contains API configuration, screen size helpers, colors, and debounce functions+ */import type { PublicUser, User } from '~/stores/db_strustures';+/** Provides API and CDN base URLs from runtime config */export function useApi() {const config = useRuntimeConfig();const CDN = config.public.baseCdn;const API = `${config.public.baseApi}/api`;return { CDN, API };}-// Little screen size++// Screen size breakpointsexport const isMobile = () => (import.meta.client ? window.innerWidth <= 768 : false);-// Intermediate screen sizeexport const isTablet = () => (import.meta.client ? window.innerWidth <= 1280 : false);+/** Get user avatar URL or fallback to default */export function useAvatar(user?: User | PublicUser | null): string {const { CDN } = useApi();return user?.avatar ? CDN + '/' + user.id + '/avatar' : '/default_avatar.avif';}-export const appColors = ['blue', 'red', 'green', 'yellow', 'purple', 'pink', 'teal', 'grey'];-export function getAppColor(index: number = 0, defaultPrimary?: boolean): string {- if ((defaultPrimary && index < 0) || index == -2) return 'primary';- if (index == -1) return '';- return appColors[index % appColors.length] || 'primary';-}--export function formatDate(timestamp: number | undefined): string {- const date = new Date(timestamp || 0);- return `${date.getDate()} ${date.toLocaleString('default', { month: 'short' })} ${date.getFullYear()}`;-}--export function numericDate(timestamp: number): string {- const date = new Date(timestamp);- return date.toLocaleDateString('en-US', {- year: 'numeric',- month: '2-digit',- day: '2-digit',- });-}--export function setAppColor(color: string | number) {- if (typeof color === 'number') {- color = getAppColor(color);- }- if (color === 'primary') color = 'default';- document.documentElement.style.setProperty('--primary', `var(--${color})`);- document.documentElement.style.setProperty('--primary-dark', `var(--${color}-dark)`);- document.documentElement.style.setProperty('--primary-bg', `var(--${color}-bg)`);- document.documentElement.style.setProperty('--primary-border', `var(--${color}-border)`);-- const colorMode = useColorMode();- usePreferences().set('darkMode', colorMode.value === 'dark');- document.body.style.colorScheme = colorMode.preference;-}-export function debounce<T extends (...args: unknown[]) => void>(fn: T, delay = 500) {let timeout: ReturnType<typeof setTimeout> | null = null;let called = false;diff --git a/frontend/app/helpers/node.ts b/frontend/app/helpers/node.tsindex 6fbb01a3..db500467 100644--- a/frontend/app/helpers/node.ts+++ b/frontend/app/helpers/node.ts@@ -1,6 +1,11 @@+/**+ * Node utilities - centralized helpers for working with nodes (documents, categories, workspaces, resources)+ * Roles: 1 = Workspace, 2 = Category, 3 = Document, 4 = Resource+ */import type { Node } from '~/stores';-export const resolveIcon = (item: Node) => {+/** Resolve the appropriate icon for a node based on its role and properties */+export const resolveIcon = (item: Node): string => {if (item.icon) return item.icon;if (item.role === 1) return 'workspace';if (item.role === 2) return item.shared ? 'shared_folder' : 'folder';@@ -8,3 +13,17 @@ export const resolveIcon = (item: Node) => {if (item.role === 4) return item.metadata?.filetype == 'application/pdf' ? 'pdf' : 'sidebar/image';return 'sidebar/file';};++/** Get the dashboard route for a node */+export const resolveNodeLink = (node: Node): string => {+ if (node.role === 1 || node.role === 2) return `/dashboard/categories/${node.id}`;+ if (node.role === 3) return `/dashboard/docs/${node.id}`;+ if (node.role === 4) return `/dashboard/cdn/${node.id}/preview`;+ return '/dashboard';+};++/** Get human-readable type name for a node */+export const resolveNodeType = (node: Node): string => {+ const types: Record<number, string> = { 1: 'Workspace', 2: 'Category', 3: 'Document', 4: 'Resource' };+ return types[node.role] || '';+};diff --git a/frontend/app/helpers/ressources.ts b/frontend/app/helpers/ressources.tsindex 39aa951e..dd9aed71 100644--- a/frontend/app/helpers/ressources.ts+++ b/frontend/app/helpers/ressources.ts@@ -1,5 +1,10 @@+/**+ * Resource/File utilities+ * Helpers for working with uploaded files and CDN resources+ */import type { Node } from '~/stores';+/** Convert bytes to human-readable size (e.g., "1.5 MB") */const readableFileSize = (bytes: number): string => {if (bytes === 0) return '0 B';const k = 1024;@@ -8,13 +13,15 @@ const readableFileSize = (bytes: number): string => {return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i];};-const isImageFile = (filetype: string): boolean => {- return filetype.startsWith('image/');-};+/** Check if a filetype MIME string represents an image */+const isImageFile = (filetype: string): boolean => filetype.startsWith('image/');+/** Get the CDN preview URL for a resource node */const resolvePreviewUrl = (node: Node): string => {const { CDN } = useApi();- if (isImageFile((node.metadata?.filetype as string) || '')) return `${CDN}/${node.user_id}/${node.metadata?.transformed_path}`;+ if (isImageFile((node.metadata?.filetype as string) || '')) {+ return `${CDN}/${node.user_id}/${node.metadata?.transformed_path}`;+ }return '/file_placeholder.png';};diff --git a/frontend/app/helpers/utils.ts b/frontend/app/helpers/utils.tsindex 9ce1045f..25b7945a 100644--- a/frontend/app/helpers/utils.ts+++ b/frontend/app/helpers/utils.ts@@ -1,18 +1,23 @@+/**+ * String & parsing utilities+ * Contains hash-based color generation and user agent parsing+ */+const colors = ['var(--blue)', 'var(--teal)', 'var(--yellow)', 'var(--red)', 'var(--red)'];+/** Generate a consistent color from a string (useful for avatars, labels) */export function useColorHash(str: string, list = colors): string {- // Calculer un hash unique pour la chaînelet hash = 0;for (let i = 0; i < str.length; i++) {hash = str.charCodeAt(i) + ((hash << 5) - hash);}-- const index = Math.abs(hash % list.length);- return list[index] as string;+ return list[Math.abs(hash % list.length)] as string;}+/** Parse a user agent string to extract OS and browser info */export function parseUserAgent(uaString?: string) {if (!uaString) return { os: 'Unknown OS', browser: 'Unknown Browser' };+const osList = [{ name: 'Windows 10', regex: /Windows NT 10.0/ },{ name: 'Windows 8.1', regex: /Windows NT 6.3/ },diff --git a/frontend/app/pages/(public)/login/index.vue b/frontend/app/pages/(public)/login/index.vueindex 7922b906..48e89ca2 100644--- a/frontend/app/pages/(public)/login/index.vue+++ b/frontend/app/pages/(public)/login/index.vue@@ -42,26 +42,16 @@<script setup lang="ts">import AppHeader from '../_components/AppHeader.vue';import AppFooter from '../_components/AppFooter.vue';+const username = ref('');-const errors = ref({- username: '',- password: '',- general: '',-});-const showPassword = ref(false);const password = ref('');+const errors = ref({ username: '', password: '', general: '' });+const { showPassword, togglePassword } = usePasswordField();const userStore = useUserStore();-function togglePassword() {- showPassword.value = !showPassword.value;-}-function login() {- if (!username.value) errors.value.username = 'Username is required';- else errors.value.username = '';-- if (!password.value) errors.value.password = 'Password is required';- else errors.value.password = '';+ errors.value.username = !username.value ? 'Username is required' : '';+ errors.value.password = !password.value ? 'Password is required' : '';if (username.value && password.value) {connect(username.value, password.value);@@ -70,7 +60,7 @@ function login() {async function connect(username: string, password: string) {const result = await userStore.login(username, password);- if (result == true) useRouter().push('/dashboard');+ if (result === true) useRouter().push('/dashboard');else errors.value.general = String(result);}</script>diff --git a/frontend/app/pages/(public)/signup.vue b/frontend/app/pages/(public)/signup.vueindex e2e2a0f6..a272e710 100644--- a/frontend/app/pages/(public)/signup.vue+++ b/frontend/app/pages/(public)/signup.vue@@ -67,63 +67,31 @@ import AppHeader from './_components/AppHeader.vue';import AppFooter from './_components/AppFooter.vue';const router = useRouter();+const userStore = useUserStore();++// Form fieldsconst username = ref('');const email = ref('');const password = ref('');const confirmPassword = ref('');-const showPassword = ref(false);-const showConfirmPassword = ref(false);-const errors = ref({- username: '',- email: '',- password: '',- confirmPassword: '',- general: '',-});-const userStore = useUserStore();--function togglePassword() {- showPassword.value = !showPassword.value;-}+const errors = ref({ username: '', email: '', password: '', confirmPassword: '', general: '' });-function toggleConfirmPassword() {- showConfirmPassword.value = !showConfirmPassword.value;-}+// Reusable password visibility toggles+const { showPassword, togglePassword } = usePasswordField();+const { showPassword: showConfirmPassword, togglePassword: toggleConfirmPassword } = usePasswordField();function register() {- let valid = true;-- if (!username.value) {- errors.value.username = 'Username is required';- valid = false;- } else {- errors.value.username = '';- }-- if (!email.value) {- errors.value.email = 'Email is required';- valid = false;- } else {- errors.value.email = '';- }-- if (!password.value) {- errors.value.password = 'Password is required';- valid = false;- } else {- errors.value.password = '';- }-- if (!confirmPassword.value) {- errors.value.confirmPassword = 'Password confirmation is required';- valid = false;- } else if (password.value !== confirmPassword.value) {- errors.value.confirmPassword = 'Passwords do not match';- valid = false;- } else {- errors.value.confirmPassword = '';- }-+ // Validate all fields+ errors.value.username = !username.value ? 'Username is required' : '';+ errors.value.email = !email.value ? 'Email is required' : '';+ errors.value.password = !password.value ? 'Password is required' : '';+ errors.value.confirmPassword = !confirmPassword.value+ ? 'Password confirmation is required'+ : password.value !== confirmPassword.value+ ? 'Passwords do not match'+ : '';++ const valid = !Object.values(errors.value).some(e => e);if (valid) createAccount(username.value, email.value, password.value);}diff --git a/frontend/app/pages/dashboard/home.vue b/frontend/app/pages/dashboard/home.vueindex f96d8f22..634f9026 100644--- a/frontend/app/pages/dashboard/home.vue+++ b/frontend/app/pages/dashboard/home.vue@@ -140,7 +140,7 @@</template><script setup lang="ts">-import { resolveIcon } from '~/helpers/node';+import { resolveIcon, resolveNodeLink, resolveNodeType } from '~/helpers/node';import type { Node } from '~/stores';import CreateCategoryModal from '~/pages/dashboard/categories/_modals/CreateCategoryModal.vue';@@ -216,21 +216,8 @@ const searchResults = computed(() => {// Helpersconst getCategory = (id?: string) => nodesStore.getById(id || '');--const getNodeLink = (node: Node) => {- if (node.role === 1 || node.role === 2) return `/dashboard/categories/${node.id}`;- if (node.role === 3) return `/dashboard/docs/${node.id}`;- if (node.role === 4) return `/dashboard/cdn/${node.id}/preview`;- return '/dashboard';-};--const getNodeType = (node: Node) => {- if (node.role === 1) return 'Workspace';- if (node.role === 2) return 'Category';- if (node.role === 3) return 'Document';- if (node.role === 4) return 'Resource';- return '';-};+const getNodeLink = resolveNodeLink; // Use centralized helper+const getNodeType = resolveNodeType; // Use centralized helperconst getNodePath = (node: Node) => {const parts: string[] = [];diff --git a/frontend/app/stores/_utils.ts b/frontend/app/stores/_utils.tsindex e65dd6d0..e4a5a7b4 100644--- a/frontend/app/stores/_utils.ts+++ b/frontend/app/stores/_utils.ts@@ -1,3 +1,8 @@+/**+ * API utilities for making authenticated requests+ * Handles token refresh and retry logic automatically+ */+export interface APIResult<Data> {status: 'success' | 'error';message: string;@@ -5,8 +10,10 @@ export interface APIResult<Data> {}export interface FetchOptions {- id: string; // id of the ressource+ id: string;}++/** Low-level fetch wrapper with credentials and proper headers */function customFetch(route: string, method: string, body: object) {const { API } = useApi();if (route.endsWith('/')) route = route.slice(0, -1);