import { ROUTE_ANY_MODULES, ROUTE_MODULES } from "@/app/lib/routeModules"; // Client-side mirror of the server-side protected-names denylist // (solvway-mobile-api AdminModuleService.PROTECTED_NAMES, spec // "Protected Nodes Are Guarded Against Structural Change"). These nodes have // hardcoded code dependencies (server literals, nav structure, route gates) // whose breakage the DB cannot detect, so delete AND structural edits // (reparent/type/url) are refused server-side; desc/icon edits stay allowed. // The /modules page derives the same set so protected nodes render their // structural fields disabled. // // Derived from ROUTE_MODULES rather than hand-listed: a new route-gated module // is protected automatically (the server list must be updated in the same // change — the AdminModuleService.PROTECTED_NAMES javadoc says so). export const FIXED_PROTECTED_MODULE_NAMES: readonly string[] = [ "BO_ROOT", "BO_ADMINISTRATION", "BO_SYSTEM", "BO_WALLET", "BO_ROLES", // Catalogue nav group (add-admin-catalog-setup) — not route-gated (type M, // no url), so it is not auto-derived from ROUTE_MODULES and must be listed // explicitly, same as the other group headers above. "BO_CATALOG", ]; export const PROTECTED_MODULE_NAMES: ReadonlySet = new Set([ ...FIXED_PROTECTED_MODULE_NAMES, ...Object.values(ROUTE_MODULES), ...Object.values(ROUTE_ANY_MODULES).flat(), ]); /** {@code true} when the node's {@code name} has hardcoded code dependencies. */ export function isProtectedModuleName(name: string | undefined): boolean { return name != null && PROTECTED_MODULE_NAMES.has(name); }