Skip to content

Commit

Permalink
Version 2.7.2 (#51)
Browse files Browse the repository at this point in the history
- Removed logging that might disclose sensitive info
- Fixed name of bag item disambiguateMessage event in TypeScript
- Added new CMM message types and properties
- Typescript bots-node-sdk did not allow creating sub-type items for DateTime bag item.
  • Loading branch information
stevendavelaar authored Nov 22, 2023
1 parent eea4ced commit b94ee7d
Show file tree
Hide file tree
Showing 27 changed files with 563 additions and 58 deletions.
12 changes: 12 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Release Notes

- [Version 2.7.2](#v272)
- [Version 2.7.1](#v271)
- [Version 2.7.0](#v270)
- [Version 2.6.8](#v268)
Expand All @@ -20,6 +21,17 @@
- [Version 2.4.3](#v243)
- [Version 2.4.2](#v242)

## <a name="v272">Version 2.7.2 </a>

### New Features
- Added new CMM message types and properties

### Fixed Issues

- Removed logging that might disclose sensitive info
- Fixed name of bag item disambiguateMessage event in TypeScript
- Fixed issue with nested items not supported in entity item event in TypeScript

## <a name="v271">Version 2.7.1 </a>

### Fixed Issues
Expand Down
7 changes: 1 addition & 6 deletions lib/dataquery/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ async function invokeDataQueryEventHandlers(component, context) {
// update row with formatted value if attribute is included in the row and has a value
if (row[attributeName]) {
event.properties = {'attributeValue': row[attributeName]};
logger.debug(`Invoking event handler ${handlerPath} with event: ${JSON.stringify(event)}`);
let returnValue = await Promise.resolve(handler(event.properties, context));
if (returnValue) {
row[attributeName] = returnValue
Expand All @@ -43,7 +42,6 @@ async function invokeDataQueryEventHandlers(component, context) {
let metadata = context.getAttributeUISettings(attributeName);
if (metadata) {
event.properties = {'settings': metadata};
logger.debug(`Invoking event handler ${handlerPath} with event: ${JSON.stringify(event)}`);
let returnValue = await Promise.resolve(handler(event.properties, context));
if (returnValue) {
context.setAttributeUISettings(attributeName, returnValue);
Expand All @@ -54,7 +52,6 @@ async function invokeDataQueryEventHandlers(component, context) {
let settings = context.getUISettings();
if (settings) {
event.properties = {'settings': settings};
logger.debug(`Invoking event handler ${handlerPath} with event: ${JSON.stringify(event)}`);
let returnValue = await Promise.resolve(handler(event.properties, context));
if (returnValue) {
context.setUISettings(returnValue);
Expand All @@ -63,21 +60,19 @@ async function invokeDataQueryEventHandlers(component, context) {
} else if (handlerPath === `entity.changeResponseData`) {
let data = context.getQueryResult() || [];
event.properties = {'responseData': data};
logger.debug(`Invoking event handler ${handlerPath} with event: ${JSON.stringify(event)}`);
let returnValue = await Promise.resolve(handler(event.properties, context));
if (returnValue) {
context.setQueryResult(returnValue);
}
} else if (handlerPath === `entity.changeBotMessages`) {
event.properties = {'messages': context.getRequest().candidateMessages};
logger.debug(`Invoking event handler ${handlerPath} with event: ${JSON.stringify(event)}`);
let returnValue = await Promise.resolve(handler(event.properties, context));
if (returnValue) {
context.getResponse().messages = returnValue;
}
}
} else {
logger.debug(`No handler found for event: ${handlerPath}`);
logger.error(`No handler found for event: ${handlerPath}`);
break;
}
}
Expand Down
4 changes: 1 addition & 3 deletions lib/entity/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,13 @@ async function invokeResolveEntitiesEventHandlers(component, context) {
handlerPath = `entity.${eventName}`;
}
if (handler) {
logger.debug(`Invoking event handler ${handlerPath} with event: ${JSON.stringify(event)}`);
// event handlers can be async (returning a promise), but we dont want to enforce
// every event handler is async, hence Promise.resolve wrapping of invocation
let returnValue = await Promise.resolve(handler(event.properties || {}, context));
// make sure return value is a boolean
let retValue = returnValue === undefined ? true : (returnValue+''==='true')
logger.debug(`${eventName} returned ${retValue}`);
if (eventName==='shouldPrompt') {
logger.debug(`Adding ${itemName} to shouldPrompt cache with value ${retValue}`);
context._getShouldPromptCache()[itemName] = retValue;
if (retValue) {
// only invoke next shouldPrompt handler when current handler returned false
Expand All @@ -62,7 +60,7 @@ async function invokeResolveEntitiesEventHandlers(component, context) {
}
}
} else {
logger.debug(`No handler found for event: ${handlerPath}`);
logger.error(`No handler found for event: ${handlerPath}`);
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oracle/bots-node-sdk",
"version": "2.7.1",
"version": "2.7.2",
"description": "Oracle Digital Assistant SDK for custom component development and webhook integrations",
"main": "index.js",
"browser": "index-browser.js",
Expand Down
2 changes: 1 addition & 1 deletion ts/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export namespace Lib {

export type EntityItemPublishPromptMessageEvent = lib.EntityItemPublishPromptMessageEvent

export type EntityItemPublishDisambiguationMessageEvent = lib.EntityItemPublishDisambiguationMessageEvent
export type EntityItemPublishDisambiguateMessageEvent = lib.EntityItemPublishDisambiguateMessageEvent

export type EntityItemMaxPromptsReachedEvent = lib.EntityItemMaxPromptsReachedEvent

Expand Down
5 changes: 3 additions & 2 deletions ts/lib/component/kinds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ export interface EntityEvent {
}

export interface EntityItemEvents {
items?: EntityItems;
shouldPrompt?(event: EntityValidateEvent, context: EntityResolutionContext): void
validate?(event: EntityItemValidateEvent, context: EntityResolutionContext): void
publishPromptMessage?(event: EntityItemPublishPromptMessageEvent, context: EntityResolutionContext): void
publishDisambiguationMessage?(event: EntityItemPublishDisambiguationMessageEvent, context: EntityResolutionContext): void
publishDisambiguateMessage?(event: EntityItemPublishDisambiguateMessageEvent, context: EntityResolutionContext): void
maxPromptsReached?(event: EntityItemMaxPromptsReachedEvent, context: EntityResolutionContext): void
}

Expand Down Expand Up @@ -139,7 +140,7 @@ export interface EntityItemPublishPromptMessageEvent extends EntityBaseEvent {
promptCount: number;
}

export interface EntityItemPublishDisambiguationMessageEvent extends EntityBaseEvent {
export interface EntityItemPublishDisambiguateMessageEvent extends EntityBaseEvent {
disambiguationValues: object[];
}

Expand Down
7 changes: 1 addition & 6 deletions ts/lib/dataquery/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export async function invokeDataQueryEventHandlers(component: DataQueryEventHand
// update row with formatted value if attribute is included in the row and has a value
if (row[attributeName]) {
event.properties = {'attributeValue': row[attributeName]};
logger.debug(`Invoking event handler ${handlerPath} with event: ${JSON.stringify(event)}`);
let returnValue = await Promise.resolve(handler(event.properties, context));
if (returnValue) {
row[attributeName] = returnValue
Expand All @@ -46,7 +45,6 @@ export async function invokeDataQueryEventHandlers(component: DataQueryEventHand
let metadata = context.getAttributeUISettings(attributeName);
if (metadata) {
event.properties = {'settings': metadata};
logger.debug(`Invoking event handler ${handlerPath} with event: ${JSON.stringify(event)}`);
let returnValue = await Promise.resolve(handler(event.properties, context));
if (returnValue) {
context.setAttributeUISettings(attributeName, returnValue);
Expand All @@ -57,7 +55,6 @@ export async function invokeDataQueryEventHandlers(component: DataQueryEventHand
let settings = context.getUISettings();
if (settings) {
event.properties = {'settings': settings};
logger.debug(`Invoking event handler ${handlerPath} with event: ${JSON.stringify(event)}`);
let returnValue = await Promise.resolve(handler(event.properties, context));
if (returnValue) {
context.setUISettings(returnValue);
Expand All @@ -66,21 +63,19 @@ export async function invokeDataQueryEventHandlers(component: DataQueryEventHand
} else if (handlerPath === `entity.changeResponseData`) {
let data = context.getQueryResult() || [];
event.properties = {'responseData': data};
logger.debug(`Invoking event handler ${handlerPath} with event: ${JSON.stringify(event)}`);
let returnValue = await Promise.resolve(handler(event.properties, context));
if (returnValue) {
context.setQueryResult(returnValue);
}
} else if (handlerPath === `entity.changeBotMessages`) {
event.properties = {'messages': context.getRequest().candidateMessages};
logger.debug(`Invoking event handler ${handlerPath} with event: ${JSON.stringify(event)}`);
let returnValue = await Promise.resolve(handler(event.properties, context));
if (returnValue) {
context.getResponse().messages = returnValue;
}
}
} else {
logger.debug(`No handler found for event: ${handlerPath}`);
logger.error(`No handler found for event: ${handlerPath}`);
break;
}
}
Expand Down
5 changes: 1 addition & 4 deletions ts/lib/entity/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,12 @@ export async function invokeResolveEntitiesEventHandlers(
handlerPath = `entity.${eventName}`;
}
if (handler) {
logger.debug(`Invoking event handler ${handlerPath} with event: ${JSON.stringify(event)}`);
// event handlers can be async (returning a promise), but we dont want to enforce
// every event handler is async, hence Promise.resolve wrapping of invocation
let returnValue = await Promise.resolve(handler(event.properties || {}, context));
// make sure return value is a boolean
let retValue = returnValue === undefined ? true : (returnValue + '' === 'true')
logger.debug(`${eventName} returned ${retValue}`);
if (eventName === 'shouldPrompt') {
logger.debug(`Adding ${itemName} to shouldPrompt cache with value ${retValue}`);
context._getShouldPromptCache()[itemName] = retValue;
if (retValue) {
// only invoke next shouldPrompt handler when current handler returned false
Expand All @@ -60,7 +57,7 @@ export async function invokeResolveEntitiesEventHandlers(
}
}
} else {
logger.debug(`No handler found for event: ${handlerPath}`);
logger.error(`No handler found for event: ${handlerPath}`);
break;
}
}
Expand Down
6 changes: 1 addition & 5 deletions ts/lib2/llmcomponent/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,11 @@ export async function invokeLlmComponentHandlers(component: LlmComponentHandler,
// event handlers can be async (returning a promise), but we dont want to enforce
// every event handler is async, hence Promise.resolve wrapping of invocation
if (eventName === `validateResponsePayload` || eventName === `validateRequestPayload`) {
logger.debug(`Invoking event handler ${eventName}`);
let returnValue = await Promise.resolve(handler(event.properties, context));
// make sure return value is a boolean
let retValue = returnValue === undefined ? true : (returnValue + '' === 'true')
logger.debug(`${eventName} returned ${retValue}`);
context.getResponse().valid = retValue;
} else if (eventName === `changeBotMessages` ) {
logger.debug(`Invoking event handler ${eventName}`);
// convert json messages to message class
const mf = context.getMessageFactory();
let messages = event.properties.messages.map(msg => mf.messageFromJson(msg));
Expand All @@ -48,11 +45,10 @@ export async function invokeLlmComponentHandlers(component: LlmComponentHandler,
let currMessages = context.getResponse().messages || [];
context.getResponse().messages = currMessages.concat(messages);
} else {
logger.debug(`Invoking ${event.custom ? 'custom ' : ''}event handler ${eventName}`);
await Promise.resolve(handler(event.properties, context));
}
} else {
logger.debug(`No handler found for event: ${eventName}`);
logger.error(`No handler found for event: ${eventName}`);
}
}

Expand Down
4 changes: 1 addition & 3 deletions ts/lib2/llmtransformation/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,18 @@ export async function invokeLlmTransformationHandlers(component: LlmTransformati
// event handlers can be async (returning a promise), but we dont want to enforce
// every event handler is async, hence Promise.resolve wrapping of invocation
if (eventName === `transformRequestPayload`) {
logger.debug(`Invoking event handler ${eventName}`);
let returnValue = await Promise.resolve(handler(event.properties, context));
if (returnValue) {
context.setRequestPayload(returnValue);
}
} else if (eventName === `transformResponsePayload` || eventName === `transformErrorResponsePayload`) {
logger.debug(`Invoking event handler ${eventName}`);
let returnValue = await Promise.resolve(handler(event.properties, context));
if (returnValue) {
context.setResponsePayload(returnValue);
}
}
} else {
logger.debug(`No handler found for event: ${eventName}`);
logger.error(`No handler found for event: ${eventName}`);
}
}

Expand Down
28 changes: 28 additions & 0 deletions ts/lib2/messagev2/action/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class Action extends ChannelCustomizable {
private voice?: Voice;
private imageUrl?: string;
private style?: ActionStyle;
private displayType?: DisplayType;

/**
* Deserialize nested object properties into corresponding class instances
Expand Down Expand Up @@ -119,6 +120,24 @@ export class Action extends ChannelCustomizable {
return this;
}

/**
* Gets the style of the action.
* @returns {DisplayType} The display type of the action.
*/
public getDisplayType(): DisplayType {
return this.displayType;
}

/**
* Sets the display type of the action.
* @param {DisplayType} displayType - The display type to set.
* @returns The current instance of the Action class.
*/
public setDisplayType(displayType: DisplayType): this {
this.displayType = displayType;
return this;
}

}

/**
Expand All @@ -129,3 +148,12 @@ export enum ActionStyle {
danger = 'danger',
}

/**
* Represents the display type of an action.
*/
export enum DisplayType {
button = 'button',
link = 'link',
icon = 'icon',
}

1 change: 1 addition & 0 deletions ts/lib2/messagev2/action/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './callAction';
export * from './popupAction';
export * from './action';
export * from './keyword';
export * from './locationAction';
Expand Down
53 changes: 53 additions & 0 deletions ts/lib2/messagev2/action/popupAction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { Action, NonRawMessage, MessageUtil } from '../internal';

/**
* Represents a popup action. When clicked a popup dialog opens that shows the popup content
* @extends Action
*/
export class PopupAction extends Action {
public readonly type: string = 'popup';
private popupContent: NonRawMessage;

/**
* Creates an instance of PopupAction.
* @param label - The label of the popup action.
* @param popupContent - The popup content associated with the popup action.
*/
constructor(label: string, popupContent: NonRawMessage) {
super(label);
this.popupContent = popupContent;
}

/**
* Deserialize nested object properties into corresponding class instances
*/
public deserializeNestedProperties(): void {
super.deserializeNestedProperties();
if (this.popupContent) {
this.popupContent = MessageUtil.deserializeMessage(this.popupContent);
}
}

/**
* Gets the popup content associated with the popup action.
* @returns The popup content associated with the popup action.
*/
public getPopupContent(): NonRawMessage {
return this.popupContent;
}

/**
* Sets the popup content associated with the popup action.
* @param popupContent - The popup content to set.
* @returns The current instance of the PopupAction class.
*/
public setPopupContent(popupContent: NonRawMessage): this {
this.popupContent = popupContent;
return this;
}

}




Loading

0 comments on commit b94ee7d

Please sign in to comment.