ibm-wch-sdk-api
v5.0.361
Published
Exposes framework independent APIs for ibm-wch-sdk-ng and similar SDKs.
Downloads
27
Readme
ibm-wch-sdk-api
Exposes framework independent APIs for ibm-wch-sdk-ng and similar SDKs.
Details
Refer to the documentation.
Changes
Class documentation
Refer to the documentation.
Usage
Install the module via
npm install --save ibm-wch-sdk-theme
API
Changelog
Current
Changed
Added
- New quick access fields
group
andgroups
on theRenderingContext
- Typing support for
group
elements - Declaration of the event types and payloads for cross iframe events to switch between public and protected mode.
5.0.217
Added
- Initial version
ibm-wch-sdk-api
Index
External modules
- "index"
- "interfaces/delivery/v1/base.item"
- "interfaces/delivery/v1/content/content.item"
- "interfaces/delivery/v1/content/elements"
- "interfaces/delivery/v1/error/error"
- "interfaces/delivery/v1/layout/layout"
- "interfaces/delivery/v1/rendering/context/content.item.with.layout"
- "interfaces/delivery/v1/rendering/context/extended.context"
- "interfaces/delivery/v1/rendering/context/hub.context"
- "interfaces/delivery/v1/rendering/context/rendering.context"
- "interfaces/delivery/v1/search/search.result"
- "interfaces/delivery/v1/site/site"
- "interfaces/delivery/v1/site/site.child"
- "interfaces/delivery/v1/site/site.context"
- "interfaces/delivery/v1/site/site.page"
- "interfaces/delivery/v1/user/user"
- "interfaces/delivery/v1/users/currentuser/constants"
- "interfaces/logging/logger"
- "interfaces/logging/logger.factory"
- "interfaces/login/v1/basicauth/index"
- "interfaces/login/v1/redirect/index"
- "interfaces/login/v1/removecookies/index"
- "interfaces/messages/messages"
- "interfaces/messages/sdk.navigate.by.path.message"
- "interfaces/messages/sdk.refresh.message"
- "interfaces/messages/sdk.set.mode.message"
- "interfaces/messages/sdk.subscribe.active.route.message"
- "interfaces/messages/sdk.subscribe.message"
- "interfaces/messages/sdk.subscribe.mode.message"
- "interfaces/messages/sdk.subscribe.route.message"
- "interfaces/query"
- "interfaces/registry/v1/currenttenant/index"
- "interfaces/sdk/router/router"
- "interfaces/sdk/sdk"
- "interfaces/sdk/search/search"
- "interfaces/sdk/version/version"
- "interfaces/user-profile/v1/users/currentuser/index"
- "services/hub-info/hub-info"
- "services/hub-info/hub-info.config"
- "services/info/url.config"
- "services/logging/logger.service"
Services
- [logging][./logging/]
- [info][./info/]
Interfaces
External module: "index"
Index
ibm-wch-sdk-api > "interfaces/delivery/v1/base.item"
External module: "interfaces/delivery/v1/base.item"
Index
Enumerations
Interfaces
ibm-wch-sdk-api > "interfaces/delivery/v1/content/content.item"
External module: "interfaces/delivery/v1/content/content.item"
Index
Interfaces
ibm-wch-sdk-api > "interfaces/delivery/v1/content/elements"
External module: "interfaces/delivery/v1/content/elements"
Index
Type aliases
Variables
- _ELEMENT_TYPE_CATEGORY
- _ELEMENT_TYPE_DATE
- _ELEMENT_TYPE_FILE
- _ELEMENT_TYPE_FORMATTED_TEXT
- _ELEMENT_TYPE_GROUP
- _ELEMENT_TYPE_IMAGE
- _ELEMENT_TYPE_LINK
- _ELEMENT_TYPE_LOCATION
- _ELEMENT_TYPE_NUMBER
- _ELEMENT_TYPE_OPTION_SELECTION
- _ELEMENT_TYPE_REFERENCE
- _ELEMENT_TYPE_TEXT
- _ELEMENT_TYPE_TOGGLE
- _ELEMENT_TYPE_VIDEO
Type aliases
ELEMENT_TYPE
Ƭ ELEMENT_TYPE: * "text" | "number" | "toggle" | "formattedtext" | "link" | "datetime" | "file" | "video" | "image" | "reference" | "category" | "location" | "optionselection" | "group" *
Defined in interfaces/delivery/v1/content/elements.ts:2
Variables
<Const>
_ELEMENT_TYPE_CATEGORY
● _ELEMENT_TYPE_CATEGORY: "category" = "category"
Defined in interfaces/delivery/v1/content/elements.ts:14
<Const>
_ELEMENT_TYPE_DATE
● _ELEMENT_TYPE_DATE: "datetime" = "datetime"
Defined in interfaces/delivery/v1/content/elements.ts:13
<Const>
_ELEMENT_TYPE_FILE
● _ELEMENT_TYPE_FILE: "file" = "file"
Defined in interfaces/delivery/v1/content/elements.ts:15
<Const>
_ELEMENT_TYPE_FORMATTED_TEXT
● _ELEMENT_TYPE_FORMATTED_TEXT: "formattedtext" = "formattedtext"
Defined in interfaces/delivery/v1/content/elements.ts:9
<Const>
_ELEMENT_TYPE_GROUP
● _ELEMENT_TYPE_GROUP: "group" = "group"
Defined in interfaces/delivery/v1/content/elements.ts:6
<Const>
_ELEMENT_TYPE_IMAGE
● _ELEMENT_TYPE_IMAGE: "image" = "image"
Defined in interfaces/delivery/v1/content/elements.ts:17
<Const>
_ELEMENT_TYPE_LINK
● _ELEMENT_TYPE_LINK: "link" = "link"
Defined in interfaces/delivery/v1/content/elements.ts:12
<Const>
_ELEMENT_TYPE_LOCATION
● _ELEMENT_TYPE_LOCATION: "location" = "location"
Defined in interfaces/delivery/v1/content/elements.ts:19
<Const>
_ELEMENT_TYPE_NUMBER
● _ELEMENT_TYPE_NUMBER: "number" = "number"
Defined in interfaces/delivery/v1/content/elements.ts:10
<Const>
_ELEMENT_TYPE_OPTION_SELECTION
● _ELEMENT_TYPE_OPTION_SELECTION: "optionselection" = "optionselection"
Defined in interfaces/delivery/v1/content/elements.ts:7
<Const>
_ELEMENT_TYPE_REFERENCE
● _ELEMENT_TYPE_REFERENCE: "reference" = "reference"
Defined in interfaces/delivery/v1/content/elements.ts:18
<Const>
_ELEMENT_TYPE_TEXT
● _ELEMENT_TYPE_TEXT: "text" = "text"
Defined in interfaces/delivery/v1/content/elements.ts:8
<Const>
_ELEMENT_TYPE_TOGGLE
● _ELEMENT_TYPE_TOGGLE: "toggle" = "toggle"
Defined in interfaces/delivery/v1/content/elements.ts:11
<Const>
_ELEMENT_TYPE_VIDEO
● _ELEMENT_TYPE_VIDEO: "video" = "video"
Defined in interfaces/delivery/v1/content/elements.ts:16
ibm-wch-sdk-api > "interfaces/delivery/v1/error/error"
External module: "interfaces/delivery/v1/error/error"
Index
Interfaces
ibm-wch-sdk-api > "interfaces/delivery/v1/layout/layout"
External module: "interfaces/delivery/v1/layout/layout"
Index
Interfaces
ibm-wch-sdk-api > "interfaces/delivery/v1/rendering/context/content.item.with.layout"
External module: "interfaces/delivery/v1/rendering/context/content.item.with.layout"
Index
Interfaces
ibm-wch-sdk-api > "interfaces/delivery/v1/rendering/context/extended.context"
External module: "interfaces/delivery/v1/rendering/context/extended.context"
Index
Interfaces
ibm-wch-sdk-api > "interfaces/delivery/v1/rendering/context/hub.context"
External module: "interfaces/delivery/v1/rendering/context/hub.context"
Index
Interfaces
ibm-wch-sdk-api > "interfaces/delivery/v1/rendering/context/rendering.context"
External module: "interfaces/delivery/v1/rendering/context/rendering.context"
Index
Interfaces
- AbstractElement
- Asset
- Category
- CategoryElement
- DateElement
- ElementMap
- File
- FileElement
- FormattedTextElement
- Group
- GroupElement
- Image
- ImageElement
- Link
- LinkElement
- Location
- LocationElement
- MultiDateElement
- MultiFileElement
- MultiFormattedTextElement
- MultiGroupElement
- MultiImageElement
- MultiLinkElement
- MultiNumberElement
- MultiOptionSelectionElement
- MultiReferenceElement
- MultiTextElement
- MultiToggleElement
- MultiVideoElement
- NumberElement
- OptionSelection
- OptionSelectionElement
- ReferenceElement
- RenderingContext
- Rendition
- Resource
- SingleDateElement
- SingleFileElement
- SingleFormattedTextElement
- SingleGroupElement
- SingleImageElement
- SingleLinkElement
- SingleNumberElement
- SingleOptionSelectionElement
- SingleReferenceElement
- SingleTextElement
- SingleToggleElement
- SingleVideoElement
- TextElement
- ToggleElement
- TypeRef
- Video
- VideoElement
Type aliases
Type aliases
Element
Ƭ Element: * LocationElement | SingleReferenceElement | MultiReferenceElement | SingleImageElement | MultiImageElement | SingleVideoElement | MultiVideoElement | SingleFileElement | MultiFileElement | SingleToggleElement | MultiToggleElement | SingleTextElement | MultiTextElement | SingleNumberElement | MultiNumberElement | SingleLinkElement | MultiLinkElement | SingleFormattedTextElement | MultiFormattedTextElement | SingleOptionSelectionElement | MultiOptionSelectionElement | SingleDateElement | MultiDateElement | SingleGroupElement | MultiGroupElement *
Defined in interfaces/delivery/v1/rendering/context/rendering.context.ts:386
GroupType
Ƭ GroupType: ElementMap<SimpleType>
Defined in interfaces/delivery/v1/rendering/context/rendering.context.ts:402
SimpleType
Ƭ SimpleType: * string
| string
[] | number
| number
[] | Image | Image[] | Date
| Date
[] | Video | Video[] | File | File[] | boolean
| boolean
[] | Link | Link[] | OptionSelection | OptionSelection[] | RenderingContext | RenderingContext[] | Category | Location | object
*
Defined in interfaces/delivery/v1/rendering/context/rendering.context.ts:398
ibm-wch-sdk-api > "interfaces/delivery/v1/search/search.result"
External module: "interfaces/delivery/v1/search/search.result"
Index
Interfaces
- PageSearchResult
- RenderingContextQueryResult
- RenderingContextSearchResult
- SearchResult
- SearchResults
- SitePagesQueryResult
ibm-wch-sdk-api > "interfaces/delivery/v1/site/site"
External module: "interfaces/delivery/v1/site/site"
Index
Interfaces
ibm-wch-sdk-api > "interfaces/delivery/v1/site/site.child"
External module: "interfaces/delivery/v1/site/site.child"
Index
Interfaces
ibm-wch-sdk-api > "interfaces/delivery/v1/site/site.context"
External module: "interfaces/delivery/v1/site/site.context"
Index
Interfaces
ibm-wch-sdk-api > "interfaces/delivery/v1/site/site.page"
External module: "interfaces/delivery/v1/site/site.page"
Index
Interfaces
ibm-wch-sdk-api > "interfaces/delivery/v1/user/user"
External module: "interfaces/delivery/v1/user/user"
Index
Interfaces
ibm-wch-sdk-api > "interfaces/delivery/v1/users/currentuser/constants"
External module: "interfaces/delivery/v1/users/currentuser/constants"
Index
Variables
Variables
<Const>
REL_PATH_CURRENT_USER
● REL_PATH_CURRENT_USER: "user-profile/v1/users/currentuser" = "user-profile/v1/users/currentuser"
Defined in interfaces/delivery/v1/users/currentuser/constants.ts:2
ibm-wch-sdk-api > "interfaces/logging/logger"
External module: "interfaces/logging/logger"
Index
Interfaces
ibm-wch-sdk-api > "interfaces/logging/logger.factory"
External module: "interfaces/logging/logger.factory"
Index
Interfaces
ibm-wch-sdk-api > "interfaces/login/v1/basicauth/index"
External module: "interfaces/login/v1/basicauth/index"
Index
Variables
- HEADER_BASICAUTH_TENANT_ID
- KEY_BASICAUTH_LOGIN_PASSWORD
- KEY_BASICAUTH_LOGIN_USERNAME
- REL_PATH_BASICAUTH_LOGIN
Variables
<Const>
HEADER_BASICAUTH_TENANT_ID
● HEADER_BASICAUTH_TENANT_ID: "x-ibm-dx-tenant-id" = "x-ibm-dx-tenant-id"
Defined in interfaces/login/v1/basicauth/index.ts:6
<Const>
KEY_BASICAUTH_LOGIN_PASSWORD
● KEY_BASICAUTH_LOGIN_PASSWORD: "j_password" = "j_password"
Defined in interfaces/login/v1/basicauth/index.ts:4
<Const>
KEY_BASICAUTH_LOGIN_USERNAME
● KEY_BASICAUTH_LOGIN_USERNAME: "j_username" = "j_username"
Defined in interfaces/login/v1/basicauth/index.ts:3
<Const>
REL_PATH_BASICAUTH_LOGIN
● REL_PATH_BASICAUTH_LOGIN: "login/v1/basicauth" = "login/v1/basicauth"
Defined in interfaces/login/v1/basicauth/index.ts:2
ibm-wch-sdk-api > "interfaces/login/v1/redirect/index"
External module: "interfaces/login/v1/redirect/index"
Index
Variables
Variables
<Const>
PARAM_REDIRECT_LOGIN_TARGET_TENANT
● PARAM_REDIRECT_LOGIN_TARGET_TENANT: "targetTenant" = "targetTenant"
Defined in interfaces/login/v1/redirect/index.ts:3
<Const>
PARAM_REDIRECT_LOGIN_TARGET_URL
● PARAM_REDIRECT_LOGIN_TARGET_URL: "targetUrl" = "targetUrl"
Defined in interfaces/login/v1/redirect/index.ts:2
<Const>
REL_PATH_REDIRECT_LOGIN
● REL_PATH_REDIRECT_LOGIN: "login/v1/redirect" = "login/v1/redirect"
Defined in interfaces/login/v1/redirect/index.ts:1
ibm-wch-sdk-api > "interfaces/login/v1/removecookies/index"
External module: "interfaces/login/v1/removecookies/index"
Index
Variables
Variables
<Const>
REL_PATH_REMOVECOOKIES
● REL_PATH_REMOVECOOKIES: "login/v1/removecookies" = "login/v1/removecookies"
Defined in interfaces/login/v1/removecookies/index.ts:2
ibm-wch-sdk-api > "interfaces/messages/messages"
External module: "interfaces/messages/messages"
Index
Interfaces
Type aliases
Type aliases
SdkMessageHandlerCallback
Ƭ SdkMessageHandlerCallback: function
Defined in interfaces/messages/messages.ts:21
Type declaration
▸(aPayload: SdkMessagePayload, aEvent: MessageEvent
): PromiseLike
<SdkMessagePayload> | SdkMessagePayload | null
| undefined
Parameters:
| Param | Type |
| ------ | ------ |
| aPayload | SdkMessagePayload |
| aEvent | MessageEvent
|
Returns: PromiseLike
<SdkMessagePayload> | SdkMessagePayload | null
| undefined
ibm-wch-sdk-api > "interfaces/messages/sdk.navigate.by.path.message"
External module: "interfaces/messages/sdk.navigate.by.path.message"
Index
Interfaces
Variables
Variables
<Const>
SDK_NAVIGATE_BY_PATH_EVENT_TYPE
● SDK_NAVIGATE_BY_PATH_EVENT_TYPE: "WchSdk.router.navigateByPath" = "WchSdk.router.navigateByPath"
Defined in interfaces/messages/sdk.navigate.by.path.message.ts:7
ibm-wch-sdk-api > "interfaces/messages/sdk.refresh.message"
External module: "interfaces/messages/sdk.refresh.message"
Index
Interfaces
Variables
Variables
<Const>
SDK_REFRESH_EVENT_TYPE
● SDK_REFRESH_EVENT_TYPE: "WchSdk.refresh" = "WchSdk.refresh"
Defined in interfaces/messages/sdk.refresh.message.ts:7
ibm-wch-sdk-api > "interfaces/messages/sdk.set.mode.message"
External module: "interfaces/messages/sdk.set.mode.message"
Index
Interfaces
Variables
Variables
<Const>
SDK_SET_MODE_EVENT_TYPE
● SDK_SET_MODE_EVENT_TYPE: "WchSdk.setMode" = "WchSdk.setMode"
Defined in interfaces/messages/sdk.set.mode.message.ts:8
ibm-wch-sdk-api > "interfaces/messages/sdk.subscribe.active.route.message"
External module: "interfaces/messages/sdk.subscribe.active.route.message"
Index
Interfaces
Variables
Variables
<Const>
SDK_ACTIVE_ROUTE_EVENT_TYPE
● SDK_ACTIVE_ROUTE_EVENT_TYPE: "WchSdk.router.activeRoute" = "WchSdk.router.activeRoute"
Defined in interfaces/messages/sdk.subscribe.active.route.message.ts:18
<Const>
SDK_SUBSCRIBE_ACTIVE_ROUTE_EVENT_TYPE
● SDK_SUBSCRIBE_ACTIVE_ROUTE_EVENT_TYPE: "WchSdk.router.activeRoute.subscribe" = "WchSdk.router.activeRoute.subscribe"
Defined in interfaces/messages/sdk.subscribe.active.route.message.ts:9
ibm-wch-sdk-api > "interfaces/messages/sdk.subscribe.message"
External module: "interfaces/messages/sdk.subscribe.message"
Index
Interfaces
Variables
Variables
<Const>
SDK_UNSUBSCRIBE_EVENT_TYPE
● SDK_UNSUBSCRIBE_EVENT_TYPE: "WchSdk.unsubscribe" = "WchSdk.unsubscribe"
Defined in interfaces/messages/sdk.subscribe.message.ts:15
ibm-wch-sdk-api > "interfaces/messages/sdk.subscribe.mode.message"
External module: "interfaces/messages/sdk.subscribe.mode.message"
Index
Enumerations
Interfaces
Variables
Variables
<Const>
SDK_MODE_EVENT_TYPE
● SDK_MODE_EVENT_TYPE: "WchSdk.mode" = "WchSdk.mode"
Defined in interfaces/messages/sdk.subscribe.mode.message.ts:22
<Const>
SDK_SUBSCRIBE_MODE_EVENT_TYPE
● SDK_SUBSCRIBE_MODE_EVENT_TYPE: "WchSdk.mode.subscribe" = "WchSdk.mode.subscribe"
Defined in interfaces/messages/sdk.subscribe.mode.message.ts:8
ibm-wch-sdk-api > "interfaces/messages/sdk.subscribe.route.message"
External module: "interfaces/messages/sdk.subscribe.route.message"
Index
Interfaces
Variables
Variables
<Const>
SDK_ROUTE_EVENT_TYPE
● SDK_ROUTE_EVENT_TYPE: "WchSdk.router.route" = "WchSdk.router.route"
Defined in interfaces/messages/sdk.subscribe.route.message.ts:23
<Const>
SDK_SUBSCRIBE_ROUTE_EVENT_TYPE
● SDK_SUBSCRIBE_ROUTE_EVENT_TYPE: "WchSdk.router.route.subscribe" = "WchSdk.router.route.subscribe"
Defined in interfaces/messages/sdk.subscribe.route.message.ts:9
ibm-wch-sdk-api > "interfaces/query"
External module: "interfaces/query"
Index
Interfaces
Type aliases
Type aliases
QueryValue
Ƭ QueryValue: * string
| number
| boolean
*
Defined in interfaces/query.ts:4
ibm-wch-sdk-api > "interfaces/registry/v1/currenttenant/index"
External module: "interfaces/registry/v1/currenttenant/index"
Index
Variables
Variables
<Const>
REL_PATH_CURRENT_TENANT
● REL_PATH_CURRENT_TENANT: "registry/v1/currenttenant" = "registry/v1/currenttenant"
Defined in interfaces/registry/v1/currenttenant/index.ts:2
ibm-wch-sdk-api > "interfaces/sdk/router/router"
External module: "interfaces/sdk/router/router"
Index
Interfaces
ibm-wch-sdk-api > "interfaces/sdk/sdk"
External module: "interfaces/sdk/sdk"
Index
Interfaces
Variables
Variables
<Const>
WCH_SDK_MODULE_NAME
● WCH_SDK_MODULE_NAME: "WchSdk" = "WchSdk"
Defined in interfaces/sdk/sdk.ts:7
ibm-wch-sdk-api > "interfaces/sdk/search/search"
External module: "interfaces/sdk/search/search"
Index
Interfaces
Type aliases
Type aliases
QueryInput
Ƭ QueryInput: * string
| string
[] | null
| undefined
| URLSearchParams
| Query
*
Defined in interfaces/sdk/search/search.ts:7
ibm-wch-sdk-api > "interfaces/sdk/version/version"
External module: "interfaces/sdk/version/version"
Index
Interfaces
ibm-wch-sdk-api > "interfaces/user-profile/v1/users/currentuser/index"
External module: "interfaces/user-profile/v1/users/currentuser/index"
Index
Variables
Variables
<Const>
REGEXP_ANONYMOUS_USER_ID
● REGEXP_ANONYMOUS_USER_ID: RegExp
= /^\w{8}-\w{4}-f\w{3}-\w{4}-\w{12}$/
Defined in interfaces/user-profile/v1/users/currentuser/index.ts:2
<Const>
REL_PATH_CURRENT_USER
● REL_PATH_CURRENT_USER: "user-profile/v1/users/currentuser" = "user-profile/v1/users/currentuser"
Defined in interfaces/user-profile/v1/users/currentuser/index.ts:1
ibm-wch-sdk-api > "services/hub-info/hub-info"
External module: "services/hub-info/hub-info"
Index
Interfaces
ibm-wch-sdk-api > "services/hub-info/hub-info.config"
External module: "services/hub-info/hub-info.config"
Index
Enumerations
Classes
Interfaces
Type aliases
Type aliases
HubInfoUrlProvider
Ƭ HubInfoUrlProvider: * null
| undefined
| URL
| string
| function
*
Defined in services/hub-info/hub-info.config.ts:33
ibm-wch-sdk-api > "services/info/url.config"
External module: "services/info/url.config"
Index
Interfaces
ibm-wch-sdk-api > "services/logging/logger.service"
External module: "services/logging/logger.service"
Index
Interfaces
Logging
The logger interfaces allow to plug custom loggers via the LoggerFactory
. In addition they expose a simple logger interface, modelled after the standard console logger.
Delivery
Typescript definitions of the WCH Delivery APIs.
WchSdk
The SDK defines the plain JS WCH SDK APIs .
Properties
Methods
refresh()
: causes the currently displayed data to be refreshed
The SDK is available on the global window object
window.WchSdk
Cross Origin Eventing
The SDK supports WebMessaging to allow communication across frames via the postMessage functionality. Each message sent to the SDK needs to contain a type
and an id
field. The type is used to identify the meaning of the message, the id to allow the caller to correlate potential responses.
Responses to messages sent to the iframe (e.g. messages back from the SDK to the parent frame) can optionally use channelMessaging. If the first element of the transfer object contains a messagePort, this will be used for reply messages or notifications. Else these replies will be sent against the parent window, directly.
Supported Message Types
WchSdk.refresh
: refreshes the data currently displayed by the application. The message has no response.WchSdk.router.navigateByPath
: navigates to the specified path. Responds with aWchSdk.router.navigateByPathResponse
response. Takes:path
: path to navigate to
WchSdk.router.activeRoute.subscribe
: subscribes a listener for changes in the active route (i.e. navigations). The event will be responsed by a response containing a handle that can be used to unsubscribe. Whenever a navigation occurs, the SDK will send aWchSdk.router.activeRoute
message to the caller.WchSdk.router.route.subscribe
: subscribes a listener for changes for a given route. The event will be responsed by a response containing a handle that can be used to unsubscribe. Whenever the route changes, comes into existence or is deleted, the SDK will send aWchSdk.router.route
message to the caller. Takes:route
: a string or string array that describes the route to listen to. If the value is a string, then it must be the escaped path, starting with a slash but not ending with a slash. If it is a string array, each value represents the unescaped path segment, the segments to not contain slashes.
WchSdk.unsubscribe
: unsubscribes from a subscription given the subscription handlehandle
: the subscription handle
Supported Response Types
WchSdk.router.navigateByPathResponse
: sent as a response to aWchSdk.router.navigateByPath
message from the SDK to the caller. Replicates the caller message fields and in addition:success
: true if the navigation completed, else falseerror
: an optional error object
WchSdk.router.activeRoute.subscribeResponse
: sent as a response toWchSdk.router.activeRoute.subscribe
.handle
: handle to the subscription, can be used to unsubscribe
WchSdk.router.route.subscribeResponse
: sent as a response toWchSdk.router.route.subscribe
.handle
: handle to the subscription, can be used to unsubscribe
WchSdk.router.activeRoute
: sent from the SDK to the subscriber for modifications in the navigation.page
: The selected page. Will benull
if this is the last event (e.g. because of an application shutdown)
Examples
Listen for Navigation Events
This example shows how a parent frame can listen for navigation events of an SPA. The example uses channelMessaging to establish a direct communication channel from the SDK to the parent frame. Navigation events will be sent via this channel.
Note that the use of a channel is not required. If no channel is passed in, the navigation events will be sent directly to the parent window via postMessage.
The example doe NOT show how to unsubscribe.
/**
* Message sent to the SDK to subscribe for navigation notifications
*/
var msg = {
type: 'WchSdk.router.activeRoute.subscribe',
id: 'someid'
};
// use a message channel to receive the responses
var channel = new MessageChannel();
/** Perform the subscription, transfer one end of the channel to the SDK.
* Note that the second parameter is the origin of the iframe.
*/
myframe.contentWindow.postMessage(msg, "http://localhost:4200", [channel.port2]);
/**
* Listen for changes in the navigation
* We expect two types of callbacks here, one for each navigation event
* and a response sending the subscription handle, so we can unsubscribe later.
*/
channel.port1.addEventListener('message', msg => {
// check for the message type
const data = msg.data;
if (data.type === 'WchSdk.router.activeRoute') {
// log the active route
console.log('navigation in iframe', data.page.route);
} else
if (data.type === 'WchSdk.router.activeRoute.subscribeResponse') {
console.log('subscription handle', data.handle);
}
});
// start the bi-directional communication
channel.port1.start();
Messaging
Cross Origin Eventing
The SDK supports WebMessaging to allow communication across frames via the postMessage functionality. Each message sent to the SDK needs to contain a type
and an id
field. The type is used to identify the meaning of the message, the id to allow the caller to correlate potential responses.
Responses to messages sent to the iframe (e.g. messages back from the SDK to the parent frame) can optionally use channelMessaging. If the first element of the transfer object contains a messagePort, this will be used for reply messages or notifications. Else these replies will be sent against the parent window, directly.
Supported Message Types
WchSdk.refresh
: refreshes the data currently displayed by the application. The message has no response.WchSdk.router.navigateByPath
: navigates to the specified path. Responds with aWchSdk.router.navigateByPathResponse
response. Takes:path
: path to navigate to
WchSdk.router.activeRoute.subscribe
: subscribes a listener for changes in the active route (i.e. navigations). The event will be responsed by a response containing a handle that can be used to unsubscribe. Whenever a navigation occurs, the SDK will send aWchSdk.router.activeRoute
message to the caller.WchSdk.router.route.subscribe
: subscribes a listener for changes for a given route. The event will be responsed by a response containing a handle that can be used to unsubscribe. Whenever the route changes, comes into existence or is deleted, the SDK will send aWchSdk.router.route
message to the caller. Takes:route
: a string or string array that describes the route to listen to. If the value is a string, then it must be the escaped path, starting with a slash but not ending with a slash. If it is a string array, each value represents the unescaped path segment, the segments to not contain slashes.
WchSdk.unsubscribe
: unsubscribes from a subscription given the subscription handlehandle
: the subscription handle
Supported Response Types
WchSdk.router.navigateByPathResponse
: sent as a response to aWchSdk.router.navigateByPath
message from the SDK to the caller. Replicates the caller message fields and in addition:success
: true if the navigation completed, else falseerror
: an optional error object
WchSdk.router.activeRoute.subscribeResponse
: sent as a response toWchSdk.router.activeRoute.subscribe
.handle
: handle to the subscription, can be used to unsubscribe
WchSdk.router.route.subscribeResponse
: sent as a response toWchSdk.router.route.subscribe
.handle
: handle to the subscription, can be used to unsubscribe
WchSdk.router.activeRoute
: sent from the SDK to the subscriber for modifications in the navigation.page
: The selected page. Will benull
if this is the last event (e.g. because of an application shutdown)
Examples
Listen for Navigation Events
This example shows how a parent frame can listen for navigation events of an SPA. The example uses channelMessaging to establish a direct communication channel from the SDK to the parent frame. Navigation events will be sent via this channel.
Note that the use of a channel is not required. If no channel is passed in, the navigation events will be sent directly to the parent window via postMessage.
The example doe NOT show how to unsubscribe.
/**
* Message sent to the SDK to subscribe for navigation notifications
*/
var msg = {
type: 'WchSdk.router.activeRoute.subscribe',
id: 'someid'
};
// use a message channel to receive the responses
var channel = new MessageChannel();
/** Perform the subscription, transfer one end of the channel to the SDK.
* Note that the second parameter is the origin of the iframe.
*/
myframe.contentWindow.postMessage(msg, "http://localhost:4200", [channel.port2]);
/**
* Listen for changes in the navigation
* We expect two types of callbacks here, one for each navigation event
* and a response sending the subscription handle, so we can unsubscribe later.
*/
channel.port1.addEventListener('message', msg => {
// check for the message type
const data = msg.data;
if (data.type === 'WchSdk.router.activeRoute') {
// log the active route
console.log('navigation in iframe', data.page.route);
} else
if (data.type === 'WchSdk.router.activeRoute.subscribeResponse') {
console.log('subscription handle', data.handle);
}
});
// start the bi-directional communication
channel.port1.start();
ibm-wch-sdk-api
Index
External modules
- "index"
- "interfaces/delivery/v1/base.item"
- "interfaces/delivery/v1/content/content.item"
- "interfaces/delivery/v1/content/elements"
- "interfaces/delivery/v1/error/error"
- "interfaces/delivery/v1/layout/layout"
- "interfaces/delivery/v1/rendering/context/content.item.with.layout"
- "interfaces/delivery/v1/rendering/context/extended.context"
- "interfaces/delivery/v1/rendering/context/hub.context"
- "interfaces/delivery/v1/rendering/context/rendering.context"
- "interfaces/delivery/v1/search/search.result"
- "interfaces/delivery/v1/site/site"
- "interfaces/delivery/v1/site/site.child"
- "interfaces/delivery/v1/site/site.context"
- "interfaces/delivery/v1/site/site.page"
- "interfaces/delivery/v1/user/user"
- "interfaces/delivery/v1/users/currentuser/constants"
- "interfaces/logging/logger"
- "interfaces/logging/logger.factory"
- "interfaces/login/v1/basicauth/index"
- "interfaces/login/v1/redirect/index"
- "interfaces/login/v1/removecookies/index"
- "interfaces/messages/messages"
- "interfaces/messages/sdk.navigate.by.path.message"
- "interfaces/messages/sdk.refresh.message"
- "interfaces/messages/sdk.set.mode.message"
- "interfaces/messages/sdk.subscribe.active.route.message"
- "interfaces/messages/sdk.subscribe.message"
- "interfaces/messages/sdk.subscribe.mode.message"
- "interfaces/messages/sdk.subscribe.route.message"
- "interfaces/query"
- "interfaces/registry/v1/currenttenant/index"
- "interfaces/sdk/router/router"
- "interfaces/sdk/sdk"
- ["interfaces/sdk/search/s