[data-reveal]{opacity:1!important;transform:none!important}
AntelopeJS DMS
DocumentationModules and dynamic menus

Modules and dynamic menus

Register a module root in the sidebar, report its state on the modules catalog, and add menu entries resolved per request.

A module is a feature area with its own root in the sidebar, under /modules. A dynamic menu provider adds menu entries resolved for each request, such as one entry per project a tenant owns. Both live in @antelopejs/interface-dms/page. Pages and categories, which modules group, are described in Pages and modules.

Declare a module

RegisterModule(info) creates the module root under modulesCategory and returns its CategoryInfo.

typescript
import { RegisterModule } from "@antelopejs/interface-dms/page";

RegisterModule({
  id: "automation",
  title: "$dms_automation.module.title",
  description: "$dms_automation.module.description",
  icon: "i-ph-flow-arrow",
  defaultCategory: { displayName: "$dms_automation.module.pages", order: 0 },
});

Call RegisterModule before any page that names the module id. A page resolves its module inside the PageController call of its class declaration, before @RegisterPage() runs, and an unknown module id throws. Registering the same id twice also throws.

ModuleInfo

OptionTypeDescription
idstringModule id. Also the URL segment under /modules. Required.
titlestringDisplay name of the module root. Required.
descriptionstringDescription carried on the module root. Required.
iconstringIcon name. Required.
landingPagestringId of the page the module opens on. /modules/<id> redirects to it and keeps the query and hash. Defaults to the first page by order. An id that matches no page of the module logs a warning and falls back to that default.
versionstringVersion shown on the catalog tile (1.4.0).
catalogCategorystringCategory the module is filed under in the module catalog ("Content", "Developer"), possibly a $ i18n key. The Modules page and the module store both use it. Without one, a store module takes the category of the store catalog, and any other module goes under "Other". It has no relation to menu categories (MenuOptions.category, defaultCategory).
status(context: ModuleCatalogContext) => MaybePromise<ModuleStatus>Reports the module's state on its catalog tile.
readout(context: ModuleCatalogContext) => MaybePromise<ModuleReadoutLine[]>Returns short lines that say what the module is doing now.
defaultCategory{ displayName?, icon?, order?, urlSlug? }Groups the module's pages that declare module without a category. Without it, those pages attach directly to the module root.

The generated default category has the id pages and the urlSlug "pages" unless you set one. Its label falls back to "$menu.section.pages" when displayName is empty or omitted.

Catalog hooks

The DMS calls status and readout on each load of the modules catalog. The catalog is for platform owners only. Each hook receives a ModuleCatalogContext:

typescript
interface ModuleCatalogContext {
  user: User | undefined;
  tenantId: string;
}

ModuleStatus is "live" | "beta" | "update" | "attention". live means the module works normally, beta that it is usable and still changing, update that a newer version is available, and attention that a platform owner must act, for example on a failing job. A module without status shows as live.

ModuleReadoutLine is { text: string; tone?: ModuleReadoutTone }, where text may be a $ i18n key and ModuleReadoutTone is "success" | "info" | "warning" | "error". The tile shows at most three lines. A line with empty text is dropped, and a tone outside the four values shows as info.

A hook that throws, or that does not answer within two seconds, is ignored and logged once. The tile then shows live and no readout. A status that returns a value outside ModuleStatus also falls back to live.

Attach pages to a module

Set module on the page options. category stays available to group pages inside the module:

typescript
import {
  PageController,
  RegisterPage,
} from "@antelopejs/interface-dms/page";
import "./module";

@RegisterPage()
export class OverviewPage extends PageController("overview", {
  displayName: "$dms_automation.overview.title",
  icon: "i-ph-gauge",
  module: "automation",
  order: 0,
}) {}

The bare ./module import runs the file that calls RegisterModule, so the module exists before the page declares itself.

A page that declares both module and a category must name a category under that module's root. Otherwise registration throws. A page or category that declares module cannot sit under settingsCategory either. Registration throws for that combination too.

Module URLs and ids

MODULE_URL_PREFIX is "/modules". The module root's urlSlug is the module id and its parent is modulesCategory, so module pages resolve under /modules/<moduleId>/.... Their ids follow the same chain. The module root's fullId is modules.<moduleId>. A page attached to the root is modules.<moduleId>.<pageId>, and a page in the default category is modules.<moduleId>.pages.<pageId>.

isInsideModule(entry) returns whether an entry belongs to a module. It accepts any object with optional module, category and isModuleRoot fields, so a CategoryInfo or a PageInfo qualifies. It returns true when the entry is a module root or declares module, and otherwise walks the category chain looking for a module root. isOwnerOnly(entry) also holds for an entry that declares or inherits ownerOnly, and it decides who reaches the entry.

typescript
import { isOwnerOnly } from "@antelopejs/interface-dms/page";

if (isOwnerOnly(pageInfo)) {
  showOwnerBadge();
}

The permissions of a module entry are marked module-scoped instead of entering the grantable permission tree, and a module page is served to platform owners only. Module-scoped permissions describes the consequences.

Contribute menu entries at request time

Category, PageController and RegisterModule declare the menu at import time. A dynamic menu provider adds entries resolved for each request, such as one entry for each project or workspace the tenant owns.

typescript
import { RegisterDynamicMenuProvider } from "@antelopejs/interface-dms/page";

RegisterDynamicMenuProvider("pages.projects", async (user, tenantId) => {
  const projects = await listProjects(tenantId);
  return projects.map((project, index) => ({
    id: project.slug,
    displayName: project.name,
    fullSlug: "/projects/:projectId",
    params: { projectId: project.id },
    icon: "i-ph-folder",
    order: index,
  }));
});
typescript
function RegisterDynamicMenuProvider(
  categoryFullId: string,
  resolver: DynamicMenuResolver,
): () => void;

type DynamicMenuResolver = (
  user: User | undefined,
  tenantId: string,
  permissions: Set<string>,
) => MaybePromise<DynamicMenuItem[]>;

A registration is a DynamicMenuProviderInfo, which pairs the categoryFullId and the resolver. The resolver runs during /sitelayout. Its entries go into that request's copy of the tree only, and the global navigation tree never changes, so one tenant's entries never reach another tenant's site layout. The dynamic and static children of a category sort together by order, then by display name and id, so entries of equal rank keep the same order on every host and across restarts.

permissions is the caller's effective permission set as the parent category sees it. The set is empty while a tenant access gate denies the tenant, unless the category is flagged bypassTenantAccessGate, which keeps the real set. user is undefined for an unauthenticated request.

Providers run concurrently. A provider that throws, or that does not answer within two seconds, contributes nothing to that request and is reported once. The rest of the menu still resolves, and the provider's entries return when it answers again.

The registration belongs to the registering module, not to the category it targets. A provider whose category is not registered stays dormant and resolves as soon as the category appears, so module start order and hot reloads need no coordination. The registration is removed when the registering module unloads. The returned function removes it earlier, for a module that stops providing entries while it stays loaded.

DynamicMenuItem

An item is not a page. It links to a registered page, so one page can back any number of entries. That page typically has :name segments in its slug, or declares validation.requiredQueryParams.

params fills the :name segments of fullSlug with URL-encoded values, and the entry links to the result. fullSlug: "/projects/:projectId" with params: { projectId: "acme" } links to /projects/acme. The values must fill every segment and nothing else. An entry that leaves a segment empty, or that names a parameter the slug does not have, is skipped with a warning.

FieldTypeDescription
idstringUnique among siblings. The DMS appends it to the parent's fullId with a dot, and top-level entries use the provider category as their parent. An id that contains a dot is skipped with a warning. For a duplicate sibling id, the first admitted entry wins and the others are skipped with a warning. Required.
displayNamestringEntry label. Required.
fullSlugstringFull slug of the page the entry links to, :name segments included. Required.
paramsMenuItemParamsValues for the :name segments of fullSlug. MenuItemParams is Record<string, string>.
queryMenuItemQueryQuery parameters added to the link.
descriptionstringLonger description.
iconstringIcon name.
ordernumberSort order among the category's children, dynamic and static alike.
variantMenuItemVariantSemantic look.
statusMenuItemStatusStatus dot. It trails a leaf entry and sits on the leading icon of a parent, so a parent with a status declares an icon.
badgestringShort count or label at the end of the entry (3, new).
permissionIdstringPermission required to see the entry, as a raw id. Unset means always visible.
childrenreadonly DynamicMenuItem[]Nested entries. An omitted or empty array means a leaf.

The DMS lists an entry only when the caller can access its target page, so the menu never offers a link that the target refuses. Each child is admitted on its own target access and permission, and a parent that is not admitted drops its whole subtree. The tree is at most three levels deep, counting provider entries as level 1. Deeper entries are dropped with a warning.

permissionId is a raw id, unlike MenuOptions.permission, which takes a whole permission or an Action. It is matched against the permission set the caller's browser receives, the way the browser matches it: the wildcard or a literal grant, never a defaultGranted fallback. The sidebar therefore never offers an entry whose controls would be inert. While a gate denies the tenant, that set holds only the surfaces flagged bypassTenantAccessGate, so a recovery entry declares its permission under its target page, as in <recoveryPageFullId>.settle.

permissionId decides only whether the entry is listed. The target page receives the entry's query like any other input from the caller, and it authorizes the value itself.

NotifyMenuChanged

typescript
const NotifyMenuChanged: (tenantId?: string) => void;

Call NotifyMenuChanged when the data behind a provider changes, for example after a project is created or deleted, so connected clients resync. The signal carries no data. Each client fetches its own /sitelayout again, resolved against its own permissions.

Pass the tenantId whose data changed, so only that tenant's sessions fetch again. Without it, the menu of every connected session is invalidated, which suits changes that are not scoped to a tenant.