Alokai

UnifiedConfig

interface UnifiedConfig {
	componentCache?: {
    namespace?: string;
    ttl: ((component: Component | null) => number) | number;
  };
	getDepthLevelForComponent?: (params: GetDepthLevelForComponentParams) => number | undefined;
	getReferenceFieldsForComponent?: (component: Component) => ReferenceField[];
	normalizers?: {
    addCustomFields?: DefineAddCustomFields<CustomizableNormalizers>[];
    override?: Partial<CustomizableNormalizers>;
  };
	resolveFallbackPage: (context: SmarteditIntegrationContext) => FallbackPageMatcher | Promise<FallbackPageMatcher>;
	resolvePages: (context: SmarteditIntegrationContext) => Promise<ResolvedPages> | ResolvedPages;
	resolveUnknownComponents?: (context: SmarteditIntegrationContext, params: ResolveUnknownComponentsParams) => Promise<Record<string, unknown>[]>;
	transformImageUrl?: (url: string) => string;
	transformVideoUrl?: (url: string) => string;
}

Properties

NameRequiredTypeDescription
componentCacheOptional{ namespace?: string; ttl: ((component: Component | null) => number) | number; }Cache for resolved CMS components. When ttl is set, caching is enabled. Caches both successful lookups and misses (negative cache) to avoid repeated API calls for non-existent component IDs. On startup, the middleware pings Redis. If reachable, Redis is used (shared across pods). Otherwise, falls back to an in-memory mock. Caching is disabled when componentCache is omitted or ttl is not set.
getDepthLevelForComponentOptional(params: GetDepthLevelForComponentParams) => number | undefinedControls the maximum depth of nested component resolution on a per-component basis. Unresolved references (when the depth limit is reached) preserve their original string content so the frontend can lazily fetch them.
getReferenceFieldsForComponentOptional(component: Component) => ReferenceField[]Determines which fields in a component contain references to other components that should be resolved. This function is called during the reference resolution phase (before normalization) to identify fields containing component IDs that need to be replaced with actual component data. SmartEdit typically stores component references as space-separated strings of component UIDs. How Reference Resolution Works: - String fields: Space-separated component IDs → Array of resolved components - Object fields: path indicates WHERE to replace, idField (supports dot notation) indicates WHERE to find the component ID - Nested paths: Support dot notation in both path and idField for deeply nested structures
normalizersOptional{ addCustomFields?: DefineAddCustomFields<CustomizableNormalizers>[]; override?: Partial<CustomizableNormalizers>; }Normalizers are used to transform Smartedit's content types into an unified format, that can be used by the frontend.
resolveFallbackPageRequired(context: SmarteditIntegrationContext) => FallbackPageMatcher | Promise<FallbackPageMatcher>Define Smartedit page to be rendered in case no exact or partial page match is found.
resolvePagesRequired(context: SmarteditIntegrationContext) => Promise<ResolvedPages> | ResolvedPagesDefine one-to-many relations between frontend urls and specific Smartedit pages. (e.g. associate all category pages with a single Smartedit page). Define what content type should be used for specific frontend urls and what reference paths should be included in Smartedit API responses. Paths are matched using the path-to-regexp library. The first match is used, so make sure to define more specific paths first.
resolveUnknownComponentsOptional(context: SmarteditIntegrationContext, params: ResolveUnknownComponentsParams) => Promise<Record<string, unknown>[]>Callback invoked when component IDs referenced by getReferenceFieldsForComponent or automatic itemType references are not returned by the standard CMS API (getComponentsByIdsAndUser). Use this to resolve components that live on custom SAPCC endpoints (e.g. /story-book/items). Resolved components are merged into the standard normalization pipeline and their own references are resolved recursively. If the callback throws, the error is logged and the missing components are silently dropped (same behaviour as without the callback).
transformImageUrlOptional(url: string) => stringTransforms image url to the format that is used by the frontend. SAPCC returns relative path to the image, so this function can be used to prepend the media host.
transformVideoUrlOptional(url: string) => stringTransforms video url to the format that is used by the frontend. SAPCC returns relative path to the video, so this function can be used to prepend the media host.

Referenced Types

On this page