configurapi-runner-ws 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,4 +8,5 @@
8
8
  - The last chunk will have `X-Stream: done` header.
9
9
  - Check `X-Stream-ID: $id` header for the stream ID. A chunk belonging to the same stream will have the same stream ID.
10
10
  - connectionId is available at `event.request.headers.connectionId`
11
- - `on_connect` and `on_disconnect` will be called when a new connection is made or closed.
11
+ - `on_connect` and `on_disconnect` will be called when a new connection is made or closed.
12
+ - Use `Request.headers.push-function` to send an out-of-band message. The function is async and accepts an object to send back to the caller.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "configurapi-runner-ws",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "description": "Websocket runner for configurapi.",
5
5
  "bin": {
6
6
  "configurapi-runner-ws": "src/app.mjs"
package/src/wsAdapter.js CHANGED
@@ -94,7 +94,7 @@ module.exports = {
94
94
 
95
95
  if (ws.readyState === WebSocket.OPEN)
96
96
  {
97
- const headers = { 'X-Stream-Id': streamId, 'X-Stream': 'done' };
97
+ const headers = { 'X-Stream-ID': streamId, 'X-Stream': 'done' };
98
98
  const response = new Response('', 204, headers);
99
99
 
100
100
  ws.send(JSON.stringify(response), (err) =>
@@ -149,7 +149,8 @@ module.exports = {
149
149
  request.params = data.params || {};
150
150
  request.payload = data.payload || undefined;
151
151
 
152
- request.headers['connectionId'] = ws.connectionId;
152
+ request.headers['Connection-ID'] = ws.connectionId;
153
+ request.headers['Push-Function'] = async (data)=>await this.write(ws, data);
153
154
 
154
155
  return request;
155
156
  }