chore: shorten verbose block comments across SaaS branch

This commit is contained in:
Anthony Stirling
2026-06-08 18:38:00 +01:00
parent 8b2baaf0a0
commit 1d5ce8a1d2
12 changed files with 24 additions and 159 deletions
+1 -3
View File
@@ -8,7 +8,5 @@
# Userback feedback widget — leave blank to disable
VITE_USERBACK_TOKEN=
# Development-only auth bypass — allows unauthenticated access on localhost in dev mode
# The URL subpath prefix is read from BASE_PATH at runtime, sourced from the
# top-level RUN_SUBPATH env var which Vite consumes at build time.
# Dev-only auth bypass for localhost. Subpath comes from RUN_SUBPATH (build-time).
VITE_DEV_BYPASS_AUTH=false
+1 -4
View File
@@ -39,10 +39,7 @@ export const absoluteWithBasePath = (path: string): string => {
return `${window.location.origin}${BASE_PATH}${clean}`;
};
/**
* Remove the BASE_PATH prefix from a pathname so comparisons against
* bare app routes ("/login", "/files", …) work under any subpath deploy.
*/
/** Strip BASE_PATH prefix so route comparisons work under any subpath deploy. */
export const stripBasePath = (pathname: string): string => {
if (!BASE_PATH) return pathname;
if (pathname === BASE_PATH) return "/";
@@ -13,11 +13,7 @@ export function setupApiInterceptors(client: AxiosInstance): void {
);
}
/**
* Auth headers for raw fetch() calls (SSE streams, etc.).
* Proprietary overrides with stored JWT + XSRF; SaaS overrides with the live
* Supabase access token. Async because SaaS has to consult the auth client.
*/
/** Auth headers for raw fetch() calls — empty in core; proprietary/SaaS override. */
export async function getAuthHeaders(): Promise<Record<string, string>> {
return {};
}
@@ -1,53 +1,21 @@
import { NavKey } from "@app/components/shared/config/types";
import { stripBasePath, withBasePath } from "@app/constants/app";
/**
* Navigate to a specific settings section
*
* @param section - The settings section key to navigate to
*
* @example
* // Navigate to People section
* navigateToSettings('people');
*
* // Navigate to Admin Premium section
* navigateToSettings('adminPremium');
*/
/** Push the URL for a settings section and notify listeners. */
export function navigateToSettings(section: NavKey) {
const newPath = withBasePath(`/settings/${section}`);
window.history.pushState({}, "", newPath);
// Trigger a popstate event to notify components
window.dispatchEvent(new PopStateEvent("popstate"));
}
/**
* Get the URL path for a settings section
* Useful for creating links
*
* @param section - The settings section key
* @returns The URL path for the settings section
*
* @example
* <a href={getSettingsUrl('people')}>Go to People Settings</a>
* // Returns: "/settings/people" (or "/bpp/settings/people" under subpath)
*/
/** URL for a settings section (subpath-aware). */
export function getSettingsUrl(section: NavKey): string {
return withBasePath(`/settings/${section}`);
}
/**
* Check if currently viewing a settings section
*
* @param section - Optional section key to check for specific section
* @returns True if in settings (and matching specific section if provided)
*/
/** Whether the current URL is in /settings (optionally a specific section). */
export function isInSettings(section?: NavKey): boolean {
const pathname = stripBasePath(window.location.pathname);
if (!section) {
return pathname.startsWith("/settings");
}
if (!section) return pathname.startsWith("/settings");
return pathname === `/settings/${section}`;
}
@@ -390,12 +390,7 @@ self.addEventListener(
let compDoc: PDFDocumentProxy | null = null;
try {
// `CanvasFactory`/`FilterFactory` are supported at runtime but not declared on legacy types.
// pdfjs-dist 5.x renamed the option to `CanvasFactory` (capital C); without a FilterFactory
// the default DOMFilterFactory crashes in a worker calling document.createElementNS.
// Resolve CMap/standard-font URLs against the worker's own origin. Vite copies these
// directories from pdfjs-dist at build time via viteStaticCopy (see vite.config.ts).
// import.meta.env.BASE_URL ends with a slash and includes any subpath prefix.
// Resolve pdfjs CMap/standard-font URLs against the worker's origin + subpath.
const assetsBase = new URL(
`${import.meta.env.BASE_URL}pdfjs/`,
self.location.origin,
@@ -100,10 +100,7 @@ async function refreshAuthToken(client: AxiosInstance): Promise<string> {
}
}
/**
* Auth headers for raw fetch() calls (SSE streams, etc.).
* Async to match the SaaS override, which has to await the Supabase session.
*/
/** Auth headers for raw fetch() calls (SSE streams). Async to match SaaS override. */
export async function getAuthHeaders(): Promise<Record<string, string>> {
const headers: Record<string, string> = {};
const jwt = getJwtTokenFromStorage();
@@ -1,20 +1,7 @@
import type { AxiosInstance } from "axios";
import { supabase } from "@app/auth/supabase";
/**
* SaaS auth headers for raw fetch() calls (e.g. AI chat streaming).
*
* Pulls the live Supabase access token. Required because the SaaS apiClient's
* axios interceptor attaches this header to every axios call, but raw fetch()
* calls bypass that path and end up with no Authorization header → backend
* returns 401. The chat streaming endpoint uses fetch() (not axios) because
* axios doesn't stream SSE responses well, so this override exists to give
* it the same bearer token the axios calls already get.
*
* supabase.auth.getSession() reads from in-memory cache when possible; only
* issues a network request if the session needs refreshing. Adds an Accept
* header so the backend negotiates JSON correctly.
*/
/** SaaS auth headers for raw fetch() calls — Supabase access token from current session. */
export async function getAuthHeaders(): Promise<Record<string, string>> {
const headers: Record<string, string> = {};
try {
@@ -30,12 +17,5 @@ export async function getAuthHeaders(): Promise<Record<string, string>> {
return headers;
}
/**
* SaaS apiClient wires up its own interceptors inline (see saas/services/apiClient.ts).
* This re-export exists so the cascade through @app/services/apiClientSetup
* remains consistent for callers that import setupApiInterceptors — currently
* none in SaaS mode, but keeps the shape uniform.
*/
export function setupApiInterceptors(_client: AxiosInstance): void {
// No-op: SaaS apiClient handles its own interceptors with the Supabase session.
}
/** No-op: SaaS apiClient wires its own interceptors (see saas/services/apiClient.ts). */
export function setupApiInterceptors(_client: AxiosInstance): void {}
+1 -2
View File
@@ -1,8 +1,7 @@
import { URL_TO_TOOL_MAP } from "@app/utils/urlMapping";
import { BASE_PATH } from "@app/constants/app";
// BASE_PATH is "/bpp" or "" (no trailing slash). Strip the leading slash
// to match the legacy SUBPATH shape used below ("bpp" or "").
// "bpp" or "" — BASE_PATH without leading slash.
const SUBPATH = BASE_PATH.replace(/^\//, "");
/**