Skip to content
SegmentStream/ Docs

Loading documentation…

↑ ↓ to navigate  ↵ to open  Esc to close
Website Console
Section menu

@segmentstream/ontology/navigation-catalog

16 public exports from @segmentstream/ontology/navigation-catalog.

Public exports

PageCatalog
type PageCatalog = PageCatalogV1 | PageCatalogV2;
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;
    }[];
}
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>>;
}
createPageCatalog

Generate an immutable catalog identity from normalized metadata, ontology, and source identity.

function createPageCatalog(pages: readonly PageEntry[], context: {
    readonly ontologyHash: string;
    readonly sourceHash: string;
}): PageCatalog;
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;
pageCatalogVersion

The catalog version its pages need: 2 once a page shows a record, 1 otherwise.

function pageCatalogVersion(pages: readonly PageEntry[]): 1 | 2;
parsePageCatalog

Validate and copy an untrusted artifact. Entity existence is checked against the serving ontology.

function parsePageCatalog(value: unknown): PageCatalog;
recordFieldsOf

The fields of an entity's records a record page's address may use.

function recordFieldsOf(entity: PageCatalogEntity): ReadonlySet<string>;
recordPageProblem

Why a page cannot show records of the entity it names, or `undefined` when it can: the entity must exist, have every field the address uses, and have no property named `url`, the key its records carry their page's address under.

function recordPageProblem(page: PageEntry, entity: PageCatalogEntity | undefined): string | undefined;