@segmentstream/app/navigation/build
28 public exports from @segmentstream/app/navigation/build.
Public exports
GeneratePageCatalogInput
interface GeneratePageCatalogInput {
readonly files: ReadonlyMap<string, string>;
readonly routing?: PageCatalogRouting;
readonly ontology: PageCatalogOntology;
readonly sourceHash: string;
}PAGE_CATALOG_COMPILED_PATH
const PAGE_CATALOG_COMPILED_PATH = ".segmentstream/navigation/compiled.json"
PAGE_CATALOG_CONTEXT_PATH
const PAGE_CATALOG_CONTEXT_PATH = ".segmentstream/navigation/build-context.json"
PAGE_CATALOG_PATH
const PAGE_CATALOG_PATH = ".segmentstream/navigation/page-catalog.json"
PageCatalog
type PageCatalog = PageCatalogV1 | PageCatalogV2;
PageCatalogBuildError
class PageCatalogBuildError extends Error {
readonly code: string;
readonly name = "PageCatalogBuildError";
constructor(code: string, message: string, options?: ErrorOptions);
}PageCatalogEntity
An ontology entity as a catalog is checked against it; its manifest entry is one.
interface PageCatalogEntity {
readonly name: string;
readonly properties?: readonly {
readonly name: string;
}[];
readonly relationships?: readonly {
readonly name: string;
readonly cardinality?: string;
readonly on?: unknown;
}[];
}PageCatalogOntology
interface PageCatalogOntology {
readonly hash: string;
readonly entities: readonly PageCatalogEntity[];
}PageCatalogRouting
interface PageCatalogRouting {
readonly basePath?: string;
readonly trailingSlash?: boolean;
readonly pageExtensions?: readonly string[];
}PageCatalogV1
A catalog without record pages, as every version of the SDK reads it.
interface PageCatalogV1 {
readonly version: 1;
readonly revision: string;
readonly pages: readonly PageEntry[];
}PageCatalogV2
A catalog with at least one record page; an SDK whose artifact version is 2 or later reads it.
interface PageCatalogV2 {
readonly version: 2;
readonly revision: string;
readonly pages: readonly PageEntry[];
}PageEntry
interface PageEntry {
readonly ref: string;
readonly route: string;
readonly title: string;
readonly description: string;
readonly entities: readonly string[];
readonly parameters: readonly {
readonly name: string;
readonly kind: "segment" | "catch_all";
readonly required: boolean;
readonly description?: string;
}[];
readonly query: Readonly<Record<string, string>>;
readonly record?: PageRecordBinding;
}PageMetadata
Workspace-authored metadata beside an ordinary UI page. Routes are generated, never authored.
interface PageMetadata {
readonly title: string;
readonly entities: readonly string[];
readonly description: string;
readonly parameters?: Readonly<Record<string, string>>;
readonly query?: Readonly<Record<string, string>>;
readonly record?: {
readonly entity: string;
readonly parameters?: Readonly<Record<string, string>>;
readonly query?: Readonly<Record<string, string>>;
};
}PageRecordBinding
A page that shows one record of an entity: each route parameter and query key it names is filled from a field of the record, `id`, a property or a `<relationship>_id` key. An entity has at most one such page, the address its records' `url` gives.
interface PageRecordBinding {
readonly entity: string;
readonly parameters: Readonly<Record<string, string>>;
readonly query: Readonly<Record<string, string>>;
}PageRoute
interface PageRoute {
readonly file: string;
readonly appPath: string;
readonly pathname: string;
readonly route: string;
readonly parallel: boolean;
readonly intercepted: boolean;
}extractPageRoutes
Extract App Router page files without importing or executing page components.
function extractPageRoutes(files: ReadonlyMap<string, string>, routing?: PageCatalogRouting): readonly PageRoute[];
generatePageCatalog
Pure, deterministic Node build-time compiler. Source strings are never executed.
function generatePageCatalog(input: GeneratePageCatalogInput): PageCatalog;
normalizePageRoute
function normalizePageRoute(pathname: string, routing?: PageCatalogRouting): string;
pageCatalogCoverage
function pageCatalogCoverage(files: ReadonlyMap<string, string>, routing?: PageCatalogRouting): {
pages: number;
annotated: number;
unannotated: number;
};pageCatalogEntity
What a catalog needs of an entity, as JSON: its name, its properties' names and its relationships that give its records a `<relationship>_id` key.
function pageCatalogEntity(entity: PageCatalogEntity): PageCatalogEntity;
parsePageCatalog
Validate and copy an untrusted artifact. Entity existence is checked against the serving ontology.
function parsePageCatalog(value: unknown): PageCatalog;
preparePageCatalog
Run before parallel app/ontology builds, using the ontology evaluated from the same immutable source.
function preparePageCatalog(input: {
readonly projectDir: string;
readonly ontology: PageCatalogOntology;
readonly sourceHash: string;
}): Promise<{
enabled: false;
coverage: {
pages: number;
annotated: number;
unannotated: number;
};
catalog?: undefined;
catalogPath?: undefined;
} | {
enabled: true;
catalog: import("./generate.js").PageCatalog;
catalogPath: string;
coverage: {
pages: number;
annotated: number;
unannotated: number;
};
}>;readPageCatalogFiles
Read only routing source, never dependencies, generated output, or page modules via import.
function readPageCatalogFiles(projectDir: string): Promise<ReadonlyMap<string, string>>;
verifyCompiledPageCatalog
Compiler-stage safety check; final verification below must also follow the complete build command.
function verifyCompiledPageCatalog(input: {
projectDir: string;
distDir: string;
routing?: PageCatalogRouting;
}): Promise<void>;verifyPageCatalogBuild
Verify final resolved routes after any app build command, including custom commands.
function verifyPageCatalogBuild(input: {
readonly projectDir: string;
}): Promise<{
enabled: false;
revision?: undefined;
pages?: undefined;
} | {
enabled: true;
revision: string;
pages: number;
}>;verifyPageCatalogRouting
Prove static matches exactly and compare complete path shapes for dynamic pages.
function verifyPageCatalogRouting(catalog: ReturnType<typeof generatePageCatalog>, inventory: RoutingInventory, frameworkInterceptions?: readonly RoutingRule[]): void;
withPageCatalog
Opt into page discovery without changing page components or replacing other Next plugins.
function withPageCatalog(config: NextConfig): NextConfig;
function withPageCatalog(config: NextConfigFunction): NextConfigFunction;
function withPageCatalog(config: Promise<NextConfig>): Promise<NextConfig>;