Shoalrun documentation frameworkMenu
For agents
Start with https://www.shoalrun.com/llms.txt for the documentation index, then read the Markdown pages it links. Skip to article. Documentation index. Read this page as Markdown.
Code API reference

shoalrun.content

module: shoalrun.content

Updated
Read as Markdown

Module shoalrun.content

Functions

Name Kind Description
contentRefKey function Serialize a reference to a deterministic key without including publication scope.
contentResourceKey function Public identity only: independent of publication, revision, and export filenames.
mountContent function Mount trusted compiler HTML with instance-specific anchor and accessibility IDs. This is not a sanitizer. The result must come from trusted compiler output. The mount replaces the container's children and rewrites local routing metadata.
openManifestContentSource function Open and validate one immutable static manifest revision. The caller owns trust in the compiler output and host. Browser URLs must use the application's origin. Requests reject redirects and unexpected content types.
openRestContentSource function Open a REST inventory and pin subsequent resource reads to its revision.
validateContentManifest function Validate a parsed manifest's shape, identities, paths, and resource bounds. This assertion narrows the value but doesn't verify fetched file bytes or trust in a host.

Members

Name Kind Description
ContentAnchor type Mapping from a canonical document fragment to its exported HTML ID.
ContentAsset type A content-addressed file with its declared media type.
ContentDeliveryError class Delivery failure with a machine-readable code and a human-readable message.
ContentDeliveryLimits type Positive safe-integer bounds applied when opening and reading content.
ContentErrorCode type Stable error categories raised by content-source validation and reads.
ContentFile type Export-relative file path, byte length, and SHA-256 digest.
ContentFormat type Portable representations a content client can request.
ContentLink type Classified link and optional resource identity for application routing.
ContentManifest type One validated, content-addressed export inventory.
ContentMount type Handles and rewritten routing metadata for one mounted HTML instance.
ContentPublication type Exact documentation publication selected by a content source.
ContentRef type Stable identity of a page, a section within a page, or a named snippet instance. A reference is scoped to the publication and revision of the opened snapshot.
ContentRepresentation type One portable format, including its file metadata, anchors, and typed links.
ContentResource type Inventory entry describing one exported document, section, or snippet instance.
ContentRestEntry type One resource inventory entry with its REST lookup key.
ContentRestError type JSON error envelope returned by the content REST service.
ContentRestErrorCode type Error categories used by the content REST protocol.
ContentRestList type Revision-scoped inventory envelope returned by the content REST service.
ContentRestResource type Revision-scoped metadata envelope for a single content resource.
ContentResult type A fetched representation together with the metadata needed to render or route it.
ContentSnapshot interface A client pinned to one immutable inventory revision and publication.
ManifestContentSourceOptions type Configuration for opening a static content-export manifest.
RestContentSourceOptions type Options for a REST inventory and its revision-pinned resource reads.

shoalrun.content.ContentAnchor

Type shoalrun.content.ContentAnchor

type ContentAnchor = {
    id: string;
    exportedId: string;
    title?: string;
};

Mapping from a canonical document fragment to its exported HTML ID.

Fields

Name Type Required / default Description
exportedId string Required —
id string Required —
title string | undefined Optional —

shoalrun.content.ContentAsset

Type shoalrun.content.ContentAsset

type ContentAsset = ContentFile & {
    mediaType: string;
};

A content-addressed file with its declared media type.

Fields

Name Type Required / default Description
mediaType string Required —

shoalrun.content.ContentDeliveryError

Class shoalrun.content.ContentDeliveryError

class ContentDeliveryError extends Error

Delivery failure with a machine-readable code and a human-readable message.

Constructor

new ContentDeliveryError(code: ContentErrorCode, message: string): ContentDeliveryError

Bases: Error

Fields

Name Type Required / default Description
code ContentErrorCode Required —

shoalrun.content.ContentDeliveryLimits

Type shoalrun.content.ContentDeliveryLimits

type ContentDeliveryLimits = {
    manifestBytes?: number;
    resourceBytes?: number;
    resources?: number;
};

Positive safe-integer bounds applied when opening and reading content.

Fields

Name Type Required / default Description
manifestBytes number | undefined Optional Maximum manifest or REST inventory bytes. Defaults to 5,000,000.
resourceBytes number | undefined Optional Maximum bytes for an individual representation. Defaults to 8,000,000.
resources number | undefined Optional Maximum resource count in the inventory. Defaults to 10,000.

shoalrun.content.ContentErrorCode

Type shoalrun.content.ContentErrorCode

type ContentErrorCode = 'invalid_manifest' | 'not_found' | 'unsupported_format' | 'stale_revision' | 'network_error' | 'invalid_content' | 'disposed';

Stable error categories raised by content-source validation and reads.

shoalrun.content.ContentFile

Type shoalrun.content.ContentFile

type ContentFile = {
    path: string;
    bytes: number;
    digest: string;
};

Export-relative file path, byte length, and SHA-256 digest.

Fields

Name Type Required / default Description
bytes number Required —
digest string Required —
path string Required —

shoalrun.content.ContentFormat

Type shoalrun.content.ContentFormat

type ContentFormat = 'html' | 'markdown';

Portable representations a content client can request.

Type shoalrun.content.ContentLink

type ContentLink = {
    key: string;
    kind: 'resource' | 'canonical' | 'external' | 'asset';
    href: string;
    ref?: ContentRef;
    fragment?: string;
    query?: string;
    asset?: string;
};

Classified link and optional resource identity for application routing.

Fields

Name Type Required / default Description
asset string | undefined Optional —
fragment string | undefined Optional —
href string Required —
key string Required —
kind "resource" | "canonical" | "external" | "asset" Required —
query string | undefined Optional —
ref ContentRef | undefined Optional —

shoalrun.content.ContentManifest

Type shoalrun.content.ContentManifest

type ContentManifest = {
    schemaVersion: 1 | 2;
    kind: 'shoalrun-content-export';
    digest: string;
    publicBase: string;
    publication: ContentPublication;
    review: {
        status: 'ok' | 'required';
        apis: Array<{
            apiId: string;
            digest: string;
        }>;
    };
    resources: ContentResource[];
    assets: ContentAsset[];
    files: ContentFile[];
    diagnostics: Array<{
        code: string;
        documentId?: string;
        message: string;
    }>;
};

One validated, content-addressed export inventory.

Fields

Name Type Required / default Description
assets ContentAsset[] Required —
diagnostics { code: string; documentId?: string; message: string; }[] Required —
digest string Required —
files ContentFile[] Required —
kind "shoalrun-content-export" Required —
publicBase string Required —
publication ContentPublication Required —
resources ContentResource[] Required —
review { status: "ok" | "required"; apis: Array<{ apiId: string; digest: string; }>; } Required —
schemaVersion 1 | 2 Required —

shoalrun.content.ContentMount

Type shoalrun.content.ContentMount

type ContentMount = {
    anchors: readonly ContentAnchor[];
    links: readonly ContentLink[];
    unmount(): void;
};

Handles and rewritten routing metadata for one mounted HTML instance.

Fields

Name Type Required / default Description
anchors readonly ContentAnchor[] Required Anchors after instance-specific ID rewriting.
links readonly ContentLink[] Required Typed links, including rewritten local fragments for this instance.

Methods

Name Kind Description
unmount method Remove nodes that still belong to this mount.

shoalrun.content.ContentPublication

Type shoalrun.content.ContentPublication

type ContentPublication = {
    channel: string;
    version: string;
    language: string;
    product?: string;
};

Exact documentation publication selected by a content source.

Fields

Name Type Required / default Description
channel string Required —
language string Required —
product string | undefined Optional —
version string Required —

shoalrun.content.ContentRef

Type shoalrun.content.ContentRef

type ContentRef = {
    kind: 'page';
    documentId: string;
} | {
    kind: 'section';
    documentId: string;
    sectionId: string;
} | {
    kind: 'snippet';
    id: string;
};

Stable identity of a page, a section within a page, or a named snippet instance. A reference is scoped to the publication and revision of the opened snapshot.

shoalrun.content.ContentRepresentation

Type shoalrun.content.ContentRepresentation

type ContentRepresentation = ContentAsset & {
    anchors: ContentAnchor[];
    links: ContentLink[];
};

One portable format, including its file metadata, anchors, and typed links.

Fields

Name Type Required / default Description
anchors ContentAnchor[] Required —
links ContentLink[] Required —

shoalrun.content.ContentResource

Type shoalrun.content.ContentResource

type ContentResource = {
    ref: ContentRef;
    publication: ContentPublication;
    title: string;
    summary: string;
    type: string;
    canonicalUrl?: string;
    source?: {
        documentId?: string;
        snippetId?: string;
        valuesDigest?: string;
    };
    representations: Partial<Record<ContentFormat, ContentRepresentation>>;
    assets: string[];
    externalDependencies: Array<{
        url: string;
        kind: 'image';
    }>;
};

Inventory entry describing one exported document, section, or snippet instance.

Fields

Name Type Required / default Description
assets string[] Required —
canonicalUrl string | undefined Optional —
externalDependencies { url: string; kind: "image"; }[] Required —
publication ContentPublication Required Exact product, channel, version, and documentation language.
ref ContentRef Required Stable identity used by ContentSnapshot.get.
representations Partial<Record<ContentFormat, ContentRepresentation>> Required Available portable formats and their files, anchors, and typed links.
source { documentId?: string; snippetId?: string; valuesDigest?: string; } | undefined Optional —
summary string Required Short explanation of the resource's purpose.
title string Required Human-readable resource title.
type string Required Authored document type, or section/snippet for a selected resource.

shoalrun.content.ContentRestEntry

Type shoalrun.content.ContentRestEntry

type ContentRestEntry = {
    key: string;
    resource: ContentResource;
};

One resource inventory entry with its REST lookup key.

Fields

Name Type Required / default Description
key string Required —
resource ContentResource Required —

shoalrun.content.ContentRestError

Type shoalrun.content.ContentRestError

type ContentRestError = {
    error: {
        code: ContentRestErrorCode;
        message: string;
    };
};

JSON error envelope returned by the content REST service.

Fields

Name Type Required / default Description
error { code: ContentRestErrorCode; message: string; } Required —

shoalrun.content.ContentRestErrorCode

Type shoalrun.content.ContentRestErrorCode

type ContentRestErrorCode = 'invalid_request' | 'not_found' | 'unsupported_format' | 'stale_revision' | 'method_not_allowed' | 'internal_error';

Error categories used by the content REST protocol.

shoalrun.content.ContentRestList

Type shoalrun.content.ContentRestList

type ContentRestList = {
    schemaVersion: 1 | 2;
    revision: string;
    publication: ContentPublication;
    resources: ContentRestEntry[];
};

Revision-scoped inventory envelope returned by the content REST service.

Fields

Name Type Required / default Description
publication ContentPublication Required —
resources ContentRestEntry[] Required —
revision string Required —
schemaVersion 1 | 2 Required —

shoalrun.content.ContentRestResource

Type shoalrun.content.ContentRestResource

type ContentRestResource = {
    schemaVersion: 1 | 2;
    revision: string;
    publication: ContentPublication;
    key: string;
    resource: ContentResource;
};

Revision-scoped metadata envelope for a single content resource.

Fields

Name Type Required / default Description
key string Required —
publication ContentPublication Required —
resource ContentResource Required —
revision string Required —
schemaVersion 1 | 2 Required —

shoalrun.content.ContentResult

Type shoalrun.content.ContentResult

type ContentResult = {
    resource: Readonly<ContentResource>;
    representation: Readonly<ContentRepresentation>;
    format: ContentFormat;
    content: string;
    revision: string;
};

A fetched representation together with the metadata needed to render or route it.

Fields

Name Type Required / default Description
content string Required Validated UTF-8 HTML or Markdown text.
format ContentFormat Required Representation actually returned by the source.
representation Readonly<ContentRepresentation> Required File, media type, anchors, and typed links for the selected format.
resource Readonly<ContentResource> Required Inventory entry that was selected by the requested reference.
revision string Required Revision shared by this response and its opened content snapshot.

shoalrun.content.ContentSnapshot

Interface shoalrun.content.ContentSnapshot

interface ContentSnapshot

A client pinned to one immutable inventory revision and publication.

Fields

Name Type Required / default Description
publication Readonly<ContentPublication> Required Publication shared by every resource available from this snapshot.
revision string Required Content digest identifying this inventory revision.

Methods

Name Kind Description
dispose method Cancel pending requests and prevent subsequent reads or inventory access.
get method Fetch one available representation of a stable content reference.
list method List the resources in the opened inventory without fetching their bodies.

shoalrun.content.ManifestContentSourceOptions

Type shoalrun.content.ManifestContentSourceOptions

type ManifestContentSourceOptions = {
    manifestUrl: string | URL;
    fetch?: typeof globalThis.fetch;
    signal?: AbortSignal;
    limits?: ContentDeliveryLimits;
};

Configuration for opening a static content-export manifest.

Fields

Name Type Required / default Description
fetch ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) | undefined Optional Fetch implementation. Defaults to globalThis.fetch.
limits ContentDeliveryLimits | undefined Optional Inventory and representation bounds.
manifestUrl string | URL Required Manifest URL; a browser resolves relative URLs against its current location.
signal AbortSignal | undefined Optional Cancel the opening request. Use get's signal to cancel an individual read.

shoalrun.content.RestContentSourceOptions

Type shoalrun.content.RestContentSourceOptions

type RestContentSourceOptions = {
    baseUrl: string | URL;
    publication: ContentPublication;
    revision?: string;
    fetch?: typeof globalThis.fetch;
    signal?: AbortSignal;
    limits?: ContentDeliveryLimits;
};

Options for a REST inventory and its revision-pinned resource reads.

Fields

Name Type Required / default Description
baseUrl string | URL Required REST mount URL, such as /content/v1. Browser requests must use the application's origin.
fetch ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) | undefined Optional Fetch implementation. Defaults to globalThis.fetch.
limits ContentDeliveryLimits | undefined Optional Inventory and representation bounds.
publication ContentPublication Required Exact publication to request; include product for a product-scoped source.
revision string | undefined Optional Expected inventory revision. Omit it to open the current revision.
signal AbortSignal | undefined Optional Cancel the inventory-opening request.

shoalrun.content.contentRefKey

Function shoalrun.content.contentRefKey

contentRefKey(ref: ContentRef): string

Serialize a reference to a deterministic key without including publication scope.

Parameters

Parameter Type / default Description
ref ContentRef —

Returns

string

shoalrun.content.contentResourceKey

Function shoalrun.content.contentResourceKey

contentResourceKey(ref: ContentRef): string

Public identity only: independent of publication, revision, and export filenames.

Parameters

Parameter Type / default Description
ref ContentRef —

Returns

string

shoalrun.content.mountContent

Function shoalrun.content.mountContent

mountContent(container: Element, result: ContentResult, options?: { instanceId?: string; signal?: AbortSignal; }): ContentMount

Mount trusted compiler HTML with instance-specific anchor and accessibility IDs. This is not a sanitizer. The result must come from trusted compiler output. The mount replaces the container's children and rewrites local routing metadata.

Parameters

Parameter Type / default Description
container Element DOM element receiving the content.
result ContentResult A validated HTML representation; Markdown results aren't accepted.
options { instanceId?: string; signal?: AbortSignal; } | undefined Optional unique instance ID and cancellation signal.

Returns

ContentMount

Rewritten anchors, typed links, and an unmount handle.

shoalrun.content.openManifestContentSource

Function shoalrun.content.openManifestContentSource

openManifestContentSource(options: ManifestContentSourceOptions): Promise<ContentSnapshot>

Open and validate one immutable static manifest revision. The caller owns trust in the compiler output and host. Browser URLs must use the application's origin. Requests reject redirects and unexpected content types.

Parameters

Parameter Type / default Description
options ManifestContentSourceOptions Manifest URL, request implementation, cancellation, and limits.

Returns

Promise<ContentSnapshot>

A revision-pinned snapshot for listing and reading exported resources.

Examples

const snapshot = await openManifestContentSource({ manifestUrl: '/help/manifest.json' });
const page = await snapshot.get({ kind: 'page', documentId: 'guide.start' }, { format: 'markdown' });
snapshot.dispose();

shoalrun.content.openRestContentSource

Function shoalrun.content.openRestContentSource

openRestContentSource(options: RestContentSourceOptions): Promise<ContentSnapshot>

Open a REST inventory and pin subsequent resource reads to its revision.

Parameters

Parameter Type / default Description
options RestContentSourceOptions REST mount, exact publication, optional revision, and request settings.

Returns

Promise<ContentSnapshot>

A snapshot with the same list/get/dispose interface as the manifest source.

shoalrun.content.validateContentManifest

Function shoalrun.content.validateContentManifest

validateContentManifest(value: any, maxResources?: number, maxResourceBytes?: number): asserts value is ContentManifest

Validate a parsed manifest's shape, identities, paths, and resource bounds. This assertion narrows the value but doesn't verify fetched file bytes or trust in a host.

Parameters

Parameter Type / default Description
value any Parsed JSON manifest to validate.
maxResources number | undefined Maximum allowed resource count; defaults to 10,000.
maxResourceBytes number | undefined Maximum declared representation bytes; defaults to 8,000,000.

Returns

void