Skip to content

Commit

Permalink
New version 2.6.6 (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevendavelaar authored Jun 4, 2023
1 parent 876b3b9 commit 195a582
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 9 deletions.
9 changes: 7 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Release Notes

- [Version 2.6.6](#v266)
- [Version 2.6.5](#v265)
- [Version 2.6.4](#v264)
- [Version 2.6.3](#v263)
Expand All @@ -15,14 +16,18 @@
- [Version 2.4.3](#v243)
- [Version 2.4.2](#v242)

## Version 2.6.6 <a name="v266">

### Fixed Issues

- Documentation fixes

## Version 2.6.5 <a name="v265">

### New Features

- **New UserInputReceived Entity Event Handler Method**: See [Writing Entity Event Handlers](https://github.com/oracle/bots-node-sdk/blob/master/ENTIY_EVENT_HANDLER.md) for more information.

- **REST Service Event Handlers**: REST service event handlers can be used to transform the REST request and response body when using the Call REST component in your flow. See [Writing REST Service Event Handlers](https://github.com/oracle/bots-node-sdk/blob/master/REST_SERVCICE_EVENT_HANDLER.md) for more information. This feature is only available in the Limited Availability release of Oracle Digital Assistant version 23.06.

### Fixed Issues

- Fixed TypeScript definition of EntityValidateEvent
Expand Down
25 changes: 23 additions & 2 deletions REST_SERVICE_EVENT_HANDLER.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ module.exports = {
*/
transformResponsePayload: async (event, context) => {
return event.payload;
},

/**
* Handler to transform the error response payload
* @param {TransformPayloadEvent} event
* @param {RestServiceContext} context
* @returns {object} the transformed error response payload
*/
transformErrorResponsePayload: async (event, context) => {
return event.payload;
}
}
};
Expand Down Expand Up @@ -95,6 +105,16 @@ export class MyRestServiceEventHandler implements RestServiceEventHandler {
*/
transformResponsePayload: async (event: TransformPayloadEvent, context: RestServiceContext): Promise<any> => {
return event.payload;
},

/**
* Handler to transform the error response payload
* @param {TransformPayloadEvent} event
* @param {RestServiceContext} context
* @returns {object} the transformed error response payload
*/
transformErrorResponsePayload: async (event: TransformPayloadEvent, context: RestServiceContext): Promise<any> => {
return event.payload;
}

};
Expand Down Expand Up @@ -122,6 +142,7 @@ The table below lists the event methods that can be implemented:

| Event | Description | Event Properties |
|--|--|--|
| `transformRequestPayload` | A handler that can be used to trasnform the REST request body. | <ul><li><b>payload</b>: The request body object.</li></ul>
| `transformResponsePayload` | A handler that can be used to trasnform the REST response body. | <ul><li><b>payload</b>: The response body object.</li></ul>
| `transformRequestPayload` | A handler that can be used to transform the REST request body. | <ul><li><b>payload</b>: The request body object.</li></ul>
| `transformResponsePayload` | A handler that can be used to transform the REST response body. | <ul><li><b>payload</b>: The response body object.</li></ul>
| `transformErrorResponsePayload` | A handler that can be used to transform the REST response body when the REST service returned an error status (400 or higher). | <ul><li><b>payload</b>: The response body object.</li></ul>

11 changes: 11 additions & 0 deletions bin/templates/components/restserviceeventhandler/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,18 @@ module.exports = {
*/
transformResponsePayload: async (event, context) => {
return event.payload;
},

/**
* Handler to transform the error response payload
* @param {TransformPayloadEvent} event
* @param {RestServiceContext} context
* @returns {object} the transformed error response payload
*/
transformErrorResponsePayload: async (event, context) => {
return event.payload;
}

}
};

Expand Down
10 changes: 10 additions & 0 deletions bin/templates/components/restserviceeventhandler/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ export class {{className}} implements RestServiceEventHandler {
*/
transformResponsePayload: async (event: TransformPayloadEvent, context: RestServiceContext): Promise<any> => {
return event.payload;
},

/**
* Handler to transform the error response payload
* @param {TransformPayloadEvent} event
* @param {RestServiceContext} context
* @returns {object} the transformed error response payload
*/
transformErrorResponsePayload: async (event: TransformPayloadEvent, context: RestServiceContext): Promise<any> => {
return event.payload;
}

};
Expand Down
2 changes: 1 addition & 1 deletion lib/restservice/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async function invokeRestServiceEventHandlers(component, context) {
if (returnValue) {
context.setRequestPayload(returnValue);
}
} else if (eventName === `transformResponsePayload`) {
} else if (eventName === `transformResponsePayload` || eventName === `transformErrorResponsePayload`) {
let payload = context.getResponsePayload();
event.properties = {'payload': payload};
logger.debug(`Invoking event handler ${eventName}`);
Expand Down
4 changes: 2 additions & 2 deletions 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.6.5",
"version": "2.6.6",
"description": "Oracle Bots 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/restservice/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function invokeRestServiceEventHandlers(component: RestServiceEvent
if (returnValue) {
context.setRequestPayload(returnValue);
}
} else if (eventName === `transformResponsePayload`) {
} else if (eventName === `transformResponsePayload` || eventName === `transformErrorResponsePayload`) {
let payload = context.getResponsePayload();
event.properties = {'payload': payload};
logger.debug(`Invoking event handler ${eventName}`);
Expand Down

0 comments on commit 195a582

Please sign in to comment.