@openfin/bloomberg
Advanced tools
Comparing version 1.0.0 to 1.1.0-beta.1
@@ -1,9 +0,1 @@ | ||
MIT License | ||
Copyright (c) 2022 OpenFin Ltd | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
Please refer to the [OpenFin Developer License Agreement](https://www.openfin.co/developer-agreement/). |
{ | ||
"name": "@openfin/bloomberg", | ||
"description": "Connect apps running in OpenFin with the Bloomberg Terminal.", | ||
"version": "1.0.0", | ||
"version": "1.1.0-beta.1", | ||
"author": "OpenFin Inc.", | ||
@@ -11,3 +11,3 @@ "homepage": "https://www.openfin.co/", | ||
], | ||
"license": "MIT", | ||
"license": "SEE LICENSE IN LICENSE.MD", | ||
"main": "openfin.bloomberg.js", | ||
@@ -17,5 +17,5 @@ "types": "types/index.d.ts", | ||
"@finos/fdc3": "^1.2.0", | ||
"@openfin/core": "^26.70.16", | ||
"deepmerge-ts": "^4.0.3" | ||
"@openfin/core": "^28.72.19", | ||
"deepmerge-ts": "^4.3.0" | ||
} | ||
} |
@@ -24,7 +24,5 @@ # Bloomberg Integration for OpenFin Container | ||
The code in this package is distributed under the MIT license. | ||
You can learn more about OpenFin licensing at the links listed below or email us at support@openfin.co with questions. | ||
However, if you run this code, it may call on the OpenFin RVM or OpenFin Runtime, which are covered by OpenFin's Developer, Community, and Enterprise licenses. You can learn more about OpenFin licensing at the links listed below or email us at support@openfin.co with questions. | ||
- [Licensing](https://www.openfin.co/licensing/) | ||
- [Developer agreement](https://openfin.co/developer-agreement/) |
@@ -1,1 +0,1 @@ | ||
class Group{constructor(e,s,t){this._lastUpdate=0,this._securityCacheExpiration=15e3,this._securityCache="",this._name=s,this._type=t,this._terminalProxy=e}get name(){return this._name}get type(){return this._type}getSecurity(){return new Promise(((e,s)=>{this._terminalProxy.getAllGroups((t=>{const n=t.find((e=>e.name===this._name));n?(this._securityCache=n.security,this._lastUpdate=(new Date).getTime(),e(this._securityCache)):s(new Error(`Group ${name} is not found.`))}),((e,t)=>{s(new Error(t))}))}))}getCachedSecurity(){return new Promise((async(e,s)=>{const t=(new Date).getTime();(!this._securityCache||!this._lastUpdate||t-this._lastUpdate>this._securityCacheExpiration)&&await this.getSecurity(),e(this._securityCache)}))}setSecurity(e,s){return new Promise(((t,n)=>{this._terminalProxy.setGroupSecurity((()=>{this._securityCache=e,this._lastUpdate=(new Date).getTime(),t()}),((e,s)=>{n(new Error(s))}),this._name,e,s)}))}}function isBBEnvAvailable(){return!!(window.bb&&window.bb.apps&&window.bb.apps.app&&window.bb.apps.event)}function uuid(){const e="0123456789ABCDEF".split("");let s,t=[],n=Math.random;t[8]=t[13]=t[18]=t[23]="-",t[14]="4";for(var r=0;r<36;r++)t[r]||(s=0|16*n(),t[r]=e[19==r?3&s|8:15&s]);return t.join("")}function base64Encode(e){const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let t,n,r,i,o,c,u,a="",l=0;for(;l<e.length;)t=e.charCodeAt(l++),n=e.charCodeAt(l++),r=e.charCodeAt(l++),i=t>>2,o=(3&t)<<4|n>>4,c=(15&n)<<2|r>>6,u=63&r,isNaN(n)?c=u=64:isNaN(r)&&(u=64),a=a+s.charAt(i)+s.charAt(o)+s.charAt(c)+s.charAt(u);return a}class WebSocketProxy{constructor(){this._seqNumber=0,this._isConnecting=!1,this._isConnected=!1,this._isRegistered=!1,this._sessionId="",this._queuedRequests=[],this._pendingRequests={},this._minPortRange=51800,this._maxPortRange=51820,this._currentPort=51800,this._responseTimeout=15e3,this._disconnectEventSubscriptions={},this._groupEventSubscriptions={},this.sendRemoteMessage=(e,s,t,n)=>{if(this._isRegistered||e.register||this.sendRemoteMessage({register:{}},12,null,console.error),this._sessionId||(this._sessionId=`{${uuid()}}`),e.setGroupValue&&!e.setGroupValue.cookie&&(e.setGroupValue.cookie=this._sessionId),e.subscribeGroupEvents){const s=e.subscribeGroupEvents.subId;delete e.subscribeGroupEvents.subId,n=e=>{delete this._groupEventSubscriptions[s],n&&n(e)}}const r={sessionId:this._sessionId,correlationId:++this._seqNumber,request:e},i=JSON.stringify(r),o=s>12,c=o?{appId:r.appId,sessionId:r.sessionId,correlationId:r.correlationId,payloadSchemaName:"ap3g_internal",payloadSchemaVersion:2,payloadMsgType:s,payload:base64Encode(i)}:void 0,u={envelope:{schemaName:o?"blp_lpad_msg":"blp_remote_controller",schemaVersion:2,message:o?JSON.stringify(c):i},correlationId:r.correlationId,expectResponse:!0,onsuccess:t,onerror:n};this._pendingRequests[r.correlationId]=u,this._isConnected?this.sendRequest(u):(this._queuedRequests.push(u),this.connect())}}addEventListener(e){const s=Object.keys(this._groupEventSubscriptions).length+1;return this._groupEventSubscriptions[s]=e,s}removeEventListener(e){return delete this._groupEventSubscriptions[e],Object.keys(this._groupEventSubscriptions).length}addDisconnectEventListener(e){const s=Object.keys(this._disconnectEventSubscriptions).length+1;return this._disconnectEventSubscriptions[s]=e,s}removeDisconnectEventListener(e){const s=Object.keys(this._disconnectEventSubscriptions).length;return delete this._disconnectEventSubscriptions[e],s!==Object.keys(this._disconnectEventSubscriptions).length}sendRequest(e){const s=JSON.stringify(e.envelope);this._webSocket&&this._webSocket.send(s),e.expectResponse?setTimeout((()=>{this._pendingRequests[e.correlationId]&&(delete this._pendingRequests[e.correlationId],e.onerror&&e.onerror(0,"Response Timeout"))}),this._responseTimeout):delete this._pendingRequests[e.correlationId]}connect(){try{if(this._isConnecting)return;this._isConnecting=!0,this._webSocket=new WebSocket("ws://localhost:"+this._currentPort,"terminal_api"),this._webSocket.onopen=this.onWebSocketOpen.bind(this),this._webSocket.onmessage=this.onWebSocketMessage.bind(this),this._webSocket.onclose=this.onWebSocketClose.bind(this),this._webSocket.onerror=this.onWebSocketError.bind(this)}catch(e){this._webSocket=void 0,this.cancelPendingRequests("WebSocket Exception "+e),console.error(e)}}cancelPendingRequests(e){this._isConnected=!1,this._isConnecting=!1,this._isRegistered=!1,this._sessionId="";for(let s in this._pendingRequests){const t=this._pendingRequests[s];t&&t.onerror&&t.onerror(0,e)}this._pendingRequests={}}onWebSocketClose(e){if(console.log("WebSocket Closed; Reason: "+e.reason+", Code: "+e.code+", WasClean: "+e.wasClean),this._isConnected){const s={};e&&void 0!==e.reason&&(s.reason=e.reason),e&&void 0!==e.code&&(s.code=e.code),e&&void 0!==e.wasClean&&(s.wasClean=e.wasClean),this._currentPort=this._minPortRange,this.cancelPendingRequests({status:"error",message:"Connection Closed",details:s});for(let e in this._disconnectEventSubscriptions){const s=this._disconnectEventSubscriptions[e];s&&s(e)}}}onWebSocketError(){if(console.log("WebSocket Error; readyState: "+(this._webSocket&&this._webSocket.readyState)),this._isConnecting=!1,this._currentPort<this._maxPortRange)this._currentPort+=1,this.connect();else{this._currentPort=this._minPortRange;const e={readyState:this._webSocket&&this._webSocket.readyState};this.cancelPendingRequests({status:"error",message:"Connection Error",details:e})}}onWebSocketOpen(){for(this._isConnected=!0,this._isConnecting=!1;this._queuedRequests.length>0;)this.sendRequest(this._queuedRequests.shift())}onWebSocketMessage(e){var s=e&&e.data?e.data:"null",t=JSON.parse(s),n=t?JSON.parse(t.message):null,r=n&&n.response?this._pendingRequests[n.correlationId]:null;r&&delete this._pendingRequests[n.correlationId],this.processResponse(r,n.response)}getGroupInfo(e){return e?{name:e.name,type:e.type,security:"security"===e.type&&e.value?e.value:void 0}:{}}processResponse(e,s){if(s.success)e.onsuccess&&e.onsuccess();else if(s.registrationComplete)this._isRegistered=!0,console.log("Registration Complete; Session: "+this._sessionId),e.onsuccess&&e.onsuccess();else if(s.getAllGroups){const t=s.getAllGroups.group;e.onsuccess&&e.onsuccess(t?t.map(this.getGroupInfo):[])}else if(s.groupValue)e.onsuccess&&e.onsuccess(this.getGroupInfo(s.groupValue.group));else if(s.groupEvent){if(s.groupEvent.valueChanged){const e=s.groupEvent.valueChanged.group,t=s.groupEvent.valueChanged.cookie===this._sessionId?void 0:s.groupEvent.valueChanged.cookie;for(let s in this._groupEventSubscriptions){const n=this._groupEventSubscriptions[s];n&&n(e,t)}}}else e.onerror&&e.onerror(s.failure&&s.failure.code||0,s.failure?`${s.failure.message} ${s.failure.humanMessage}`:"Unknown Response")}}class WebSocketTerminalConnect{constructor(){this._webSocket=new WebSocketProxy}runFunction(e,s,t,n,r,i,o,c){let u="";if(t&&t.length?1!==n&&2!==n&&3!==n&&4!==n&&5!==n&&(u="Invalid Or Missing Parameter: panel"):u="Invalid Or Missing Parameter: mnemonic",u)return console.error("runFunctionInPanel error: "+u),void(s&&s(0,u));const a={runFunctionInPanel:{mnemonic:t,panel:n}};if(r){const e=[];e.push(r),i&&e.push(i),a.runFunctionInPanel.securities=e}o&&(a.runFunctionInPanel.tails=o),c&&(a.runFunctionInPanel.applicationProperties=c),this._webSocket.sendRemoteMessage(a,0,e,s)}getAllGroups(e,s){this._webSocket.sendRemoteMessage({getAllGroups:{}},13,e,s)}getGroup(e,s,t){if(!t||!t.length){const e="Invalid Or Missing Parameter: name";return console.error(e),void(s&&s(0,e))}this._webSocket.sendRemoteMessage({getGroupValue:{name:t}},15,e,s)}setGroupSecurity(e,s,t,n,r){let i="";if(t&&t.length?n&&n.length||(i="Invalid Or Missing Parameter: security"):i="Invalid Or Missing Parameter: name",i)return console.error("setGroupContext error: "+i),void(s&&s(0,i));this._webSocket.sendRemoteMessage({setGroupValue:{name:t,value:n,cookie:r}},14,e,s)}subscribeGroupEvents(e,s,t){if(!t){const e="Invalid Or Missing Parameter: callback";return console.error("subscribeGroupEvents error: "+e),void(s&&s(0,e))}const n=this._webSocket.addEventListener(t);1===n?this._webSocket.sendRemoteMessage({subscribeGroupEvents:{subId:n}},16,(()=>{e&&e(n)}),(e=>{s&&s(0,e)})):e&&e(n)}unsubscribeGroupEvents(e,s,t){if(!t){const e="Invalid Or Missing Parameter: cookie";return console.error("unsubscribeGroupEvents error: "+e),void(s&&s(0,e))}0===this._webSocket.removeEventListener(t)?this._webSocket.sendRemoteMessage({unsubscribeGroupEvents:{}},17,e,s):e&&e()}subscribeDisconnectEvent(e,s,t){if(!t){const e="Invalid Or Missing Parameter: callback";return console.error("subscribeDisconnectEvent error: "+e),s&&s(0,e),null}const n=this._webSocket.addDisconnectEventListener(t);return e&&e(n),n}unsubscribeDisconnectEvent(e,s,t){if(!t){const e="Invalid Or Missing Parameter: cookie";return console.error("unsubscribeDisconnectEvent error: "+e),s&&s(0,e),!1}return this._webSocket.removeDisconnectEventListener(t)?(e&&e(),!0):(s&&s(0,"Invalid Subscription"),!1)}}class WebappTerminalConnect{constructor(){this.runFunction=window.bb.apps.tc.runFunction,this.getGroup=window.bb.apps.tc.getGroup,this.setGroupSecurity=window.bb.apps.tc.setGroupSecurity,this.getAllGroups=window.bb.apps.tc.getAllGroups,this.subscribeGroupEvents=window.bb.apps.tc.subscribeGroupEvents,this.unsubscribeGroupEvents=window.bb.apps.tc.unsubscribeGroupEvents}subscribeDisconnectEvent(e,s,t){}unsubscribeDisconnectEvent(e,s,t){}}class GlobalTerminal{constructor(e=!isBBEnvAvailable()){this._helperSetGroupValues=e=>{const s=new Group(this._terminalProxy,e.name,e.type);return s._securityCache=e.security,s._lastUpdate=(new Date).getTime(),s},this._terminalProxy=e?new WebSocketTerminalConnect:new WebappTerminalConnect}runFunction(e,s,t,n,r){return new Promise(((i,o)=>{this._terminalProxy.runFunction(i,((e,s)=>{o(new Error(s))}),e,s,t||null,n||null,r||null)}))}getAllGroups(){return new Promise(((e,s)=>{this._terminalProxy.getAllGroups((s=>{e(Array.from(s,this._helperSetGroupValues))}),((e,t)=>{s(new Error(t))}))}))}getGroup(e){return new Promise(((s,t)=>{this._terminalProxy.getAllGroups((n=>{const r=n.find((s=>s.name===e));r?s(this._helperSetGroupValues(r)):t(new Error(`Group ${e} is not found.`))}),((e,s)=>{t(new Error(s))}))}))}subscribeGroupEvents(e){return new Promise(((s,t)=>{this._terminalProxy.subscribeGroupEvents((e=>{s(e)}),((e,s)=>{t(new Error(s))}),((s,t)=>{e(this._helperSetGroupValues(s),t)}))}))}unsubscribeGroupEvents(e){return new Promise(((s,t)=>{this._terminalProxy.unsubscribeGroupEvents((()=>{s()}),((e,s)=>{t(new Error(s))}),e)}))}}export const terminal=(window.BB=window.BB||{},window.BB.Apps=window.BB.Apps||{},window.BB.Apps.Terminal=window.BB.Apps.Terminal||new GlobalTerminal,window.BB.Apps.Terminal); | ||
class Group{constructor(e,s,t){this._lastUpdate=0,this._securityCacheExpiration=15e3,this._securityCache="",this._name=s,this._type=t,this._terminalProxy=e}get name(){return this._name}get type(){return this._type}getSecurity(){return new Promise(((e,s)=>{this._terminalProxy.getAllGroups((t=>{const n=t.find((e=>e.name===this._name));n?(this._securityCache=n.security,this._lastUpdate=(new Date).getTime(),e(this._securityCache)):s(new Error(`Group ${name} is not found.`))}),((e,t)=>{s(new Error(t))}))}))}getCachedSecurity(){return new Promise((async(e,s)=>{const t=(new Date).getTime();(!this._securityCache||!this._lastUpdate||t-this._lastUpdate>this._securityCacheExpiration)&&await this.getSecurity(),e(this._securityCache)}))}setSecurity(e,s){return new Promise(((t,n)=>{this._terminalProxy.setGroupSecurity((()=>{this._securityCache=e,this._lastUpdate=(new Date).getTime(),t()}),((e,s)=>{n(new Error(s))}),this._name,e,s)}))}}function isBBEnvAvailable(){return!!(window.bb&&window.bb.apps&&window.bb.apps.app&&window.bb.apps.event)}function uuid(){const e="0123456789ABCDEF".split("");let s,t=[],n=Math.random;t[8]=t[13]=t[18]=t[23]="-",t[14]="4";for(var r=0;r<36;r++)t[r]||(s=0|16*n(),t[r]=e[19==r?3&s|8:15&s]);return t.join("")}function base64Encode(e){const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let t,n,r,i,o,c,u,a="",l=0;for(;l<e.length;)t=e.charCodeAt(l++),n=e.charCodeAt(l++),r=e.charCodeAt(l++),i=t>>2,o=(3&t)<<4|n>>4,c=(15&n)<<2|r>>6,u=63&r,isNaN(n)?c=u=64:isNaN(r)&&(u=64),a=a+s.charAt(i)+s.charAt(o)+s.charAt(c)+s.charAt(u);return a}class WebSocketProxy{constructor(){this._seqNumber=0,this._isConnecting=!1,this._isConnected=!1,this._isRegistered=!1,this._sessionId="",this._queuedRequests=[],this._pendingRequests={},this._minPortRange=51800,this._maxPortRange=51820,this._currentPort=51800,this._responseTimeout=15e3,this._disconnectEventSubscriptions={},this._groupEventSubscriptions={},this.sendRemoteMessage=(e,s,t,n)=>{if(this._isRegistered||e.register||this.sendRemoteMessage({register:{}},12,null,console.error),this._sessionId||(this._sessionId=`{${uuid()}}`),e.setGroupValue&&!e.setGroupValue.cookie&&(e.setGroupValue.cookie=this._sessionId),e.subscribeGroupEvents){const s=e.subscribeGroupEvents.subId;delete e.subscribeGroupEvents.subId,n=e=>{delete this._groupEventSubscriptions[s],n&&n(e)}}const r={sessionId:this._sessionId,correlationId:++this._seqNumber,request:e},i=JSON.stringify(r),o=s>12,c=o?{appId:r.appId,sessionId:r.sessionId,correlationId:r.correlationId,payloadSchemaName:"ap3g_internal",payloadSchemaVersion:2,payloadMsgType:s,payload:base64Encode(i)}:void 0,u={envelope:{schemaName:o?"blp_lpad_msg":"blp_remote_controller",schemaVersion:2,message:o?JSON.stringify(c):i},correlationId:r.correlationId,expectResponse:!0,onsuccess:t,onerror:n};this._pendingRequests[r.correlationId]=u,this._isConnected?this.sendRequest(u):(this._queuedRequests.push(u),this.connect())}}addEventListener(e){const s=Object.keys(this._groupEventSubscriptions).length+1;return this._groupEventSubscriptions[s]=e,s}removeEventListener(e){return delete this._groupEventSubscriptions[e],Object.keys(this._groupEventSubscriptions).length}addDisconnectEventListener(e){const s=Object.keys(this._disconnectEventSubscriptions).length+1;return this._disconnectEventSubscriptions[s]=e,s}removeDisconnectEventListener(e){const s=Object.keys(this._disconnectEventSubscriptions).length;delete this._disconnectEventSubscriptions[e];return s!==Object.keys(this._disconnectEventSubscriptions).length}sendRequest(e){const s=JSON.stringify(e.envelope);this._webSocket&&this._webSocket.send(s),e.expectResponse?setTimeout((()=>{this._pendingRequests[e.correlationId]&&(delete this._pendingRequests[e.correlationId],e.onerror&&e.onerror(0,"Response Timeout"))}),this._responseTimeout):delete this._pendingRequests[e.correlationId]}connect(){try{if(this._isConnecting)return;this._isConnecting=!0,this._webSocket=new WebSocket("ws://localhost:"+this._currentPort,"terminal_api"),this._webSocket.onopen=this.onWebSocketOpen.bind(this),this._webSocket.onmessage=this.onWebSocketMessage.bind(this),this._webSocket.onclose=this.onWebSocketClose.bind(this),this._webSocket.onerror=this.onWebSocketError.bind(this)}catch(e){this._webSocket=void 0,this.cancelPendingRequests("WebSocket Exception "+e),console.error(e)}}cancelPendingRequests(e){this._isConnected=!1,this._isConnecting=!1,this._isRegistered=!1,this._sessionId="";for(let s in this._pendingRequests){const t=this._pendingRequests[s];t&&t.onerror&&t.onerror(0,e)}this._pendingRequests={}}onWebSocketClose(e){if(console.log("WebSocket Closed; Reason: "+e.reason+", Code: "+e.code+", WasClean: "+e.wasClean),this._isConnected){const s={};e&&void 0!==e.reason&&(s.reason=e.reason),e&&void 0!==e.code&&(s.code=e.code),e&&void 0!==e.wasClean&&(s.wasClean=e.wasClean),this._currentPort=this._minPortRange,this.cancelPendingRequests({status:"error",message:"Connection Closed",details:s});for(let e in this._disconnectEventSubscriptions){const s=this._disconnectEventSubscriptions[e];s&&s(e)}}}onWebSocketError(){if(console.log("WebSocket Error; readyState: "+(this._webSocket&&this._webSocket.readyState)),this._isConnecting=!1,this._currentPort<this._maxPortRange)this._currentPort+=1,this.connect();else{this._currentPort=this._minPortRange;const e={readyState:this._webSocket&&this._webSocket.readyState};this.cancelPendingRequests({status:"error",message:"Connection Error",details:e})}}onWebSocketOpen(){for(this._isConnected=!0,this._isConnecting=!1;this._queuedRequests.length>0;)this.sendRequest(this._queuedRequests.shift())}onWebSocketMessage(e){var s=e&&e.data?e.data:"null",t=JSON.parse(s),n=t?JSON.parse(t.message):null,r=n&&n.response?this._pendingRequests[n.correlationId]:null;r&&delete this._pendingRequests[n.correlationId],this.processResponse(r,n.response)}getGroupInfo(e){return e?{name:e.name,type:e.type,security:"security"===e.type&&e.value?e.value:void 0}:{}}processResponse(e,s){if(s.success)e.onsuccess&&e.onsuccess();else if(s.registrationComplete)this._isRegistered=!0,console.log("Registration Complete; Session: "+this._sessionId),e.onsuccess&&e.onsuccess();else if(s.getAllGroups){const t=s.getAllGroups.group;e.onsuccess&&e.onsuccess(t?t.map(this.getGroupInfo):[])}else if(s.groupValue)e.onsuccess&&e.onsuccess(this.getGroupInfo(s.groupValue.group));else if(s.groupEvent){if(s.groupEvent.valueChanged){const e=s.groupEvent.valueChanged.group,t=s.groupEvent.valueChanged.cookie===this._sessionId?void 0:s.groupEvent.valueChanged.cookie;for(let s in this._groupEventSubscriptions){const n=this._groupEventSubscriptions[s];n&&n(e,t)}}}else e.onerror&&e.onerror(s.failure&&s.failure.code||0,s.failure?`${s.failure.message} ${s.failure.humanMessage}`:"Unknown Response")}}class WebSocketTerminalConnect{constructor(){this._webSocket=new WebSocketProxy}runFunction(e,s,t,n,r,i,o,c){let u="";if(t&&t.length?1!==n&&2!==n&&3!==n&&4!==n&&5!==n&&(u="Invalid Or Missing Parameter: panel"):u="Invalid Or Missing Parameter: mnemonic",u)return console.error("runFunctionInPanel error: "+u),void(s&&s(0,u));const a={runFunctionInPanel:{mnemonic:t,panel:n}};if(r){const e=[];e.push(r),i&&e.push(i),a.runFunctionInPanel.securities=e}o&&(a.runFunctionInPanel.tails=o),c&&(a.runFunctionInPanel.applicationProperties=c),this._webSocket.sendRemoteMessage(a,0,e,s)}getAllGroups(e,s){this._webSocket.sendRemoteMessage({getAllGroups:{}},13,e,s)}getGroup(e,s,t){if(!t||!t.length){const e="Invalid Or Missing Parameter: name";return console.error(e),void(s&&s(0,e))}this._webSocket.sendRemoteMessage({getGroupValue:{name:t}},15,e,s)}setGroupSecurity(e,s,t,n,r){let i="";if(t&&t.length?n&&n.length||(i="Invalid Or Missing Parameter: security"):i="Invalid Or Missing Parameter: name",i)return console.error("setGroupContext error: "+i),void(s&&s(0,i));this._webSocket.sendRemoteMessage({setGroupValue:{name:t,value:n,cookie:r}},14,e,s)}subscribeGroupEvents(e,s,t){if(!t){const e="Invalid Or Missing Parameter: callback";return console.error("subscribeGroupEvents error: "+e),void(s&&s(0,e))}const n=this._webSocket.addEventListener(t);1===n?this._webSocket.sendRemoteMessage({subscribeGroupEvents:{subId:n}},16,(()=>{e&&e(n)}),(e=>{s&&s(0,e)})):e&&e(n)}unsubscribeGroupEvents(e,s,t){if(!t){const e="Invalid Or Missing Parameter: cookie";return console.error("unsubscribeGroupEvents error: "+e),void(s&&s(0,e))}0===this._webSocket.removeEventListener(t)?this._webSocket.sendRemoteMessage({unsubscribeGroupEvents:{}},17,e,s):e&&e()}subscribeDisconnectEvent(e,s,t){if(!t){const e="Invalid Or Missing Parameter: callback";return console.error("subscribeDisconnectEvent error: "+e),s&&s(0,e),null}const n=this._webSocket.addDisconnectEventListener(t);return e&&e(n),n}unsubscribeDisconnectEvent(e,s,t){if(!t){const e="Invalid Or Missing Parameter: cookie";return console.error("unsubscribeDisconnectEvent error: "+e),s&&s(0,e),!1}return this._webSocket.removeDisconnectEventListener(t)?(e&&e(),!0):(s&&s(0,"Invalid Subscription"),!1)}}class WebappTerminalConnect{constructor(){this.runFunction=window.bb.apps.tc.runFunction,this.getGroup=window.bb.apps.tc.getGroup,this.setGroupSecurity=window.bb.apps.tc.setGroupSecurity,this.getAllGroups=window.bb.apps.tc.getAllGroups,this.subscribeGroupEvents=window.bb.apps.tc.subscribeGroupEvents,this.unsubscribeGroupEvents=window.bb.apps.tc.unsubscribeGroupEvents}subscribeDisconnectEvent(e,s,t){}unsubscribeDisconnectEvent(e,s,t){}}class GlobalTerminal{constructor(e=!isBBEnvAvailable()){this._helperSetGroupValues=e=>{const s=new Group(this._terminalProxy,e.name,e.type);return s._securityCache=e.security,s._lastUpdate=(new Date).getTime(),s},this._terminalProxy=e?new WebSocketTerminalConnect:new WebappTerminalConnect}runFunction(e,s,t,n,r){return new Promise(((i,o)=>{this._terminalProxy.runFunction(i,((e,s)=>{o(new Error(s))}),e,s,t||null,n||null,r||null)}))}getAllGroups(){return new Promise(((e,s)=>{this._terminalProxy.getAllGroups((s=>{e(Array.from(s,this._helperSetGroupValues))}),((e,t)=>{s(new Error(t))}))}))}getGroup(e){return new Promise(((s,t)=>{this._terminalProxy.getAllGroups((n=>{const r=n.find((s=>s.name===e));r?s(this._helperSetGroupValues(r)):t(new Error(`Group ${e} is not found.`))}),((e,s)=>{t(new Error(s))}))}))}subscribeGroupEvents(e){return new Promise(((s,t)=>{this._terminalProxy.subscribeGroupEvents((e=>{s(e)}),((e,s)=>{t(new Error(s))}),((s,t)=>{e(this._helperSetGroupValues(s),t)}))}))}unsubscribeGroupEvents(e){return new Promise(((s,t)=>{this._terminalProxy.unsubscribeGroupEvents((()=>{s()}),((e,s)=>{t(new Error(s))}),e)}))}}export const terminal=(window.BB=window.BB||{},window.BB.Apps=window.BB.Apps||{},window.BB.Apps.Terminal=window.BB.Apps.Terminal||new GlobalTerminal,window.BB.Apps.Terminal); |
/** | ||
* Bloomberg Launchpad group name ('*' represents all groups). | ||
*/ | ||
export declare type BloombergGroup = '*' | string; | ||
export type BloombergGroup = '*' | string; | ||
/** | ||
* Bloomberg security market sector. | ||
*/ | ||
export declare type BloombergMarketSector = 'Comdty' | 'Corp' | 'Curncy' | 'Equity' | 'Govt' | 'Index' | 'M-Mkt' | 'Mtge' | 'Muni' | 'Pfd'; | ||
export type BloombergMarketSector = 'Comdty' | 'Corp' | 'Curncy' | 'Equity' | 'Govt' | 'Index' | 'M-Mkt' | 'Mtge' | 'Muni' | 'Pfd'; | ||
/** | ||
* Bloomberg Terminal panel ID. | ||
*/ | ||
export declare type BloombergPanel = 1 | 2 | 3 | 4; | ||
export type BloombergPanel = 1 | 2 | 3 | 4; |
@@ -5,5 +5,5 @@ import { BloombergConnection, BloombergConnectionConfig } from './connection.types'; | ||
* | ||
* The Terminal must be running locally and logged in, otherwise an error will be thrown. | ||
* Note: The Terminal must be running locally and logged in, otherwise an error will be thrown. | ||
* | ||
* @param config Configuration for the connection. | ||
* @param config Connection configuration settings. Uses [default configuration](https://developers.openfin.co/of-docs/docs/integration-with-terminal-connect#default-integration-configuration) if none provided. | ||
* | ||
@@ -13,2 +13,5 @@ * @throws {@link TerminalConnectionError} if the Bloomberg Terminal is not running or logged in. | ||
*/ | ||
export declare const connect: (config: BloombergConnectionConfig) => Promise<BloombergConnection>; | ||
export declare const connect: (config?: BloombergConnectionConfig) => Promise<BloombergConnection>; | ||
export declare const getDisconnectHandler: (registrations?: Array<{ | ||
unsubscribe: () => void; | ||
}>, groupSubscriptionId?: number) => () => Promise<void>; |
@@ -12,3 +12,3 @@ import * as fdc3 from '@finos/fdc3'; | ||
*/ | ||
export declare type BloombergAction = BloombergTerminalCommand | BloombergGroup; | ||
export type BloombergAction = BloombergTerminalCommand | BloombergGroup; | ||
/** | ||
@@ -18,3 +18,3 @@ * Configuration determining which [context types](https://developers.openfin.co/of-docs/docs/interoperability-overview#context) and | ||
*/ | ||
export declare type BloombergActionsConfig = { | ||
export type BloombergActionsConfig = { | ||
/** Context types that will be handled along with their corresponding actions. */ | ||
@@ -29,3 +29,3 @@ contexts?: ContextActionMap; | ||
*/ | ||
export declare type BloombergConnection = { | ||
export type BloombergConnection = { | ||
/** Closes the connection preventing context types and intents from being handled by the Bloomberg Terminal. */ | ||
@@ -37,3 +37,3 @@ disconnect: () => Promise<void>; | ||
*/ | ||
export declare type BloombergConnectionConfig = { | ||
export type BloombergConnectionConfig = { | ||
/** Context types and intents that will be handled along with their corresponding actions. */ | ||
@@ -59,3 +59,3 @@ actions?: BloombergActionsConfig; | ||
*/ | ||
export declare type BloombergTerminalCommand = { | ||
export type BloombergTerminalCommand = { | ||
/** Mnemonic code of the Terminal function to execute. */ | ||
@@ -71,14 +71,14 @@ mnemonic: string; | ||
*/ | ||
export declare type ContextActionMap = Map<ContextType, BloombergAction | undefined>; | ||
export type ContextActionMap = Map<ContextType, BloombergAction | undefined>; | ||
/** | ||
* Type name of a [context](https://developers.openfin.co/of-docs/docs/interoperability-overview#context) object. | ||
*/ | ||
export declare type ContextType = string; | ||
export type ContextType = string; | ||
/** | ||
* Map associating intents with their corresponding context types and actions. | ||
*/ | ||
export declare type IntentActionMap = Map<IntentName, ContextActionMap | undefined>; | ||
export type IntentActionMap = Map<IntentName, ContextActionMap | undefined>; | ||
/** | ||
* Name of an [intent](https://developers.openfin.co/of-docs/docs/interoperability-overview#intent). | ||
*/ | ||
export declare type IntentName = string; | ||
export type IntentName = string; |
import * as fdc3 from '@finos/fdc3'; | ||
export declare type BloombergApiContext = fdc3.Context & { | ||
export type BloombergApiContext = fdc3.Context & { | ||
openfinBbgApi: boolean; | ||
}; |
import { Context, Instrument } from '@finos/fdc3'; | ||
import { UsageFeatureName } from './utils.types'; | ||
export declare const getInstrumentContextFromSecurity: (security: string) => Context; | ||
@@ -28,1 +29,2 @@ export declare const getSecurityFromInstrumentContext: (context: Instrument) => string | undefined; | ||
export declare const isIsin: (text: string) => boolean; | ||
export declare const registerUsage: (featureName: UsageFeatureName) => Promise<void>; |
@@ -1,1 +0,1 @@ | ||
export declare const API_VERSION = "1.0.0"; | ||
export declare const API_VERSION = "1.1.0-beta.1"; |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
20
361
0
57277
1
1
80
1
28
+ Added@openfin/core@28.72.19(transitive)
- Removed@openfin/core@26.71.9(transitive)
Updated@openfin/core@^28.72.19
Updateddeepmerge-ts@^4.3.0