@jayesol/jayeson.lib.sports 2.2.3 → 2.2.5-v20
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 +113 -77
- package/lib/basketball_codec.d.ts +1 -1
- package/lib/basketball_codec.js +1 -1
- package/lib/client.d.ts +2 -2
- package/lib/client.js +1 -1
- package/lib/codec.d.ts +2 -2
- package/lib/codec.js +1 -1
- package/lib/core.d.ts +1 -1
- package/lib/core.js +1 -1
- package/lib/data_structure.d.ts +1 -1
- package/lib/data_structure.js +1 -1
- package/lib/dispatch.js +1 -1
- package/lib/index.js +1 -1
- package/lib/merge.d.ts +1 -1
- package/lib/merge.js +1 -1
- package/lib/message_class.d.ts +1 -1
- package/lib/message_class.js +1 -1
- package/lib/module.js +1 -1
- package/lib/mutable.d.ts +1 -1
- package/lib/mutable.js +1 -1
- package/lib/protobuf_bundle.d.ts +3 -409
- package/lib/protobuf_bundle.js +1 -1
- package/lib/receive.d.ts +1 -1
- package/lib/receive.js +1 -1
- package/lib/soccer_codec.d.ts +1 -1
- package/lib/soccer_codec.js +1 -1
- package/lib/tennis_codec.d.ts +1 -1
- package/lib/tennis_codec.js +1 -1
- package/package.json +49 -57
package/lib/message_class.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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;
|
|
1
|
+
var __extends=this&&this.__extends||(()=>{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)}})(),deliver=(Object.defineProperty(exports,"__esModule",{value:!0}),require("@jayesol/jayeson.lib.delivery")),jayeson_lib_record_1=require("@longchau/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=(n=>{function e(e,t,s,r,o){var a=n.call(this,e,t,s)||this;return a._msgGroup=e,a._id=t,a._instanceClass=s,a._sportCodecs=r,a._partitionCodec=o,a.unpack=function(e){var t,s,r=proto.DataMessage.decode(e.message),o=(e.message=new data_structure_1.IndexedSnapshotImpl({}),r.stringPool),n=r.feedKey;void 0!==n&&null!=(t=a.asSportType(n.sport))&&null!=(s=a._sportCodecs.getCodec(t))&&(n=a._partitionCodec.decode(new proto.PartitionKey(n),o),r=a.read(r,s,o,n),(s={})[t]=r,(o=new Collections.Dictionary).setValue(n,(new Date).getTime()),e.message=new data_structure_1.IndexedSnapshotImpl(s,o))},a}return __extends(e,n),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){e=proto.SportType[e];return jayeson_lib_record_1.SportType[e]},e})(deliver.IMessageClass),FilterMessageClass=(exports.AbstractMessageClass=AbstractMessageClass,(s=>{function e(e,t){return s.call(this,e,t,codec_1.FilterRequest)||this}return __extends(e,s),e})(deliver.JSonMessageClass)),SportsCodecs=(exports.FilterMessageClass=FilterMessageClass,(()=>{function e(e){void 0===(this.sportsMappings=e=void 0===e?void 0: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})()),PartitionCodec=(exports.SportsCodecs=SportsCodecs,(()=>{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})()),InsertMatchMessageClass=(exports.PartitionCodec=PartitionCodec,(o=>{function e(e,t,s,r){return o.call(this,e,t,data_structure_1.IndexedSnapshotImpl,s,r)||this}return __extends(e,o),e.prototype.read=function(e,t,s,r){e=e.matches.matches.map(function(e){return new proto.BaseMatch(e)});return t.decodeMatch(e,s,codec_1.EncodeAction.INSERT,r)},e})(AbstractMessageClass)),InsertEventMessageClass=(exports.InsertMatchMessageClass=InsertMatchMessageClass,(o=>{function e(e,t,s,r){return o.call(this,e,t,data_structure_1.IndexedSnapshotImpl,s,r)||this}return __extends(e,o),e.prototype.read=function(e,t,s,r){e=e.events.events.map(function(e){return new proto.BaseEvent(e)});return t.decodeEvent(e,s,codec_1.EncodeAction.INSERT,r)},e})(AbstractMessageClass)),InsertOddMessageClass=(exports.InsertEventMessageClass=InsertEventMessageClass,(o=>{function e(e,t,s,r){return o.call(this,e,t,data_structure_1.IndexedSnapshotImpl,s,r)||this}return __extends(e,o),e.prototype.read=function(e,t,s,r){e=e.odds.odds.map(function(e){return new proto.BaseRecord(e)});return t.decodeRecord(e,s,codec_1.EncodeAction.INSERT,r)},e})(AbstractMessageClass)),UpdateMatchMessageClass=(exports.InsertOddMessageClass=InsertOddMessageClass,(o=>{function e(e,t,s,r){return o.call(this,e,t,data_structure_1.IndexedSnapshotImpl,s,r)||this}return __extends(e,o),e.prototype.read=function(e,t,s,r){e=e.matches.matches.map(function(e){return new proto.BaseMatch(e)});return t.decodeMatch(e,s,codec_1.EncodeAction.UPDATE,r)},e})(AbstractMessageClass)),UpdateEventMessageClass=(exports.UpdateMatchMessageClass=UpdateMatchMessageClass,(o=>{function e(e,t,s,r){return o.call(this,e,t,data_structure_1.IndexedSnapshotImpl,s,r)||this}return __extends(e,o),e.prototype.read=function(e,t,s,r){e=e.events.events.map(function(e){return new proto.BaseEvent(e)});return t.decodeEvent(e,s,codec_1.EncodeAction.UPDATE,r)},e})(AbstractMessageClass)),UpdateOddMessageClass=(exports.UpdateEventMessageClass=UpdateEventMessageClass,(o=>{function e(e,t,s,r){return o.call(this,e,t,data_structure_1.IndexedSnapshotImpl,s,r)||this}return __extends(e,o),e.prototype.read=function(e,t,s,r){e=e.odds.odds.map(function(e){return new proto.BaseRecord(e)});return t.decodeRecord(e,s,codec_1.EncodeAction.UPDATE,r)},e})(AbstractMessageClass)),DeleteMatchMessageClass=(exports.UpdateOddMessageClass=UpdateOddMessageClass,(o=>{function e(e,t,s,r){return o.call(this,e,t,data_structure_1.IndexedSnapshotImpl,s,r)||this}return __extends(e,o),e.prototype.read=function(e,t,s,r){e=e.matches.matches.map(function(e){return new proto.BaseMatch(e)});return t.decodeMatch(e,s,codec_1.EncodeAction.DELETE,r)},e})(AbstractMessageClass)),DeleteEventMessageClass=(exports.DeleteMatchMessageClass=DeleteMatchMessageClass,(o=>{function e(e,t,s,r){return o.call(this,e,t,data_structure_1.IndexedSnapshotImpl,s,r)||this}return __extends(e,o),e.prototype.read=function(e,t,s,r){e=e.events.events.map(function(e){return new proto.BaseEvent(e)});return t.decodeEvent(e,s,codec_1.EncodeAction.DELETE,r)},e})(AbstractMessageClass)),DeleteOddMessageClass=(exports.DeleteEventMessageClass=DeleteEventMessageClass,(o=>{function e(e,t,s,r){return o.call(this,e,t,data_structure_1.IndexedSnapshotImpl,s,r)||this}return __extends(e,o),e.prototype.read=function(e,t,s,r){e=e.odds.odds.map(function(e){return new proto.BaseRecord(e)});return t.decodeRecord(e,s,codec_1.EncodeAction.DELETE,r)},e})(AbstractMessageClass)),ResetMessageClass=(exports.DeleteOddMessageClass=DeleteOddMessageClass,(o=>{function e(e,t,s,r){return o.call(this,e,t,data_structure_1.IndexedSnapshotImpl,s,r)||this}return __extends(e,o),e.prototype.read=function(e,t,s,r){return[]},e})(AbstractMessageClass)),TTLRemoveMessageClass=(exports.ResetMessageClass=ResetMessageClass,(o=>{function e(e,t,s,r){return o.call(this,e,t,data_structure_1.IndexedSnapshotImpl,s,r)||this}return __extends(e,o),e.prototype.read=function(e,t,s,r){return[]},e})(AbstractMessageClass)),TTLRestoreMessageClass=(exports.TTLRemoveMessageClass=TTLRemoveMessageClass,(o=>{function e(e,t,s,r){return o.call(this,e,t,data_structure_1.IndexedSnapshotImpl,s,r)||this}return __extends(e,o),e.prototype.read=function(e,t,s,r){return[]},e})(AbstractMessageClass)),SwitchFilterStartMessageClass=(exports.TTLRestoreMessageClass=TTLRestoreMessageClass,(s=>{function e(e,t){return s.call(this,e,t)||this}return __extends(e,s),e})(deliver.EmptyMessageClass)),SwitchFilterEndMessageClass=(exports.SwitchFilterStartMessageClass=SwitchFilterStartMessageClass,(s=>{function e(e,t){return s.call(this,e,t)||this}return __extends(e,s),e})(deliver.EmptyMessageClass)),SwitchFilterFailMessageClass=(exports.SwitchFilterEndMessageClass=SwitchFilterEndMessageClass,(s=>{function e(e,t){return s.call(this,e,t)||this}return __extends(e,s),e})(deliver.EmptyMessageClass)),StartSubscribeFeed=(exports.SwitchFilterFailMessageClass=SwitchFilterFailMessageClass,function(e,t){this.exclude=e,this.wireFormat=t}),RefreshMessage=(exports.StartSubscribeFeed=StartSubscribeFeed,function(){}),RefreshMessageClass=(s=>{function e(e,t){e=s.call(this,e,t,RefreshMessage)||this;return e.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)},e}return __extends(e,s),e.prototype.inHandlers=function(){return s.prototype.inHandlers.call(this).concat([{unpack:this.unpack}])},e})(deliver.JSonMessageClass),SportsFeedMessageGroup=(exports.RefreshMessageClass=RefreshMessageClass,(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;
|
package/lib/module.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0});var D=require("@jayesol/jayeson.lib.delivery"),message_class_1=require("./message_class"),receive_1=require("./receive"),core_1=require("./core"),dispatch_1=require("./dispatch"),client_1=require("./client"),SportsFeedCoreComponentModule=(()=>{function e(){}return e.getBindingArray=function(e,r,o){return void 0===o&&(o=client_1.MemoryDispatcher.MEMORY_STREAM),[{provide:message_class_1.StartSubscribeFeed,useValue:new message_class_1.StartSubscribeFeed(e=void 0===e?[]:e,r=void 0===r?"":r)},{provide:message_class_1.SportsFeedMessageGroup,useValue:new message_class_1.SportsFeedMessageGroup},D.StreamNameCode,receive_1.InEndPointEventHandler,{provide:core_1.FSRepoImpl.outputStream,useValue:o},core_1.FSRepoImpl,{provide:core_1.AbstractFSRepo,useExisting:core_1.FSRepoImpl},{provide:core_1.FSREPO_IMPL,useExisting:core_1.FSRepoImpl},dispatch_1.RelayEPG,dispatch_1.EndPointGroupManager,core_1.TTLConfig,core_1.RecycleBin,receive_1.StreamCommandProcessor,receive_1.SportsFeedInProcessor,{provide:D.IMessageGroupProcessor,useExisting:receive_1.SportsFeedInProcessor},{provide:dispatch_1.EPGM_IMPL,useExisting:dispatch_1.EndPointGroupManager},client_1.FeedView,client_1.SportsFeedClient]},e})();exports.SportsFeedCoreComponentModule=SportsFeedCoreComponentModule;
|
package/lib/mutable.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OddType, LBType, TimeType, OddFormat, PivotBias, PivotType, StringMap, IBetEvent, IBetRecord, IBetEventState, IBetMatch, PartitionKey } from "@
|
|
1
|
+
import { OddType, LBType, TimeType, OddFormat, PivotBias, PivotType, StringMap, IBetEvent, IBetRecord, IBetEventState, IBetMatch, PartitionKey } from "@longchau/jayeson.lib.record";
|
|
2
2
|
import { IndexedSnapshot } from "./data_structure";
|
|
3
3
|
export interface ObjectMap<T> {
|
|
4
4
|
[index: string]: T;
|
package/lib/mutable.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __extends=this&&this.__extends||function(){var i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(t,e){function r(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}();Object.defineProperty(exports,"__esModule",{value:!0});var jayeson_lib_record_1=require("@jayesol/jayeson.lib.record"),data_structure_1=require("./data_structure"),codec_1=require("./codec"),Collections=require("typescript-collections"),Const=function(){function t(){}return t.generateKey=function(t){return t.source()+this.SEPARATOR+t.id()},t.AGGREGATE_KEY="AGGREGATE_KEY",t.SEPARATOR="_",t}();exports.Const=Const;var Builder,IndexedSnapshotBuilder=function(){function t(t){if(this._matches={},this._partitions=new Collections.Dictionary,null!=t){for(var e=0,r=t.matches();e<r.length;e++){var i=r[e];this._matches[i.id()]=i}for(var o=0,n=t.getPartitionMap().keys();o<n.length;o++){var s=n[o];this._partitions.setValue(s,t.getPartitionMap().getValue(s))}}}return t.prototype.matches=function(){return this._matches},t.prototype.partitions=function(){return this._partitions},t.prototype.setPartition=function(t){this._partitions=t},t.prototype.setPartitionValue=function(t,e){this._partitions.setValue(t,e)},t.prototype.removePartitionKey=function(t){return this._partitions.remove(t)},t.prototype.markPartitionAsUpdated=function(t,e){null==e&&(e=(new Date).getMilliseconds()),this._partitions.setValue(t,e)},t.prototype.replaceMatch=function(t){this._matches[t.id()]=t},t.prototype.reset=function(t){if(!this._partitions.containsKey(t))return null;var e=this._matches,r=BuilderProvider.getSnapshotBuilder(this.build());r._matches={},r._partitions.clear();var i=this.removePartitionKey(t);for(var o in r.setPartitionValue(t,i),this._matches){var n=this._matches[o],s=BuilderProvider.getMatchBuilder(n),a=s.reset(t);null==a||a.isEmpty()||r.insertChild(a.build()),s.isEmpty()?delete e[n.id()]:e[n.id()]=s.build()}return this._matches=e,r},t.prototype.insertChild=function(t){var e=this._matches[t.id()],r=null;if(null==e)this._matches[t.id()]=t;else{r=t.id();var i=BuilderProvider.getMatchBuilder(e);i.aggregateInsert(t),this._matches[t.id()]=i.build()}return r},t.prototype.updateChild=function(t){var e=this._matches[t.id()];if(null!=e){var r=BuilderProvider.getMatchBuilder(e);r.aggregateUpdate(t),this._matches[t.id()]=r.build()}else console.error("[UpdateMatch] Cannot found matchId %s to execute update match from %s",t.id(),t.meta()[Const.AGGREGATE_KEY])},t.prototype.deleteChild=function(t){var e=this._matches[t.id()],r=null;if(null!=e){var i=BuilderProvider.getMatchBuilder(e);return i.aggregateDelete(t)?delete this._matches[t.id()]:(this._matches[t.id()]=i.build(),r=t.id()),r}console.error("[DeleteMatch] Cannot found matchId %s to execute delete match from %s",t.id(),t.meta()[Const.AGGREGATE_KEY])},t.prototype.build=function(){var t={};for(var e in this._matches){var r=this._matches[e],i=t[r.sportType()];null==i&&(i=[],t[r.sportType()]=i),i.push(r)}return new data_structure_1.IndexedSnapshotImpl(t,this._partitions)},t}(),B2MatchBuilder=function(){function t(t){this._events={},this.mergeFrom(t)}return t.prototype.meta=function(){return this._meta},t.prototype.startTime=function(){return this._startTime},t.prototype.events=function(){return this._events},t.prototype.id=function(){return this._id},t.prototype.league=function(){return this._league},t.prototype.sport=function(){return this._sport},t.prototype.meata=function(){return this._meta},t.prototype.p1=function(){return this._p1},t.prototype.p2=function(){return this._p2},t.prototype.setEvent=function(t){this._events=t},t.prototype.mergeFrom=function(t){for(var e in this._startTime=t.startTime(),this._id=t.id(),this._league=t.league(),this._sport=t.sportType(),this._meta={},t.meta())this._meta[e]=t.meta()[e];if(null!=t.events())for(var r=0,i=t.events();r<i.length;r++){var o=i[r];this._events[o.id()]=o}var n=t;this._p1=n.participantOne(),this._p2=n.participantTwo()},t.prototype.replaceEvent=function(t){this._events[t.id()]=t},t.prototype.reset=function(t){var e=t.toString(),r=this._meta[Const.AGGREGATE_KEY];if(!codec_1.Util.containsKey(r,e))return null;var i=BuilderProvider.getMatchBuilder(this.build()),o=codec_1.Util.removeKey(r,e);this._meta[Const.AGGREGATE_KEY]=o,i._meta[Const.AGGREGATE_KEY]=e;var n={};for(var s in i._events={},this._events){var a=this._events[s],u=BuilderProvider.getEventBuilder(a),h=u.reset(t);null==h||h.isEmpty()||i.insertChild(h.build()),u.isEmpty()?delete n[a.id()]:n[a.id()]=u.build()}return this._events=n,i},t.prototype.aggregateInsert=function(t){for(var e in t.meta())e!==Const.AGGREGATE_KEY&&(this._meta[e]=t.meta()[e]);var r=t.meta()[Const.AGGREGATE_KEY],i=this._meta[Const.AGGREGATE_KEY];this._meta[Const.AGGREGATE_KEY]=codec_1.Util.addKey(i,r)},t.prototype.aggregateUpdate=function(t){for(var e in t.meta())e!==Const.AGGREGATE_KEY&&(this._meta[e]=t.meta()[e])},t.prototype.aggregateDelete=function(t){var e=t.meta()[Const.AGGREGATE_KEY],r=this._meta[Const.AGGREGATE_KEY],i=codec_1.Util.removeKey(r,e);return""===(this._meta[Const.AGGREGATE_KEY]=i)},t.prototype.isEmpty=function(){var t=this._meta[Const.AGGREGATE_KEY];return null==t||""==t},t.prototype.insertChild=function(t){var e=this._events[t.id()],r=null;if(null==e)this._events[t.id()]=t;else{var i=BuilderProvider.getEventBuilder(e);i.aggregateInsert(t),this._events[t.id()]=i.build(),r=t.id()}return r},t.prototype.updateChild=function(t){var e=this._events[t.id()];if(null!=e){var r=BuilderProvider.getEventBuilder(e);r.aggregateUpdate(t),this._events[t.id()]=r.build()}else console.error("[UpdateEvent] Cannot found eventId %s to execute update event from %s",t.id(),t.meta()[Const.AGGREGATE_KEY])},t.prototype.deleteChild=function(t){var e=this._events[t.id()],r=null;if(null!=e){var i=BuilderProvider.getEventBuilder(e);return i.aggregateDelete(t)?delete this._events[t.id()]:(r=t.id(),this._events[t.id()]=i.build()),r}console.error("[DeleteEvent] Cannot found eventId %s to execute delete event from %s",t.id(),t.meta()[Const.AGGREGATE_KEY])},t.prototype.build=function(){throw new TypeError("Not supported in Abstract class")},t}(),B2EventBuilder=function(){function t(t){this._records={},this._states={},this.mergeFrom(t)}return t.prototype.id=function(){return this._id},t.prototype.records=function(){return this._records},t.prototype.matchId=function(){return this._matchId},t.prototype.eventType=function(){return this._eventType},t.prototype.meta=function(){return this._meta},t.prototype.states=function(){return this._states},t.prototype.mergeFrom=function(t){var e=t;if(this._id=t.id(),null!=t.records())for(var r=0,i=e.records();r<i.length;r++){var o=i[r],n=Const.generateKey(o);this._records[n]=o}for(var n in this.setStates(e.eventStates()),this._matchId=t.matchId(),this._eventType=t.eventType(),this._meta={},t.meta())this._meta[n]=t.meta()[n]},t.prototype.setStates=function(t){if(null!=t)for(var e=0,r=t;e<r.length;e++){var i=r[e];this._states[i.partitionKey().toString()]=i}},t.prototype.insertChild=function(t){return this._records[Const.generateKey(t)]=t,null},t.prototype.updateChild=function(t){var e=this._records[Const.generateKey(t)];if(null!=e){var r=BuilderProvider.getRecordBuilder(e);r.merge(t),this._records[Const.generateKey(e)]=r.build()}else console.error("[UpdateOdd] Cannot find record "+this._matchId+" "+this._id+" "+t.source()+" "+t.id())},t.prototype.deleteChild=function(t){return delete this._records[Const.generateKey(t)],null},t.prototype.aggregateInsert=function(t){var e=this;t.eventStates().forEach(function(t){e._states[t.partitionKey().toString()]=t})},t.prototype.aggregateUpdate=function(t){var e=this;t.eventStates().forEach(function(t){e._states[t.partitionKey().toString()]=t})},t.prototype.aggregateDelete=function(t){var e=this;return t.eventStates().forEach(function(t){delete e._states[t.partitionKey().toString()]}),0==Object.keys(this._states).length},t.prototype.reset=function(t){if(null==this._states[t.toString()])return null;var e=BuilderProvider.getEventBuilder(this.build());e._states={},e._records={};var r=this._states[t.toString()];e._states[t.toString()]=r,delete this._states[t.toString()];for(var i=0,o=Object.keys(this._records);i<o.length;i++){var n=o[i],s=this._records[n];s.source()===t.source()&&this.getOddTypeInt(s.oddType())===this.getOddTypeInt(t.oddType())&&(e.insertChild(s),delete this._records[n])}return e},t.prototype.getOddTypeInt=function(t){return isNaN(t)?Number(jayeson_lib_record_1.OddType[t]):Number(t)},t.prototype.isEmpty=function(){return null==this._states||0==Object.keys(this._states).length},t.prototype.build=function(){throw new TypeError("Not Implemented for abstract class")},t}(),B2EventStateBuilder=function(){function t(t){this.mergeFrom(t)}return t.prototype.statsOne=function(){return this._statsOne},t.prototype.stateTwo=function(){return this._statsTwo},t.prototype.duration=function(){return this._duration},t.prototype.key=function(){return this._key},t.prototype.matchId=function(){return this._matchId},t.prototype.eventId=function(){return this._eventId},t.prototype.createdTime=function(){return this._createdTime},t.prototype.build=function(){throw new TypeError("UnSupported Operation in abstract class")},t.prototype.mergeFrom=function(t){var e=t;this._statsOne=e.statsOne(),this._statsTwo=e.statsTwo(),this._duration=e.duration(),this._key=e.partitionKey(),this._matchId=e.matchId(),this._eventId=e.eventId(),this._createdTime=(new Date).getMilliseconds()},t.prototype.merge=function(t){var e=t;this.setStatsOne(e.statsOf(0)),this.setStatsTwo(e.statsOf(1)),this.setDuration(e.duration()),this.setEventId(e.eventId()),this.setMatchId(e.matchId()),this.setKey(e.partitionKey())},t.prototype.setStatsOne=function(t){this._statsOne=t},t.prototype.setStatsTwo=function(t){this._statsTwo=t},t.prototype.setDuration=function(t){this._duration=t},t.prototype.setKey=function(t){this._key=t},t.prototype.setMatchId=function(t){this._matchId=t},t.prototype.setEventId=function(t){this._eventId=t},t.prototype.setCreatedTime=function(t){this._createdTime=t},t}(),B2RecordBuilder=function(){function t(t){this.mergeFrom(t)}return t.prototype.eventId=function(){return this._eventId},t.prototype.matchId=function(){return this._matchId},t.prototype.id=function(){return this._id},t.prototype.oddType=function(){return this._oddType},t.prototype.lbType=function(){return this._lbType},t.prototype.timetype=function(){return this._timetype},t.prototype.sportbook=function(){return this._sportbook},t.prototype.meta=function(){return this._meta},t.prototype.oddFormat=function(){return this._oddFormat},t.prototype.rateOver=function(){return this._rateOver},t.prototype.rateUnder=function(){return this._rateUnder},t.prototype.rateEqual=function(){return this._rateEqual},t.prototype.pivotValue=function(){return this._pivotValue},t.prototype.pivotType=function(){return this._pivotType},t.prototype.pivotBias=function(){return this._pivotBias},t.prototype.rateOverId=function(){return this._rateOverId},t.prototype.rateUnderId=function(){return this._rateUnderId},t.prototype.rateEqualId=function(){return this._rateEqualId},t.prototype.isSwapped=function(){return this._isSwapped},t.prototype.setEventId=function(t){this._eventId=t},t.prototype.setMatchId=function(t){this._matchId=t},t.prototype.setId=function(t){this._id=t},t.prototype.setOddType=function(t){this._oddType=t},t.prototype.setLbType=function(t){this._lbType=t},t.prototype.setTimeType=function(t){this._timetype=t},t.prototype.setSportbook=function(t){this._sportbook=t},t.prototype.setMeta=function(t){this._meta=t},t.prototype.setOddFormat=function(t){this._oddFormat=t},t.prototype.setRateOver=function(t){this._rateOver=t},t.prototype.setRateUnder=function(t){this._rateUnder=t},t.prototype.setRateEqual=function(t){this._rateEqual=t},t.prototype.setPivotValue=function(t){this._pivotValue=t},t.prototype.setPivotType=function(t){this._pivotType=t},t.prototype.setPivotBias=function(t){this._pivotBias=t},t.prototype.setRateOverId=function(t){this._rateOverId=t},t.prototype.setRateUnderId=function(t){this._rateUnderId=t},t.prototype.setRateEqualId=function(t){this._rateEqualId=t},t.prototype.setSwapped=function(t){this._isSwapped=t},t.prototype.build=function(){throw new TypeError("UnSupported in Abstract class")},t.prototype.merge=function(t){var e=t;this.setRateOver(e.rateOver()),this.setRateUnder(e.rateUnder()),this.setRateEqual(e.rateEqual()),e.rateOverId&&this.setRateOverId(e.rateOverId()),e.rateUnderId&&this.setRateOverId(e.rateUnderId()),e.rateEqualId&&this.setRateOverId(e.rateEqualId())},t.prototype.mergeFrom=function(t){var e=t;this._eventId=e.eventId(),this._matchId=e.matchId(),this._id=e.id(),this._oddType=e.oddType(),this._lbType=e.lbType(),this._timetype=e.timeType(),this._sportbook=e.source(),this._meta=e.meta(),this._oddFormat=e.oddFormat(),this._rateOver=e.rateOver(),this._rateUnder=e.rateUnder(),this._rateEqual=e.rateEqual(),this._pivotValue=e.pivotValue(),this._pivotType=e.pivotType(),this._pivotBias=e.pivotBias(),this._rateOverId=e.rateOverId(),this._rateUnderId=e.rateUnderId(),this._rateEqualId=e.rateEqualId(),this._isSwapped=e.isSwapped()},t}();exports.B2RecordBuilder=B2RecordBuilder,function(t){var e,r=(__extends(i,e=IndexedSnapshotBuilder),i);function i(t){return e.call(this,t)||this}t.Snapshot=r}(Builder=Builder||{}),function(t){!function(t){var r,e=(__extends(i,r=B2MatchBuilder),i.prototype.setGender=function(t){this.gender=t},i.prototype.setCountry=function(t){this.country=t},i.prototype.mergeFrom=function(t){r.prototype.mergeFrom.call(this,t);var e=t;this.setGender(e.gender()),this.setCountry(e.country())},i.prototype.build=function(){for(var t=[],e=0,r=Object.keys(this._events);e<r.length;e++){var i=r[e];t.push(this._events[i])}return new jayeson_lib_record_1.TennisMatchImpl(this._p1,this._p2,this._startTime,t,this._id,this._league,this.gender,this.country,this._meta)},i);function i(t){return r.call(this,t)||this}t.Tennis=e;var o,n=(__extends(s,o=B2MatchBuilder),s.prototype.leagueType=function(){return this._leagueType},s.prototype.gender=function(){return this._gender},s.prototype.country=function(){return this._country},s.prototype.setLeagueType=function(t){this._leagueType=t},s.prototype.setGender=function(t){this._gender=t},s.prototype.setCountry=function(t){this._country=t},s.prototype.mergeFrom=function(t){o.prototype.mergeFrom.call(this,t);var e=t;this.setLeagueType(e.leagueType()),this.setCountry(t.country()),this.setGender(e.gender())},s.prototype.build=function(){for(var t=[],e=0,r=Object.keys(this._events);e<r.length;e++){var i=r[e];t.push(this._events[i])}return new jayeson_lib_record_1.SoccerMatchImpl(this._p1,this._p2,this._startTime,t,this._id,this._league,this._meta,this._leagueType,this._gender,this._country)},s);function s(t){return o.call(this,t)||this}t.Soccer=n;var a,u=(__extends(h,a=B2MatchBuilder),h.prototype.gender=function(){return this._gender},h.prototype.country=function(){return this._country},h.prototype.setGender=function(t){this._gender=t},h.prototype.setCountry=function(t){this._country=t},h.prototype.build=function(){for(var t=[],e=0,r=Object.keys(this._events);e<r.length;e++){var i=r[e];t.push(this._events[i])}return new jayeson_lib_record_1.BasketballMatchImpl(this._p1,this._p2,this._startTime,t,this._id,this._league,this._gender,this._country,this._meta)},h.prototype.mergeFrom=function(t){a.prototype.mergeFrom.call(this,t);var e=t;this.setGender(e.gender()),this.setCountry(e.country())},h);function h(t){return a.call(this,t)||this}t.Basketball=u}(t.Match||(t.Match={}))}(Builder=Builder||{}),function(t){!function(t){var e,r=(__extends(i,e=B2EventBuilder),i.prototype.build=function(){for(var t=[],e=0,r=Object.keys(this._records);e<r.length;e++){var i=r[e];t.push(this._records[i])}for(var o=[],n=0,s=Object.keys(this._states);n<s.length;n++){var a=s[n];o.push(this._states[a])}return new jayeson_lib_record_1.TennisEventImpl(this._id,t,o,this._matchId,this._eventType,this._meta)},i);function i(t){return e.call(this,t)||this}t.Tennis=r;var o,n=(__extends(s,o=B2EventBuilder),s.prototype.build=function(){for(var t=[],e=0,r=Object.keys(this._records);e<r.length;e++){var i=r[e];t.push(this._records[i])}for(var o=[],n=0,s=Object.keys(this._states);n<s.length;n++){var a=s[n];o.push(this._states[a])}return new jayeson_lib_record_1.SoccerEventImpl(this._id,t,o,this._matchId,this._eventType,this._meta)},s);function s(t){return o.call(this,t)||this}t.Soccer=n;var a,u=(__extends(h,a=B2EventBuilder),h.prototype.build=function(){for(var t=[],e=0,r=Object.keys(this._records);e<r.length;e++){var i=r[e];t.push(this._records[i])}for(var o=[],n=0,s=Object.keys(this._states);n<s.length;n++){var a=s[n];o.push(this._states[a])}return new jayeson_lib_record_1.BasketballEventImpl(this._id,t,o,this._matchId,this._eventType,this._meta)},h);function h(t){return a.call(this,t)||this}t.Basketball=u}(t.Event||(t.Event={}))}(Builder=Builder||{}),function(t){!function(t){var e,r=(__extends(i,e=B2RecordBuilder),i.prototype.build=function(){return new jayeson_lib_record_1.TennisRecord(this._matchId,this._eventId,this._id,this._oddType,this._lbType,this._timetype,this._sportbook,this._oddFormat,this._meta,this._rateOver,this._rateUnder,this._rateEqual,this._pivotValue,this._pivotType,this._pivotBias,this._rateOverId,this._rateUnderId,this._rateEqualId,this._isSwapped)},i);function i(t){return e.call(this,t)||this}t.Tennis=r;var o,n=(__extends(s,o=B2RecordBuilder),s.prototype.build=function(){return new jayeson_lib_record_1.SoccerRecord(this._matchId,this._eventId,this._id,this._oddType,this._lbType,this._timetype,this._sportbook,this._oddFormat,this._meta,this._rateOver,this._rateUnder,this._rateEqual,this._pivotValue,this._pivotType,this._pivotBias,this._rateOverId,this._rateUnderId,this._rateEqualId,this._isSwapped)},s);function s(t){return o.call(this,t)||this}t.Soccer=n;var a,u=(__extends(h,a=B2RecordBuilder),h.prototype.build=function(){return new jayeson_lib_record_1.BasketballRecord(this._matchId,this._eventId,this._id,this._oddType,this._lbType,this._timetype,this._sportbook,this._oddFormat,this._meta,this._rateOver,this._rateUnder,this._rateEqual,this._pivotValue,this._pivotType,this._pivotBias,this._rateOverId,this._rateUnderId,this._rateEqualId,this._isSwapped)},h);function h(t){return a.call(this,t)||this}t.Basketball=u}(t.Record||(t.Record={}))}(Builder=Builder||{}),function(t){!function(t){var r,e=(__extends(i,r=B2EventStateBuilder),i.prototype.build=function(){return new jayeson_lib_record_1.SoccerEventState(this._duration,this._key,this._matchId,this._eventId,null,this._statsOne.getScores()[0],this._statsTwo.getScores()[0],this._statsOne.getScores()[1],this._statsTwo.getScores()[1],this.segment,this.bookPriority)},i.prototype.setHostScore=function(t){var e=this._statsOne.getScores();e[0]=t,this._statsOne.setScores(e)},i.prototype.setHostCard=function(t){var e=this._statsOne.getScores();e[1]=t,this._statsOne.setScores(e)},i.prototype.setGuestScore=function(t){var e=this._statsTwo.getScores();e[0]=t,this._statsTwo.setScores(e)},i.prototype.setGuestCard=function(t){var e=this._statsTwo.getScores();e[1]=t,this._statsTwo.setScores(e)},i.prototype.setSegment=function(t){this.segment=t},i.prototype.setBookPriority=function(t){this.bookPriority=t},i.prototype.mergeFrom=function(t){r.prototype.mergeFrom.call(this,t);var e=t;this.setHostCard(e.hostCard()),this.setGuestCard(e.guestCard()),this.setHostScore(e.hostScore()),this.setGuestScore(e.guestScore()),this.setSegment(e.segment()),this.setBookPriority(e.bookPriority())},i.prototype.merge=function(t){r.prototype.merge.call(this,t);var e=t;null!=e.segment&&this.setSegment(e.segment())},i);function i(t){return r.call(this,t)||this}t.Soccer=e;var o,n=(__extends(s,o=B2EventStateBuilder),s.prototype.build=function(){return new jayeson_lib_record_1.TennisEventState(this._statsOne,this._statsTwo,this._duration,this._key,this._matchId,this._eventId,this._createdTime,this.setScore,this.game,this.bookPriority)},s.prototype.setSet=function(t){this.setScore=t},s.prototype.setGame=function(t){this.game=t},s.prototype.setBookPriority=function(t){this.bookPriority=t},s.prototype.mergeFrom=function(t){o.prototype.mergeFrom.call(this,t);var e=t;this.setSet(e.set()),this.setGame(e.game()),this.setBookPriority(e.bookPriority())},s);function s(t){return o.call(this,t)||this}t.Tennis=n;var a,u=(__extends(h,a=B2EventStateBuilder),h.prototype.build=function(){return new jayeson_lib_record_1.BasketballEventState(this._statsOne,this._statsTwo,this._duration,this._key,this._matchId,this._eventId,this._createdTime,this.segment,this.isTimeout,this.bookPriority)},h.prototype.setSegment=function(t){this.segment=t},h.prototype.setBookPriority=function(t){this.bookPriority=t},h.prototype.setTimeout=function(t){this.isTimeout=t},h.prototype.mergeFrom=function(t){a.prototype.mergeFrom.call(this,t)},h);function h(t){return a.call(this,t)||this}t.Basketball=u}(t.EventState||(t.EventState={}))}(Builder=Builder||{});var BuilderProvider=function(){function t(){}return t.getMatchBuilder=function(t){if(t instanceof jayeson_lib_record_1.SoccerMatchImpl)return new Builder.Match.Soccer(t);if(t instanceof jayeson_lib_record_1.TennisMatchImpl)return new Builder.Match.Tennis(t);if(t instanceof jayeson_lib_record_1.BasketballMatchImpl)return new Builder.Match.Basketball(t);throw new TypeError("Cannot Create Builder for "+t.constructor.toString())},t.getEventBuilder=function(t){if(t instanceof jayeson_lib_record_1.SoccerEventImpl)return new Builder.Event.Soccer(t);if(t instanceof jayeson_lib_record_1.TennisEventImpl)return new Builder.Event.Tennis(t);if(t instanceof jayeson_lib_record_1.BasketballEventImpl)return new Builder.Event.Basketball(t);throw new TypeError("Cannot Create Builder for "+t.constructor.toString())},t.getRecordBuilder=function(t){if(t instanceof jayeson_lib_record_1.SoccerRecord)return new Builder.Record.Soccer(t);if(t instanceof jayeson_lib_record_1.TennisRecord)return new Builder.Record.Tennis(t);if(t instanceof jayeson_lib_record_1.BasketballRecord)return new Builder.Record.Basketball(t);throw new TypeError("Cannot Create Builder for "+t.constructor.toString())},t.getEventStateBuilder=function(t){if(t instanceof jayeson_lib_record_1.SoccerEventState)return new Builder.EventState.Soccer(t);if(t instanceof jayeson_lib_record_1.TennisEventState)return new Builder.EventState.Tennis(t);if(t instanceof jayeson_lib_record_1.BasketballEventState)return new Builder.EventState.Basketball(t);throw new TypeError("Cannot Create Builder for "+t.constructor.toString())},t.getSnapshotBuilder=function(t){return new Builder.Snapshot(t)},t}();exports.BuilderProvider=BuilderProvider;
|
|
1
|
+
var Builder,__extends=this&&this.__extends||(()=>{var i=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])});return function(t,e){function r(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}})(),jayeson_lib_record_1=(Object.defineProperty(exports,"__esModule",{value:!0}),require("@longchau/jayeson.lib.record")),data_structure_1=require("./data_structure"),codec_1=require("./codec"),Collections=require("typescript-collections"),Const=(()=>{function t(){}return t.generateKey=function(t){return t.source()+this.SEPARATOR+t.id()},t.AGGREGATE_KEY="AGGREGATE_KEY",t.SEPARATOR="_",t})(),IndexedSnapshotBuilder=(exports.Const=Const,(()=>{function t(t){if(this._matches={},this._partitions=new Collections.Dictionary,null!=t){for(var e=0,r=t.matches();e<r.length;e++){var i=r[e];this._matches[i.id()]=i}for(var o=0,n=t.getPartitionMap().keys();o<n.length;o++){var s=n[o];this._partitions.setValue(s,t.getPartitionMap().getValue(s))}}}return t.prototype.matches=function(){return this._matches},t.prototype.partitions=function(){return this._partitions},t.prototype.setPartition=function(t){this._partitions=t},t.prototype.setPartitionValue=function(t,e){this._partitions.setValue(t,e)},t.prototype.removePartitionKey=function(t){return this._partitions.remove(t)},t.prototype.markPartitionAsUpdated=function(t,e){null==e&&(e=(new Date).getMilliseconds()),this._partitions.setValue(t,e)},t.prototype.replaceMatch=function(t){this._matches[t.id()]=t},t.prototype.reset=function(t){if(!this._partitions.containsKey(t))return null;var e,r=this._matches,i=BuilderProvider.getSnapshotBuilder(this.build()),o=(i._matches={},i._partitions.clear(),this.removePartitionKey(t));for(e in i.setPartitionValue(t,o),this._matches){var n=this._matches[e],s=BuilderProvider.getMatchBuilder(n),a=s.reset(t);null==a||a.isEmpty()||i.insertChild(a.build()),s.isEmpty()?delete r[n.id()]:r[n.id()]=s.build()}return this._matches=r,i},t.prototype.insertChild=function(t){var e=this._matches[t.id()],r=null;return null==e?this._matches[t.id()]=t:(r=t.id(),(e=BuilderProvider.getMatchBuilder(e)).aggregateInsert(t),this._matches[t.id()]=e.build()),r},t.prototype.updateChild=function(t){var e=this._matches[t.id()];null==e?console.error("[UpdateMatch] Cannot found matchId %s to execute update match from %s",t.id(),t.meta()[Const.AGGREGATE_KEY]):((e=BuilderProvider.getMatchBuilder(e)).aggregateUpdate(t),this._matches[t.id()]=e.build())},t.prototype.deleteChild=function(t){var e=this._matches[t.id()],r=null;if(null!=e)return(e=BuilderProvider.getMatchBuilder(e)).aggregateDelete(t)?delete this._matches[t.id()]:(this._matches[t.id()]=e.build(),r=t.id()),r;console.error("[DeleteMatch] Cannot found matchId %s to execute delete match from %s",t.id(),t.meta()[Const.AGGREGATE_KEY])},t.prototype.build=function(){var t,e={};for(t in this._matches){var r=this._matches[t],i=e[r.sportType()];null==i&&(i=[],e[r.sportType()]=i),i.push(r)}return new data_structure_1.IndexedSnapshotImpl(e,this._partitions)},t})()),B2MatchBuilder=(()=>{function t(t){this._events={},this.mergeFrom(t)}return t.prototype.meta=function(){return this._meta},t.prototype.startTime=function(){return this._startTime},t.prototype.events=function(){return this._events},t.prototype.id=function(){return this._id},t.prototype.league=function(){return this._league},t.prototype.sport=function(){return this._sport},t.prototype.meata=function(){return this._meta},t.prototype.p1=function(){return this._p1},t.prototype.p2=function(){return this._p2},t.prototype.setEvent=function(t){this._events=t},t.prototype.mergeFrom=function(t){for(var e in this._startTime=t.startTime(),this._id=t.id(),this._league=t.league(),this._sport=t.sportType(),this._meta={},t.meta())this._meta[e]=t.meta()[e];if(null!=t.events())for(var r=0,i=t.events();r<i.length;r++){var o=i[r];this._events[o.id()]=o}var n=t;this._p1=n.participantOne(),this._p2=n.participantTwo()},t.prototype.replaceEvent=function(t){this._events[t.id()]=t},t.prototype.reset=function(t){var e=t.toString(),r=this._meta[Const.AGGREGATE_KEY];if(!codec_1.Util.containsKey(r,e))return null;var i,o=BuilderProvider.getMatchBuilder(this.build()),r=codec_1.Util.removeKey(r,e),n=(this._meta[Const.AGGREGATE_KEY]=r,o._meta[Const.AGGREGATE_KEY]=e,{});for(i in o._events={},this._events){var s=this._events[i],a=BuilderProvider.getEventBuilder(s),u=a.reset(t);null==u||u.isEmpty()||o.insertChild(u.build()),a.isEmpty()?delete n[s.id()]:n[s.id()]=a.build()}return this._events=n,o},t.prototype.aggregateInsert=function(t){for(var e in t.meta())e!==Const.AGGREGATE_KEY&&(this._meta[e]=t.meta()[e]);var r=t.meta()[Const.AGGREGATE_KEY],i=this._meta[Const.AGGREGATE_KEY];this._meta[Const.AGGREGATE_KEY]=codec_1.Util.addKey(i,r)},t.prototype.aggregateUpdate=function(t){for(var e in t.meta())e!==Const.AGGREGATE_KEY&&(this._meta[e]=t.meta()[e])},t.prototype.aggregateDelete=function(t){var t=t.meta()[Const.AGGREGATE_KEY],e=this._meta[Const.AGGREGATE_KEY],e=codec_1.Util.removeKey(e,t);return""===(this._meta[Const.AGGREGATE_KEY]=e)},t.prototype.isEmpty=function(){var t=this._meta[Const.AGGREGATE_KEY];return null==t||""==t},t.prototype.insertChild=function(t){var e=this._events[t.id()],r=null;return null==e?this._events[t.id()]=t:((e=BuilderProvider.getEventBuilder(e)).aggregateInsert(t),this._events[t.id()]=e.build(),r=t.id()),r},t.prototype.updateChild=function(t){var e=this._events[t.id()];null==e?console.error("[UpdateEvent] Cannot found eventId %s to execute update event from %s",t.id(),t.meta()[Const.AGGREGATE_KEY]):((e=BuilderProvider.getEventBuilder(e)).aggregateUpdate(t),this._events[t.id()]=e.build())},t.prototype.deleteChild=function(t){var e=this._events[t.id()],r=null;if(null!=e)return(e=BuilderProvider.getEventBuilder(e)).aggregateDelete(t)?delete this._events[t.id()]:(r=t.id(),this._events[t.id()]=e.build()),r;console.error("[DeleteEvent] Cannot found eventId %s to execute delete event from %s",t.id(),t.meta()[Const.AGGREGATE_KEY])},t.prototype.build=function(){throw new TypeError("Not supported in Abstract class")},t})(),B2EventBuilder=(()=>{function t(t){this._records={},this._states={},this.mergeFrom(t)}return t.prototype.id=function(){return this._id},t.prototype.records=function(){return this._records},t.prototype.matchId=function(){return this._matchId},t.prototype.eventType=function(){return this._eventType},t.prototype.meta=function(){return this._meta},t.prototype.states=function(){return this._states},t.prototype.mergeFrom=function(t){var e=t;if(this._id=t.id(),null!=t.records())for(var r=0,i=e.records();r<i.length;r++){var o=i[r],n=Const.generateKey(o);this._records[n]=o}for(n in this.setStates(e.eventStates()),this._matchId=t.matchId(),this._eventType=t.eventType(),this._meta={},t.meta())this._meta[n]=t.meta()[n]},t.prototype.setStates=function(t){if(null!=t)for(var e=0,r=t;e<r.length;e++){var i=r[e];this._states[i.partitionKey().toString()]=i}},t.prototype.insertChild=function(t){return this._records[Const.generateKey(t)]=t,null},t.prototype.updateChild=function(t){var e,r=this._records[Const.generateKey(t)];null==r?console.error("[UpdateOdd] Cannot find record "+this._matchId+" "+this._id+" "+t.source()+" "+t.id()):((e=BuilderProvider.getRecordBuilder(r)).merge(t),this._records[Const.generateKey(r)]=e.build())},t.prototype.deleteChild=function(t){return delete this._records[Const.generateKey(t)],null},t.prototype.aggregateInsert=function(t){var e=this;t.eventStates().forEach(function(t){e._states[t.partitionKey().toString()]=t})},t.prototype.aggregateUpdate=function(t){var e=this;t.eventStates().forEach(function(t){e._states[t.partitionKey().toString()]=t})},t.prototype.aggregateDelete=function(t){var e=this;return t.eventStates().forEach(function(t){delete e._states[t.partitionKey().toString()]}),0==Object.keys(this._states).length},t.prototype.reset=function(t){if(null==this._states[t.toString()])return null;var e=BuilderProvider.getEventBuilder(this.build()),r=(e._states={},e._records={},this._states[t.toString()]);e._states[t.toString()]=r,delete this._states[t.toString()];for(var i=0,o=Object.keys(this._records);i<o.length;i++){var n=o[i],s=this._records[n];s.source()===t.source()&&this.getOddTypeInt(s.oddType())===this.getOddTypeInt(t.oddType())&&(e.insertChild(s),delete this._records[n])}return e},t.prototype.getOddTypeInt=function(t){return isNaN(t)?Number(jayeson_lib_record_1.OddType[t]):Number(t)},t.prototype.isEmpty=function(){return null==this._states||0==Object.keys(this._states).length},t.prototype.build=function(){throw new TypeError("Not Implemented for abstract class")},t})(),B2EventStateBuilder=(()=>{function t(t){this.mergeFrom(t)}return t.prototype.statsOne=function(){return this._statsOne},t.prototype.stateTwo=function(){return this._statsTwo},t.prototype.duration=function(){return this._duration},t.prototype.key=function(){return this._key},t.prototype.matchId=function(){return this._matchId},t.prototype.eventId=function(){return this._eventId},t.prototype.createdTime=function(){return this._createdTime},t.prototype.build=function(){throw new TypeError("UnSupported Operation in abstract class")},t.prototype.mergeFrom=function(t){this._statsOne=t.statsOne(),this._statsTwo=t.statsTwo(),this._duration=t.duration(),this._key=t.partitionKey(),this._matchId=t.matchId(),this._eventId=t.eventId(),this._createdTime=(new Date).getMilliseconds()},t.prototype.merge=function(t){this.setStatsOne(t.statsOf(0)),this.setStatsTwo(t.statsOf(1)),this.setDuration(t.duration()),this.setEventId(t.eventId()),this.setMatchId(t.matchId()),this.setKey(t.partitionKey())},t.prototype.setStatsOne=function(t){this._statsOne=t},t.prototype.setStatsTwo=function(t){this._statsTwo=t},t.prototype.setDuration=function(t){this._duration=t},t.prototype.setKey=function(t){this._key=t},t.prototype.setMatchId=function(t){this._matchId=t},t.prototype.setEventId=function(t){this._eventId=t},t.prototype.setCreatedTime=function(t){this._createdTime=t},t})(),B2RecordBuilder=(()=>{function t(t){this.mergeFrom(t)}return t.prototype.eventId=function(){return this._eventId},t.prototype.matchId=function(){return this._matchId},t.prototype.id=function(){return this._id},t.prototype.oddType=function(){return this._oddType},t.prototype.lbType=function(){return this._lbType},t.prototype.timetype=function(){return this._timetype},t.prototype.sportbook=function(){return this._sportbook},t.prototype.meta=function(){return this._meta},t.prototype.oddFormat=function(){return this._oddFormat},t.prototype.rateOver=function(){return this._rateOver},t.prototype.rateUnder=function(){return this._rateUnder},t.prototype.rateEqual=function(){return this._rateEqual},t.prototype.pivotValue=function(){return this._pivotValue},t.prototype.pivotType=function(){return this._pivotType},t.prototype.pivotBias=function(){return this._pivotBias},t.prototype.rateOverId=function(){return this._rateOverId},t.prototype.rateUnderId=function(){return this._rateUnderId},t.prototype.rateEqualId=function(){return this._rateEqualId},t.prototype.isSwapped=function(){return this._isSwapped},t.prototype.setEventId=function(t){this._eventId=t},t.prototype.setMatchId=function(t){this._matchId=t},t.prototype.setId=function(t){this._id=t},t.prototype.setOddType=function(t){this._oddType=t},t.prototype.setLbType=function(t){this._lbType=t},t.prototype.setTimeType=function(t){this._timetype=t},t.prototype.setSportbook=function(t){this._sportbook=t},t.prototype.setMeta=function(t){this._meta=t},t.prototype.setOddFormat=function(t){this._oddFormat=t},t.prototype.setRateOver=function(t){this._rateOver=t},t.prototype.setRateUnder=function(t){this._rateUnder=t},t.prototype.setRateEqual=function(t){this._rateEqual=t},t.prototype.setPivotValue=function(t){this._pivotValue=t},t.prototype.setPivotType=function(t){this._pivotType=t},t.prototype.setPivotBias=function(t){this._pivotBias=t},t.prototype.setRateOverId=function(t){this._rateOverId=t},t.prototype.setRateUnderId=function(t){this._rateUnderId=t},t.prototype.setRateEqualId=function(t){this._rateEqualId=t},t.prototype.setSwapped=function(t){this._isSwapped=t},t.prototype.build=function(){throw new TypeError("UnSupported in Abstract class")},t.prototype.merge=function(t){this.setRateOver(t.rateOver()),this.setRateUnder(t.rateUnder()),this.setRateEqual(t.rateEqual()),t.rateOverId&&this.setRateOverId(t.rateOverId()),t.rateUnderId&&this.setRateOverId(t.rateUnderId()),t.rateEqualId&&this.setRateOverId(t.rateEqualId())},t.prototype.mergeFrom=function(t){this._eventId=t.eventId(),this._matchId=t.matchId(),this._id=t.id(),this._oddType=t.oddType(),this._lbType=t.lbType(),this._timetype=t.timeType(),this._sportbook=t.source(),this._meta=t.meta(),this._oddFormat=t.oddFormat(),this._rateOver=t.rateOver(),this._rateUnder=t.rateUnder(),this._rateEqual=t.rateEqual(),this._pivotValue=t.pivotValue(),this._pivotType=t.pivotType(),this._pivotBias=t.pivotBias(),this._rateOverId=t.rateOverId(),this._rateUnderId=t.rateUnderId(),this._rateEqualId=t.rateEqualId(),this._isSwapped=t.isSwapped()},t})(),BuilderProvider=(exports.B2RecordBuilder=B2RecordBuilder,(t=>{var e;function r(t){return e.call(this,t)||this}__extends(r,e=IndexedSnapshotBuilder),t.Snapshot=r})(Builder=Builder||{}),(t=>{var e,r,i,t=t.Match||(t.Match={});function o(t){return e.call(this,t)||this}function n(t){return r.call(this,t)||this}function s(t){return i.call(this,t)||this}__extends(o,e=B2MatchBuilder),o.prototype.setGender=function(t){this.gender=t},o.prototype.setCountry=function(t){this.country=t},o.prototype.mergeFrom=function(t){e.prototype.mergeFrom.call(this,t);this.setGender(t.gender()),this.setCountry(t.country())},o.prototype.build=function(){for(var t=[],e=0,r=Object.keys(this._events);e<r.length;e++){var i=r[e];t.push(this._events[i])}return new jayeson_lib_record_1.TennisMatchImpl(this._p1,this._p2,this._startTime,t,this._id,this._league,this.gender,this.country,this._meta)},t.Tennis=o,__extends(n,r=B2MatchBuilder),n.prototype.leagueType=function(){return this._leagueType},n.prototype.gender=function(){return this._gender},n.prototype.country=function(){return this._country},n.prototype.setLeagueType=function(t){this._leagueType=t},n.prototype.setGender=function(t){this._gender=t},n.prototype.setCountry=function(t){this._country=t},n.prototype.mergeFrom=function(t){r.prototype.mergeFrom.call(this,t);var e=t;this.setLeagueType(e.leagueType()),this.setCountry(t.country()),this.setGender(e.gender())},n.prototype.build=function(){for(var t=[],e=0,r=Object.keys(this._events);e<r.length;e++){var i=r[e];t.push(this._events[i])}return new jayeson_lib_record_1.SoccerMatchImpl(this._p1,this._p2,this._startTime,t,this._id,this._league,this._meta,this._leagueType,this._gender,this._country)},t.Soccer=n,__extends(s,i=B2MatchBuilder),s.prototype.gender=function(){return this._gender},s.prototype.country=function(){return this._country},s.prototype.setGender=function(t){this._gender=t},s.prototype.setCountry=function(t){this._country=t},s.prototype.build=function(){for(var t=[],e=0,r=Object.keys(this._events);e<r.length;e++){var i=r[e];t.push(this._events[i])}return new jayeson_lib_record_1.BasketballMatchImpl(this._p1,this._p2,this._startTime,t,this._id,this._league,this._gender,this._country,this._meta)},s.prototype.mergeFrom=function(t){i.prototype.mergeFrom.call(this,t);this.setGender(t.gender()),this.setCountry(t.country())},t.Basketball=s})(Builder=Builder||{}),(t=>{var e,r,i,t=t.Event||(t.Event={});function o(t){return e.call(this,t)||this}function n(t){return r.call(this,t)||this}function s(t){return i.call(this,t)||this}__extends(o,e=B2EventBuilder),o.prototype.build=function(){for(var t=[],e=0,r=Object.keys(this._records);e<r.length;e++){var i=r[e];t.push(this._records[i])}for(var o=[],n=0,s=Object.keys(this._states);n<s.length;n++){var a=s[n];o.push(this._states[a])}return new jayeson_lib_record_1.TennisEventImpl(this._id,t,o,this._matchId,this._eventType,this._meta)},t.Tennis=o,__extends(n,r=B2EventBuilder),n.prototype.build=function(){for(var t=[],e=0,r=Object.keys(this._records);e<r.length;e++){var i=r[e];t.push(this._records[i])}for(var o=[],n=0,s=Object.keys(this._states);n<s.length;n++){var a=s[n];o.push(this._states[a])}return new jayeson_lib_record_1.SoccerEventImpl(this._id,t,o,this._matchId,this._eventType,this._meta)},t.Soccer=n,__extends(s,i=B2EventBuilder),s.prototype.build=function(){for(var t=[],e=0,r=Object.keys(this._records);e<r.length;e++){var i=r[e];t.push(this._records[i])}for(var o=[],n=0,s=Object.keys(this._states);n<s.length;n++){var a=s[n];o.push(this._states[a])}return new jayeson_lib_record_1.BasketballEventImpl(this._id,t,o,this._matchId,this._eventType,this._meta)},t.Basketball=s})(Builder=Builder||{}),(t=>{var e,r,i,t=t.Record||(t.Record={});function o(t){return e.call(this,t)||this}function n(t){return r.call(this,t)||this}function s(t){return i.call(this,t)||this}__extends(o,e=B2RecordBuilder),o.prototype.build=function(){return new jayeson_lib_record_1.TennisRecord(this._matchId,this._eventId,this._id,this._oddType,this._lbType,this._timetype,this._sportbook,this._oddFormat,this._meta,this._rateOver,this._rateUnder,this._rateEqual,this._pivotValue,this._pivotType,this._pivotBias,this._rateOverId,this._rateUnderId,this._rateEqualId,this._isSwapped)},t.Tennis=o,__extends(n,r=B2RecordBuilder),n.prototype.build=function(){return new jayeson_lib_record_1.SoccerRecord(this._matchId,this._eventId,this._id,this._oddType,this._lbType,this._timetype,this._sportbook,this._oddFormat,this._meta,this._rateOver,this._rateUnder,this._rateEqual,this._pivotValue,this._pivotType,this._pivotBias,this._rateOverId,this._rateUnderId,this._rateEqualId,this._isSwapped)},t.Soccer=n,__extends(s,i=B2RecordBuilder),s.prototype.build=function(){return new jayeson_lib_record_1.BasketballRecord(this._matchId,this._eventId,this._id,this._oddType,this._lbType,this._timetype,this._sportbook,this._oddFormat,this._meta,this._rateOver,this._rateUnder,this._rateEqual,this._pivotValue,this._pivotType,this._pivotBias,this._rateOverId,this._rateUnderId,this._rateEqualId,this._isSwapped)},t.Basketball=s})(Builder=Builder||{}),(t=>{var e,r,i,t=t.EventState||(t.EventState={});function o(t){return e.call(this,t)||this}function n(t){return r.call(this,t)||this}function s(t){return i.call(this,t)||this}__extends(o,e=B2EventStateBuilder),o.prototype.build=function(){return new jayeson_lib_record_1.SoccerEventState(this._duration,this._key,this._matchId,this._eventId,null,this._statsOne.getScores()[0],this._statsTwo.getScores()[0],this._statsOne.getScores()[1],this._statsTwo.getScores()[1],this.segment,this.bookPriority)},o.prototype.setHostScore=function(t){var e=this._statsOne.getScores();e[0]=t,this._statsOne.setScores(e)},o.prototype.setHostCard=function(t){var e=this._statsOne.getScores();e[1]=t,this._statsOne.setScores(e)},o.prototype.setGuestScore=function(t){var e=this._statsTwo.getScores();e[0]=t,this._statsTwo.setScores(e)},o.prototype.setGuestCard=function(t){var e=this._statsTwo.getScores();e[1]=t,this._statsTwo.setScores(e)},o.prototype.setSegment=function(t){this.segment=t},o.prototype.setBookPriority=function(t){this.bookPriority=t},o.prototype.mergeFrom=function(t){e.prototype.mergeFrom.call(this,t);this.setHostCard(t.hostCard()),this.setGuestCard(t.guestCard()),this.setHostScore(t.hostScore()),this.setGuestScore(t.guestScore()),this.setSegment(t.segment()),this.setBookPriority(t.bookPriority())},o.prototype.merge=function(t){e.prototype.merge.call(this,t);null!=t.segment&&this.setSegment(t.segment())},t.Soccer=o,__extends(n,r=B2EventStateBuilder),n.prototype.build=function(){return new jayeson_lib_record_1.TennisEventState(this._statsOne,this._statsTwo,this._duration,this._key,this._matchId,this._eventId,this._createdTime,this.setScore,this.game,this.bookPriority)},n.prototype.setSet=function(t){this.setScore=t},n.prototype.setGame=function(t){this.game=t},n.prototype.setBookPriority=function(t){this.bookPriority=t},n.prototype.mergeFrom=function(t){r.prototype.mergeFrom.call(this,t);this.setSet(t.set()),this.setGame(t.game()),this.setBookPriority(t.bookPriority())},t.Tennis=n,__extends(s,i=B2EventStateBuilder),s.prototype.build=function(){return new jayeson_lib_record_1.BasketballEventState(this._statsOne,this._statsTwo,this._duration,this._key,this._matchId,this._eventId,this._createdTime,this.segment,this.isTimeout,this.bookPriority)},s.prototype.setSegment=function(t){this.segment=t},s.prototype.setBookPriority=function(t){this.bookPriority=t},s.prototype.setTimeout=function(t){this.isTimeout=t},s.prototype.mergeFrom=function(t){i.prototype.mergeFrom.call(this,t)},t.Basketball=s})(Builder=Builder||{}),(()=>{function t(){}return t.getMatchBuilder=function(t){if(t instanceof jayeson_lib_record_1.SoccerMatchImpl)return new Builder.Match.Soccer(t);if(t instanceof jayeson_lib_record_1.TennisMatchImpl)return new Builder.Match.Tennis(t);if(t instanceof jayeson_lib_record_1.BasketballMatchImpl)return new Builder.Match.Basketball(t);throw new TypeError("Cannot Create Builder for "+t.constructor.toString())},t.getEventBuilder=function(t){if(t instanceof jayeson_lib_record_1.SoccerEventImpl)return new Builder.Event.Soccer(t);if(t instanceof jayeson_lib_record_1.TennisEventImpl)return new Builder.Event.Tennis(t);if(t instanceof jayeson_lib_record_1.BasketballEventImpl)return new Builder.Event.Basketball(t);throw new TypeError("Cannot Create Builder for "+t.constructor.toString())},t.getRecordBuilder=function(t){if(t instanceof jayeson_lib_record_1.SoccerRecord)return new Builder.Record.Soccer(t);if(t instanceof jayeson_lib_record_1.TennisRecord)return new Builder.Record.Tennis(t);if(t instanceof jayeson_lib_record_1.BasketballRecord)return new Builder.Record.Basketball(t);throw new TypeError("Cannot Create Builder for "+t.constructor.toString())},t.getEventStateBuilder=function(t){if(t instanceof jayeson_lib_record_1.SoccerEventState)return new Builder.EventState.Soccer(t);if(t instanceof jayeson_lib_record_1.TennisEventState)return new Builder.EventState.Tennis(t);if(t instanceof jayeson_lib_record_1.BasketballEventState)return new Builder.EventState.Basketball(t);throw new TypeError("Cannot Create Builder for "+t.constructor.toString())},t.getSnapshotBuilder=function(t){return new Builder.Snapshot(t)},t})());exports.BuilderProvider=BuilderProvider;
|