#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere
TypeScript dockerhacktoberfestjavapdfpdf-converterpdf-editorpdf-manipulationpdf-mergerpdf-ocrpdf-toolspdf-web-appspdfmergerself-hosted
import {
PORTAL_BASENAME,
PORTAL_REVIEW_PATH,
} from "@editor/routes/portalBasename";
import { DOCS_PATH } from "@editor/routes/docsRoute";
// A static leaf module (its portal import is type-only), so it doesn't pull
// the lazy portal chunk into the main bundle the way @processor/* values would.
import { usersCapabilities } from "@editor/portal/usersCapabilities";
import type { ProcessorSearchEntry } from "@editor-core/data/processorSearchIndex";
import { HAS_PORTAL } from "@editor/routes/hasPortal";
export type { ProcessorSearchEntry };
/**
* The portal's in-app views. Deliberately a static mirror of the portal's nav
* (labels via the same portal.nav.* keys its sidebar uses) rather than an
* import from @processor/* — referencing the portal package here would pull the
* lazy portal chunk into the main bundle.
*/
const VIEWS: ProcessorSearchEntry[] = [
{
id: "home",
labelKey: "portal.nav.home",
labelFallback: "Home",
path: PORTAL_BASENAME,
keywords: ["portal", "processor", "admin"],
},
{
id: "sources",
labelKey: "portal.nav.sources",
labelFallback: "Sources",
path: `${PORTAL_BASENAME}/sources`,
keywords: ["s3", "connections", "webhooks", "folders"],
},
{
id: "policies",
labelKey: "portal.nav.policies",
labelFallback: "Policies",
path: `${PORTAL_BASENAME}/policies`,
keywords: ["enforcement", "redact", "compliance"],
},
{
id: "pipelines",
labelKey: "portal.nav.pipelines",
labelFallback: "Pipelines",
path: `${PORTAL_BASENAME}/pipelines`,
keywords: ["automation", "workflows", "operations"],
},
{
id: "documents",
labelKey: "portal.nav.documents",
labelFallback: "Documents",
path: `${PORTAL_BASENAME}/documents`,
keywords: ["audit", "files"],
},
{
id: "review",
labelKey: "portal.nav.review",
labelFallback: "Review",
path: `${PORTAL_BASENAME}${PORTAL_REVIEW_PATH}`,
keywords: ["failures", "errors", "triage", "retry"],
},
{
id: "integrations",
labelKey: "portal.nav.integrations",
labelFallback: "Integrations",
path: `${PORTAL_BASENAME}/integrations`,
keywords: ["connections", "external", "api", "webhooks"],
},
{
id: "docs",
labelKey: "portal.nav.docs",
labelFallback: "Documentation",
path: DOCS_PATH,
keywords: ["api", "documentation", "reference", "guides"],
},
];
// Empty without the portal: these destinations would 404.
export const PROCESSOR_SEARCH_INDEX: ProcessorSearchEntry[] = HAS_PORTAL
? VIEWS
: [];
/**
* Whether an entity scope's data source will serve the current session at
* all. The users roster is the one divergent case: portal access alone
* doesn't imply the roster endpoint will answer (see
* UsersCapabilities.listingRequiresAdmin) — offering the lane anyway renders
* a permanently-empty chip that fires a doomed request on every search.
*/
export function isPortalEntityScopeAccessible(
scopeId: string,
isAdmin: boolean,
): boolean {
if (scopeId !== "portal-users") return true;
return isAdmin || !usersCapabilities.listingRequiresAdmin;
}