UNPKG

@activfinancial/cg-api-json

Version:

Implementations of some cg-api interfaces using JSON data.

2 lines 14.5 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@activfinancial/middleware"),require("@activfinancial/cg-api-common")):"function"==typeof define&&define.amd?define(["@activfinancial/middleware","@activfinancial/cg-api-common"],t):"object"==typeof exports?exports.activCgApiJson=t(require("@activfinancial/middleware"),require("@activfinancial/cg-api-common")):e.activCgApiJson=t(e["@activfinancial/middleware"],e["@activfinancial/cg-api-common"])}(window,(function(e,t){return function(e){var t={};function s(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,s),i.l=!0,i.exports}return s.m=e,s.c=t,s.d=function(e,t,n){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.t=function(e,t){if(1&t&&(e=s(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(s.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)s.d(n,i,function(t){return e[t]}.bind(null,i));return n},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="",s(s.s=2)}([function(t,s){t.exports=e},function(e,s){e.exports=t},function(e,t,s){"use strict";s.r(t);var n={};s.r(n),s.d(n,"ContentGatewayInfoRequestHandle",(function(){return h})),s.d(n,"contentGatewayInfoToJSON",(function(){return m})),s.d(n,"exchangeInfoFromJSON",(function(){return f}));var i={};s.r(i),s.d(i,"storyToJSON",(function(){return O})),s.d(i,"updateToJSON",(function(){return T})),s.d(i,"RequestHandle",(function(){return v}));var o={};s.r(o),s.d(o,"imageToJSON",(function(){return x})),s.d(o,"updateToJSON",(function(){return D})),s.d(o,"RequestHandle",(function(){return J}));var r={};s.r(r),s.d(r,"symbolResponseToJSON",(function(){return H})),s.d(r,"RequestHandle",(function(){return j}));var a={};s.r(a),s.d(a,"HistoryBar",(function(){return F})),s.d(a,"IntradayBar",(function(){return P})),s.d(a,"Tick",(function(){return E})),s.d(a,"historyBarToJSON",(function(){return V})),s.d(a,"intradayBarToJSON",(function(){return K})),s.d(a,"tickToJSON",(function(){return M})),s.d(a,"RequestHandle",(function(){return B}));var l,d=s(0);function u(e){return"toJSON"in e?e.toJSON():e}function c(e){return Object(d.isAsioErrorCode)(e)?new d.AsioError(e):"statusCode"in e?new d.StatusCodeError(e.statusCode):e}!function(e){e[e.connect=0]="connect",e[e.disconnect=1]="disconnect",e[e.onBreak=2]="onBreak",e[e.onError=3]="onError",e[e.onServerMessage=4]="onServerMessage",e[e.onAliasUpdate=5]="onAliasUpdate",e[e.onFeedConflationUpdate=6]="onFeedConflationUpdate",e[e.onHeartbeat=7]="onHeartbeat",e[e.setSessionConflationParameters=8]="setSessionConflationParameters",e[e.onStreamingImage=9]="onStreamingImage",e[e.onStreamingUpdate=10]="onStreamingUpdate",e[e.onNewsStory=11]="onNewsStory",e[e.onNewsUpdate=12]="onNewsUpdate",e[e.onTimeSeriesResponse=13]="onTimeSeriesResponse",e[e.onContentGatewayInfo=14]="onContentGatewayInfo",e[e.onSymbolDirectoryResponse=15]="onSymbolDirectoryResponse",e[e.delete=16]="delete",e[e.isComplete=17]="isComplete",e[e.setRequestConflationParameters=18]="setRequestConflationParameters",e[e.onDynamicConflationUpdate=19]="onDynamicConflationUpdate"}(l||(l={}));var p=s(1);class h extends p.IterableResponse{isEmptyResponse(e){return!1}isRecordAvailable(){return 0===this.recordIndex}makeNextIteratorResult(){return++this.recordIndex,{done:!1,value:this.currentResponse}}processJsonResponse(e){switch(e.messageType){case l.onContentGatewayInfo:this.processResponse(e.message);break;case l.onError:this.isComplete=!0,this.processError(c(e.message));break;default:console.warn(`Unknown json response ${JSON.stringify(e)}`)}}}function m(e){const t=e.systemInfo;return Object.assign(Object.assign({},e),{systemInfo:Object.assign(Object.assign({},t),{processorInfoList:[...t.processorInfoList]}),permissionLevelList:[...e.permissionLevelList],conflationTypeList:[...e.conflationTypeList],conflationIntervalList:[...e.conflationIntervalList],isDynamicConflationAvailable:e.isDynamicConflationAvailable,feedConflationInfoList:[...e.feedConflationInfoList]})}function f(e){return e.holidayDates=e.holidayDates.map(e=>new d.Date(e)),e}class y{constructor(e){switch(this.id=e.id,this.statusCode=e.statusCode,this.doesUpdateLastValue=e.doesUpdateLastValue,this.type=e.type,e.type){case d.FieldType.tRational:this.value=d.TRational.fromJSON(e.value);break;case d.FieldType.rational:this.value=d.Rational.fromJSON(e.value);break;case d.FieldType.time:this.value=d.Time.fromJSON(e.value);break;case d.FieldType.dateTime:this.value=d.DateTime.fromJSON(e.value);break;case d.FieldType.date:this.value=d.Date.fromJSON(e.value);break;case d.FieldType.binaryArray:case d.FieldType.binaryString:case d.FieldType.blob:case d.FieldType.crcBlob:this.value=Uint8Array.from(e.value);break;default:this.value=e.value}}}class b{constructor(e){this[Symbol.iterator]=()=>this.fields.values(),this.fields=new Map;for(let t of e){const e=new y(t);this.fields.set(e.id,e)}}get(e){const t=this.fields.get(e);return null!=t?t:Object(p.makeNotFoundField)(e)}}function g(e){let t;switch(e.type){case d.FieldType.rational:case d.FieldType.tRational:case d.FieldType.time:case d.FieldType.dateTime:case d.FieldType.date:t=e.value.toJSON();break;case d.FieldType.binaryArray:case d.FieldType.binaryString:case d.FieldType.blob:case d.FieldType.crcBlob:t=[...e.value];break;default:t=e.value}return{id:e.id,statusCode:e.statusCode,doesUpdateLastValue:e.doesUpdateLastValue,type:e.type,value:t}}function S(e){let t=[];for(const s of e)t.push(g(s));return t}class I{constructor(e){this.newsSymbol=e.newsSymbol,this.permissionIdList=e.permissionIdList,this.fieldData=new b(e.fieldData)}getField(e){return this.fieldData.get(e)}}class R extends I{constructor(e){super(e),this.updateId=e.updateId,this.isNewRecord=e.isNewRecord,this.isDelete=e.isDelete}isDeleted(){return!1}delete(){}}function O(e){return{newsSymbol:e.newsSymbol,permissionIdList:[...e.permissionIdList],fieldData:S(e.fieldData)}}function T(e){return Object.assign(Object.assign({},O(e)),{updateId:e.updateId,isNewRecord:e.isNewRecord,isDelete:e.isDelete})}class v extends p.IterableResponse{constructor(e){super(null!=e.updateHandler),this.isSubscription&&(this.updateHandler=e.updateHandler),this.requestParameters=function(e){const t=Object.assign({},e);return null!=e.updateHandler&&(t.updateHandler=!0),t}(e)}isEmptyResponse(e){return"isComplete"in e}isRecordAvailable(){return 0===this.recordIndex}makeNextIteratorResult(){return++this.recordIndex,{done:!1,value:this.currentResponse}}processJsonResponse(e){switch(e.messageType){case l.onNewsUpdate:this.processUpdate(e.message);break;case l.onNewsStory:this.processStory(e.message);break;case l.isComplete:this.isComplete=!0,this.processResponse({isComplete:!0});break;case l.onError:this.isComplete=!0,this.processError(c(e.message));break;default:console.warn(`Unknown json response ${JSON.stringify(e)}`)}}processStory(e){this.processResponse(new I(e))}processUpdate(e){null!=this.updateHandler&&this.updateHandler(new R(e))}}class C{constructor(e){this.isNewRecord=e.isNewRecord,this.isDelete=e.isDelete,this.isAliasKey=e.isAliasKey,this.isStale=e.isStale,this.streamId=e.streamId,this.permissionId=e.permissionId,this.permissionLevel=e.permissionLevel,this.delayPeriod=e.delayPeriod,this.relationshipId=e.relationshipId,this.requestedKey=e.requestedKey,this.resolvedKey=e.resolvedKey,this.responseKey=e.responseKey,this.fieldData=new b(e.fieldData)}getField(e){return this.fieldData.get(e)}}class w extends C{constructor(e){super(e),this.statusCode=e.statusCode}}class N extends C{constructor(e){super(e),this.eventType=e.eventType,this.isConflated=e.isConflated,this.isDeferred=e.isDeferred,this.updateId=e.updateId}isDeleted(){return!1}delete(){}}function k(e){return{isNewRecord:e.isNewRecord,isDelete:e.isDelete,isAliasKey:e.isAliasKey,isStale:e.isStale,streamId:e.streamId,permissionId:e.permissionId,permissionLevel:e.permissionLevel,delayPeriod:e.delayPeriod,relationshipId:e.relationshipId,requestedKey:e.requestedKey,resolvedKey:e.resolvedKey,responseKey:e.responseKey,fieldData:S(e.fieldData)}}function x(e){return Object.assign(Object.assign({},k(e)),{statusCode:e.statusCode})}function D(e){return Object.assign(Object.assign({},k(e)),{eventType:e.eventType,isConflated:e.isConflated,isDeferred:e.isDeferred,updateId:e.updateId})}class J extends p.IterableResponse{constructor(e){super(null!=e.subscription),this.streamUpdateHandlers={},this.shouldEnableDynamicConflation=!1,null!=e.subscription&&(this.updateHandler=e.subscription.updateHandler,delete e.subscription.updateHandler,null!=e.subscription.conflation&&null!=e.subscription.conflation.dynamicConflationHandler&&(this.dynamicConflationHandler=e.subscription.conflation.dynamicConflationHandler,delete e.subscription.conflation.dynamicConflationHandler,this.shouldEnableDynamicConflation=!0))}setUpdateHandler(e,t){return null!=this.streamUpdateHandlers[e]&&(this.streamUpdateHandlers[e]=t,!0)}isEmptyResponse(e){return"isComplete"in e}isRecordAvailable(){return 0===this.recordIndex}makeNextIteratorResult(){return++this.recordIndex,{done:!1,value:this.currentResponse}}processJsonResponse(e){switch(e.messageType){case l.onStreamingUpdate:this.processUpdate(e.message);break;case l.onStreamingImage:this.processImage(e.message);break;case l.isComplete:this.isComplete=!0,this.processResponse({isComplete:!0});break;case l.onDynamicConflationUpdate:this.processDynamicConflationUpdate(e.message);break;case l.onError:this.isComplete=!0,this.processError(c(e.message));break;default:console.warn(`Unknown json response ${JSON.stringify(e)}`)}}processImage(e){null!=this.updateHandler&&(this.streamUpdateHandlers[e.streamId]=this.updateHandler),this.processResponse(new w(e))}processUpdate(e){(this.streamUpdateHandlers[e.streamId]||this.updateHandler)(new N(e))}processDynamicConflationUpdate(e){null!=this.dynamicConflationHandler&&this.dynamicConflationHandler(e)}}function H(e){return{symbolId:e.symbolId,matchData:e.matchData,entityType:e.entityType}}class j extends p.IterableResponse{constructor(){super(!1)}isEmptyResponse(e){return"isComplete"in e}isRecordAvailable(){return 0===this.recordIndex}makeNextIteratorResult(){return++this.recordIndex,{done:!1,value:this.currentResponse}}processJsonResponse(e){switch(e.messageType){case l.onSymbolDirectoryResponse:this.processResponse(e.message);break;case l.isComplete:this.isComplete=!0,this.processResponse({isComplete:!0});break;case l.onError:this.isComplete=!0,this.processError(c(e.message));break;default:console.warn(`Unknown json response ${JSON.stringify(e)}`)}}}class U{constructor(e){this.symbolId=e.symbolId,this.dateTime=new Date(e.dateTime)}}class L extends U{constructor(e){super(e),this.open=null!=e.open?d.Rational.fromJSON(e.open):null,this.high=null!=e.high?d.Rational.fromJSON(e.high):null,this.low=null!=e.low?d.Rational.fromJSON(e.low):null,this.close=null!=e.close?d.Rational.fromJSON(e.close):null,this.totalVolume=e.totalVolume,this.totalPrice=null!=e.totalPrice?d.Rational.fromJSON(e.totalPrice):null,this.totalValue=null!=e.totalValue?d.Rational.fromJSON(e.totalValue):null,this.tickCount=e.tickCount}}class F extends L{constructor(e){super(e),this.openInterest=e.openInterest}}class P extends L{constructor(e){super(e),this.altTotalVolume=e.altTotalVolume,this.hasRegularTrade=e.hasRegularTrade,this.hasOhlc=e.hasOhlc}}class E extends U{constructor(e){super(e),this.isLuld=e.isLuld,this.luldHighPrice=e.luldHighPrice,this.luldLowPrice=e.luldLowPrice,this.isTradingStatus=e.isTradingStatus,this.tradingStatus=e.tradingStatus,this.tradingStatusReason=e.tradingStatusReason,this.tickType=e.tickType,this.updateId=e.updateId,this.price=e.price,this.size=e.size,this.conditions=e.conditions,this.exchange=e.exchange,this.buyerId=e.buyerId,this.sellerId=e.sellerId,this.tradeThroughExemptFlag=e.tradeThroughExemptFlag,this.isOutOfSequence=e.isOutOfSequence}}function q(e){return{symbolId:e.symbolId,dateTime:e.dateTime}}function A(e){return Object.assign(Object.assign({},q(e)),{open:null!=e.open?e.open.toJSON():null,high:null!=e.high?e.high.toJSON():null,low:null!=e.low?e.low.toJSON():null,close:null!=e.close?e.close.toJSON():null,totalVolume:e.totalVolume,totalPrice:null!=e.totalPrice?e.totalPrice.toJSON():null,totalValue:null!=e.totalValue?e.totalValue.toJSON():null,tickCount:e.tickCount})}function V(e){return Object.assign(Object.assign({},A(e)),{openInterest:e.openInterest})}function K(e){return Object.assign(Object.assign({},A(e)),{altTotalVolume:e.altTotalVolume,hasRegularTrade:e.hasRegularTrade,hasOhlc:e.hasOhlc})}function M(e){return Object.assign(Object.assign({},q(e)),{tickType:e.tickType,updateId:e.updateId,price:null!=e.price?e.price.toJSON():null,size:e.size,conditions:e.conditions,exchange:e.exchange,buyerId:e.buyerId,sellerId:e.sellerId,tradeThroughExemptFlag:e.tradeThroughExemptFlag,isOutOfSequence:e.isOutOfSequence,isLuld:e.isLuld,luldHighPrice:e.luldHighPrice,luldLowPrice:e.luldLowPrice,isTradingStatus:e.isTradingStatus,tradingStatus:e.tradingStatus,tradingStatusReason:e.tradingStatusReason})}class B extends p.IterableResponse{constructor(e){super(!1),this.fieldSetConstructor=e}isEmptyResponse(e){return"isComplete"in e}isRecordAvailable(){return 0===this.recordIndex}makeNextIteratorResult(){return++this.recordIndex,{done:!1,value:this.currentResponse}}processJsonResponse(e){switch(e.messageType){case l.onTimeSeriesResponse:this.processResponse(new this.fieldSetConstructor(e.message));break;case l.isComplete:this.isComplete=!0,this.processResponse({isComplete:!0});break;case l.onError:this.isComplete=!0,this.processError(c(e.message));break;default:console.warn(`Unknown json response ${JSON.stringify(e)}`)}}}s.d(t,"JsonMessageType",(function(){return l})),s.d(t,"maybeToJSON",(function(){return u})),s.d(t,"maybeErrorFromJSON",(function(){return c})),s.d(t,"MetaData",(function(){return n})),s.d(t,"News",(function(){return i})),s.d(t,"Streaming",(function(){return o})),s.d(t,"SymbolDirectory",(function(){return r})),s.d(t,"TimeSeries",(function(){return a}))}])})); //# sourceMappingURL=index.js.map