@acoustic-content-sdk/component-utils

Framework independent collection of utility functions to implement services and components for sites next.

Usage no npm install needed!

<script type="module">
  import acousticContentSdkComponentUtils from 'https://cdn.skypack.dev/@acoustic-content-sdk/component-utils';
</script>

README

npm

Framework independent collection of utility functions to implement services and components for sites next.

Table of Contents

Home > @acoustic-content-sdk/component-utils

component-utils package

Framework independent collection of utility functions to implement services and components for sites next.

Classes

Class Description
AbstractComponentResolverService Base class for component type resolvers
AbstractComponentsService
AbstractDeliverySearchResolverService
AbstractLayoutMappingResolver
AbstractLayoutResolverService
AbstractProtectedContentService Service to tell whether or not to serve protected content
AbstractRenderingContextResolverService Implementation of a service that resolves the outbound parts of a rendering context
AbstractWchPageService

Functions

Function Description
assertSameOrigin(aLeft, aRight, aLogSvc) Validates that the origin of both windows is the same, otherwise throws an exception
createLayoutComponentDecorator(aComponentConsumer, aLayoutMappingConsumer) Layout decorator and metadata.
createLayoutMappingDecorator(aLayoutMappingConsumer) Constructs the laout mapping decorator. Will callback the given function with the decorated object
getEditHostWindow(aCurrentWindow) Returns the window that controls the application. This is either the parent window or the opener window.

Interfaces

Interface Description
AbstractRegisteredComponent
AbstractRegisteredLayoutMapping

Variables

Variable Description
DEFAULT_LAYOUT_ID name of the default layout
PAGE_NOT_FOUND_LAYOUT_ID
selectId
selectIdFromRenderingContext
selectMetadata
VERSION Version and build number of the package

Type Aliases

Type Alias Description
SendRequest

Home > @acoustic-content-sdk/component-utils > AbstractComponentResolverService

AbstractComponentResolverService class

Base class for component type resolvers

Signature:

export declare class AbstractComponentResolverService<TYPE> implements AbstractComponentResolver<TYPE> 

Constructors

Constructor Modifiers Description
(constructor)(aComponentsService, aLayoutResolverService, aLayoutMappingService, aComponentTypeRefResolvers, aLogSvc) Constructs a new instance of the AbstractComponentResolverService class

Properties

Property Modifiers Type Description
resolveComponent (aRenderingContext: RenderingContextV2, aLayoutMode?: string) => Observable<TYPE>

Home > @acoustic-content-sdk/component-utils > AbstractComponentsService

AbstractComponentsService class

Signature:

export declare class AbstractComponentsService<TYPE> implements AbstractComponentsRegistry<TYPE> 

Constructors

Constructor Modifiers Description
(constructor)(aDefaultComponent, aPredicate, aLogSvc) Initializes our constructor. We make sure to keep all private instance variables as part of the closure and override the methods on the instance level. Since this is a singleton service, that approach does not cause a performance problem.

Properties

Property Modifiers Type Description
getTypeByLayout (aLayout: Layout, aLayoutMode?: string) => Observable<TYPE> Returns the type object based on the layout configuration
getTypeBySelector (aSelector: string, aLayoutMode?: string) => Observable<TYPE> Returns the type object based on the layout selector
registerType (aController: string | string[], aType: TYPE, aLayoutModes?: string | string[]) => void define the methods

Home > @acoustic-content-sdk/component-utils > AbstractDeliverySearchResolverService

AbstractDeliverySearchResolverService class

Signature:

export declare class AbstractDeliverySearchResolverService implements DeliverySearchResolver 

Constructors

Constructor Modifiers Description
(constructor)(aFetchText, aProtected, aSeedResolver, aLogSvc) Constructs a new instance of the AbstractDeliverySearchResolverService class

Properties

Property Modifiers Type Description
getDeliverySearchResults <T>(aQuery: QueryInput, aClassification: string) => Observable<SearchResults<T>>

Home > @acoustic-content-sdk/component-utils > AbstractLayoutMappingResolver

AbstractLayoutMappingResolver class

Signature:

export declare class AbstractLayoutMappingResolver implements LayoutMappingResolver 

Constructors

Constructor Modifiers Description
(constructor)() Constructs a new instance of the AbstractLayoutMappingResolver class

Properties

Property Modifiers Type Description
getSelector (aLayoutMode: string, aRenderingContext: RenderingContextV2) => string | undefined Returns the layout selector based on the rendering context
registerMapping (aId: string | string[], aSelector: string | string[], aLayoutMode?: string | string[]) => void Registers a layout mapping

Home > @acoustic-content-sdk/component-utils > AbstractLayoutResolverService

AbstractLayoutResolverService class

Signature:

export declare class AbstractLayoutResolverService implements LayoutResolver 

Constructors

Constructor Modifiers Description
(constructor)(aDeliveryTypeResolver, aDeliveryLayoutMappingResolver, aDeliveryLayoutResolver, aLogSvc) Constructs a new instance of the AbstractLayoutResolverService class

Properties

Property Modifiers Type Description
resolveLayout (aLayoutMode: string, aRenderingContext: RenderingContextV2) => Observable<Layout>

Home > @acoustic-content-sdk/component-utils > AbstractProtectedContentService

AbstractProtectedContentService class

Service to tell whether or not to serve protected content

Signature:

export declare class AbstractProtectedContentService implements ProtectedContent 

Constructors

Constructor Modifiers Description
(constructor)(aUrlConfig$, aAuthStatus, aLogSvc) Constructs a new instance of the AbstractProtectedContentService class

Properties

Property Modifiers Type Description
protected$ Observable<boolean>

Home > @acoustic-content-sdk/component-utils > AbstractRenderingContextResolverService

AbstractRenderingContextResolverService class

Implementation of a service that resolves the outbound parts of a rendering context

Signature:

export declare class AbstractRenderingContextResolverService implements RenderingContextResolver 

Constructors

Constructor Modifiers Description
(constructor)(aDeliveryContentResolver, aLogSvc) Constructs a new instance of the AbstractRenderingContextResolverService class

Properties

Property Modifiers Type Description
resolveRenderingContext (aItem: RenderingContextInput, aProvider: RenderingContextProviderV2) => Observable<RenderingContextV2>

Home > @acoustic-content-sdk/component-utils > AbstractWchPageService

AbstractWchPageService class

Signature:

export declare class AbstractWchPageService implements WchPageService 

Constructors

Constructor Modifiers Description
(constructor)(aDeliveryPageResolver, aUrlConfig$, aLogSvc) Constructs a new instance of the AbstractWchPageService class

Properties

Property Modifiers Type Description
getRenderingContextByPath (aPath: string) => Observable<RenderingContextV2 | null | undefined> Resolves the rendering context given the path

Home > @acoustic-content-sdk/component-utils > assertSameOrigin

assertSameOrigin() function

Validates that the origin of both windows is the same, otherwise throws an exception

Signature:

export declare function assertSameOrigin(aLeft: WindowType, aRight: WindowType, aLogSvc?: LoggerService): void;

Parameters

Parameter Type Description
aLeft WindowType left window to check
aRight WindowType right window to check
aLogSvc LoggerService optionally the logger service

Returns:

void

Home > @acoustic-content-sdk/component-utils > createLayoutComponentDecorator

createLayoutComponentDecorator() function

Layout decorator and metadata.

Signature:

export declare function createLayoutComponentDecorator<TYPE, DIRECTIVE extends AbstractLayoutComponentDirective>(aComponentConsumer: BiConsumer<TYPE, AbstractRegisteredComponent<TYPE, DIRECTIVE>>, aLayoutMappingConsumer: BiConsumer<TYPE, AbstractRegisteredLayoutMapping<TYPE>>): <T extends TYPE>(aDirective?: DIRECTIVE) => (cls: T) => void;

Parameters

Parameter Type Description
aComponentConsumer BiConsumer<TYPE, AbstractRegisteredComponent<TYPE, DIRECTIVE>>
aLayoutMappingConsumer BiConsumer<TYPE, AbstractRegisteredLayoutMapping<TYPE>>

Returns:

<T extends TYPE>(aDirective?: DIRECTIVE) => (cls: T) => void

Home > @acoustic-content-sdk/component-utils > createLayoutMappingDecorator

createLayoutMappingDecorator() function

Constructs the laout mapping decorator. Will callback the given function with the decorated object

Signature:

export declare function createLayoutMappingDecorator<TYPE>(aLayoutMappingConsumer: BiConsumer<TYPE, AbstractRegisteredLayoutMapping<TYPE>>): <T extends TYPE>(aID: string | string[] | LayoutMappingDirective, aSelector?: string | string[] | TYPE, aLayoutMode?: string | string[]) => (cls: T) => void;

Parameters

Parameter Type Description
aLayoutMappingConsumer BiConsumer<TYPE, AbstractRegisteredLayoutMapping<TYPE>>

Returns:

<T extends TYPE>(aID: string | string[] | LayoutMappingDirective, aSelector?: string | string[] | TYPE, aLayoutMode?: string | string[]) => (cls: T) => void

Home > @acoustic-content-sdk/component-utils > getEditHostWindow

getEditHostWindow() function

Returns the window that controls the application. This is either the parent window or the opener window.

Signature:

export declare function getEditHostWindow(aCurrentWindow: WindowType): WindowType;

Parameters

Parameter Type Description
aCurrentWindow WindowType the current window

Returns:

WindowType

the controlling window

Home > @acoustic-content-sdk/component-utils > AbstractRegisteredComponent

AbstractRegisteredComponent interface

Signature:

export interface AbstractRegisteredComponent<TYPE, DIRECTIVE extends AbstractLayoutComponentDirective> 

Properties

Property Type Description
directive DIRECTIVE
type TYPE

Home > @acoustic-content-sdk/component-utils > AbstractRegisteredLayoutMapping

AbstractRegisteredLayoutMapping interface

Signature:

export interface AbstractRegisteredLayoutMapping<TYPE> 

Properties

Property Type Description
id string | string[] Type IDs or content IDs to map this to
kind CONTENT_ITEM_KIND | CONTENT_ITEM_KIND[] Type IDs to map this to
layoutMode string | string[] An optional layout mode used with this layout mapping.
selector string | string[] | TYPE Defines the mapping between the layout controller to the layout implementation. If this property is missing, the selector of the component will be used instead.

Home > @acoustic-content-sdk/component-utils > DEFAULT_LAYOUT_ID

DEFAULT_LAYOUT_ID variable

name of the default layout

Signature:

DEFAULT_LAYOUT_ID = "wch-default-layout"

Home > @acoustic-content-sdk/component-utils > PAGE_NOT_FOUND_LAYOUT_ID

PAGE_NOT_FOUND_LAYOUT_ID variable

Signature:

PAGE_NOT_FOUND_LAYOUT_ID = "wch-404"

Home > @acoustic-content-sdk/component-utils > selectId

selectId variable

Signature:

selectId: import("rxjs").UnaryFunction<any, any>

Home > @acoustic-content-sdk/component-utils > selectIdFromRenderingContext

selectIdFromRenderingContext variable

Signature:

selectIdFromRenderingContext: import("rxjs").UnaryFunction<any, string>

Home > @acoustic-content-sdk/component-utils > selectMetadata

selectMetadata variable

Signature:

selectMetadata: import("rxjs").UnaryFunction<DeliveryReferenceElement | DeliveryContentItem | DeliveryGroupElement | RenderingContextV2, import("@acoustic-content-sdk/api").DeliveryGroupElementMetadata | import("@acoustic-content-sdk/api").DeliveryReferenceElementMetadata | import("@acoustic-content-sdk/api").DeliveryContentMetadata>

Home > @acoustic-content-sdk/component-utils > VERSION

VERSION variable

Version and build number of the package

Signature:

VERSION: {
    version: {
        major: string;
        minor: string;
        patch: string;
        branch: string;
    };
    build: Date;
}

Home > @acoustic-content-sdk/component-utils > SendRequest

SendRequest type

Signature:

export declare type SendRequest = <T>(aUrl: string, aCredentials: boolean) => Observable<T>;

Home > @acoustic-content-sdk/component-utils > AbstractComponentResolverService > (constructor)

AbstractComponentResolverService.(constructor)

Constructs a new instance of the AbstractComponentResolverService class

Signature:

protected constructor(aComponentsService: AbstractComponentsService<TYPE>, aLayoutResolverService: LayoutResolver, aLayoutMappingService: LayoutMappingResolver, aComponentTypeRefResolvers?: AbstractComponentTypeRefResolver<TYPE>[], aLogSvc?: LoggerService);

Parameters

Parameter Type Description
aComponentsService AbstractComponentsService<TYPE>
aLayoutResolverService LayoutResolver
aLayoutMappingService LayoutMappingResolver
aComponentTypeRefResolvers AbstractComponentTypeRefResolver<TYPE>[]
aLogSvc LoggerService

Home > @acoustic-content-sdk/component-utils > AbstractComponentResolverService > resolveComponent

AbstractComponentResolverService.resolveComponent property

Signature:

resolveComponent: (aRenderingContext: RenderingContextV2, aLayoutMode?: string) => Observable<TYPE>;

Home > @acoustic-content-sdk/component-utils > AbstractComponentsService > (constructor)

AbstractComponentsService.(constructor)

Initializes our constructor. We make sure to keep all private instance variables as part of the closure and override the methods on the instance level. Since this is a singleton service, that approach does not cause a performance problem.

Signature:

protected constructor(aDefaultComponent: TYPE, aPredicate: EqualsPredicate<TYPE>, aLogSvc?: LoggerService);

Parameters

Parameter Type Description
aDefaultComponent TYPE
aPredicate EqualsPredicate<TYPE>
aLogSvc LoggerService

Home > @acoustic-content-sdk/component-utils > AbstractComponentsService > getTypeByLayout

AbstractComponentsService.getTypeByLayout property

Returns the type object based on the layout configuration

Signature:

getTypeByLayout: (aLayout: Layout, aLayoutMode?: string) => Observable<TYPE>;

Home > @acoustic-content-sdk/component-utils > AbstractComponentsService > getTypeBySelector

AbstractComponentsService.getTypeBySelector property

Returns the type object based on the layout selector

Signature:

getTypeBySelector: (aSelector: string, aLayoutMode?: string) => Observable<TYPE>;

Home > @acoustic-content-sdk/component-utils > AbstractComponentsService > registerType

AbstractComponentsService.registerType property

define the methods

Signature:

registerType: (aController: string | string[], aType: TYPE, aLayoutModes?: string | string[]) => void;

Home > @acoustic-content-sdk/component-utils > AbstractDeliverySearchResolverService > (constructor)

AbstractDeliverySearchResolverService.(constructor)

Constructs a new instance of the AbstractDeliverySearchResolverService class

Signature:

protected constructor(aFetchText: FetchText, aProtected: ProtectedContent, aSeedResolver?: SeedResolver, aLogSvc?: LoggerService);

Parameters

Parameter Type Description
aFetchText FetchText
aProtected ProtectedContent
aSeedResolver SeedResolver
aLogSvc LoggerService

Home > @acoustic-content-sdk/component-utils > AbstractDeliverySearchResolverService > getDeliverySearchResults

AbstractDeliverySearchResolverService.getDeliverySearchResults property

Signature:

getDeliverySearchResults: <T>(aQuery: QueryInput, aClassification: string) => Observable<SearchResults<T>>;

Home > @acoustic-content-sdk/component-utils > AbstractLayoutMappingResolver > (constructor)

AbstractLayoutMappingResolver.(constructor)

Constructs a new instance of the AbstractLayoutMappingResolver class

Signature:

protected constructor();

Home > @acoustic-content-sdk/component-utils > AbstractLayoutMappingResolver > getSelector

AbstractLayoutMappingResolver.getSelector property

Returns the layout selector based on the rendering context

Signature:

getSelector: (aLayoutMode: string, aRenderingContext: RenderingContextV2) => string | undefined;

Home > @acoustic-content-sdk/component-utils > AbstractLayoutMappingResolver > registerMapping

AbstractLayoutMappingResolver.registerMapping property

Registers a layout mapping

Signature:

registerMapping: (aId: string | string[], aSelector: string | string[], aLayoutMode?: string | string[]) => void;

Home > @acoustic-content-sdk/component-utils > AbstractProtectedContentService > (constructor)

AbstractProtectedContentService.(constructor)

Constructs a new instance of the AbstractProtectedContentService class

Signature:

protected constructor(aUrlConfig$: Observable<UrlConfig>, aAuthStatus: AuthStatus, aLogSvc?: LoggerService);

Parameters

Parameter Type Description
aUrlConfig$ Observable<UrlConfig>
aAuthStatus AuthStatus
aLogSvc LoggerService

Home > @acoustic-content-sdk/component-utils > AbstractProtectedContentService > protected$

AbstractProtectedContentService.protected$ property

Signature:

protected$: Observable<boolean>;

Home > @acoustic-content-sdk/component-utils > AbstractLayoutResolverService > (constructor)

AbstractLayoutResolverService.(constructor)

Constructs a new instance of the AbstractLayoutResolverService class

Signature:

protected constructor(aDeliveryTypeResolver: DeliveryTypeResolver, aDeliveryLayoutMappingResolver: DeliveryLayoutMappingResolver, aDeliveryLayoutResolver: DeliveryLayoutResolver, aLogSvc?: LoggerService);

Parameters

Parameter Type Description
aDeliveryTypeResolver DeliveryTypeResolver
aDeliveryLayoutMappingResolver DeliveryLayoutMappingResolver
aDeliveryLayoutResolver DeliveryLayoutResolver
aLogSvc LoggerService

Home > @acoustic-content-sdk/component-utils > AbstractLayoutResolverService > resolveLayout

AbstractLayoutResolverService.resolveLayout property

Signature:

resolveLayout: (aLayoutMode: string, aRenderingContext: RenderingContextV2) => Observable<Layout>;

Home > @acoustic-content-sdk/component-utils > AbstractWchPageService > (constructor)

AbstractWchPageService.(constructor)

Constructs a new instance of the AbstractWchPageService class

Signature:

protected constructor(aDeliveryPageResolver: DeliveryPageResolver, aUrlConfig$: Observable<UrlConfig>, aLogSvc?: LoggerService);

Parameters

Parameter Type Description
aDeliveryPageResolver DeliveryPageResolver
aUrlConfig$ Observable<UrlConfig>
aLogSvc LoggerService

Home > @acoustic-content-sdk/component-utils > AbstractWchPageService > getRenderingContextByPath

AbstractWchPageService.getRenderingContextByPath property

Resolves the rendering context given the path

Signature:

getRenderingContextByPath: (aPath: string) => Observable<RenderingContextV2 | null | undefined>;

Home > @acoustic-content-sdk/component-utils > AbstractRenderingContextResolverService > (constructor)

AbstractRenderingContextResolverService.(constructor)

Constructs a new instance of the AbstractRenderingContextResolverService class

Signature:

protected constructor(aDeliveryContentResolver: DeliveryContentResolver, aLogSvc?: LoggerService);

Parameters

Parameter Type Description
aDeliveryContentResolver DeliveryContentResolver
aLogSvc LoggerService

Home > @acoustic-content-sdk/component-utils > AbstractRenderingContextResolverService > resolveRenderingContext

AbstractRenderingContextResolverService.resolveRenderingContext property

Signature:

resolveRenderingContext: (aItem: RenderingContextInput, aProvider: RenderingContextProviderV2) => Observable<RenderingContextV2>;

Home > @acoustic-content-sdk/component-utils > AbstractRegisteredLayoutMapping > id

AbstractRegisteredLayoutMapping.id property

Type IDs or content IDs to map this to

Signature:

id?: string | string[];

Home > @acoustic-content-sdk/component-utils > AbstractRegisteredLayoutMapping > kind

AbstractRegisteredLayoutMapping.kind property

Type IDs to map this to

Signature:

kind?: CONTENT_ITEM_KIND | CONTENT_ITEM_KIND[];

Home > @acoustic-content-sdk/component-utils > AbstractRegisteredLayoutMapping > layoutMode

AbstractRegisteredLayoutMapping.layoutMode property

An optional layout mode used with this layout mapping.

Signature:

layoutMode?: string | string[];

Home > @acoustic-content-sdk/component-utils > AbstractRegisteredLayoutMapping > selector

AbstractRegisteredLayoutMapping.selector property

Defines the mapping between the layout controller to the layout implementation. If this property is missing, the selector of the component will be used instead.

Signature:

selector: string | string[] | TYPE;

Home > @acoustic-content-sdk/component-utils > AbstractRegisteredComponent > directive

AbstractRegisteredComponent.directive property

Signature:

directive: DIRECTIVE;

Home > @acoustic-content-sdk/component-utils > AbstractRegisteredComponent > type

AbstractRegisteredComponent.type property

Signature:

type: TYPE;