@bloomreach/spa-sdk
Advanced tools
Comparing version 14.4.0 to 14.5.0
{ | ||
"name": "@bloomreach/spa-sdk", | ||
"version": "14.4.0", | ||
"version": "14.5.0", | ||
"description": "Bloomreach SPA SDK", | ||
@@ -20,9 +20,9 @@ "keywords": [ | ||
}, | ||
"main": "dist/index.js", | ||
"browser": "dist/index.js", | ||
"module": "dist/index.mjs", | ||
"es2015": "dist/index.es6.js", | ||
"types": "dist/index.d.ts", | ||
"main": "lib/index.js", | ||
"browser": "lib/index.js", | ||
"module": "lib/index.mjs", | ||
"es2015": "lib/index.es6.js", | ||
"types": "lib/index.d.ts", | ||
"files": [ | ||
"dist/" | ||
"lib/" | ||
], | ||
@@ -65,3 +65,5 @@ "scripts": { | ||
"@rollup/plugin-babel": "^5.2", | ||
"@types/cookie": "^0.4", | ||
"@types/jest": "^26.0", | ||
"@types/node": "^14.14", | ||
"@types/xmldom": "^0.1", | ||
@@ -84,2 +86,3 @@ "babel-plugin-transform-async-to-promises": "^0.8", | ||
"dependencies": { | ||
"cookie": "^0.4", | ||
"emittery": "^0.7", | ||
@@ -86,0 +89,0 @@ "inversify": "^5.0", |
@@ -38,5 +38,5 @@ # Bloomreach SPA SDK | ||
const page = await initialize({ | ||
cmsBaseUrl: 'http://localhost:8080/site', | ||
path, | ||
endpoint: 'http://localhost:8080/site/resourceapi', | ||
httpClient: axios, | ||
request: { path }, | ||
}); | ||
@@ -62,2 +62,3 @@ | ||
`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`. | ||
@@ -77,6 +78,9 @@ `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. | ||
`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` | yes | _none_ | The path part of the URL, including a query string if present (e.g. `/path/to/page?foo=1`). | ||
`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. | ||
@@ -86,3 +90,3 @@ `serverIdHeader` | no | `"Server-Id"` | Header identifying the current cluster node. | ||
`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. | ||
`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. | ||
@@ -92,2 +96,20 @@ `visitor.header` | yes | _none_ | An HTTP-header using to pass the visitor identifier to the Page Model API. | ||
### 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). | ||
```javascript | ||
import express from 'express'; | ||
import { relevance } from '@bloomreach/spa-sdk/lib/express'; | ||
const app = express(); | ||
app.use(relevance); | ||
``` | ||
The middleware can be customized using the `withOptions` method. | ||
```javascript | ||
app.use(relevance.withOptions({ name: '_visitor', maxAge: 24 * 60 * 60 })); | ||
``` | ||
### Reference | ||
@@ -114,2 +136,4 @@ The complete API reference can be found [here](https://javadoc.onehippo.org/14.0/bloomreach-spa-sdk/). | ||
`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. | ||
@@ -126,2 +150,3 @@ #### Constants | ||
`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. | ||
@@ -249,3 +274,4 @@ `TYPE_LINK_INTERNAL` | Link to a page inside the current application. | ||
`getMeta(): MetaCollection` | Returns the menu meta-data collection. | ||
<code>getSelected(): MenuItem | undefined</code> | Returns the current menu item. | ||
`getName(): string` | Returns the menu name. | ||
<code>getSelected(): MenuItem | undefined</code> | Returns the current menu item. The method is **deprecated** and will be removed in the next major release. | ||
@@ -252,0 +278,0 @@ ##### MenuItem |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
388339
14
7600
334
5
25
1
+ Addedcookie@^0.4
+ Addedcookie@0.4.2(transitive)