@coveo/explorer-messenger
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -1,13 +0,32 @@ | ||
export declare function createExplorerMessenger(): { | ||
sendMessage(message: ExplorerMessage): void; | ||
}; | ||
export declare function createExplorerMessenger(): ExplorerMessenger; | ||
export declare interface EventProtocol extends Payload { | ||
/** | ||
* The `EventProtocolEvent` object defines the valid format of an event to be emitted to the Event API. | ||
*/ | ||
export declare interface EventProtocolEvent extends Payload { | ||
/** | ||
* Readonly `Meta` object. | ||
*/ | ||
meta: Readonly<Meta>; | ||
} | ||
/** | ||
* the `EventProtocolMessage` object provides a structured representation of a message to be emitted for the event protocol's validation. | ||
*/ | ||
export declare interface EventProtocolMessage { | ||
/** | ||
* Kind of message, always set to `EVENT_PROTOCOL`. | ||
*/ | ||
kind: "EVENT_PROTOCOL"; | ||
event: EventProtocol; | ||
/** | ||
* Message's structured event. | ||
*/ | ||
event: EventProtocolEvent; | ||
/** | ||
* Endpoint defined to communicate with the Event API. | ||
*/ | ||
url: string; | ||
/** | ||
* Token to authorize the access to the Event API's validation endpoint. | ||
*/ | ||
token: string; | ||
@@ -18,3 +37,18 @@ } | ||
declare interface ExplorerMessenger { | ||
/** | ||
* Sends an explorer message between window objects. | ||
* @param {ExplorerMessage} message - message to be sent. | ||
* @returns {void} | ||
*/ | ||
sendMessage: (message: ExplorerMessage) => void; | ||
} | ||
/** | ||
* The `Meta` object provides a structured representation of metadata associated with an emitted event. | ||
*/ | ||
declare interface Meta { | ||
/** | ||
* The type of event. | ||
*/ | ||
type: string; | ||
@@ -21,0 +55,0 @@ } |
{ | ||
"name": "@coveo/explorer-messenger", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "module": "./dist/messenger.js", |
@@ -7,2 +7,4 @@ # Explorer Messenger | ||
First, create an instance of explorer messenger in your project. This instance can then be used to send a message. | ||
``` | ||
@@ -14,1 +16,30 @@ import { createExplorerMessenger } from "@coveo/explorer-messenger"; | ||
``` | ||
## Message | ||
Each message's format will differ based on the kind of event it will be sent to. | ||
### Event protocol | ||
| Name | Type | Description | | ||
| ----- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------- | | ||
| kind | "EVENT_PROTOCOL" | Kind of message, always set to "EVENT_PROTOCOL" | | ||
| event | EventProtocolEvent | Message's structured event | | ||
| url | string | Endpoint defined to communicate with the Event API | | ||
| token | string | Token to authorize the access to the Event API's validation endpoint. A view access level to the validate event privilege is required | | ||
## Interfaces | ||
### EventProtocolEvent | ||
| Name | Type | Description | | ||
| ---- | ---- | ------------- | | ||
| meta | Meta | `Meta` object | | ||
You can set additional properties to define the event's payload. | ||
#### Meta | ||
| Name | Type | Description | | ||
| ---- | ------ | ----------------- | | ||
| type | string | The type of event | |
4094
62
44