New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@bloomreach/spa-sdk

Package Overview
Dependencies
Maintainers
34
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.7.0-ENT-2422 to 15.0.0

160

lib/index.d.ts

@@ -103,12 +103,12 @@ /**

*/
declare const TYPE_COMPONENT = "component";
declare const TYPE_COMPONENT$1 = "component";
/**
* Container item type.
* Container type.
*/
declare const TYPE_COMPONENT_CONTAINER_ITEM = "container-item";
declare const TYPE_COMPONENT_CONTAINER$1 = "container";
/**
* Container type.
* Container item type.
*/
declare const TYPE_COMPONENT_CONTAINER = "container";
declare type ComponentType = typeof TYPE_COMPONENT | typeof TYPE_COMPONENT_CONTAINER_ITEM | typeof TYPE_COMPONENT_CONTAINER;
declare const TYPE_COMPONENT_CONTAINER_ITEM$1 = "container-item";
declare type ComponentType$1 = typeof TYPE_COMPONENT$1 | typeof TYPE_COMPONENT_CONTAINER_ITEM$1 | typeof TYPE_COMPONENT_CONTAINER$1;
/**

@@ -120,4 +120,4 @@ * Meta-data of a component.

}
declare type ComponentLinks = 'self';
declare type ComponentModels = Record<string, any>;
declare type ComponentLinks$1 = 'self';
declare type ComponentModels$1 = Record<string, any>;
declare type ComponentParameters = Record<string, any>;

@@ -127,10 +127,10 @@ /**

*/
interface ComponentModel {
interface ComponentModel$1 {
children?: Reference[];
id: string;
links: Record<ComponentLinks, Link>;
links: Record<ComponentLinks$1, Link>;
meta: ComponentMeta;
models?: ComponentModels;
models?: ComponentModels$1;
name?: string;
type: ComponentType;
type: ComponentType$1;
}

@@ -152,3 +152,3 @@ /**

*/
getModels<T extends ComponentModels>(): T;
getModels<T extends ComponentModels$1>(): T;
/**

@@ -210,3 +210,3 @@ * @return The link to the partial component model.

interface ContentModel {
interface ContentModel$1 {
type: string;

@@ -219,3 +219,3 @@ }

*/
interface ContentModel$1 {
interface ContentModel {
_links: Record<ContentLinks, Link>;

@@ -251,4 +251,4 @@ _meta?: MetaCollectionModel;

*/
getData(): ContentModel$1;
getData<T extends Record<string, any>>(): T & ContentModel$1;
getData(): ContentModel;
getData<T extends Record<string, any>>(): T & ContentModel;
/**

@@ -364,7 +364,7 @@ * @return The link to the content.

interface MenuItem {
interface MenuItem$1 {
/**
* @return The child items.
*/
getChildren(): MenuItem[];
getChildren(): MenuItem$1[];
/**

@@ -408,7 +408,7 @@ * @return The menu item depth level.

declare const TYPE_MANAGE_MENU_BUTTON = "EDIT_MENU_LINK";
interface Menu {
interface Menu$2 {
/**
* @return The menu items.
*/
getItems(): MenuItem[];
getItems(): MenuItem$1[];
/**

@@ -426,3 +426,3 @@ * @return The menu meta-data collection.

*/
getSelected(): MenuItem | undefined;
getSelected(): MenuItem$1 | undefined;
}

@@ -433,3 +433,3 @@ /**

*/
declare function isMenu(value: unknown): value is Menu;
declare function isMenu(value: unknown): value is Menu$2;

@@ -486,3 +486,3 @@ /**

*/
interface PageRootMeta extends ComponentMeta {
interface PageRootMeta$1 extends ComponentMeta {
pageTitle?: string;

@@ -493,4 +493,4 @@ }

*/
interface PageRootModel {
meta: PageRootMeta;
interface PageRootModel$1 {
meta: PageRootMeta$1;
}

@@ -523,3 +523,3 @@ /**

*/
interface PageModel {
interface PageModel$2 {
channel: ChannelModel;

@@ -529,3 +529,3 @@ document?: Reference;

meta: PageMeta;
page: Record<string, (ComponentModel | ContainerItemModel | ContainerModel) & PageRootModel | ContentModel>;
page: Record<string, (ComponentModel$1 | ContainerItemModel$1 | ContainerModel$1) & PageRootModel$1 | ContentModel$1>;
root: Reference;

@@ -546,3 +546,3 @@ }

*/
getButton(type: typeof TYPE_MANAGE_MENU_BUTTON, menu: Menu): MetaCollection;
getButton(type: typeof TYPE_MANAGE_MENU_BUTTON, menu: Menu$2): MetaCollection;
/**

@@ -673,7 +673,8 @@ * Generates a meta-data collection for the Experience Manager buttons.

*/
interface ContainerItemModel extends ComponentModel {
interface ContainerItemModel$1 extends ComponentModel$1 {
content?: Reference;
ctype?: string;
label?: string;
meta: ContainerItemMeta;
type: typeof TYPE_COMPONENT_CONTAINER_ITEM;
type: typeof TYPE_COMPONENT_CONTAINER_ITEM$1;
}

@@ -712,3 +713,15 @@ /**

isHidden(): boolean;
/**
* Returns a [RFC-6901](https://tools.ietf.org/html/rfc6901) JSON Pointer
* to the content of this container item.
*/
getContentReference(): Reference | undefined;
}
/**
* Returns the content of this component.
*
* @param component The component that references the content
* @param page The page that contains the content
*/
declare function getContainerItemContent<T>(component: ContainerItem, page: Page): T | null;

@@ -743,4 +756,4 @@ /**

*/
interface ContainerModel extends ComponentModel {
type: typeof TYPE_COMPONENT_CONTAINER;
interface ContainerModel$1 extends ComponentModel$1 {
type: typeof TYPE_COMPONENT_CONTAINER$1;
xtype?: ContainerType;

@@ -775,4 +788,4 @@ }

*/
selectSiteMenuItem?: MenuItem$1 | null;
siteMenuItems: MenuItem$1[];
selectSiteMenuItem?: MenuItem | null;
siteMenuItems: MenuItem[];
}

@@ -782,4 +795,4 @@ /**

*/
interface MenuItem$1 {
childMenuItems: MenuItem$1[];
interface MenuItem {
childMenuItems: MenuItem[];
depth: number;

@@ -797,3 +810,3 @@ expanded: boolean;

*/
interface UrlBuilderOptions {
interface UrlBuilderOptions$1 {
/**

@@ -813,3 +826,3 @@ * Base URL to fetch the page model from.

*/
interface UrlBuilderOptions$1 {
interface UrlBuilderOptions {
/**

@@ -834,25 +847,25 @@ * Base URL to fetch the page model from.

*/
declare const TYPE_COMPONENT$1 = "COMPONENT";
declare const TYPE_COMPONENT = "COMPONENT";
/**
* Container item type.
*/
declare const TYPE_COMPONENT_CONTAINER_ITEM$1 = "CONTAINER_ITEM_COMPONENT";
declare const TYPE_COMPONENT_CONTAINER_ITEM = "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>;
declare const TYPE_COMPONENT_CONTAINER = "CONTAINER_COMPONENT";
declare type ComponentType = typeof TYPE_COMPONENT | typeof TYPE_COMPONENT_CONTAINER_ITEM | typeof TYPE_COMPONENT_CONTAINER;
declare type ComponentLinks = 'componentRendering';
declare type ComponentModels = Record<string, any>;
/**
* Model of a component.
*/
interface ComponentModel$1 {
_links: Record<ComponentLinks$1, Link>;
interface ComponentModel {
_links: Record<ComponentLinks, Link>;
_meta: ComponentMeta;
id: string;
models?: ComponentModels$1;
models?: ComponentModels;
name?: string;
type: ComponentType$1;
components?: ComponentModel$1[];
type: ComponentType;
components?: ComponentModel[];
}

@@ -863,7 +876,7 @@

*/
interface ContainerItemModel$1 extends ComponentModel$1 {
interface ContainerItemModel extends ComponentModel {
_meta: ContainerItemMeta;
ctype?: string;
label?: string;
type: typeof TYPE_COMPONENT_CONTAINER_ITEM$1;
type: typeof TYPE_COMPONENT_CONTAINER_ITEM;
}

@@ -874,4 +887,4 @@

*/
interface ContainerModel$1 extends ComponentModel$1 {
type: typeof TYPE_COMPONENT_CONTAINER$1;
interface ContainerModel extends ComponentModel {
type: typeof TYPE_COMPONENT_CONTAINER;
xtype?: ContainerType;

@@ -883,3 +896,3 @@ }

*/
interface PageRootMeta$1 extends ComponentMeta {
interface PageRootMeta extends ComponentMeta {
pageTitle?: string;

@@ -890,4 +903,4 @@ }

*/
interface PageRootModel$1 {
_meta: PageRootMeta$1;
interface PageRootModel {
_meta: PageRootMeta;
}

@@ -898,9 +911,9 @@ /**

interface PageModel$1 {
_links: PageModel['links'];
_meta: PageModel['meta'];
channel?: PageModel['channel'];
_links: PageModel$2['links'];
_meta: PageModel$2['meta'];
channel?: PageModel$2['channel'];
content?: {
[reference: string]: ContentModel$1;
[reference: string]: ContentModel;
};
page: (ComponentModel$1 | ContainerItemModel$1 | ContainerModel$1) & PageRootModel$1;
page: (ComponentModel | ContainerItemModel | ContainerModel) & PageRootModel;
}

@@ -1077,7 +1090,7 @@

*/
declare type PageModel$2 = PageModel | PageModel$1;
declare type PageModel = PageModel$2 | PageModel$1;
/**
* Menu content model.
*/
declare type Menu$2 = Menu$1 | Menu$1 & Menu;
declare type Menu = Menu$1 | Menu$1 & Menu$2;

@@ -1186,3 +1199,3 @@ /**

*/
httpClient: HttpClient<PageModel$2>;
httpClient: HttpClient<PageModel>;
/**

@@ -1217,7 +1230,7 @@ * Current user's request.

*/
live: UrlBuilderOptions$1;
live: UrlBuilderOptions;
/**
* URL mapping for the preview page model.
*/
preview: UrlBuilderOptions$1;
preview: UrlBuilderOptions;
}

@@ -1269,3 +1282,3 @@ /**

*/
interface ConfigurationWithJwt09 extends ConfigurationWithJwt, UrlBuilderOptions$1 {
interface ConfigurationWithJwt09 extends ConfigurationWithJwt, UrlBuilderOptions {
}

@@ -1275,3 +1288,3 @@ /**

*/
interface ConfigurationWithJwt10 extends ConfigurationWithJwt, UrlBuilderOptions {
interface ConfigurationWithJwt10 extends ConfigurationWithJwt, UrlBuilderOptions$1 {
/**

@@ -1292,2 +1305,7 @@ * The query string parameter used as the brXM endpoint (`cmsBaseUrl`).

/**
* Main entry point of the spa-sdk library.
* @module index
*/
/**
* Initializes the page model.

@@ -1298,3 +1316,3 @@ *

*/
declare function initialize(configuration: Configuration, model: Page | PageModel$2): Page;
declare function initialize(configuration: Configuration, model: Page | PageModel): Page;
/**

@@ -1312,2 +1330,2 @@ * Initializes the page model.

export { Component, Configuration, Container, ContainerItem, Content, Document, Image, ImageSet, Link, META_POSITION_BEGIN, META_POSITION_END, ManageContentButton, Menu$2 as Menu, MenuItem, Meta, MetaCollection, MetaComment, Page, PageModel$2 as PageModel, Pagination, PaginationItem, Reference, TYPE_CONTAINER_BOX, TYPE_CONTAINER_INLINE, TYPE_CONTAINER_ITEM_UNDEFINED, TYPE_CONTAINER_NO_MARKUP, TYPE_CONTAINER_ORDERED_LIST, TYPE_CONTAINER_UNORDERED_LIST, TYPE_LINK_EXTERNAL, TYPE_LINK_INTERNAL, TYPE_LINK_RESOURCE, TYPE_MANAGE_CONTENT_BUTTON, TYPE_MANAGE_MENU_BUTTON, destroy, initialize, isComponent, isContainer, isContainerItem, isContent, isDocument, isImageSet, isLink, isMenu, isMeta, isMetaComment, isPage, isPagination, isReference };
export { Component, Configuration, Container, ContainerItem, Content, Document, Image, ImageSet, Link, META_POSITION_BEGIN, META_POSITION_END, ManageContentButton, Menu, MenuItem$1 as MenuItem, Meta, MetaCollection, MetaComment, Page, PageModel, Pagination, PaginationItem, Reference, TYPE_CONTAINER_BOX, TYPE_CONTAINER_INLINE, TYPE_CONTAINER_ITEM_UNDEFINED, TYPE_CONTAINER_NO_MARKUP, TYPE_CONTAINER_ORDERED_LIST, TYPE_CONTAINER_UNORDERED_LIST, TYPE_LINK_EXTERNAL, TYPE_LINK_INTERNAL, TYPE_LINK_RESOURCE, TYPE_MANAGE_CONTENT_BUTTON, TYPE_MANAGE_MENU_BUTTON, destroy, getContainerItemContent, initialize, isComponent, isContainer, isContainerItem, isContent, isDocument, isImageSet, isLink, isMenu, isMeta, isMetaComment, isPage, isPagination, isReference };
{
"name": "@bloomreach/spa-sdk",
"version": "14.7.0-ENT-2422",
"version": "15.0.0",
"description": "Bloomreach SPA SDK",

@@ -12,9 +12,10 @@ "keywords": [

"license": "Apache-2.0",
"homepage": "https://www.bloomreach.com",
"repository": {
"type": "git",
"url": "https://github.com/bloomreach/brxm.git",
"directory": "spa-sdk/packages/spa-sdk"
"url": "https://github.com/bloomreach/spa-sdk",
"directory": "packages/spa-sdk"
},
"bugs": {
"url": "https://issues.onehippo.com/projects/CMS/issues"
"url": "https://issues.onehippo.com/projects/SPASDK/issues"
},

@@ -58,35 +59,35 @@ "main": "lib/index.js",

"devDependencies": {
"@babel/core": "^7.12",
"@babel/plugin-proposal-class-properties": "^7.12",
"@babel/plugin-proposal-object-rest-spread": "^7.12",
"@babel/plugin-transform-object-assign": "^7.12",
"@babel/polyfill": "^7.12",
"@babel/preset-env": "^7.12",
"@rollup/plugin-babel": "^5.2",
"@types/cookie": "^0.4",
"@types/jest": "^26.0",
"@types/node": "^14.14",
"@types/xmldom": "^0.1",
"babel-plugin-transform-async-to-promises": "^0.8",
"jest": "^26.6",
"jest-junit": "^12.0",
"js-beautify": "^1.13",
"rollup": "^2.32",
"rollup-plugin-dts": "^1.4",
"rollup-plugin-terser": "^7.0",
"rollup-plugin-typescript2": "^0.28",
"ts-jest": "^26.4",
"tslint": "^6.1",
"tslint-config-airbnb": "^5.11",
"typedoc": "^0.19",
"typedoc-plugin-external-module-map": "^1.2",
"typescript": "^4.0"
"@babel/core": "7.14.8",
"@babel/plugin-proposal-class-properties": "7.14.5",
"@babel/plugin-proposal-object-rest-spread": "7.14.7",
"@babel/plugin-transform-object-assign": "7.14.5",
"@babel/polyfill": "7.12.1",
"@babel/preset-env": "7.14.8",
"@rollup/plugin-babel": "5.3.0",
"@types/cookie": "0.4.1",
"@types/jest": "26.0.24",
"@types/node": "14.17.3",
"@types/xmldom": "0.1.31",
"babel-plugin-transform-async-to-promises": "0.8.15",
"jest": "26.6.3",
"jest-junit": "12.2.0",
"js-beautify": "1.14.0",
"rollup": "2.55.0",
"rollup-plugin-dts": "3.0.2",
"rollup-plugin-terser": "7.0.2",
"rollup-plugin-typescript2": "0.30.0",
"ts-jest": "26.5.6",
"tslint": "6.1.3",
"tslint-config-airbnb": "5.11.2",
"typedoc": "0.19.2",
"typedoc-plugin-external-module-map": "1.2.1",
"typescript": "4.1.6"
},
"dependencies": {
"cookie": "^0.4",
"emittery": "^0.7",
"inversify": "^5.0",
"reflect-metadata": "^0.1",
"xmldom": "^0.4"
"cookie": "0.4.1",
"emittery": "0.7.2",
"inversify": "5.1.1",
"reflect-metadata": "0.1.13",
"xmldom": "0.6.0"
}
}
# Bloomreach SPA SDK
[![NPM](https://img.shields.io/npm/v/@bloomreach/spa-sdk.svg)](https://www.npmjs.com/package/@bloomreach/spa-sdk)
[![License](https://img.shields.io/npm/l/@bloomreach/spa-sdk.svg)](http://www.apache.org/licenses/LICENSE-2.0)
Bloomreach SPA SDK provides simplified headless integration with [Bloomreach Experience Manager](https://www.bloomreach.com/en/products/experience-manager) for JavaScript-based applications.
This library interacts with the [Page Model API](https://documentation.bloomreach.com/library/concepts/page-model-api/introduction.html) and exposes a simplified and framework-agnostic interface over the page model.
Bloomreach SPA SDK provides simplified headless integration with [Bloomreach Experience Manager](https://www.bloomreach.com/en/products/experience-manager)
for JavaScript-based applications. This library interacts with the [Page Model API](https://documentation.bloomreach.com/library/concepts/page-model-api/introduction.html)
and exposes a simplified and framework-agnostic interface over the page model.
## What is Bloomreach Experience Manager?
Bloomreach Experience Manager (brXM) is an open and flexible CMS designed for developers and marketers. As the original headless CMS, brXM allows developers to build quickly and integrate with the systems. While it’s built for speed, it also provides top-notch personalization and channel management capabilities for marketers to drive results.
## Features
- [Page Model API](https://documentation.bloomreach.com/library/concepts/page-model-api/introduction.html) client;
- Page Model parser;
- URL generator;
- brXM integration.
- Page Model API Client
- Page Model Javascript implementation
- URL Generator
- Integration with Bloomreach Experience Manager Preview
## Get Started
### Installation
To get the SDK into your project with [NPM](https://docs.npmjs.com/cli/npm):
```bash

@@ -25,2 +25,3 @@ npm install @bloomreach/spa-sdk

And with [Yarn](https://yarnpkg.com):
```bash

@@ -31,16 +32,21 @@ yarn add @bloomreach/spa-sdk

### Usage
The following code snippet requests a related page model and shows the page's title.
```javascript
import axios from 'axios';
import { initialize } from '@bloomreach/spa-sdk';
import axios from "axios";
import { initialize } from "@bloomreach/spa-sdk";
async function showPage(path) {
const page = await initialize({
// The path to request from the Page Model API, should include query
// parameters if those are present in the url
path,
endpoint: 'http://localhost:8080/site/resourceapi',
// The location of the Page Model API of the brX channel
endpoint: "http://localhost:8080/delivery/site/v1/channels/brxsaas/pages",
// The httpClient used to make requests
httpClient: axios,
});
document.querySelector('#title').innerText = page.getTitle();
document.querySelector("#title").innerText = page.getTitle();
}

@@ -51,51 +57,13 @@

### Configuration
The `initialize` function supports several options you may use to customize page initialization.
### Relevance Integration
Option | Required | Default | Description
--- | :---: | --- | ---
`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.
`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.
`debug` | no | `false` | The option enabling debug mode.
`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` 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.
`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.live.cmsBaseUrl` | yes | _none_ | Base URL of the live site (e.g. `http://localhost:8080/site` or `http://localhost:8080/site/channel`).
`options.live.spaBaseUrl` | no | `""` | Base URL of the live SPA (e.g. `/account` or `//www.example.com`).
`options.preview` | yes | _none_ | The CMS URL options for the preview site.
`options.preview.apiBaseUrl` | no | `options.preview.cmsBaseUrl` + `"/resourceapi"` | Base URL of the Page Model API for the preview site (e.g. `http://localhost:8080/site/_cmsinternal/resourceapi` or `http://localhost:8080/site/_cmsinternal/channel/resourceapi`).
`options.preview.cmsBaseUrl` | yes | _none_ | Base URL of the live site (e.g. `http://localhost:8080/site/_cmsinternal` or `http://localhost:8080/site/_cmsinternal/channel`).
`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.
`path` | no | `/` | The path part of the URL, including a query string if present (e.g. `/path/to/page?foo=1`).
`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.emit` | no | _none_ | Emits an event in the request scope. This option can be used in [Node.js integration](https://nodejs.org/api/stream.html#stream_readable_streams).
`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` | no | `/` | The path part of the URL, including a query string if present (e.g. `/path/to/page?foo=1`). The option is **deprecated** in favor of `path`.
`request.visitor` | no | _none_ | An object holding information about the current visitor.
`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.
`visitor` | no | _none_ | An object holding information about the current visitor. The option takes precedence over `request.visitor`.
`visitor.id` | yes | _none_ | The current visitor identifier.
`visitor.header` | yes | _none_ | An HTTP-header using to pass the visitor identifier to the Page Model API.
`window` | no | `window` | A window object reference will be used to interact with brXM. It needs to be set when initialize is being called within an iframe or worker process.
(not applicable to Content SaaS)
### Relevance Integration
The SDK provides basic [Express middleware](https://expressjs.com/en/guide/using-middleware.html) for seamless integration with [the Relevance Module](https://documentation.bloomreach.com/14/library/enterprise/enterprise-features/targeting/targeting.html).
The SDK provides basic [Express
middleware](https://expressjs.com/en/guide/using-middleware.html) for seamless
integration with [the Relevance Module](https://documentation.bloomreach.com/14/library/enterprise/enterprise-features/targeting/targeting.html).
```javascript
import express from 'express';
import { relevance } from '@bloomreach/spa-sdk/lib/express';
import express from "express";
import { relevance } from "@bloomreach/spa-sdk/lib/express";

@@ -110,228 +78,290 @@ const app = express();

```javascript
app.use(relevance.withOptions({ name: '_visitor', maxAge: 24 * 60 * 60 }));
app.use(relevance.withOptions({ name: "_visitor", maxAge: 24 * 60 * 60 }));
```
### Reference
The complete API reference can be found [here](https://javadoc.onehippo.org/14.0/bloomreach-spa-sdk/).
## License
Published under [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0) license.
## Reference
#### Configuration
The `initialize` function supports several options you may use to customize page initialization.
| Commonly used options |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`debug`** <br> The option enabling debug mode. <br><br> Required: no <br> Default: `false` |
| **`endpoint`** <br> Base URL of the Page Model API (e.g. `http://localhost:8080/delivery/site/v1/channels/brxsaas/pages` or `http://localhost:8080/site/channel/resourceapi`). This option is exclusive and should not be used together with `options` or `cmsBaseUrl` <br><br> Required: yes <br> Default: . _none_ |
| **`httpClient`** <br> The HTTP client that will be used to fetch the page model. Signature is similar to [Axios](https://github.com/axios/axios#axiosconfig) client. <br><br> Required: yes <br> Default: _none_ |
| **`path`** <br> The path part of the URL, **including a query string if present (e.g. `/path/to/page?foo=1`** <br><br> Required: no <br> Default: ) `/` . |
| **`origin`** <br> 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. <br><br> Required: no <br> Default: _none_ |
| **`baseUrl`** <br> Base URL of the SPA (e.g. `/account` or `//www.example.com`). This option can only be used if `endpoint` is present. <br><br> Required: no <br> Default: `""` |
| **`apiBaseUrl`** <br> Base URL of the Page Model API (e.g. `http://localhost:8080/delivery/site/v1/channels/brxsaas/pages` or `http://localhost:8080/site/channel/resourceapi`). This option will be ignored if `options` is present. <br><br> Required: no <br> Default: `cmsBaseUrl` + `"/resourceapi"` |
| **`spaBaseUrl`** <br> Base URL of the SPA (e.g. `/account` or `//www.example.com`). This option will be ignored if `options` is present. <br><br> Required: no <br> Default: `""` |
| Extra options
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`apiVersion`** <br> Current API version. By default, the compatible with the current setup version will be chosen. <br><br> Required: no <br> Default: _none_ |
| **`apiVersionHeader`** <br> API version header. <br><br> Required: `"Accept-Version"` <br> Default: _none_ |
| **`authorizationHeader`** <br> Authorization header for the Page Model API. <br><br> Required: no <br> Default: `"Authorization"` |
| **`authorizationQueryParameter`** <br> The query string parameter used to pass authorization header value. <br><br> Required: no <br> Default: `"token"` |
| **`authorizationToken`** <br> 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. <br><br> Required: no <br> Default: _none_ |
| **`endpointQueryParameter`** <br> 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. <br><br> Required: no <br> Default: _none_ |
| **`serverId`** <br> Cluster node identifier. By default, the SDK will try to extract the value from the request query string using `serverIdQueryParameter` option. <br><br> Required: no <br> Default: _none_ |
| **`serverIdHeader`** <br> Header identifying the current cluster node. <br><br> Required: no <br> Default: `"Server-Id"` |
| **`serverIdQueryParameter`** <br> The query string parameter used to pass a cluster node identifier. <br><br> Required: no <br> Default: `"server-id"` |
| **`window`** <br> A window object reference will be used to interact with brXM. It needs to be set when initialize is being called within an iframe or worker process. <br><br> Required: no <br> Default: `window` |
| Relevance options (PaaS-only)
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------- |
| **`visitor`** <br> An object holding information about the current visitor. The option takes precedence over `request.visitor` <br><br> Required: no <br> Default: . _none_ |
| **`visitor.id`** <br> The current visitor identifier. <br><br> Required: yes <br> Default: _none_ |
| **`visitor.header`** <br> An HTTP-header using to pass the visitor identifier to the Page Model API. <br><br> Required: yes <br> Default: _none_ |
| **`request`** <br> Current user's request. <br><br> Required: yes <br> Default: _none_ |
| **`request.connection`** <br> 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) <br><br> Required: no <br> Default: . _none_ |
| **`request.emit`** <br> Emits an event in the request scope. This option can be used in [Node.js integration](https://nodejs.org/api/stream.html#stream_readable_streams) <br><br> Required: no <br> Default: . _none_ |
| **`request.headers`** <br> An object holding request headers. It should contain a `Cookie` header if rendering is happening on the server-side in the UrlRewriter-based setup. <br><br> Required: no <br> Default: `{}` |
| **`request.path`** <br> The path part of the URL, including a query string if present (e.g. `/path/to/page?foo=1`). The option is **deprecated** in favor of `path` <br><br> Required: no <br> Default: . `/` |
| **`request.visitor`** <br> An object holding information about the current visitor. <br><br> Required: no <br> Default: _none_ |
| These options are deprecated and will be removed in the next major release
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | ----------------------------------------------- |
| **`cmsBaseUrl`** <br> 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` <br><br> Required: _exclusive_ <br> Default: . _none_ |
| **`options`** <br> 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. <br><br> Required: _exclusive_ <br> Default: _none_ |
| **`options.live`** <br> The CMS URL options for the live site. <br><br> Required: yes <br> Default: _none_ |
| **`options.live.apiBaseUrl`** <br> Base URL of the Page Model API for the live site (e.g. `http://localhost:8080/delivery/site/v1/channels/brxsaas/pages` or `http://localhost:8080/site/channel/resourceapi` <br><br> Required: no <br> Default: ) `options.live.cmsBaseUrl` + `"/resourceapi"` . |
| **`options.live.cmsBaseUrl`** <br> Base URL of the live site (e.g. `http://localhost:8080/site` or `http://localhost:8080/site/channel` <br><br> Required: yes <br> Default: ) _none_ . |
| **`options.live.spaBaseUrl`** <br> Base URL of the live SPA (e.g. `/account` or `//www.example.com` <br><br> Required: no <br> Default: ) `""` . |
| **`options.preview`** <br> The CMS URL options for the preview site. <br><br> Required: yes <br> Default: _none_ |
| **`options.preview.apiBaseUrl`** <br> Base URL of the Page Model API for the preview site (e.g. `http://localhost:8080/site/_cmsinternal/resourceapi` or `http://localhost:8080/site/_cmsinternal/channel/resourceapi` <br><br> Required: no <br> Default: ) `options`<br>`.preview.cmsBaseUrl` <br>+ `"/resourceapi"` . |
| **`options.preview.cmsBaseUrl`** <br> Base URL of the live site (e.g. `http://localhost:8080/site/_cmsinternal` or `http://localhost:8080/site/_cmsinternal/channel` <br><br> Required: yes <br> Default: ) _none_ . |
| **`options.preview.spaBaseUrl`** <br> 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. <br><br> Required: no <br> Default: `""` |
#### Functions
Function | Description
--- | ---
`initialize(config, model?): Promise<Page>` | This function accepts a configuration object as an argument and returns a promisified JavaScript object representing the page model. In case, when the page model has already been fetched, you can pass this JSON blob as a second parameter.
`destroy(page: Page): void` | Destroys the integration with the SPA page object.
`isPage(value): boolean` | Checks whether a value is a page.
`isComponent(value): boolean` | Checks whether a value is a page component.
`isContainer(value): boolean` | Checks whether a value is a page container.
`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.
`isMetaComment(value): boolean` | Checks whether a value is a meta-data comment.
`isPagination(value): boolean` | Checks whether a value is a pagination.
`isLink(value): boolean` | Checks whether a value is a link.
`isReference(value): boolean` | Checks whether a value is a content reference.
`relevance(request: IncomingMessage, response: OutgoingMessage, next?: () => void): void` | Express middleware for seamless integration with [the Relevance Module](https://documentation.bloomreach.com/14/library/enterprise/enterprise-features/targeting/targeting.html).
`relevance.withOptions(options?: Options): Handler` | Customizes Express middleware for [the Relevance Module](https://documentation.bloomreach.com/14/library/enterprise/enterprise-features/targeting/targeting.html) integration.
| Function | Description |
| ----------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `initialize(config, model?): Promise<Page>` | This function accepts a configuration object as an argument and returns a promisified JavaScript object representing the page model. In case, when the page model has already been fetched, you can pass this JSON blob as a second parameter. |
| `destroy(page: Page): void` | Destroys the integration with the SPA page object. |
| `isPage(value): boolean` | Checks whether a value is a page. |
| `isComponent(value): boolean` | Checks whether a value is a page component. |
| `isContainer(value): boolean` | Checks whether a value is a page container. |
| `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. |
| `isMetaComment(value): boolean` | Checks whether a value is a meta-data comment. |
| `isPagination(value): boolean` | Checks whether a value is a pagination. |
| `isLink(value): boolean` | Checks whether a value is a link. |
| `isReference(value): boolean` | Checks whether a value is a content reference. |
| `relevance(request: IncomingMessage, response: OutgoingMessage, next?: () => void): void` | Express middleware for seamless integration with [the Relevance Module](https://documentation.bloomreach.com/14/library/enterprise/enterprise-features/targeting/targeting.html). |
| `relevance.withOptions(options?: Options): Handler` | Customizes Express middleware for [the Relevance Module](https://documentation.bloomreach.com/14/library/enterprise/enterprise-features/targeting/targeting.html) integration. |
#### Constants
Constant | Description
--- | ---
`META_POSITION_BEGIN` | Meta-data following before a page component.
`META_POSITION_END` | Meta-data following after a page component.
`TYPE_CONTAINER_BOX` | A blocked container with blocked items.
`TYPE_CONTAINER_INLINE` | A blocked container with inline items.
`TYPE_CONTAINER_NO_MARKUP` | A container without surrounding markup.
`TYPE_CONTAINER_ORDERED_LIST` | An ordered list container.
`TYPE_CONTAINER_UNORDERED_LIST` | An unordered list container.
`TYPE_CONTAINER_ITEM_UNDEFINED` | A container item without mapping.
`TYPE_LINK_EXTERNAL` | Link to a page outside the current application.
`TYPE_LINK_INTERNAL` | Link to a page inside the current application.
`TYPE_LINK_RESOURCE` | Link to a CMS resource.
`TYPE_MANAGE_MENU_BUTTON` | A manage menu button.
`TYPE_MANAGE_CONTENT_BUTTON` | A manage content button.
| Constant | Description |
| ------------------------------- | ----------------------------------------------- |
| `META_POSITION_BEGIN` | Meta-data following before a page component. |
| `META_POSITION_END` | Meta-data following after a page component. |
| `TYPE_CONTAINER_BOX` | A blocked container with blocked items. |
| `TYPE_CONTAINER_INLINE` | A blocked container with inline items. |
| `TYPE_CONTAINER_NO_MARKUP` | A container without surrounding markup. |
| `TYPE_CONTAINER_ORDERED_LIST` | An ordered list container. |
| `TYPE_CONTAINER_UNORDERED_LIST` | An unordered list container. |
| `TYPE_CONTAINER_ITEM_UNDEFINED` | A container item without mapping. |
| `TYPE_LINK_EXTERNAL` | Link to a page outside the current application. |
| `TYPE_LINK_INTERNAL` | Link to a page inside the current application. |
| `TYPE_LINK_RESOURCE` | Link to a CMS resource. |
| `TYPE_MANAGE_MENU_BUTTON` | A manage menu button. |
| `TYPE_MANAGE_CONTENT_BUTTON` | A manage content button. |
#### Objects
##### Page
The `Page` class represents the brXM page to render. This is the main entry point to the page model.
Method | Description
--- | ---
`getButton(type: string, ...params: any[]): MetaCollection` | Generates a meta-data collection for the Experience Manager buttons.
`getChannelParameters(): object` | Gets current channel parameters.
<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<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. The method is **deprecated** and will be removed in the next major release.
<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` or `baseUrl`. In case when the link starts with the same path as in `cmsBaseUrl`, this part will be removed.<br> - If the link object type is unknown, then it will return `undefined`.<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.
<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.
`isPreview(): boolean` | Returns whether the page is in the preview mode.
`rewriteLinks(content: string, type?: string): string` | 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. The `type` parameter is similar to `mimeType` parameter of the [DOMParser](https://developer.mozilla.org/en-US/docs/Web/API/DOMParser).
`sync(): void` | Synchronizes the brXM integration state (UI elements positions).
`toJSON(): object` | A plain JavaScript object of the page model.
| Method | Description |
| ------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `getButton(type: string, ...params: any[]): MetaCollection` | Generates a meta-data collection for the Experience Manager buttons. |
| `getChannelParameters(): object` | Gets current channel parameters. |
| <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<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. The method is **deprecated** and will be removed in the next major release. |
| <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` or `baseUrl`. In case when the link starts with the same path as in `cmsBaseUrl`, this part will be removed.<br> - If the link object type is unknown, then it will return `undefined`.<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. |
| <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. |
| `isPreview(): boolean` | Returns whether the page is in the preview mode. |
| `rewriteLinks(content: string, type?: string): string` | 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. The `type` parameter is similar to `mimeType` parameter of the [DOMParser](https://developer.mozilla.org/en-US/docs/Web/API/DOMParser). |
| `sync(): void` | Synchronizes the brXM integration state (UI elements positions). |
| `toJSON(): object` | A plain JavaScript object of the page model. |
##### Component
The `Component` class corresponds to page nodes, and it may hold other components inside.
Method | Description
--- | ---
`getId(): string` | Returns the component id.
`getMeta(): MetaCollection` | Returns the component meta-data collection.
`getModels(): object` | Returns the map of the component models.
<code>getUrl(): string &vert; undefined</code> | Returns the link to the partial component model.
`getName(): string` | Returns the name of the component.
`getParameters(): object` | Returns the parameters of the component.
`getChildren(): Component[]` | Returns the direct children of the component.
<code>getComponent(...componentNames: string[]): Component &vert; undefined</code> | Looks up for a nested component.
<code>getComponentById(id: string): Component &vert; undefined</code> | Looks up for a nested component by its id.
| Method | Description |
| ---------------------------------------------------------------------------------- | ------------------------------------------------ |
| `getId(): string` | Returns the component id. |
| `getMeta(): MetaCollection` | Returns the component meta-data collection. |
| `getModels(): object` | Returns the map of the component models. |
| <code>getUrl(): string &vert; undefined</code> | Returns the link to the partial component model. |
| `getName(): string` | Returns the name of the component. |
| `getParameters(): object` | Returns the parameters of the component. |
| `getChildren(): Component[]` | Returns the direct children of the component. |
| <code>getComponent(...componentNames: string[]): Component &vert; undefined</code> | Looks up for a nested component. |
| <code>getComponentById(id: string): Component &vert; undefined</code> | Looks up for a nested component by its id. |
##### Container
The `Container` class represents a page node that is actually present in the DOM but as an element surrounding its children. Container extends the Component class, and therefore, all the [Component methods](#component) are applicable here.
Method | Description
--- | ---
<code>getType(): string &vert; undefined</code> | Returns the [type](https://documentation.bloomreach.com/library/concepts/template-composer/channel-editor-containers.html) of a container.
| Method | Description |
| ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| <code>getType(): string &vert; undefined</code> | Returns the [type](https://documentation.bloomreach.com/library/concepts/template-composer/channel-editor-containers.html) of a container. |
##### Container Item
The `ContainerItem` objects are usually visible on the page and interact with the user. Container Item extends the Component class, and therefore, all the [Component methods](#component) are applicable here.
Method | Description
--- | ---
<code>getLabel(): string &vert; undefined</code> | Returns the label of a container item catalogue component.
<code>getType(): string &vert; undefined</code> | Returns the type of a container item. The available types depend on which container items have been configured in the backend (e.g. "Banner").
`isHidden(): boolean` | Returns whether the component should not render anything. Hiding components is only possible with the Relevance feature.
`on(eventName: string, listener: Function): Function` | Subscribes for an event and returns the unsubscribe function.
`off(eventName: string, listener: Function): void` | Unsubscribes from an event.
| Method | Description |
| ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| <code>getLabel(): string &vert; undefined</code> | Returns the label of a container item catalogue component. |
| <code>getType(): string &vert; undefined</code> | Returns the type of a container item. The available types depend on which container items have been configured in the backend (e.g. "Banner"). |
| `isHidden(): boolean` | Returns whether the component should not render anything. Hiding components is only possible with the Relevance feature. |
| `on(eventName: string, listener: Function): Function` | Subscribes for an event and returns the unsubscribe function. |
| `off(eventName: string, listener: Function): void` | Unsubscribes from an event. |
##### Content
The `Content` object holds document data that is used by the page components.
Method | Description
--- | ---
`getId(): string` | Returns the content id.
<code>getLocale(): string &vert; undefined</code> | Returns the content locale.
`getMeta(): MetaCollection` | Returns the content meta-data collection.
`getName(): string` | Returns the content name.
`getData(): object` | Returns the content data as it is returned in the Page Model API.
<code>getUrl(): string &vert; undefined</code> | Returns the link to the content.
| Method | Description |
| ------------------------------------------------- | ----------------------------------------------------------------- |
| `getId(): string` | Returns the content id. |
| <code>getLocale(): string &vert; undefined</code> | Returns the content locale. |
| `getMeta(): MetaCollection` | Returns the content meta-data collection. |
| `getName(): string` | Returns the content name. |
| `getData(): object` | Returns the content data as it is returned in the Page Model API. |
| <code>getUrl(): string &vert; undefined</code> | Returns the link to the content. |
##### 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.
| 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.
| 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.
| 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.
`getName(): string` | Returns the menu name.
<code>getSelected(): MenuItem &vert; undefined</code> | Returns the current menu item. The method is **deprecated** and will be removed in the next major release.
| Method | Description |
| ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| `getItems(): MenuItem[]` | Returns the menu items. |
| `getMeta(): MetaCollection` | Returns the menu meta-data collection. |
| `getName(): string` | Returns the menu name. |
| <code>getSelected(): MenuItem &vert; undefined</code> | Returns the current menu item. The method is **deprecated** and will be removed in the next major release. |
##### 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.
| 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
Method | Description
--- | ---
`clear(): void` | Clears previously rendered meta-data objects.
`render(head: HTMLElement, tail: HTMLElement): () => void;` | Renders meta-data objects on the page and returns the callback clearing rendered objects.
| Method | Description |
| ----------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| `clear(): void` | Clears previously rendered meta-data objects. |
| `render(head: HTMLElement, tail: HTMLElement): () => void;` | Renders meta-data objects on the page and returns the callback clearing rendered objects. |
##### Meta
The `Meta` objects are being used by the brXM to page and its components.
Method | Description
--- | ---
`getData(): string` | Returns the meta-data.
`getPosition(): string` | Returns the meta-data position relative to the related element.
| Method | Description |
| ----------------------- | --------------------------------------------------------------- |
| `getData(): string` | Returns the meta-data. |
| `getPosition(): string` | Returns the meta-data position relative to the related element. |
##### Pagination
The `Pagination` object holds the pagination data with all the pagination items.
Method | Description
--- | ---
`getCurrent(): PaginationItem` | Returns the current page.
`getFirst(): PaginationItem` | Returns the first page.
`getItems(): Reference[]` | Returns the current page items.
`getLast(): PaginationItem` | Returns the last page.
<code>getNext(): PaginationItem &vert; undefined</code> | Returns the next page.
`getOffset(): number` | Returns the number of items before the current page.
`getPages(): PaginationItem[]` | Returns currently listed pages.
<code>getPrevious(): PaginationItem &vert; undefined</code> | Returns the previous page.
`getSize(): number` | Returns the number of items listed on the current page.
`getTotal(): number` | Returns the total number of items.
`isEnabled(): boolean` | Returns whether the pagination is enabled.
| Method | Description |
| ----------------------------------------------------------- | ------------------------------------------------------- |
| `getCurrent(): PaginationItem` | Returns the current page. |
| `getFirst(): PaginationItem` | Returns the first page. |
| `getItems(): Reference[]` | Returns the current page items. |
| `getLast(): PaginationItem` | Returns the last page. |
| <code>getNext(): PaginationItem &vert; undefined</code> | Returns the next page. |
| `getOffset(): number` | Returns the number of items before the current page. |
| `getPages(): PaginationItem[]` | Returns currently listed pages. |
| <code>getPrevious(): PaginationItem &vert; undefined</code> | Returns the previous page. |
| `getSize(): number` | Returns the number of items listed on the current page. |
| `getTotal(): number` | Returns the total number of items. |
| `isEnabled(): boolean` | Returns whether the pagination is enabled. |
##### PaginationItem
The `PaginationItem` object holds a pagination item that is used by the `Pagination` object.
Method | Description
--- | ---
`getNumber(): number` | Returns the page number.
<code>getUrl(): string &vert; undefined</code> | Returns the page URL.
## Links
- [SPA integration concept](https://documentation.bloomreach.com/library/concepts/spa-integration/introduction.html).
- [Page Model API introduction](https://documentation.bloomreach.com/library/concepts/page-model-api/introduction.html).
## FAQ
- Information about common problems and possible solutions can be found on [the troubleshooting page](https://documentation.bloomreach.com/library/concepts/spa-integration/troubleshooting.html).
- Information about the recommended setup can be found on [the best practices page](https://documentation.bloomreach.com/library/concepts/spa-integration/best-practices.html).
## License
Published under [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0) license.
| Method | Description |
| ---------------------------------------------- | ------------------------ |
| `getNumber(): number` | Returns the page number. |
| <code>getUrl(): string &vert; undefined</code> | Returns the page URL. |

Sorry, the diff of this file is not supported yet

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

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