Pages and modules
Pages are controller classes registered into a navigation tree of categories, with their own routes, layouts, access rules and extensions.
A page is a controller class. PageController(id, options, layout?) builds a base class bound to a URL, @RegisterPage() records it, and the components declared as static fields on the class become the page's serialized layout. Categories group pages into the sidebar tree. Modules, which own a branch of that tree, and dynamic menu entries are described in Modules and dynamic menus.
To build a first screen, follow Pages & components. That guide also shows page extension placement in the running playground. Everything on this page lives in @antelopejs/interface-dms/page.
Registration happens at import time. The @RegisterPage() decorator runs when the file loads, so the order in which you import page files sets the order in which pages, categories and their permissions register.
Declare a page
PageController(id, options, layout?) returns a class that extends Controller(pageRoutePath(fullSlug)), so its routes live under PAGE_ROUTE_PREFIX (/dms/pages). Extend it, decorate it with @RegisterPage(), and declare components as static fields.
import {
Category,
PageController,
RegisterPage,
pagesCategory,
} from "@antelopejs/interface-dms/page";
import { TableView } from "@antelopejs/interface-dms/base";
import { invoiceDataAPI } from "../data-api/invoices";
export const billing = Category("billing", {
displayName: "Billing",
icon: "i-ph-receipt",
category: pagesCategory,
});
@RegisterPage()
export class InvoicesPage extends PageController("invoices", {
displayName: "Invoices",
icon: "i-ph-file-text",
category: billing,
order: 10,
}) {
static table = TableView(invoiceDataAPI, { caption: "Invoices" });
}
PageController throws when its options declare neither category nor module. The returned class extends Controller, so route decorators from @antelopejs/interface-api work on it directly, and a route declared on the page class is served under the page's slug. Identifiers a page carries gives the exact path.
The third argument is the page layout, a ComponentInfo from a layout builder such as DefaultLayout() from @antelopejs/interface-dms/base. Without it, the page uses its own layout option, then the layout of the nearest category or parent page that declares one, then DefaultLayout().
@RegisterPage() reads the class's own static properties and records every Component under its property name. It skips a property whose name starts with _, so a class can keep a helper value without turning it into a layout entry.
MenuOptions
| Option | Type | Description |
|---|---|---|
displayName | string | Label shown in the sidebar. Required. |
category | CategoryInfo | ControllerClass | Parent category: a CategoryInfo from Category, RootCategory or RegisterModule, or a controller class from PageController or RootPageController. |
module | string | Id of a module registered with RegisterModule. Attaches the entry to that module's tree. |
urlSlug | string | URL segment for this entry. Defaults to id. |
description | string | Longer description carried in the page metadata. |
order | number | Sort order among siblings. |
icon | string | Icon name. |
hidden | boolean | Keeps the entry out of the menu. A page or category under a hidden category is hidden too. |
parent | ControllerClass | The page this one is a detail of. The breadcrumb shows it before this page ("Operations / Projects / parentSlug. Read on pages only. |
permission | Partial<Permission> | Action | Overrides the derived page permission, or binds the page to an existing component Action. See Permissions. |
publicAccess | boolean | Serves the page without authentication. A page inherits it from its category. |
authOnly | boolean | Requires a signed-in user and no permission. A page inherits it from its category. |
memberAccess | boolean | "self" | Opens the entry, its components and their actions to every signed-in member without a role grant. Their permissions register as defaultGranted, so guards still check them, the tenant access gate still applies, and the roles editor does not list them. true passes to what is declared under the entry. "self" opens the entry alone. settingsCategory declares "self", so every member opens the settings overview while the workspace pages under it stay gated. MemberAccess names this type. |
type | MenuItemType | "label" or "link". |
validation | PageValidation | Preconditions for opening the page. |
setupId | string | Id of a page setup function to run while the page is mounted. |
noComponentPermissions | boolean | Registers no permission for the page's components. |
ownerOnly | boolean | Only a platform owner reaches the entry, as on a module page. Its permission and its components' are marked module-scoped instead of registered, so no role can be granted them and the roles editor does not list them. Anyone else is refused with 403. A page inherits it from its category, and it wins over publicAccess, authOnly and memberAccess. |
query | MenuItemQuery | Query parameters carried by the entry's menu link. |
variant | MenuItemVariant | Semantic look of the entry. |
status | MenuItemStatus | Semantic state dot at the end of the entry. |
badge | string | Short count or label at the end of the entry (3, new). It takes the place of status and of a counted navigation badge. |
placement | "footer" | Draws a first-level entry in the sidebar footer, above "Modules". |
layout | ComponentInfo | Default layout of the entry and of every page and category under it that sets none. The nearest declaring ancestor wins, and a page's layout argument always overrides it. |
bypassTenantAccessGate | boolean | Keeps the page reachable while a tenant access gate denies the tenant. The pages of a flagged category inherit it. |
live | PageLiveOptions | Gives the page a Live and Pause state over the realtime of its blocks. Read on pages only. |
MenuItemType is "label" | "link".
PageValidation has three optional fields:
requiredQueryParams, astring[]of query parameters the page needs, each with a non-empty value.customFunctionId, the id of a validation function the frontend registers.redirectTo, the dashboard path a page that fails its validation sends the user to instead of answering "Page not found". The path may use the{{params.X}}and{{query.X}}tokens of the page URL. Page setup and validation shows it in use.
PageLiveOptions has three optional fields. Live pages explains the behaviour they control.
maxRate, the shortest interval in seconds between two refetches of one block, and the polling interval while the realtime stream is down.slowRateAfter, aPageLiveSlowRateof{ period: PageLivePeriod; maxRate: number }. Once the period the page shows spansperiod, itsmaxRatereplaces the page's.PageLivePeriodis a whole number followed bym,hord, such as"7d".rememberKey, a key that shares the remembered Live or Pause choice between the pages that declare it.
A rate that is not a positive number, a period that does not read like 30m, 24h or 7d, or an empty rememberKey throws at declaration.
Menu entry appearance
Three types describe how an entry looks, so a consumer never ships raw classes:
type MenuItemVariant = "default" | "accent";
type MenuItemStatus = "success" | "warning" | "error" | "neutral";
type MenuItemQuery = Record<string, string>;
accent renders the entry in the theme's primary color, for a call to action such as "New project". status maps to the theme's semantic colors.
query appends parameters to the entry's link, so one page can serve many entries. Declare the parameter in validation.requiredQueryParams, then point several entries at the page:
import { PageController, RegisterPage, pagesCategory } from "@antelopejs/interface-dms/page";
@RegisterPage()
export class ProjectPage extends PageController("project", {
displayName: "Project",
category: pagesCategory,
validation: { requiredQueryParams: ["project"] },
query: { project: "acme-website" },
}) {}
Reach a page behind a tenant gate
bypassTenantAccessGate is the page-level mirror of the guard option of the same name (Permissions). It covers the page's visibility, its menu entry and its own layout route, and a flagged category passes it to its pages. Permission checks still apply. authOnly, by contrast, drops them.
The flag does not cover the data routes that feed the page. A data API belongs to no single page, so it opts out through its own guard, or through TableViewOptions.bypassTenantAccessGate for a table view. Reserve the flag for recovery surfaces, such as billing or a payment portal, that a blocked tenant must reach to unblock itself.
Group pages with categories
Category(id, options) returns a CategoryInfo that you pass as another entry's category. Categories nest, and each one throws unless it declares a category or a module.
import {
Category,
pagesCategory,
} from "@antelopejs/interface-dms/page";
export const crm = Category("crm", {
displayName: "CRM",
icon: "i-ph-users",
category: pagesCategory,
});
export const contacts = Category("contacts", {
displayName: "Contacts",
category: crm,
});
Creating a category registers a permission keyed to its fullId. The permission is defaultGranted when the category declares publicAccess or memberAccess, and its permission option overrides the derived fields. A category inside a module or declaring ownerOnly marks its id module-scoped instead, and a category whose permission is an Action registers none. Permissions covers both.
Root categories
RootCategory(id, options) creates a top-level group next to the built-in ones. Its options are MenuOptions without category and module, and type defaults to "label". The ids pages, modules and settings are reserved and throw.
import { RootCategory } from "@antelopejs/interface-dms/page";
export const catalogCategory = RootCategory("catalog", {
displayName: "Catalog",
icon: "i-ph-books",
order: 9,
});
The interface exports these built-in roots:
| Export | Kind | URL slug | order |
|---|---|---|---|
pagesCategory | CategoryInfo | / | 1 |
modulesCategory | controller class (RootPageController) | /modules | 2 |
settingsCategory | controller class (RootPageController) | /settings | 3 |
settingsCategory declares layout: SettingsLayout(), so every page under it renders in the settings frame unless it passes its own layout. workspaceSettingsCategory is Category("workspace", …) under settingsCategory, with the full id settings.workspace and the URL /settings/workspace. It holds the workspace settings, such as members, invitations and roles, and a project adds its own there (Settings pages).
modulesCategory is the module root that every module registered with RegisterModule attaches under. A page or category that declares a module cannot resolve to a category under settingsCategory. That combination throws.
RootPageController
RootPageController(id, options, layout?) builds a page controller at the root of the tree. Its options are MenuOptions without category and module, plus an optional isModuleRoot boolean. It requires no parent, so it suits a top-level landing screen.
Identifiers a page carries
Category, PageController and RootPageController compute two identifiers from the entry's id and its parent chain:
fullIdis the chain of ids joined by dots, from the root category (pages.crm.contacts). It is the page's permission id and the key its realtime topics register under.fullSlugis the chain of URL slugs (/crm/contacts).
CategoryInfo extends MenuOptions without parent. It redeclares category as a required CategoryInfo | ControllerClass | undefined that holds the resolved parent, and adds id, fullId, fullSlug, an optional isModuleRoot, and an optional urlTransparent. urlTransparent is true when the category adds no URL segment of its own, as urlSlug: "/" produces. Such a category is a section heading, not a route, and any number of them may sit under one parent.
PageInfo extends CategoryInfo with layoutUrl and an optional parentSlug. layoutUrl is the URL the page's component tree is served from: /dms/pages, then the page's fullSlug, then /pagelayout. parentSlug is the full slug of the page declared as parent.
A page controller serves its routes under PAGE_ROUTE_PREFIX (/dms/pages), not at the page's own path. The frontend server answers the page's own path with the page, and proxies only the backend prefixes declared to it, which are /api/** and /dms/** for the DMS. @Get("/sessions") on the page /settings/user/security is GET /dms/pages/settings/user/security/sessions, which pageRoutePath("/settings/user/security", "/sessions") returns. A plain Controller that a module mounts for its frontend sits under /api/<module>/ instead, or under a prefix it declares in backendProxies.
GetPermissionId(target) returns the permission id recorded for a page controller class, a Component, or a child position, or undefined when the target never registered. A child component resolves to its full positional path. When one component instance is mounted more than once, every position registers a permission, but the instance alone resolves to its first registered position. GetComponentPermissionIds(component) returns the ids of every live position of a reusable component.
import { GetPermissionId } from "@antelopejs/interface-dms/page";
const pagePermission = GetPermissionId(InvoicesPage);
For the page declared above, pagePermission is "pages.billing.invoices". GetRegisteredPageIds() returns the ids of every registered page, sorted.
Extend a page from another module
@RegisterPageExtension(targetPageId) injects components into a page that another module owns. The decorated class is not a page. Every static component field on it becomes a component of the target page, keyed by its field name.
import { RegisterPageExtension } from "@antelopejs/interface-dms/page";
import { CustomComponent } from "@antelopejs/interface-dms/base/custom";
@RegisterPageExtension("settings.workspace.members")
export class SeatQuotaExtension {
static seatQuota = CustomComponent("SeatQuotaBanner")
.meta({ name: "Seat quota" })
.before("table");
}
The target is named by its page id, the fullId it registered under, which is also its permission id. The DMS members page is settings.workspace.members. The extending module imports nothing from the owning module, so it depends on @antelopejs/interface-dms alone. GetRegisteredPageIds() lists the ids, and GetPermissionId(ThePageClass) returns one inside the owning module.
The field name is the component key, so an injected component's permission is <target fullId>.<field name> in the target page's own permission tree, like a component the target declares itself. The target's fields and those of every extension share that namespace.
.before(anchor) and .after(anchor) on the component set its placement. The anchor is a component key of the target page: "table" for a static field, or "content.tasks" for a nested position. Without an anchor, the component goes after the page's own components. When several components land at the same spot, .order(n) decides, and equal orders fall back to the extension class name and then to declaration order, never to module start order. Components covers those builder methods.
The injection applies once the target page finishes registering, whichever module starts first, so anchors resolve against the page's complete component set. It is removed when the extending module stops. The components are prepared as the extending module, each time the target page registers. What they register, such as permissions, native upload fields, form sub-pages and realtime topics, belongs to the extending module. It survives a reload of the DMS or of the target's module and goes away with the extending module.
Nothing about the target can be checked when the decorator runs, so the checks happen when the injection applies:
- An empty target id throws at the decorator.
- An extension class with no component field logs a warning and injects nothing.
- A page id that no module registers keeps the extension pending, with a warning once every module has started.
- A key that the page or another extension already uses, or an anchor that the page does not declare, is reported at error level with the extension name, the target id and the key. That extension alone is skipped.
interface PageExtensionInfo {
extensionName: string;
targetFullId: string;
components: PageExtensionComponent[];
}
interface PageExtensionComponent {
key: string;
component: Component;
side: PlacementSide;
anchorPath?: readonly string[];
order: number;
}
PageExtensionInfo is the registration handle that is unregistered when the extending module stops. key is the static field name, and also the last segment of the component's permission id on the target page. anchorPath is the anchor split into its dotted segments.
Page layouts
A page layout is the serialized description of the page's components:
interface PageLayout<T = unknown> {
components: Record<string, ComponentInfoSerialized<T>>;
layout?: ComponentInfo<T>;
allComponentsHidden?: true;
}
components is keyed by the static field name on the page class, and each value is the serialized component (Components). layout is the layout component. allComponentsHidden is set when the page declares components and the caller may see none of them, so the browser can say so instead of drawing a blank page.
Registering a page installs a PageLayoutHandler for its fullSlug:
interface PageLayoutRequest {
user: User | undefined;
memberModel: TenantMemberModel;
roleModel: RoleModel;
tenantId: string;
query?: Readonly<Record<string, string>>;
params?: Readonly<Record<string, string>>;
resolverContext?: PermissionsResolverContext;
}
type PageLayoutHandler = (request: PageLayoutRequest) => Promise<PageLayout>;
query and params are the page URL's query and route parameters, handed to header-button availability. resolverContext goes to the permissions resolvers, with preview set when the layout is served for a role preview.
The handler drops the components the caller has no permission for and applies each component's own filter. A page with publicAccess, authOnly or noComponentPermissions skips the permission step and returns every component. Native upload tokens are bound to the exact page and component mount at page registration, not by this handler, and upload and metadata requests still check live authorization (File storage).
GetPageLayoutBySlug(slug) returns the handler, or undefined for an unknown slug:
import { GetModel } from "@antelopejs/interface-database-decorators";
import {
type PageLayout,
GetPageLayoutBySlug,
} from "@antelopejs/interface-dms/page";
import {
RoleModel,
TenantMemberModel,
} from "@antelopejs/interface-dms/db";
import type { User } from "@antelopejs/interface-dms/auth/db";
async function renderLayout(
slug: string,
user: User | undefined,
tenantId: string,
): Promise<PageLayout | undefined> {
const handler = GetPageLayoutBySlug(slug);
return handler?.({
user,
memberModel: GetModel(TenantMemberModel, tenantId),
roleModel: GetModel(RoleModel, tenantId),
tenantId,
});
}
ClearPageLayoutBySlug(slug) drops the handler. A page unregisters through it, because /dms/pagelayout reaches the handler by slug. A handler left behind would keep serving the layout of a page already gone from the registry, the navigation tree and its own route.
PageMetadata
PageMetadata is the record the decorator fills in for each controller. GetMetadata(controllerClass, PageMetadata) returns it. It holds pageInfo, layout and components, and exposes:
| Member | Description |
|---|---|
SetInfo(id, fullSlug, menuOptions, pageLayout?) | Computes and stores the PageInfo and the layout. |
SetComponent(id, component) | Attaches a component under a key. |
inherit(parent) | Merges another PageMetadata's info, layout and components into this one. |
Register() | Registers the page: permissions, layout handler, /pagelayout route and auth decorators. |
ComponentPermissionIds(component) | Returns the permission ids of every position the component holds on this page. |
target | The controller class the record belongs to. |
@RegisterPage() calls SetComponent for each static component and then Register(). Use PageMetadata directly only to generate pages programmatically.
Registration also runs each component's onCreated callback with this record. It registers a permission for each component and each component action, unless the page sets noComponentPermissions or authOnly, or sits inside a module (Permissions).
A declaration that the page cannot honour throws PageDeclarationConflictError and the page fails to register. FormPageRouteConflictError extends it for two page-mode table views that register the same form sub-page.
Page access
Registering a page installs an auth decorator on the controller's user property, chosen from the options:
| Options | Decorator installed |
|---|---|
publicAccess: true | None. The page is served to anonymous callers. |
authOnly: true | AuthUser from @antelopejs/interface-dms/auth. A signed-in user, no permission check. |
page whose fullSlug starts with /modules/ | AuthOwnerOnly from @antelopejs/interface-dms/auth. Module pages are for platform owners only. |
| default | AuthUserWithPermission(pageClass, { bypassTenantAccessGate }) with the page's own permission (Permissions). |
On a page that is neither publicAccess nor authOnly, registration also binds roleModel, memberModel and tenantId properties on the controller, scoped to the request's tenant (Tenancy). Routes declared on the page class inherit that gating, so a route on a default page already requires the page's permission.
Declare an injected property on the class to read it in a handler. The provider runs on every request, whether or not the handler reads it:
import { Get } from "@antelopejs/interface-api";
import {
PageController,
RegisterPage,
} from "@antelopejs/interface-dms/page";
import type { User } from "@antelopejs/interface-dms/auth/db";
import { crm } from "./categories";
@RegisterPage()
export class MyContactsPage extends PageController("mine", {
displayName: "My contacts",
category: crm,
}) {
declare user: User;
@Get("/count")
async count() {
return { owner: this.user._id };
}
}
Page setup functions
setupId names a function that runs while the page is mounted. The backend carries only the id. The frontend registers the function, runs it when the page mounts, and passes it a PageSetupContext.
type PageSetupFunction = (
context: PageSetupContext,
) => MaybePromise<PageSetupCleanup | void>;
Member of PageSetupContext | Description |
|---|---|
pageInfo | The PageInfo of the mounted page. |
permissions | Set<string> of the caller's effective permission ids. |
on(component, event, handler) | Subscribes to a component event. Returns an unsubscribe function. |
emit(component, event, data?) | Dispatches an event on the shared event bus. |
PageSetupCleanup is () => void. The setup function returns it to release what it allocated, and the frontend calls it when the page unmounts. MaybePromise<T> is T | Promise<T>, re-exported from @antelopejs/interface-dms/types.
import {
PageController,
RegisterPage,
} from "@antelopejs/interface-dms/page";
import { billing } from "./category";
@RegisterPage()
export class LifecyclePage extends PageController("lifecycle", {
displayName: "Lifecycle",
category: billing,
setupId: "billing:invoice-lifecycle",
}) {}
Frontend modules and request helpers
Frontend modules and request helpers describes the functions a module's backend calls outside page declarations.
The frontend reads the project, not the backend's registrations. ajs dms dev, ajs dms build and ajs dms start call the module's frontendModule function, which the module's package.json names as dmsFrontend ("dmsFrontend": "dist/frontend-module.js"). Keep the registration in that pure function of the module's config, and pass its result to AddFrontendModule. A module that only calls AddFrontendModule is left out of the frontend, in development and in production.
import path from "node:path";
import type { FrontendModuleFunction } from "@antelopejs/interface-dms/page";
interface BillingConfig {
prefix?: string;
}
export const frontendModule: FrontendModuleFunction<BillingConfig> = (
config,
) => ({
name: "@acme/dms-billing",
sourcePath: path.join(__dirname, "../frontend-vue"),
renderer: { name: "vue", version: "3" },
configKey: "dmsBilling",
options: { prefix: config.prefix ?? "Billing" },
});
AddFrontendModuleOptions
The options of AddFrontendModule, which registers the frontend a module ships, are listed in AddFrontendModuleOptions.
Public URLs
GetApiBaseUrl() and GetClientBaseUrl() are described in Public URLs.
Client address
getClientIp(context) and ResolveClientIp(source) are described in Client address.
SaveComponentFiles
SaveComponentFiles is described in SaveComponentFiles.
Next steps
Components covers the builders that produce the values you assign to those static fields. Modules and dynamic menus covers module roots and per-request menu entries.