UNPKG

13.7 kBJavaScriptView Raw
1"use strict";var __extends=this&&this.__extends||function(){var r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var s in t)t.hasOwnProperty(s)&&(e[s]=t[s])};return function(e,t){function s(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(s.prototype=t.prototype,new s)}}();Object.defineProperty(exports,"__esModule",{value:!0});var deliver=require("@jayesol/jayeson.lib.delivery"),jayeson_lib_record_1=require("@jayesol/jayeson.lib.record"),data_structure_1=require("./data_structure"),proto=require("./protobuf_bundle"),Collections=require("typescript-collections"),codec_1=require("./codec"),soccer_codec_1=require("./soccer_codec"),basketball_codec_1=require("./basketball_codec"),tennis_codec_1=require("./tennis_codec"),AbstractMessageClass=function(o){function e(e,t,s,r,n){var p=o.call(this,e,t,s)||this;return p._msgGroup=e,p._id=t,p._instanceClass=s,p._sportCodecs=r,p._partitionCodec=n,p.unpack=function(e){var t=proto.DataMessage.decode(e.message);e.message=new data_structure_1.IndexedSnapshotImpl({});var s=t.stringPool,r=t.feedKey;if(void 0!==r){var n=p.asSportType(r.sport);if(null!=n){var o=p._sportCodecs.getCodec(n);if(null!=o){var a=p._partitionCodec.decode(new proto.PartitionKey(r),s),_=p.read(t,o,s,a),c={};c[n]=_;var i=new Collections.Dictionary;i.setValue(a,(new Date).getTime()),e.message=new data_structure_1.IndexedSnapshotImpl(c,i)}}}},p}return __extends(e,o),e.prototype.id=function(){return this._id},e.prototype.SportsFeedMessageGroup=function(){return this._msgGroup},e.prototype.instanceClass=function(){return this._instanceClass},e.prototype.sportCodecs=function(){return this._sportCodecs},e.prototype.partitionCodec=function(){return this._partitionCodec},e.prototype.inHandlers=function(){return[{unpack:this.unpack}]},e.prototype.outHandlers=function(){return[]},e.prototype.asSportType=function(e){var t=proto.SportType[e];return jayeson_lib_record_1.SportType[t]},e}(deliver.IMessageClass);exports.AbstractMessageClass=AbstractMessageClass;var FilterMessageClass=function(s){function e(e,t){return s.call(this,e,t,codec_1.FilterRequest)||this}return __extends(e,s),e}(deliver.JSonMessageClass);exports.FilterMessageClass=FilterMessageClass;var SportsCodecs=function(){function e(e){void 0===e&&(e=void 0),void 0===(this.sportsMappings=e)&&(this.sportsMappings=new Collections.Dictionary,this.sportsMappings.setValue(jayeson_lib_record_1.SportType.SOCCER,new soccer_codec_1.SoccerCodec),this.sportsMappings.setValue(jayeson_lib_record_1.SportType.TENNIS,new tennis_codec_1.TennisCodec),this.sportsMappings.setValue(jayeson_lib_record_1.SportType.BASKETBALL,new basketball_codec_1.BasketballCodec))}return e.prototype.getCodec=function(e){return this.sportsMappings.getValue(e)},e}();exports.SportsCodecs=SportsCodecs;var PartitionCodec=function(){function e(){}return e.prototype.decode=function(e,t){var s=jayeson_lib_record_1.OddType.LIVE;switch(e.oddType){case proto.OddType.LIVE:s=jayeson_lib_record_1.OddType.LIVE;break;case proto.OddType.TODAY:s=jayeson_lib_record_1.OddType.TODAY;break;case proto.OddType.EARLY:s=jayeson_lib_record_1.OddType.EARLY}var r=jayeson_lib_record_1.SportType.SOCCER;switch(e.sport){case proto.SportType.SOCCER:r=jayeson_lib_record_1.SportType.SOCCER;break;case proto.SportType.BASKETBALL:r=jayeson_lib_record_1.SportType.BASKETBALL;break;case proto.SportType.HOCKEY:r=jayeson_lib_record_1.SportType.HOCKEY;break;case proto.SportType.TENNIS:r=jayeson_lib_record_1.SportType.TENNIS;break;case proto.SportType.HORSE_RACING:r=jayeson_lib_record_1.SportType.HORSE_RACING;break;case proto.SportType.MOTOR_SPORT:r=jayeson_lib_record_1.SportType.MOTOR_SPORT;break;case proto.SportType.HANDBALL:r=jayeson_lib_record_1.SportType.HANDBALL;break;case proto.SportType.CRICKET:r=jayeson_lib_record_1.SportType.CRICKET;break;case proto.SportType.POOL:r=jayeson_lib_record_1.SportType.POOL}return new jayeson_lib_record_1.PartitionKey(t[e.source],s,r)},e}();exports.PartitionCodec=PartitionCodec;var InsertMatchMessageClass=function(n){function e(e,t,s,r){return n.call(this,e,t,data_structure_1.IndexedSnapshotImpl,s,r)||this}return __extends(e,n),e.prototype.read=function(e,t,s,r){var n=e.matches.matches.map(function(e){return new proto.BaseMatch(e)});return t.decodeMatch(n,s,codec_1.EncodeAction.INSERT,r)},e}(AbstractMessageClass);exports.InsertMatchMessageClass=InsertMatchMessageClass;var InsertEventMessageClass=function(n){function e(e,t,s,r){return n.call(this,e,t,data_structure_1.IndexedSnapshotImpl,s,r)||this}return __extends(e,n),e.prototype.read=function(e,t,s,r){var n=e.events.events.map(function(e){return new proto.BaseEvent(e)});return t.decodeEvent(n,s,codec_1.EncodeAction.INSERT,r)},e}(AbstractMessageClass);exports.InsertEventMessageClass=InsertEventMessageClass;var InsertOddMessageClass=function(n){function e(e,t,s,r){return n.call(this,e,t,data_structure_1.IndexedSnapshotImpl,s,r)||this}return __extends(e,n),e.prototype.read=function(e,t,s,r){var n=e.odds.odds.map(function(e){return new proto.BaseRecord(e)});return t.decodeRecord(n,s,codec_1.EncodeAction.INSERT,r)},e}(AbstractMessageClass);exports.InsertOddMessageClass=InsertOddMessageClass;var UpdateMatchMessageClass=function(n){function e(e,t,s,r){return n.call(this,e,t,data_structure_1.IndexedSnapshotImpl,s,r)||this}return __extends(e,n),e.prototype.read=function(e,t,s,r){var n=e.matches.matches.map(function(e){return new proto.BaseMatch(e)});return t.decodeMatch(n,s,codec_1.EncodeAction.UPDATE,r)},e}(AbstractMessageClass);exports.UpdateMatchMessageClass=UpdateMatchMessageClass;var UpdateEventMessageClass=function(n){function e(e,t,s,r){return n.call(this,e,t,data_structure_1.IndexedSnapshotImpl,s,r)||this}return __extends(e,n),e.prototype.read=function(e,t,s,r){var n=e.events.events.map(function(e){return new proto.BaseEvent(e)});return t.decodeEvent(n,s,codec_1.EncodeAction.UPDATE,r)},e}(AbstractMessageClass);exports.UpdateEventMessageClass=UpdateEventMessageClass;var UpdateOddMessageClass=function(n){function e(e,t,s,r){return n.call(this,e,t,data_structure_1.IndexedSnapshotImpl,s,r)||this}return __extends(e,n),e.prototype.read=function(e,t,s,r){var n=e.odds.odds.map(function(e){return new proto.BaseRecord(e)});return t.decodeRecord(n,s,codec_1.EncodeAction.UPDATE,r)},e}(AbstractMessageClass);exports.UpdateOddMessageClass=UpdateOddMessageClass;var DeleteMatchMessageClass=function(n){function e(e,t,s,r){return n.call(this,e,t,data_structure_1.IndexedSnapshotImpl,s,r)||this}return __extends(e,n),e.prototype.read=function(e,t,s,r){var n=e.matches.matches.map(function(e){return new proto.BaseMatch(e)});return t.decodeMatch(n,s,codec_1.EncodeAction.DELETE,r)},e}(AbstractMessageClass);exports.DeleteMatchMessageClass=DeleteMatchMessageClass;var DeleteEventMessageClass=function(n){function e(e,t,s,r){return n.call(this,e,t,data_structure_1.IndexedSnapshotImpl,s,r)||this}return __extends(e,n),e.prototype.read=function(e,t,s,r){var n=e.events.events.map(function(e){return new proto.BaseEvent(e)});return t.decodeEvent(n,s,codec_1.EncodeAction.DELETE,r)},e}(AbstractMessageClass);exports.DeleteEventMessageClass=DeleteEventMessageClass;var DeleteOddMessageClass=function(n){function e(e,t,s,r){return n.call(this,e,t,data_structure_1.IndexedSnapshotImpl,s,r)||this}return __extends(e,n),e.prototype.read=function(e,t,s,r){var n=e.odds.odds.map(function(e){return new proto.BaseRecord(e)});return t.decodeRecord(n,s,codec_1.EncodeAction.DELETE,r)},e}(AbstractMessageClass);exports.DeleteOddMessageClass=DeleteOddMessageClass;var ResetMessageClass=function(n){function e(e,t,s,r){return n.call(this,e,t,data_structure_1.IndexedSnapshotImpl,s,r)||this}return __extends(e,n),e.prototype.read=function(e,t,s,r){return[]},e}(AbstractMessageClass);exports.ResetMessageClass=ResetMessageClass;var TTLRemoveMessageClass=function(n){function e(e,t,s,r){return n.call(this,e,t,data_structure_1.IndexedSnapshotImpl,s,r)||this}return __extends(e,n),e.prototype.read=function(e,t,s,r){return[]},e}(AbstractMessageClass);exports.TTLRemoveMessageClass=TTLRemoveMessageClass;var TTLRestoreMessageClass=function(n){function e(e,t,s,r){return n.call(this,e,t,data_structure_1.IndexedSnapshotImpl,s,r)||this}return __extends(e,n),e.prototype.read=function(e,t,s,r){return[]},e}(AbstractMessageClass);exports.TTLRestoreMessageClass=TTLRestoreMessageClass;var SwitchFilterStartMessageClass=function(s){function e(e,t){return s.call(this,e,t)||this}return __extends(e,s),e}(deliver.EmptyMessageClass);exports.SwitchFilterStartMessageClass=SwitchFilterStartMessageClass;var SwitchFilterEndMessageClass=function(s){function e(e,t){return s.call(this,e,t)||this}return __extends(e,s),e}(deliver.EmptyMessageClass);exports.SwitchFilterEndMessageClass=SwitchFilterEndMessageClass;var SwitchFilterFailMessageClass=function(s){function e(e,t){return s.call(this,e,t)||this}return __extends(e,s),e}(deliver.EmptyMessageClass);exports.SwitchFilterFailMessageClass=SwitchFilterFailMessageClass;var StartSubscribeFeed=function(e,t){this.exclude=e,this.wireFormat=t};exports.StartSubscribeFeed=StartSubscribeFeed;var RefreshMessage=function(){},RefreshMessageClass=function(r){function e(e,t){var s=r.call(this,e,t,RefreshMessage)||this;return s.unpack=function(e){var t=e.message,s=new Collections.Dictionary;t.partitionKeys.forEach(function(e){s.setValue(jayeson_lib_record_1.PartitionKey.fromString(e),(new Date).getTime())}),e.message=new data_structure_1.IndexedSnapshotImpl({},s)},s}return __extends(e,r),e.prototype.inHandlers=function(){return r.prototype.inHandlers.call(this).concat([{unpack:this.unpack}])},e}(deliver.JSonMessageClass);exports.RefreshMessageClass=RefreshMessageClass;var SportsFeedMessageGroup=function(r){function e(e,t){void 0===e&&(e=new SportsCodecs),void 0===t&&(t=new PartitionCodec);var s=r.call(this,70)||this;return s._DATA_RESET=new ResetMessageClass(s,0,e,t),s._DATA_INSERT_ODD=new InsertOddMessageClass(s,1,e,t),s._DATA_UPDATE_ODD=new UpdateOddMessageClass(s,2,e,t),s._DATA_DELETE_ODD=new DeleteOddMessageClass(s,3,e,t),s._DATA_INSERT_EVENT=new InsertEventMessageClass(s,4,e,t),s._DATA_UPDATE_EVENT=new UpdateEventMessageClass(s,5,e,t),s._DATA_DELETE_EVENT=new DeleteEventMessageClass(s,6,e,t),s._DATA_INSERT_MATCH=new InsertMatchMessageClass(s,7,e,t),s._DATA_UPDATE_MATCH=new UpdateMatchMessageClass(s,8,e,t),s._DATA_DELETE_MATCH=new DeleteMatchMessageClass(s,9,e,t),s._TTL_RESTORE=new TTLRestoreMessageClass(s,10,e,t),s._TTL_REMOVE=new TTLRestoreMessageClass(s,11,e,t),s._FILTER_REMOVE=new deliver.StringMessageClass(s,13),s._FILTER_SET=new FilterMessageClass(s,14),s._ADMIN_START_SUBSCRIBE_FEED=new deliver.JSonMessageClass(s,16,StartSubscribeFeed),s._ADMIN_REFRESH=new RefreshMessageClass(s,17),s._SWITCH_FILTER_START=new deliver.StringMessageClass(s,18),s._SWITCH_FILTER_END=new deliver.EmptyMessageClass(s,19),s._FULLSNAPSHOT_START=new deliver.EmptyMessageClass(s,20),s._FULLSNAPSHOT_END=new deliver.EmptyMessageClass(s,21),s._SWITCH_FILTER_FAIL=new deliver.StringMessageClass(s,22),s._TTL_RESTORE_START=new TTLRestoreMessageClass(s,23,e,t),s._TTL_RESTORE_END=new deliver.EmptyMessageClass(s,24),[s._DATA_RESET,s._DATA_INSERT_ODD,s._DATA_UPDATE_ODD,s._DATA_DELETE_ODD,s._DATA_INSERT_EVENT,s._DATA_UPDATE_EVENT,s._DATA_DELETE_EVENT,s._DATA_INSERT_MATCH,s._DATA_UPDATE_MATCH,s._DATA_DELETE_MATCH,s._TTL_RESTORE,s._TTL_REMOVE,s._FILTER_REMOVE,s._FILTER_SET,s._ADMIN_START_SUBSCRIBE_FEED,s._ADMIN_REFRESH,s._SWITCH_FILTER_START,s._SWITCH_FILTER_END,s._FULLSNAPSHOT_START,s._FULLSNAPSHOT_END,s._SWITCH_FILTER_FAIL,s._TTL_RESTORE_START,s._TTL_RESTORE_END].forEach(function(e){s._classes[e.id()]=e}),s}return __extends(e,r),e.prototype.DATA_RESET=function(){return this._DATA_RESET},e.prototype.DATA_INSERT_ODD=function(){return this._DATA_INSERT_ODD},e.prototype.DATA_UPDATE_ODD=function(){return this._DATA_UPDATE_ODD},e.prototype.DATA_DELETE_ODD=function(){return this._DATA_DELETE_ODD},e.prototype.DATA_INSERT_EVENT=function(){return this._DATA_INSERT_EVENT},e.prototype.DATA_UPDATE_EVENT=function(){return this._DATA_UPDATE_EVENT},e.prototype.DATA_DELETE_EVENT=function(){return this._DATA_DELETE_EVENT},e.prototype.TTL_REMOVE=function(){return this._TTL_REMOVE},e.prototype.TTL_RESTORE=function(){return this._TTL_RESTORE},e.prototype.TTL_RESTORE_START=function(){return this._TTL_RESTORE_START},e.prototype.TTL_RESTORE_END=function(){return this._TTL_RESTORE_END},e.prototype.DATA_INSERT_MATCH=function(){return this._DATA_INSERT_MATCH},e.prototype.DATA_UPDATE_MATCH=function(){return this._DATA_UPDATE_MATCH},e.prototype.DATA_DELETE_MATCH=function(){return this._DATA_DELETE_MATCH},e.prototype.FILTER_REMOVE=function(){return this._FILTER_REMOVE},e.prototype.FILTER_SET=function(){return this._FILTER_SET},e.prototype.ADMIN_START_SUBSCRIBE_FEED=function(){return this._ADMIN_START_SUBSCRIBE_FEED},e.prototype.ADMIN_REFRESH=function(){return this._ADMIN_REFRESH},e.prototype.SWITCH_FILTER_START=function(){return this._SWITCH_FILTER_START},e.prototype.SWITCH_FILTER_END=function(){return this._SWITCH_FILTER_END},e.prototype.FULLSNAPSHOT_START=function(){return this._FULLSNAPSHOT_START},e.prototype.FULLSNAPSHOT_END=function(){return this._FULLSNAPSHOT_END},e.prototype.SWITCH_FILTER_FAIL=function(){return this._SWITCH_FILTER_FAIL},e.prototype.isIndicatorMessage=function(e){return e==this.SWITCH_FILTER_START()||e==this.SWITCH_FILTER_END()||e==this.FULLSNAPSHOT_START()||e==this.FULLSNAPSHOT_END()||e==this.SWITCH_FILTER_FAIL()||e==this.TTL_RESTORE_START()||e==this.TTL_RESTORE_END()},e.prototype.isSwitchFilterStatusMsg=function(e){return e==this.SWITCH_FILTER_START()||e==this.SWITCH_FILTER_FAIL()},e}(deliver.IMessageGroup);exports.SportsFeedMessageGroup=SportsFeedMessageGroup;
\No newline at end of file