Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bloomreach/spa-sdk

Package Overview
Dependencies
Maintainers
32
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bloomreach/spa-sdk - npm Package Compare versions

Comparing version 14.2.2 to 14.3.0

dist/index.es6.js

1080

dist/index.d.ts

@@ -1,16 +0,1082 @@

import { PageModel, Page } from './page';
import { Configuration } from './configuration';
/**
* Link to a page outside the current application.
*/
declare const TYPE_LINK_EXTERNAL = "external";
/**
* Link to a page inside the current application.
*/
declare const TYPE_LINK_INTERNAL = "internal";
/**
* Link to a CMS resource.
*/
declare const TYPE_LINK_RESOURCE = "resource";
declare type LinkType = typeof TYPE_LINK_EXTERNAL | typeof TYPE_LINK_INTERNAL | typeof TYPE_LINK_RESOURCE;
/**
* A link to a resource or a page.
*/
interface Link {
href: string;
type?: LinkType;
}
/**
* Checks whether a value is a link.
* @param value The value to check.
*/
declare function isLink(value: any): value is Link;
declare const TYPE_META_COMMENT = "comment";
/**
* Meta-data following before a page component.
*/
declare const META_POSITION_BEGIN = "begin";
/**
* Meta-data following after a page component.
*/
declare const META_POSITION_END = "end";
declare type MetaType = typeof TYPE_META_COMMENT;
declare type MetaPosition = typeof META_POSITION_BEGIN | typeof META_POSITION_END;
interface MetaModel {
data: string;
type: MetaType;
}
/**
* Meta information describing a part of the page.
*/
interface Meta {
/**
* @return The meta-data.
*/
getData(): string;
/**
* @return The meta-data position relative to the related element.
*/
getPosition(): MetaPosition;
}
/**
* Checks whether a value is a meta-data object.
* @param value The value to check.
*/
declare function isMeta(value: any): value is Meta;
interface MetaCollectionModel {
beginNodeSpan?: MetaModel[];
endNodeSpan?: MetaModel[];
}
/**
* Collection of the meta-data describing a part of the page.
* @note The collection extends the built-in Array type for backward compatibility.
*/
interface MetaCollection extends Array<Meta> {
/**
* Clears previously rendered meta-data objects.
*/
clear(): void;
/**
* Renders meta-data objects on the page.
* @param head The heading node of the page fragment.
* @param tail The tailing node of the page fragment.
*/
render(head: Node, tail: Node): void;
}
/**
* A reference to an entity within the page model.
*/
interface Reference {
$ref: string;
}
/**
* Checks whether a value is a reference.
* @param value The value to check.
*/
declare function isReference(value: any): value is Reference;
/**
* Generic component type.
*/
declare const TYPE_COMPONENT = "component";
/**
* Container item type.
*/
declare const TYPE_COMPONENT_CONTAINER_ITEM = "container-item";
/**
* Container type.
*/
declare const TYPE_COMPONENT_CONTAINER = "container";
declare type ComponentType = typeof TYPE_COMPONENT | typeof TYPE_COMPONENT_CONTAINER_ITEM | typeof TYPE_COMPONENT_CONTAINER;
/**
* Meta-data of a component.
*/
interface ComponentMeta extends MetaCollectionModel {
params?: ComponentParameters;
}
declare type ComponentLinks = 'self';
declare type ComponentModels = Record<string, any>;
declare type ComponentParameters = Partial<Record<string, string>>;
/**
* Model of a component.
*/
interface ComponentModel {
children?: Reference[];
id: string;
links: Record<ComponentLinks, Link>;
meta: ComponentMeta;
models?: ComponentModels;
name?: string;
type: ComponentType;
}
/**
* A component in the current page.
*/
interface Component {
/**
* @return The component id.
*/
getId(): string;
/**
* @return The component meta-data collection.
*/
getMeta(): MetaCollection;
/**
* @return The map of the component models.
*/
getModels<T extends ComponentModels>(): T;
/**
* @return The link to the partial component model.
*/
getUrl(): string | undefined;
/**
* @return The name of the component.
*/
getName(): string;
/**
* @return The parameters of the component.
*/
getParameters(): ComponentParameters;
/**
* @return The direct children of the component.
*/
getChildren(): Component[];
/**
* Looks up for a nested component.
* @param componentNames A lookup path.
*/
getComponent<U extends Component>(...componentNames: string[]): U | undefined;
getComponent(): this;
/**
* Looks up for a nested component by its id.
* @param id A component id.
*/
getComponentById<U extends Component>(id: string): U | this | undefined;
}
/**
* Event listener.
*/
declare type Listener<T, U extends Extract<keyof T, string>> = (eventData: T[U]) => any;
/**
* Function to unsubscribe a listener from an event.
*/
declare type UnsubscribeFn = () => void;
/**
* Event emitter.
*/
interface Emitter<T> {
/**
* Subscribes for an event.
* @param eventName The event name.
* @param listener The event listener.
* @return The unsubscribe function.
*/
on<U extends Extract<keyof T, string>>(eventName: U, listener: Listener<T, U>): UnsubscribeFn;
/**
* Unsubscribes from an event.
* @param eventName The event name.
* @param listener The event listener.
*/
off<U extends Extract<keyof T, string>>(eventName: U, listener: Listener<T, U>): void;
}
declare const PARAMETER_HIDDEN = "com.onehippo.cms7.targeting.TargetingParameterUtil.hide";
interface ContainerItemParameters {
[PARAMETER_HIDDEN]?: 'on' | 'off';
[parameter: string]: string | undefined;
}
/**
* Meta-data of a container item.
*/
interface ContainerItemMeta extends ComponentMeta {
params?: ContainerItemParameters;
paramsInfo?: ComponentMeta['params'];
}
/**
* Model of a container item.
*/
interface ContainerItemModel extends ComponentModel {
meta: ContainerItemMeta;
label?: string;
type: typeof TYPE_COMPONENT_CONTAINER_ITEM;
}
/**
* Container item update event.
*/
interface ContainerItemUpdateEvent {
}
interface ContainerItemEvents {
update: ContainerItemUpdateEvent;
}
/**
* A component that can be configured in the UI.
*/
interface ContainerItem extends Component, Emitter<ContainerItemEvents> {
/**
* Returns the type of a container item. The available types depend on which
* container items have been configured in the backend.
*
* @return The type of a container item (e.g. "Banner").
*/
getType(): string | undefined;
/**
* Returns whether the component should not render anything.
* Hiding components is only possible with the Relevance feature.
*
* @return Whether the component is hidden or not.
*/
isHidden(): boolean;
}
/**
* A blocked container with blocked items.
*/
declare const TYPE_CONTAINER_BOX = "hst.vbox";
/**
* An unordered list container.
*/
declare const TYPE_CONTAINER_UNORDERED_LIST = "hst.unorderedlist";
/**
* An ordered list container.
*/
declare const TYPE_CONTAINER_ORDERED_LIST = "hst.orderedlist";
/**
* A blocked container with inline items.
*/
declare const TYPE_CONTAINER_INLINE = "hst.span";
/**
* A container without surrounding markup.
*/
declare const TYPE_CONTAINER_NO_MARKUP = "hst.nomarkup";
/**
* Container Type.
* @see https://documentation.bloomreach.com/library/concepts/template-composer/channel-editor-containers.html
*/
declare type ContainerType = typeof TYPE_CONTAINER_BOX | typeof TYPE_CONTAINER_UNORDERED_LIST | typeof TYPE_CONTAINER_ORDERED_LIST | typeof TYPE_CONTAINER_INLINE | typeof TYPE_CONTAINER_NO_MARKUP;
/**
* Model of a container item.
*/
interface ContainerModel extends ComponentModel {
type: typeof TYPE_COMPONENT_CONTAINER;
xtype?: ContainerType;
}
/**
* A component that holds an ordered list of container item components.
*/
interface Container extends Component {
/**
* Returns the type of a container.
*
* @see https://documentation.bloomreach.com/library/concepts/template-composer/channel-editor-containers.html
* @return The type of a container (e.g. `TYPE_CONTAINER_BOX`).
*/
getType(): ContainerType | undefined;
/**
* @return The children of a container.
*/
getChildren(): ContainerItem[];
}
interface MenuItem {
/**
* @return The child items.
*/
getChildren(): MenuItem[];
/**
* @return The menu item depth level.
*/
getDepth(): number;
/**
* @return The menu item link.
*/
getLink(): Link | undefined;
/**
* @return The menu item name.
*/
getName(): string;
/**
* @return The menu item parameters.
*/
getParameters(): object;
/**
* @return The menu item url.
*/
getUrl(): string | undefined;
/**
* @return Whether the menu item is expanded.
*/
isExpanded(): boolean;
/**
* @return Whether the menu item is repository based.
*/
isRepositoryBased(): boolean;
/**
* @return Whether the menu item is selected.
*/
isSelected(): boolean;
}
interface Menu {
/**
* @return The menu items.
*/
getItems(): MenuItem[];
/**
* @return The menu meta-data collection.
*/
getMeta(): MetaCollection;
/**
* @return The current menu item.
*/
getSelected(): MenuItem | undefined;
}
/**
* Checks whether a value is a menu.
* @param value The value to check.
*/
declare function isMenu(value: unknown): value is Menu;
declare type MenuItemLinks = 'site';
/**
* Essentials component menu model.
*/
interface Menu$1 {
_meta?: MetaCollectionModel;
selectSiteMenuItem: MenuItem$1 | null;
siteMenuItems: MenuItem$1[];
}
/**
* Essentials component menu item model.
*/
interface MenuItem$1 {
childMenuItems: MenuItem$1[];
depth: number;
expanded: boolean;
name: string;
parameters: object;
repositoryBased: boolean;
selected: boolean;
_links: Partial<Record<MenuItemLinks, Link>>;
}
interface ContentModel {
type: string;
}
declare type ContentLinks = 'site';
/**
* Model of a content item.
*/
interface ContentModel$1 {
_links: Record<ContentLinks, Link>;
_meta?: MetaCollectionModel;
id: string;
localeString?: string;
name: string;
[property: string]: any;
}
/**
* Content used on the page.
*/
interface Content {
/**
* @return The content id.
*/
getId(): string;
/**
* @return The content locale.
*/
getLocale(): string | undefined;
/**
* @return The content meta-data collection.
*/
getMeta(): MetaCollection;
/**
* @return The content name.
*/
getName(): string;
/**
* @return The content data as it is returned in the Page Model API.
*/
getData(): ContentModel$1;
getData<T extends Record<string, any>>(): T & ContentModel$1;
/**
* @return The link to the content.
*/
getUrl(): string | undefined;
}
/**
* Checks whether a value is a content.
* @param value The value to check.
*/
declare function isContent(value: any): value is Content;
/**
* Meta-data of a visitor.
* @see https://documentation.bloomreach.com/library/enterprise/enterprise-features/targeting/visitors-visits-and-cookies.html
*/
interface Visitor {
/**
* The visitor identifier.
*/
id: string;
/**
* An HTTP-header using to pass the visitor id to the Page Model API.
*/
header: string;
/**
* New visitor flag.
*/
new: boolean;
}
/**
* Meta-data of a current visit.
* @see https://documentation.bloomreach.com/library/enterprise/enterprise-features/targeting/visitors-visits-and-cookies.html
*/
interface Visit {
/**
* The visit identifier.
*/
id: string;
/**
* New visit flag.
*/
new: boolean;
}
declare type PageLinks = 'self' | 'site';
/**
* Meta-data of a page root component.
*/
interface PageRootMeta extends ComponentMeta {
pageTitle?: string;
}
/**
* Model of a page root component.
*/
interface PageRootModel {
meta: PageRootMeta;
}
/**
* Meta-data of a page.
*/
interface PageMeta {
/**
* The current Page Model version.
*/
version?: string;
/**
* Meta-data about the current visitor. Available when the Relevance Module is enabled.
* @see https://documentation.bloomreach.com/library/enterprise/enterprise-features/targeting/targeting.html
*/
visitor?: Visitor;
/**
* Meta-data about the current visit. Available when the Relevance Module is enabled.
* @see https://documentation.bloomreach.com/library/enterprise/enterprise-features/targeting/targeting.html
*/
visit?: Visit;
/**
* Preview mode flag.
*/
preview?: boolean;
}
/**
* Model of a page.
*/
interface PageModel {
document?: Reference;
links: Record<PageLinks, Link>;
meta: PageMeta;
page: Record<string, (ComponentModel | ContainerItemModel | ContainerModel) & PageRootModel | ContentModel>;
root: Reference;
}
/**
* The current page to render.
*/
interface Page {
/**
* Gets a root component in the page.
* @return The root component.
*/
getComponent<T extends Component>(): T;
/**
* Gets a component in the page (e.g. `getComponent('main', 'right')`).
* @param componentNames The names of the component and its parents.
* @return The component, or `undefined` if no such component exists.
*/
getComponent<T extends Component>(...componentNames: string[]): T | undefined;
/**
* Gets a content item used on the page.
* @param reference The reference to the content. It can be an object containing
* an [RFC-6901](https://tools.ietf.org/html/rfc6901) JSON Pointer.
*/
getContent(reference: Reference | string): Content | undefined;
/**
* Gets a custom content item used on the page.
* @param reference The reference to the content. It can be an object containing
* an [RFC-6901](https://tools.ietf.org/html/rfc6901) JSON Pointer.
*/
getContent<T>(reference: Reference | string): T | undefined;
/**
* Gets the page root document.
* This option is available only along with the Experience Pages feature.
*/
getDocument<T>(): T | undefined;
/**
* Generates a meta-data collection from the provided meta-data model.
* @param meta The meta-data collection model as returned by the page-model-api.
*/
getMeta(meta: MetaCollectionModel): MetaCollection;
/**
* @return The title of the page, or `undefined` if not configured.
*/
getTitle(): string | undefined;
/**
* Generates a URL for a link object.
* - If the link object type is internal, then it will prepend `spaBaseUrl` or `baseUrl`.
* In case when the link starts with the same path as in `cmsBaseUrl`, this part will be removed.
* For example, for link `/site/_cmsinternal/spa/about` with configuration options
* `cmsBaseUrl = "http://localhost:8080/site/_cmsinternal/spa"` and `spaBaseUrl = "http://example.com"`
* it will generate `http://example.com/about`.
* - If the link parameter is omitted, then the link to the current page will be returned.
* - In other cases, the link will be returned as-is.
* @param link The link object to generate URL.
*/
getUrl(link?: Link): string;
/**
* Generates an SPA URL for the path.
* - If it is a relative path and `cmsBaseUrl` is present, then it will prepend `spaBaseUrl`.
* - If it is an absolute path and `cmsBaseUrl` is present,
* then the behavior will be similar to internal link generation.
* - If it is a relative path and `endpoint` is present,
* then it will resolve this link relative to the current page URL.
* - If it is an absolute path and `endpoint` is present,
* then it will resolve this link relative to the `baseUrl` option.
* @param path The path to generate URL.
*/
getUrl(path: string): string;
/**
* @return The Page Model version.
*/
getVersion(): string | undefined;
/**
* @return The current visitor data.
*/
getVisitor(): Visitor | undefined;
/**
* @return The current visit data.
*/
getVisit(): Visit | undefined;
/**
* @returns Whether the page is in the preview mode.
*/
isPreview(): boolean;
/**
* Rewrite links to pages and resources in the HTML content.
* This method looks up for `a` tags with `data-type` and `href` attributes and `img` tags with `src` attribute.
* Links will be updated according to the configuration used to initialize the page.
* @param content The HTML content to rewrite links.
* @param type The content type.
*/
rewriteLinks(content: string, type?: SupportedType): string;
/**
* Synchronizes the CMS integration state.
*/
sync(): void;
/**
* @return A plain JavaScript object of the page model.
*/
toJSON(): object;
}
/**
* Mapping of the incoming HTTP request path to the URL of the page model API.
*/
interface UrlBuilderOptions {
/**
* Base URL to fetch the page model from.
*/
endpoint?: string;
/**
* Base URL of the SPA. Everything after it will be interpreted as a route into the page model.
* The default base url is an empty string.
*/
baseUrl?: string;
}
/**
* Mapping of the incoming HTTP request path to the URL of the page model API.
*/
interface UrlBuilderOptions$1 {
/**
* Base URL to fetch the page model from.
* The default URL is `cmsBaseUrl` + `/resourceapi`.
*/
apiBaseUrl?: string;
/**
* Base URL of the CMS.
*/
cmsBaseUrl?: string;
/**
* Base URL of the SPA. Everything after it will be interpreted as a route into the page model.
* The default base url is an empty string.
*/
spaBaseUrl?: string;
}
/**
* Generic component type.
*/
declare const TYPE_COMPONENT$1 = "COMPONENT";
/**
* Container item type.
*/
declare const TYPE_COMPONENT_CONTAINER_ITEM$1 = "CONTAINER_ITEM_COMPONENT";
/**
* Container type.
*/
declare const TYPE_COMPONENT_CONTAINER$1 = "CONTAINER_COMPONENT";
declare type ComponentType$1 = typeof TYPE_COMPONENT$1 | typeof TYPE_COMPONENT_CONTAINER_ITEM$1 | typeof TYPE_COMPONENT_CONTAINER$1;
declare type ComponentLinks$1 = 'componentRendering';
declare type ComponentModels$1 = Record<string, any>;
/**
* Model of a component.
*/
interface ComponentModel$1 {
_links: Record<ComponentLinks$1, Link>;
_meta: ComponentMeta;
id: string;
models?: ComponentModels$1;
name?: string;
type: ComponentType$1;
components?: ComponentModel$1[];
}
/**
* Model of a container item.
*/
interface ContainerItemModel$1 extends ComponentModel$1 {
_meta: ContainerItemMeta;
label?: string;
type: typeof TYPE_COMPONENT_CONTAINER_ITEM$1;
}
/**
* Model of a container item.
*/
interface ContainerModel$1 extends ComponentModel$1 {
type: typeof TYPE_COMPONENT_CONTAINER$1;
xtype?: ContainerType;
}
/**
* Meta-data of a page root component.
*/
interface PageRootMeta$1 extends ComponentMeta {
pageTitle?: string;
}
/**
* Model of a page root component.
*/
interface PageRootModel$1 {
_meta: PageRootMeta$1;
}
/**
* Model of a page.
*/
interface PageModel$1 {
_links: PageModel['links'];
_meta: PageModel['meta'];
content?: {
[reference: string]: ContentModel$1;
};
page: (ComponentModel$1 | ContainerItemModel$1 | ContainerModel$1) & PageRootModel$1;
}
interface DocumentDataModel {
id: string;
localeString?: string;
name: string;
[property: string]: any;
}
/**
* Document used on the page.
*/
interface Document {
/**
* @return The document id.
*/
getId(): string;
/**
* @return The document locale.
*/
getLocale(): string | undefined;
/**
* @return The document meta-data collection.
*/
getMeta(): MetaCollection;
/**
* @return The document name.
*/
getName(): string;
/**
* @return The document data.
*/
getData(): DocumentDataModel;
getData<T extends Record<string, any>>(): T & DocumentDataModel;
/**
* @return The link to the content.
*/
getUrl(): string | undefined;
}
/**
* Checks whether a value is a document.
* @param value The value to check.
*/
declare function isDocument(value: any): value is Document;
interface Image {
/**
* @return The image display name.
*/
getDisplayName(): string;
/**
* @return The image file name.
*/
getFileName(): string | undefined;
/**
* @return The image height.
*/
getHeight(): number;
/**
* @return The image mime-type.
*/
getMimeType(): string;
/**
* @return The image name.
*/
getName(): string;
/**
* @return The image size.
*/
getSize(): number;
/**
* @return The image link.
*/
getUrl(): string | undefined;
/**
* @return The image width.
*/
getWidth(): number;
}
interface ImageSet {
/**
* @return The image set description.
*/
getDescription(): string | undefined;
/**
* @return The image set display name.
*/
getDisplayName(): string;
/**
* @return The image set file name.
*/
getFileName(): string;
/**
* @return The image set id.
*/
getId(): string;
/**
* @return The image set locale.
*/
getLocale(): string | undefined;
/**
* @return The image name.
*/
getName(): string;
/**
* @return The original image.
*/
getOriginal(): Image | undefined;
/**
* @return The thumbnail.
*/
getThumbnail(): Image | undefined;
}
/**
* Checks whether a value is an image set.
* @param value The value to check.
*/
declare function isImageSet(value: unknown): value is ImageSet;
interface MetaComment extends Meta {
}
/**
* Checks whether a value is a meta-data comment.
* @param value The value to check.
*/
declare function isMetaComment(value: any): value is MetaComment;
/**
* Checks whether a value is a page component.
* @param value The value to check.
*/
declare function isComponent(value: any): value is Component;
/**
* Checks whether a value is a page container.
* @param value The value to check.
*/
declare function isContainer(value: any): value is Container;
/**
* Checks whether a value is a page container item.
* @param value The value to check.
*/
declare function isContainerItem(value: any): value is ContainerItem;
/**
* Checks whether a value is a page.
* @param value The value to check.
*/
declare function isPage(value: any): value is Page;
/**
* Model of a page.
*/
declare type PageModel$2 = PageModel | PageModel$1;
/**
* Menu content model.
*/
declare type Menu$2 = Menu$1 | Menu$1 & Menu;
/**
* Fetches the page model data.
*/
declare type HttpClient<T> = (config: HttpClientConfig) => Promise<HttpResponse<T>>;
/**
* Configuration of an HTTP client call.
*/
declare type HttpClientConfig = {
/**
* HTTP request method.
*/
method: 'GET' | 'POST';
/**
* The URL to send the HTTP request to.
*/
url: string;
/**
* Optional: the headers to send with the HTTP request.
*/
headers?: HttpHeaders;
/**
* Optional: the data to send with the HTTP request.
* Will only be provided when the 'method' is 'post'.
*/
data?: any;
};
/**
* Map of HTTP headers.
*/
declare type HttpHeaders = Partial<Record<string, string | string[]>>;
/**
* An HTTP connection.
*/
interface HttpConnection {
/**
* Client's remote IP address.
*/
remoteAddress?: string;
}
/**
* An HTTP request
*/
interface HttpRequest {
/**
* HTTP connection data.
*/
connection?: HttpConnection;
/**
* All request headers (including cookies).
*/
headers?: HttpHeaders;
/**
* The path part of the URL, including a query string if present.
* For example: '/path/to/page?foo=1'. The path always starts with '/'.
*/
path: string;
}
/**
* An HTTP response.
*/
interface HttpResponse<T> {
/**
* The data returned in the response.
*/
data: T;
}
interface ApiOptions {
/**
* API version header.
* By default, `Accept-Version` will be used.
*/
apiVersionHeader?: string;
/**
* Current API version.
* By default, the compatible with the current setup version will be chosen.
*/
apiVersion?: string;
/**
* Authorization header.
* By default, `Authorization` will be used.
*/
authorizationHeader?: string;
/**
* Authorization token.
* By default, the SDK will try to extract the token from the request query string
* using `authorizationQueryParameter` option.
*/
authorizationToken?: string;
/**
* HTTP client that will be used to fetch the page model.
*/
httpClient: HttpClient<PageModel$2>;
/**
* Current user's request.
*/
request: HttpRequest;
/**
* Header identifying the current cluster node.
* By default, `Server-Id` will be used.
*/
serverIdHeader?: string;
/**
* Cluster node identifier.
* By default, the SDK will try to extract the value from the request query string
* using `serverIdQueryParameter` option.
*/
serverId?: string;
/**
* Current visitor.
*/
visitor?: Omit<Visitor, 'new'>;
}
interface CmsOptions {
/**
* The window reference for the CMS integration.
* By default the global window object will be used.
*/
window?: Window;
}
interface PostMessageOptions {
/**
* The brXM origin to verify an integration with the Experience Manager.
* This option should be used when the brXM is accessible from a host other than the Page Model API.
* By default, the origin from the `apiBaseUrl` or `endpoint` parameters is used.
*/
origin?: string;
/**
* The window reference for the CMS integration.
* By default the global window object will be used.
*/
window?: Window;
}
/**
* Configuration options for generating the page model URL.
*/
interface UrlOptions {
/**
* URL mapping for the live page model.
*/
live: UrlBuilderOptions$1;
/**
* URL mapping for the preview page model.
*/
preview: UrlBuilderOptions$1;
}
/**
* Configuration of the SPA SDK using reverse proxy-based setup.
*/
interface ConfigurationWithProxy extends ApiOptions, CmsOptions {
/**
* Options for generating the page model API URL.
*/
options: UrlOptions;
}
/**
* Configuration of the SPA SDK using the JWT token-based setup.
*/
interface ConfigurationWithJwt extends ApiOptions, CmsOptions, PostMessageOptions {
/**
* The query string parameter used to pass authorization header value.
* By default, `token` parameter is used.
*/
authorizationQueryParameter?: string;
/**
* The query string parameter used to pass a cluster node identifier.
* By default, `server-id` parameter is used.
*/
serverIdQueryParameter?: string;
}
/**
* Configuration of the SPA SDK using the JWT token-based setup and the Page Model API v0.9.
*/
interface ConfigurationWithJwt09 extends ConfigurationWithJwt, UrlBuilderOptions$1 {
}
/**
* Configuration of the SPA SDK using the JWT token-based setup and the Page Model API v1.0.
*/
interface ConfigurationWithJwt10 extends ConfigurationWithJwt, UrlBuilderOptions {
/**
* The query string parameter used as the brXM endpoint (`cmsBaseUrl`).
* The option will be ignored if the `cmsBaseUrl` option is not empty.
* In case when this option is used, the `apiBaseUrl` will be prepended with the value from the query parameter.
* This option should be used only for testing or debugging.
* By default, the option is disabled.
*/
endpointQueryParameter?: string;
}
/**
* Configuration of the SPA SDK.
*/
declare type Configuration = ConfigurationWithProxy | ConfigurationWithJwt09 | ConfigurationWithJwt10;
/**
* Initializes the page model.
*
* @param config Configuration of the SPA integration with brXM.
* @param configuration Configuration of the SPA integration with brXM.
* @param model Preloaded page model.
*/
export declare function initialize(config: Configuration, model?: PageModel): Promise<Page>;
declare function initialize(configuration: Configuration, model: Page | PageModel$2): Page;
/**
* Initializes the page model.
*
* @param configuration Configuration of the SPA integration with brXM.
*/
declare function initialize(configuration: Configuration): Promise<Page>;
/**
* Destroys the integration with the SPA page.
* @param page Page instance to destroy.
*/
export declare function destroy(page: Page): void;
export { Configuration } from './configuration';
export { Component, ContainerItem, Container, Content, Link, Menu, MetaCollection, MetaComment, Meta, PageModel, Page, Reference, isComponent, isContainerItem, isContainer, isLink, isMetaComment, isMeta, isPage, isReference, META_POSITION_BEGIN, META_POSITION_END, TYPE_CONTAINER_BOX, TYPE_CONTAINER_INLINE, TYPE_CONTAINER_NO_MARKUP, TYPE_CONTAINER_ORDERED_LIST, TYPE_CONTAINER_UNORDERED_LIST, TYPE_LINK_EXTERNAL, TYPE_LINK_INTERNAL, TYPE_LINK_RESOURCE, } from './page';
declare function destroy(page: Page): void;
export { Component, Configuration, Container, ContainerItem, Content, Document, Image, ImageSet, Link, META_POSITION_BEGIN, META_POSITION_END, Menu$2 as Menu, MenuItem, Meta, MetaCollection, MetaComment, Page, PageModel$2 as PageModel, Reference, TYPE_CONTAINER_BOX, TYPE_CONTAINER_INLINE, TYPE_CONTAINER_NO_MARKUP, TYPE_CONTAINER_ORDERED_LIST, TYPE_CONTAINER_UNORDERED_LIST, TYPE_LINK_EXTERNAL, TYPE_LINK_INTERNAL, TYPE_LINK_RESOURCE, destroy, initialize, isComponent, isContainer, isContainerItem, isContent, isDocument, isImageSet, isLink, isMenu, isMeta, isMetaComment, isPage, isReference };

26

package.json
{
"name": "@bloomreach/spa-sdk",
"version": "14.2.2",
"version": "14.3.0",
"description": "Bloomreach SPA SDK",

@@ -23,3 +23,3 @@ "keywords": [

"module": "dist/index.mjs",
"es2015": "dist/index.es6.mjs",
"es2015": "dist/index.es6.js",
"types": "dist/index.d.ts",

@@ -31,3 +31,3 @@ "files": [

"build": "rollup -c rollup.config.js",
"docs": "tsc --emitDeclarationOnly && dts-bundle-generator --out-file dist/spa-sdk.d.ts dist/index.d.ts && typedoc dist/spa-sdk.d.ts && minicat src/docs/typedoc.css >> docs/assets/css/main.css && rm dist/spa-sdk.d.ts",
"docs": "typedoc",
"lint": "tslint --project .",

@@ -39,4 +39,15 @@ "prepare": "$npm_execpath run build",

"preset": "ts-jest",
"reporters": [
"default",
"jest-junit"
],
"setupFiles": [
"reflect-metadata"
],
"testEnvironment": "jsdom"
},
"jest-junit": {
"outputDirectory": "coverage",
"outputName": "TEST-spa-sdk.xml"
},
"browserslist": [

@@ -58,8 +69,8 @@ "last 1 chrome version",

"babel-plugin-transform-async-to-promises": "^0.8",
"dts-bundle-generator": "^4.3",
"jest": "^26.0",
"jest-junit": "^11.1",
"js-beautify": "^1.11",
"minicat": "^1.0",
"rollup": "^2.10",
"rollup-plugin-babel": "^4.4",
"rollup-plugin-dts": "^1.4",
"rollup-plugin-terser": "^5.3",

@@ -71,2 +82,3 @@ "rollup-plugin-typescript2": "^0.27",

"typedoc": "^0.17",
"typedoc-plugin-external-module-map": "^1.2",
"typescript": "^3.8"

@@ -76,4 +88,6 @@ },

"emittery": "^0.7",
"inversify": "^5.0",
"reflect-metadata": "^0.1",
"xmldom": "^0.3"
}
}
}

@@ -54,6 +54,14 @@ # Bloomreach SPA SDK

--- | :---: | --- | ---
`apiVersion` | no | _none_ | Current API version. By default, the compatible with the current setup version will be chosen.
`apiVersionHeader` | `"Accept-Version"` | _none_ | API version header.
`apiBaseUrl` | no | `cmsBaseUrl` + `"/resourceapi"` | Base URL of the Page Model API (e.g. `http://localhost:8080/site/resourceapi` or `http://localhost:8080/site/channel/resourceapi`). This option will be ignored if `options` is present.
`cmsBaseUrl` | _exclusive_ | _none_ | Base URL of the site (e.g. `http://localhost:8080/site` or `http://localhost:8080/site/channel`). This option is exclusive and should not be used together with `options`.
`authorizationHeader` | no | `"Authorization"` | Authorization header for the Page Model API.
`authorizationQueryParameter` | no | `"token"` | The query string parameter used to pass authorization header value.
`authorizationToken` | no | _none_ | Authorization token for the Page Model API. By default, the SDK will try to extract the token from the request query string using `authorizationQueryParameter` option.
`baseUrl` | no | `""` | Base URL of the SPA (e.g. `/account` or `//www.example.com`). This option can only be used if `endpoint` is present.
`endpoint` | _exclusive_ | _none_ | Base URL of the Page Model API (e.g. `http://localhost:8080/site/resourceapi` or `http://localhost:8080/site/channel/resourceapi`). This option is exclusive and should not be used together with `options` or `cmsBaseUrl`.
`endpointQueryParameter` | no | _none_ | The query string parameter used as the brXM endpoint (`cmsBaseUrl`). The option will be ignored if the `cmsBaseUrl` option is not empty. In case when this option is used, the `apiBaseUrl` will be prepended with the value from the query parameter. This option should be used only for testing or debugging. By default, the option is disabled.
`cmsBaseUrl` | _exclusive_ | _none_ | Base URL of the site (e.g. `http://localhost:8080/site` or `http://localhost:8080/site/channel`). This option is exclusive and should not be used together with `options` or `endpoint`.
`httpClient` | yes | _none_ | The HTTP client that will be used to fetch the page model. Signature is similar to [Axios](https://github.com/axios/axios#axiosconfig) client.
`options` | _exclusive_ | _none_ | The CMS URL options. This option is exclusive and should not be used together with `cmsBaseUrl`. Use this property to enable the UrlRewriter-based setup. The option is **deprecated** and will be removed in the next major release.
`options` | _exclusive_ | _none_ | The CMS URL options. This option is exclusive and should not be used together with `cmsBaseUrl` or `endpoint`. Use this property to enable the UrlRewriter-based setup. The option is **deprecated** and will be removed in the next major release.
`options.live` | yes | _none_ | The CMS URL options for the live site.

@@ -67,5 +75,10 @@ `options.live.apiBaseUrl` | no | `options.live.cmsBaseUrl` + `"/resourceapi"` | Base URL of the Page Model API for the live site (e.g. `http://localhost:8080/site/resourceapi` or `http://localhost:8080/site/channel/resourceapi`).

`options.preview.spaBaseUrl` | no | `""` | Base URL of the live SPA (e.g. `/site/_cmsinternal?bloomreach-preview=true` or `/site/_cmsinternal/channel?bloomreach-preview=true`). This path and query string parameters will be used to detect whether it is a preview mode or not.
`origin` | no | _none_ | The brXM origin to verify an integration with the Experience Manager. This option should be used when the brXM is accessible from a host other than the Page Model API. By default, the origin from the `apiBaseUrl` or `endpoint` parameters is used.
`request` | yes | _none_ | Current user's request.
`request.connection` | no | _none_ | Current request remote connection containing the remote address. This option is used in [the Relevance Module](https://documentation.bloomreach.com/14/library/enterprise/enterprise-features/targeting/targeting.html).
`request.headers` | no | `{}` | An object holding request headers. It should contain a `Cookie` header if rendering is happening on the server-side in the UrlRewriter-based setup.
`request.path` | yes | _none_ | The path part of the URL, including a query string if present (e.g. `/path/to/page?foo=1`).
`request.headers` | no | `{}` | An object holding request headers. It should contain a `Cookie` header if rendering is happening on the server-side.
`serverId` | no | _none_ | Cluster node identifier. By default, the SDK will try to extract the value from the request query string using `serverIdQueryParameter` option.
`serverIdHeader` | no | `"Server-Id"` | Header identifying the current cluster node.
`serverIdQueryParameter` | no | `"server-id"` | The query string parameter used to pass a cluster node identifier.
`spaBaseUrl` | no | `""` | Base URL of the SPA (e.g. `/account` or `//www.example.com`). This option will be ignored if `options` is present.

@@ -89,2 +102,6 @@ `visitor` | no | _none_ | An object holding information about the current visitor.

`isContainerItem(value): boolean` | Checks whether a value is a page container item.
`isContent(value): boolean` | Checks whether a value is a content object.
`isDocument(value): boolean` | Checks whether a value is a document object.
`isImageSet(value): boolean` | Checks whether a value is an image set object.
`isMenu(value): boolean` | Checks whether a value is a menu object.
`isMeta(value): boolean` | Checks whether a value is a meta-data object.

@@ -116,7 +133,9 @@ `isMetaComment(value): boolean` | Checks whether a value is a meta-data comment.

<code>getComponent(...componentNames): Component &vert; undefined</code> | Gets a component in the page (e.g. `getComponent('main', 'right')`). If `componentNames` is omitted, then the page root component will be returned.
<code>getContent(reference: Reference &vert; string): Content &vert; undefined</code> | Gets a content item used on the page.
<code>getContent<T>(reference: Reference &vert; string): Content &vert; T &vert; undefined</code> | Gets a content item used on the page.
<code>getDocument<T>(): T &vert; undefined</code> | Gets the page root document. This option is available only along with the Experience Pages feature.
`getMeta(meta): MetaCollection` | Generates a meta-data collection from the provided `meta` model.
<code>getTitle(): string &vert; undefined</code> | Gets the title of the page, or `undefined` if not configured.
`getUrl(link?: Link): string` | Generates a URL for a link object.<br> - If the link object type is internal, then it will prepend `spaBaseUrl`. In case when the link starts with the same path as in `cmsBaseUrl`, this part will be removed.<br> - If the link parameter is omitted, then the link to the current page will be returned.<br> - In other cases, the link will be returned as-is.
`getUrl(path: string): string` | Generates an SPA URL for the path.<br> - If it is a relative path, then it will prepend `spaBaseUrl`.<br> - If it is an absolute path, then the behavior will be similar to internal link generation.
`getUrl(link?: Link): string` | Generates a URL for a link object.<br> - If the link object type is internal, then it will prepend `spaBaseUrl` or `baseUrl`. In case when the link starts with the same path as in `cmsBaseUrl`, this part will be removed.<br> - If the link parameter is omitted, then the link to the current page will be returned.<br> - In other cases, the link will be returned as-is.
`getUrl(path: string): string` | Generates an SPA URL for the path.<br> - If it is a relative path and `cmsBaseUrl` is present, then it will prepend `spaBaseUrl`.<br> - If it is an absolute path and `cmsBaseUrl` is present, then the behavior will be similar to internal link generation.<br> - If it is a relative path and `endpoint` is present, then it will resolve this link relative to the current page URL.<br> - If it is an absolute path and `endpoint` is present, then it will resolve this link relative to the `baseUrl` option.
<code> getVersion(): string &vert; undefined</code> | Returns the Page Model version.
<code>getVisitor(): Visitor &vert; undefined</code> | Gets the current visitor information, or undefined if the [Relevance Module](https://documentation.bloomreach.com/library/enterprise/enterprise-features/targeting/targeting.html) is not enabled. The `Visitor` object consists of the following properties:<br> - `id: string` - the current visitor identifier;<br> - `header: string` - an HTTP-header using to pass the visitor identifier to the Page Model API.

@@ -173,2 +192,67 @@ <code>getVisit(): Visit &vert; undefined</code> | Gets the current visit information, or undefined if the [Relevance Module](https://documentation.bloomreach.com/library/enterprise/enterprise-features/targeting/targeting.html) is not enabled. The `Visit` object consists of the following properties:<br> - `id: string` - the current visit identifier;<br> - `new: boolean` - a flag showing that this is a new visit.

##### Document
The `Document` object holds document data that is used by the page components.
Method | Description
--- | ---
`getId(): string` | Returns the document id.
<code>getLocale(): string &vert; undefined</code> | Returns the document locale.
`getMeta(): MetaCollection` | Returns the document meta-data collection.
`getName(): string` | Returns the document name.
`getData(): object` | Returns the document data as it is returned in the Page Model API.
<code>getUrl(): string &vert; undefined</code> | Returns the link to the content.
##### ImageSet
The `ImageSet` object holds images collection that is used by the page components.
Method | Description
--- | ---
<code>getDescription(): string &vert; undefined;</code> | Returns the image set description.
`getDisplayName(): string` | Returns the image set display name.
`getId(): string` | Returns the document id.
`getFileName(): string` | Returns the image set file name.
`getId(): string` | Returns the image set id.
`getLocale(): string | undefined` | Returns the image set locale.
`getName(): string` | Returns the image name.
<code>getOriginal(): Image &vert; undefined</code> | Returns the original image.
<code>getThumbnail(): Image &vert; undefined</code> | Returns the thumbnail.
##### Image
The `Image` object holds an image object that is used by the `ImageSet` object.
Method | Description
--- | ---
`getDisplayName(): string` | Returns the image display name.
<code>getFileName(): string &vert; undefined</code> | Returns the image file name.
`getHeight(): number` | Returns the image height.
`getMimeType(): string` | Returns the image mime-type.
`getName(): string` | Returns the image name.
`getSize(): number` | Returns the image size.
<code>getUrl(): string &vert; undefined</code> | Returns the image link.
`getWidth(): number` | Returns the image width.
##### Menu
The `Menu` object holds the page menu data with all the menu items.
Method | Description
--- | ---
`getItems(): MenuItem[]` | Returns the menu items.
`getMeta(): MetaCollection` | Returns the menu meta-data collection.
<code>getSelected(): MenuItem &vert; undefined</code> | Returns the current menu item.
##### MenuItem
The `MenuItem` object holds a menu item that is used by the `Menu` object.
Method | Description
--- | ---
`getChildren(): MenuItem[]` | Returns the child items.
`getDepth(): number` | Returns the menu item depth level.
<code>getLink(): Link &vert; undefined</code> | Returns the menu item link.
`getName(): string` | Returns the menu item name.
`getParameters(): object` | Returns the menu item parameters.
<code>getUrl(): string &vert; undefined</code> | Returns the menu item url.
`isExpanded(): boolean` | Returns whether the menu item is expanded.
`isRepositoryBased(): boolean` | Returns whether the menu item is repository based.
`isSelected(): boolean` | Returns whether the menu item is selected.
##### MetaCollection

@@ -175,0 +259,0 @@ Method | Description

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc