@jayesol/jayeson.lib.sports 2.2.7-beta5 → 2.2.7-beta6

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BasketballCodec=void 0;var tslib_1=require("tslib"),jayeson_lib_record_1=require("@jayesol/jayeson.lib.record"),proto=tslib_1.__importStar(require("./protobuf_bundle")),codec_1=require("./codec"),BasketballCodec=function(){function e(e){void 0===e&&(e=new codec_1.CodecHelper),this.codecHelper=e}return e.prototype.decodeMatch=function(e,a,t,r){var o=this;return e.map(function(e){var t=a[e.participants[0]],l=a[e.participants[1]],s=a[e.id],n=o.codecHelper.coerceInt64(e.startTime),_=a[e.league],c=a[e.country],i=null,b={};null!=e.metaInfo&&(b=e.metaInfo);var d=e.basketballMatch;if(d)switch(d.gender){case proto.BasketballMatch.Gender.MEN:i=jayeson_lib_record_1.BasketballGender.MEN;break;case proto.BasketballMatch.Gender.WOMEN:i=jayeson_lib_record_1.BasketballGender.WOMEN}return b=o.codecHelper.populatePKIntoMetaInfo(b,r),new jayeson_lib_record_1.BasketballMatchImpl(t,l,n,[],s,_,i,c,b)})},e.prototype.decodeEvent=function(e,a,t,r){var o=this,l=[],s={};for(var n in e.forEach(function(e){var l=a[e.id],n=e.metaInfo,_=jayeson_lib_record_1.BasketballEventType.NONE;switch(e.eventType.basketballEventType){case proto.BasketballEvent.Type.NONE:_=jayeson_lib_record_1.BasketballEventType.NONE;break;case proto.BasketballEvent.Type.FIRST_TO_20:_=jayeson_lib_record_1.BasketballEventType.FIRST_TO_20;break;case proto.BasketballEvent.Type.LAST_BASKET:_=jayeson_lib_record_1.BasketballEventType.LAST_BASKET;break;case proto.BasketballEvent.Type.TEAM_POINTS:_=jayeson_lib_record_1.BasketballEventType.TEAM_POINTS;break;case proto.BasketballEvent.Type.THREE_POINTERS:_=jayeson_lib_record_1.BasketballEventType.THREE_POINTERS;break;case proto.BasketballEvent.Type.HOME_POINT:_=jayeson_lib_record_1.BasketballEventType.HOME_POINT;break;case proto.BasketballEvent.Type.AWAY_POINT:_=jayeson_lib_record_1.BasketballEventType.AWAY_POINT}var c=a[e.matchId],i=[];null!=e.state&&i.push(o.decodeState(c,l,e.state,a,t,r));var b=new jayeson_lib_record_1.BasketballEventImpl(l,[],i,c,_,n);void 0===s[c]&&(s[c]=[]),s[c].push(b)}),s){var _=new jayeson_lib_record_1.BasketballMatchImpl("","",0,s[n],n,"",jayeson_lib_record_1.BasketballGender.MEN,"",{});l.push(_)}return l},e.prototype.decodeRecord=function(e,a,t,r){var o=this,l=[],s={};for(var n in e.forEach(function(e){var t=o.codecHelper.coerceInt64(e.id),r=jayeson_lib_record_1.OddType[e.oddType.toString()],l=jayeson_lib_record_1.LBType[e.lbType.toString()],n=null,_=e.timeType.basketballTimeType;switch(proto.BasketballTimeType.SettleOn[_.settle.toString()]){case"FT":n=jayeson_lib_record_1.BasketballTimeType.FT;break;case"H1":n=jayeson_lib_record_1.BasketballTimeType.H1;break;case"H2":n=jayeson_lib_record_1.BasketballTimeType.H2;break;case"Q1":n=jayeson_lib_record_1.BasketballTimeType.Q1;break;case"Q2":n=jayeson_lib_record_1.BasketballTimeType.Q2;break;case"Q3":n=jayeson_lib_record_1.BasketballTimeType.Q3;break;case"Q4":n=jayeson_lib_record_1.BasketballTimeType.Q4}var c=a[e.source],i=jayeson_lib_record_1.OddFormat[e.format.toString()],b=e.metaInfo,d=e.pivotValue,p=jayeson_lib_record_1.PivotType[e.pivotType.toString()],y=jayeson_lib_record_1.PivotBias[e.pivotBias.toString()],T=e.basketballRecord,k=!1;T&&(k=T.swapped);var v=o.codecHelper.formatRate(e.rates[0]),B=o.codecHelper.formatRate(e.rates[1]),E=o.codecHelper.formatRate(e.rates[2]),u=a[e.rateIds[0]],j=a[e.rateIds[1]],m=a[e.rateIds[2]],f=a[e.eventId],h=a[e.matchId],I=new jayeson_lib_record_1.BasketballRecord(h,f,t,r,l,n,c,i,b,v,B,E,d,p,y,u,j,m,k);void 0===s[h]&&(s[h]={}),void 0===s[h][f]&&(s[h][f]=[]),s[h][f].push(I)}),s){var _=s[n],c=[];for(var i in _){var b=new jayeson_lib_record_1.BasketballEventImpl(i,_[i],[],n,jayeson_lib_record_1.BasketballEventType.NONE,{});c.push(b)}var d=new jayeson_lib_record_1.BasketballMatchImpl("","",0,c,n,"",jayeson_lib_record_1.BasketballGender.MEN,"",{});l.push(d)}return l},e.prototype.decodeState=function(e,a,t,r,o,l,s){void 0===s&&(s=Date.now());var n=t.duration,_=t.basketballEventState,c=jayeson_lib_record_1.BasketballSegment[t.basketballEventState.segment.toString()],i=_.timeout,b=t.participantStats[0].scores,d=t.participantStats[1].scores;if(b.length<7)for(var p=b.length,y=0;p+y<7;y++)b.push(-1);if(d.length<7){var T=d.length;for(y=0;T+y<7;y++)d.push(-1)}var k=new jayeson_lib_record_1.BasketballStats(b[0],b[1],b[2],b[3],b[4],b[5],b[6]),v=new jayeson_lib_record_1.BasketballStats(d[0],d[1],d[2],d[3],d[4],d[5],d[6]),B=_.bookPriority;return new jayeson_lib_record_1.BasketballEventState(k,v,n,l,e,a,s,c,i,B)},e}();exports.BasketballCodec=BasketballCodec;
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var o=Object.getOwnPropertyDescriptor(t,a);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,o)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&__createBinding(t,e,a);return __setModuleDefault(t,e),t};Object.defineProperty(exports,"__esModule",{value:!0}),exports.BasketballCodec=void 0;var jayeson_lib_record_1=require("@jayesol/jayeson.lib.record"),proto=__importStar(require("./protobuf_bundle")),codec_1=require("./codec"),BasketballCodec=function(){function e(e){void 0===e&&(e=new codec_1.CodecHelper),this.codecHelper=e}return e.prototype.decodeMatch=function(e,t,a,r){var o=this;return e.map(function(e){var a=t[e.participants[0]],l=t[e.participants[1]],n=t[e.id],s=o.codecHelper.coerceInt64(e.startTime),_=t[e.league],c=t[e.country],i=null,b={};null!=e.metaInfo&&(b=e.metaInfo);var d=e.basketballMatch;if(d)switch(d.gender){case proto.BasketballMatch.Gender.MEN:i=jayeson_lib_record_1.BasketballGender.MEN;break;case proto.BasketballMatch.Gender.WOMEN:i=jayeson_lib_record_1.BasketballGender.WOMEN}return b=o.codecHelper.populatePKIntoMetaInfo(b,r),new jayeson_lib_record_1.BasketballMatchImpl(a,l,s,[],n,_,i,c,b)})},e.prototype.decodeEvent=function(e,t,a,r){var o=this,l=[],n={};for(var s in e.forEach(function(e){var l=t[e.id],s=e.metaInfo,_=jayeson_lib_record_1.BasketballEventType.NONE;switch(e.eventType.basketballEventType){case proto.BasketballEvent.Type.NONE:_=jayeson_lib_record_1.BasketballEventType.NONE;break;case proto.BasketballEvent.Type.FIRST_TO_20:_=jayeson_lib_record_1.BasketballEventType.FIRST_TO_20;break;case proto.BasketballEvent.Type.LAST_BASKET:_=jayeson_lib_record_1.BasketballEventType.LAST_BASKET;break;case proto.BasketballEvent.Type.TEAM_POINTS:_=jayeson_lib_record_1.BasketballEventType.TEAM_POINTS;break;case proto.BasketballEvent.Type.THREE_POINTERS:_=jayeson_lib_record_1.BasketballEventType.THREE_POINTERS;break;case proto.BasketballEvent.Type.HOME_POINT:_=jayeson_lib_record_1.BasketballEventType.HOME_POINT;break;case proto.BasketballEvent.Type.AWAY_POINT:_=jayeson_lib_record_1.BasketballEventType.AWAY_POINT}var c=t[e.matchId],i=[];null!=e.state&&i.push(o.decodeState(c,l,e.state,t,a,r));var b=new jayeson_lib_record_1.BasketballEventImpl(l,[],i,c,_,s);void 0===n[c]&&(n[c]=[]),n[c].push(b)}),n){var _=new jayeson_lib_record_1.BasketballMatchImpl("","",0,n[s],s,"",jayeson_lib_record_1.BasketballGender.MEN,"",{});l.push(_)}return l},e.prototype.decodeRecord=function(e,t,a,r){var o=this,l=[],n={};for(var s in e.forEach(function(e){var a=o.codecHelper.coerceInt64(e.id),r=jayeson_lib_record_1.OddType[e.oddType.toString()],l=jayeson_lib_record_1.LBType[e.lbType.toString()],s=null,_=e.timeType.basketballTimeType;switch(proto.BasketballTimeType.SettleOn[_.settle.toString()]){case"FT":s=jayeson_lib_record_1.BasketballTimeType.FT;break;case"H1":s=jayeson_lib_record_1.BasketballTimeType.H1;break;case"H2":s=jayeson_lib_record_1.BasketballTimeType.H2;break;case"Q1":s=jayeson_lib_record_1.BasketballTimeType.Q1;break;case"Q2":s=jayeson_lib_record_1.BasketballTimeType.Q2;break;case"Q3":s=jayeson_lib_record_1.BasketballTimeType.Q3;break;case"Q4":s=jayeson_lib_record_1.BasketballTimeType.Q4}var c=t[e.source],i=jayeson_lib_record_1.OddFormat[e.format.toString()],b=e.metaInfo,d=e.pivotValue,p=jayeson_lib_record_1.PivotType[e.pivotType.toString()],y=jayeson_lib_record_1.PivotBias[e.pivotBias.toString()],u=e.basketballRecord,v=!1;u&&(v=u.swapped);var T=o.codecHelper.formatRate(e.rates[0]),k=o.codecHelper.formatRate(e.rates[1]),B=o.codecHelper.formatRate(e.rates[2]),f=t[e.rateIds[0]],E=t[e.rateIds[1]],j=t[e.rateIds[2]],h=t[e.eventId],m=t[e.matchId],S=new jayeson_lib_record_1.BasketballRecord(m,h,a,r,l,s,c,i,b,T,k,B,d,p,y,f,E,j,v);void 0===n[m]&&(n[m]={}),void 0===n[m][h]&&(n[m][h]=[]),n[m][h].push(S)}),n){var _=n[s],c=[];for(var i in _){var b=new jayeson_lib_record_1.BasketballEventImpl(i,_[i],[],s,jayeson_lib_record_1.BasketballEventType.NONE,{});c.push(b)}var d=new jayeson_lib_record_1.BasketballMatchImpl("","",0,c,s,"",jayeson_lib_record_1.BasketballGender.MEN,"",{});l.push(d)}return l},e.prototype.decodeState=function(e,t,a,r,o,l,n){void 0===n&&(n=Date.now());var s=a.duration,_=a.basketballEventState,c=jayeson_lib_record_1.BasketballSegment[a.basketballEventState.segment.toString()],i=_.timeout,b=a.participantStats[0].scores,d=a.participantStats[1].scores;if(b.length<7)for(var p=b.length,y=0;p+y<7;y++)b.push(-1);if(d.length<7){var u=d.length;for(y=0;u+y<7;y++)d.push(-1)}var v=new jayeson_lib_record_1.BasketballStats(b[0],b[1],b[2],b[3],b[4],b[5],b[6]),T=new jayeson_lib_record_1.BasketballStats(d[0],d[1],d[2],d[3],d[4],d[5],d[6]),k=_.bookPriority;return new jayeson_lib_record_1.BasketballEventState(v,T,s,l,e,t,n,c,i,k)},e}();exports.BasketballCodec=BasketballCodec;
package/lib/client.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SportsFeedClient=exports.MemoryDispatcher=exports.AbstractComparableEPDispatcher=exports.FeedView=exports.Reset=exports.DeleteOdd=exports.UpdateOdd=exports.InsertOdd=exports.DeleteEvent=exports.UpdateEvent=exports.InsertEvent=exports.DeleteMatch=exports.UpdateMatch=exports.InsertMatch=void 0;var tslib_1=require("tslib"),dispatch_1=require("./dispatch"),codec_1=require("./codec"),core_1=require("./core"),delivery=tslib_1.__importStar(require("@jayesol/jayeson.lib.delivery")),jayeson_lib_delivery_1=require("@jayesol/jayeson.lib.delivery"),Collections=tslib_1.__importStar(require("typescript-collections")),T=tslib_1.__importStar(require("ts-promise")),data_structure_1=require("./data_structure"),receive_1=require("./receive"),message_class_1=require("./message_class");require("reflect-metadata");var injection_js_1=require("injection-js"),InsertMatch=function(){function t(t,e){this._after=t,this._get=e}return t.prototype.after=function(){return this._after},t.prototype.get=function(){return this._get},t}();exports.InsertMatch=InsertMatch;var UpdateMatch=function(){function t(t,e){this._after=t,this._get=e}return t.prototype.after=function(){return this._after},t.prototype.get=function(){return this._get},t}();exports.UpdateMatch=UpdateMatch;var DeleteMatch=function(){function t(t,e){this._after=t,this._get=e}return t.prototype.after=function(){return this._after},t.prototype.get=function(){return this._get},t}();exports.DeleteMatch=DeleteMatch;var InsertEvent=function(){function t(t,e){this._after=t,this._get=e}return t.prototype.after=function(){return this._after},t.prototype.get=function(){return this._get},t}();exports.InsertEvent=InsertEvent;var UpdateEvent=function(){function t(t,e){this._after=t,this._get=e}return t.prototype.after=function(){return this._after},t.prototype.get=function(){return this._get},t}();exports.UpdateEvent=UpdateEvent;var DeleteEvent=function(){function t(t,e){this._after=t,this._get=e}return t.prototype.after=function(){return this._after},t.prototype.get=function(){return this._get},t}();exports.DeleteEvent=DeleteEvent;var InsertOdd=function(){function t(t,e){this._after=t,this._get=e}return t.prototype.after=function(){return this._after},t.prototype.get=function(){return this._get},t}();exports.InsertOdd=InsertOdd;var UpdateOdd=function(){function t(t,e){this._after=t,this._get=e}return t.prototype.after=function(){return this._after},t.prototype.get=function(){return this._get},t}();exports.UpdateOdd=UpdateOdd;var DeleteOdd=function(){function t(t,e){this._after=t,this._get=e}return t.prototype.after=function(){return this._after},t.prototype.get=function(){return this._get},t}();exports.DeleteOdd=DeleteOdd;var Reset=function(){function t(t,e){this._after=t,this._get=e}return t.prototype.after=function(){return this._after},t.prototype.get=function(){return this._get},t}();exports.Reset=Reset;var FeedView=function(){function t(t,e,r){this._epgm=t,this._fsRepo=e,this._grp=r,this._handlers=[]}return t.prototype.fsRepo=function(){return this._fsRepo},t.prototype.epgm=function(){return this._epgm},t.prototype.grp=function(){return this._grp},t.prototype.snapshot=function(){return this._fsRepo.getSnapshot("")},t.prototype.register=function(t){if(this.hasHandler(t))console.warn("Handler already registered.");else{var e=new MemoryDispatcher(this._fsRepo,this._grp,t);this._epgm.registerEPD(e),this._handlers.push(new HandlerDispatcherTuple(t,e))}},t.prototype.unregister=function(t){var e=this.removeHandler(t);null!=e&&this._epgm.deregisterEPD(e)},t.prototype.hasHandler=function(t){return this._handlers.some(function(e){return e.handler===t})},t.prototype.removeHandler=function(t){var e=this._handlers.find(function(e){return e.handler===t});if(void 0!==e){var r=this._handlers.indexOf(e);return this._handlers.splice(r,1),e.dispatch}return null},t.prototype.handlerSize=function(){return this._handlers.length},t.prototype.cleanUp=function(){var t,e,r=this._handlers.slice(0);try{for(var n=tslib_1.__values(r),i=n.next();!i.done;i=n.next()){var s=i.value;this.unregister(s.handler)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}},t=tslib_1.__decorate([(0,injection_js_1.Injectable)(),tslib_1.__param(0,(0,injection_js_1.Inject)(dispatch_1.EPGM_IMPL)),tslib_1.__param(1,(0,injection_js_1.Inject)(core_1.FSREPO_IMPL)),tslib_1.__metadata("design:paramtypes",[Object,Object,message_class_1.SportsFeedMessageGroup])],t)}();exports.FeedView=FeedView;var HandlerDispatcherTuple=function(t,e){this.handler=t,this.dispatch=e},AbstractComparableEPDispatcher=function(){function t(t,e){this._stream=t,this._grp=e}return t.prototype.id=function(){throw new Error("Method not implemented.")},t.prototype.submit=function(t){throw new Error("Method not implemented.")},t.prototype.onException=function(t){throw new Error("Method not implemented.")},t.prototype.stream=function(){return this._stream},t.prototype.grp=function(){return this._grp},t.prototype.isInitialized=function(){return null},t.prototype.readyToDispatch=function(){this._readyToDispatch=!0},t.prototype.isReadyToDispatch=function(){return this._readyToDispatch},t}();exports.AbstractComparableEPDispatcher=AbstractComparableEPDispatcher;var MemoryDispatcher=function(t){function e(e,n,i){var s=t.call(this,r.MEMORY_STREAM,n)||this;return s._fsRepo=e,s.lastPushedSs=data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT,s._grp=n,s._handler=i,s._id=delivery.generateUUID(),s}var r;return tslib_1.__extends(e,t),r=e,e.prototype.grp=function(){return this._grp},e.prototype.handler=function(){return this._handler},e.prototype.id=function(){return this._id},e.prototype.submit=function(t){this.isInitialized().isFulfilled()&&this.isInitialized().value()&&this.handleMessage(t)},e.prototype.onException=function(t){console.error("Exception when dispatching outgoing messages to dispatchers:"+t)},e.prototype.handleMessage=function(t){if(this.grp().isIndicatorMessage(t.msgType()))if(t.msgType()==this._grp.SWITCH_FILTER_START()){var e=Number(t.msg());this.pushSwitchFilterStart(e)}else if(t.msgType()==this._grp.SWITCH_FILTER_END())this.pushSwitchFilterEnd();else if(t.msgType()==this._grp.FULLSNAPSHOT_START())this.pushFullSnapshotStart();else if(t.msgType()==this._grp.FULLSNAPSHOT_END())this.pushFullSnapshotEnd();else if(t.msgType()==this._grp.SWITCH_FILTER_FAIL()){e=Number(t.msg());this.pushSwitchFilterFail(e)}else t.msgType()==this._grp.TTL_RESTORE_START()?this.pushFullSnapshotStart():t.msgType()==this._grp.TTL_RESTORE_END()&&this.pushFullSnapshotEnd();else{var r=t;this.isSame(r.msgType(),this._grp.DATA_INSERT_MATCH())?this.pushInsertMatch(r):this.isSame(r.msgType(),this._grp.DATA_INSERT_EVENT())?this.pushInsertEvent(r):this.isSame(r.msgType(),this._grp.DATA_INSERT_ODD())?this.pushInsertOdd(r):this.isSame(r.msgType(),this._grp.DATA_UPDATE_MATCH())?this.pushUpdateMatch(r):this.isSame(r.msgType(),this._grp.DATA_UPDATE_EVENT())?this.pushUpdateEvent(r):this.isSame(r.msgType(),this._grp.DATA_UPDATE_ODD())?this.pushUpdateOdd(r):this.isSame(r.msgType(),this._grp.DATA_DELETE_MATCH())?this.pushDeleteMatch(r):this.isSame(r.msgType(),this._grp.DATA_DELETE_EVENT())?this.pushDeleteEvent(r):this.isSame(r.msgType(),this._grp.DATA_DELETE_ODD())?this.pushDeleteOdd(r):this.isSame(r.msgType(),this._grp.DATA_RESET())&&this.pushReset(r)}},e.prototype.pushSwitchFilterStart=function(t){this._handler.onSwitchFilterStart(t)},e.prototype.pushSwitchFilterEnd=function(){this._handler.onSwitchFilterEnd()},e.prototype.pushFullSnapshotStart=function(){this._handler.onFullSnapshotStart()},e.prototype.pushFullSnapshotEnd=function(){this._handler.onFullSnapshotEnd()},e.prototype.pushSwitchFilterFail=function(t){this._handler.onSwitchFilterFail(t)},e.prototype.pushInsertMatch=function(t){var e,r,n=[],i=[];try{for(var s=tslib_1.__values(t.delta().matches()),o=s.next();!o.done;o=s.next()){var a=o.value;t.before().hasMatch(a.id())?i.push(a):n.push(a)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}if(0!=n.length){var p=new InsertMatch(t.after(),n);this._handler.onInsertMatch(p)}if(0!=i.length){var h=new UpdateMatch(t.after(),i);this._handler.onUpdateMatch(h)}},e.prototype.pushInsertEvent=function(t){var e,r,n=[],i=[];try{for(var s=tslib_1.__values(this.events(t.delta().matches())),o=s.next();!o.done;o=s.next()){var a=o.value,p=t.before().match(a.matchId());null!=p&&p.hasEvent(a.id())?i.push(a):n.push(a)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}if(0!=n.length){var h=new InsertEvent(t.after(),n);this._handler.onInsertEvent(h)}if(i.length>0){var l=new UpdateEvent(t.after(),i);this._handler.onUpdateEvent(l)}},e.prototype.pushInsertOdd=function(t){var e=this.records(this.events(t.delta().matches()));if(e.length>0){var r=new InsertOdd(t.after(),e);this._handler.onInsertOdd(r)}},e.prototype.pushUpdateMatch=function(t){var e=t.delta().matches();if(e.length>0){var r=new UpdateMatch(t.after(),e);this._handler.onUpdateMatch(r)}},e.prototype.pushUpdateEvent=function(t){var e=this.events(t.delta().matches());if(e.length>0){var r=new UpdateEvent(t.after(),e);this._handler.onUpdateEvent(r)}},e.prototype.pushUpdateOdd=function(t){var e=this.records(this.events(t.delta().matches()));if(e.length>0){var r=new UpdateOdd(t.after(),e);this._handler.onUpdateOdd(r)}},e.prototype.pushDeleteMatch=function(t){var e,r,n=[],i=[];try{for(var s=tslib_1.__values(t.delta().matches()),o=s.next();!o.done;o=s.next()){var a=o.value;t.after().hasMatch(a.id())?n.push(a):i.push(a)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}if(0!=i.length){var p=new DeleteMatch(t.after(),i);this._handler.onDeleteMatch(p)}if(0!=n.length){var h=new UpdateMatch(t.after(),n);this._handler.onUpdateMatch(h)}},e.prototype.pushDeleteEvent=function(t){var e,r,n=[],i=[];try{for(var s=tslib_1.__values(this.events(t.delta().matches())),o=s.next();!o.done;o=s.next()){var a=o.value,p=t.after().match(a.matchId());null!=p&&p.hasEvent(a.id())?n.push(a):i.push(a)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}if(0!=i.length){var h=new DeleteEvent(t.after(),i);this._handler.onDeleteEvent(h)}if(0!=n.length){var l=new UpdateEvent(t.after(),n);this._handler.onUpdateEvent(l)}},e.prototype.pushDeleteOdd=function(t){var e=this.records(this.events(t.delta().matches()));if(e.length>0){var r=new DeleteOdd(t.after(),e);this._handler.onDeleteOdd(r)}},e.prototype.pushReset=function(t){var e=t.delta().getPartitions().toArray(),r=new Reset(t.after(),e);this._handler.onReset(r)},e.prototype.events=function(t){var e,r,n,i,s=[];try{for(var o=tslib_1.__values(t),a=o.next();!a.done;a=o.next()){var p=a.value;try{for(var h=(n=void 0,tslib_1.__values(p.events())),l=h.next();!l.done;l=h.next()){var u=l.value;s.push(u)}}catch(t){n={error:t}}finally{try{l&&!l.done&&(i=h.return)&&i.call(h)}finally{if(n)throw n.error}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return s},e.prototype.records=function(t){var e,r,n,i,s=[];try{for(var o=tslib_1.__values(t),a=o.next();!a.done;a=o.next()){var p=a.value;try{for(var h=(n=void 0,tslib_1.__values(p.records())),l=h.next();!l.done;l=h.next()){var u=l.value;s.push(u)}}catch(t){n={error:t}}finally{try{l&&!l.done&&(i=h.return)&&i.call(h)}finally{if(n)throw n.error}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return s},e.prototype.states=function(t){var e,r,n,i,s=[];try{for(var o=tslib_1.__values(t),a=o.next();!a.done;a=o.next()){var p=a.value;try{for(var h=(n=void 0,tslib_1.__values(p.eventStates())),l=h.next();!l.done;l=h.next()){var u=l.value;s.push(u)}}catch(t){n={error:t}}finally{try{l&&!l.done&&(i=h.return)&&i.call(h)}finally{if(n)throw n.error}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return s},e.prototype.isSame=function(t,e){return t.id()==e.id()},e.prototype.isInitialized=function(){return this._fsRepo.isReady(this.stream())},e.MEMORY_STREAM="MEMORY_AGGREGATED_STREAM",e=r=tslib_1.__decorate([(0,injection_js_1.Injectable)(),tslib_1.__metadata("design:paramtypes",[Object,message_class_1.SportsFeedMessageGroup,Object])],e)}(AbstractComparableEPDispatcher);exports.MemoryDispatcher=MemoryDispatcher;var SportsFeedClient=function(){function t(t,e,r,n,i,s){this._subscriber=n,this._epgm=r,this._eventHandler=i,this.configureEventHandler(i),this._fsRepo=e,this._grp=t,this._views=new Set,this._viewTemplate=this.view(),this._viewTemplate.register(this);this.resolverMap=new Collections.Dictionary,this.filterRequestCounter=0,s.startTtlVerification()}return t.prototype.subscriber=function(){return this._subscriber},t.prototype.epgm=function(){return this._epgm},t.prototype.InEndPointEventHandler=function(){return this._eventHandler},t.prototype.fsRepo=function(){return this._fsRepo},t.prototype.grp=function(){return this._grp},t.prototype.eventHandler=function(){return this._eventHandler},t.prototype.eventListener=function(t){var e,r,n,i;if(t instanceof jayeson_lib_delivery_1.Subscriber.Event.ConsumptionStart){var s=t;try{for(var o=tslib_1.__values(s.streams),a=o.next();!a.done;a=o.next()){var p=a.value;console.log("ConsumptionsStartEvent for streams "+p+" from "+t.endPoint)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}}else if(t instanceof jayeson_lib_delivery_1.Subscriber.Event.ConsumptionError){s=t;try{for(var h=tslib_1.__values(s.streams),l=h.next();!l.done;l=h.next()){p=l.value;console.log("ConsumptionsStartEvent for streams "+p)}}catch(t){n={error:t}}finally{try{l&&!l.done&&(i=h.return)&&i.call(h)}finally{if(n)throw n.error}}}else console.log("Received event "+t+" from "+t.endPoint)},t.prototype.configureEventHandler=function(t){this._subscriber.attachListener(t)},t.prototype.setUpStreamFilter=function(t){var e=this;if(0===Object.keys(this._eventHandler.streamSources()).length){var r=new codec_1.FilterRequest(codec_1.FilterRequest.IGNORED_REQUEST_ID,t);this._eventHandler.updateFilter(r);var n=null,i=new T.Promise(function(t,e){n=t});return n(!0),i}var s=this.filterRequestCounter++,o=new codec_1.FilterRequest(s,t),a=new T.Promise(function(t,r){e.resolverMap.setValue(s,t)});return this._eventHandler.updateFilter(o),a},t.prototype.getSubscriber=function(){return this._subscriber},t.prototype.start=function(){this.getSubscriber().start()},t.prototype.view=function(){var t=new FeedView(this._epgm,this._fsRepo,this._grp);return this._views.add(t),t},t.prototype.removeView=function(t){this._views.has(t)&&(t.cleanUp(),this._views.delete(t))},t.prototype.onSwitchFilterFail=function(t){t!=codec_1.FilterRequest.IGNORED_REQUEST_ID&&this.resolverMap.remove(t)(!1)},t.prototype.onSwitchFilterStart=function(t){t!=codec_1.FilterRequest.IGNORED_REQUEST_ID&&this.resolverMap.remove(t)(!0)},t.prototype.onInsertMatch=function(t){},t.prototype.onUpdateMatch=function(t){},t.prototype.onDeleteMatch=function(t){},t.prototype.onInsertEvent=function(t){},t.prototype.onUpdateEvent=function(t){},t.prototype.onDeleteEvent=function(t){},t.prototype.onInsertOdd=function(t){},t.prototype.onUpdateOdd=function(t){},t.prototype.onDeleteOdd=function(t){},t.prototype.onReset=function(t){},t.prototype.onSwitchFilterEnd=function(){},t.prototype.onFullSnapshotStart=function(){},t.prototype.onFullSnapshotEnd=function(){},t=tslib_1.__decorate([(0,injection_js_1.Injectable)(),tslib_1.__param(1,(0,injection_js_1.Inject)(core_1.FSREPO_IMPL)),tslib_1.__param(2,(0,injection_js_1.Inject)(dispatch_1.EPGM_IMPL)),tslib_1.__metadata("design:paramtypes",[message_class_1.SportsFeedMessageGroup,Object,Object,jayeson_lib_delivery_1.Subscriber,receive_1.InEndPointEventHandler,receive_1.SportsFeedInProcessor])],t)}();exports.SportsFeedClient=SportsFeedClient;
1
+ "use strict";var __extends=this&&this.__extends||function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),__createBinding=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),__decorate=this&&this.__decorate||function(t,e,r,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s},__importStar=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&__createBinding(e,t,r);return __setModuleDefault(e,t),e},__metadata=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},__param=this&&this.__param||function(t,e){return function(r,n){e(r,n,t)}},__values=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SportsFeedClient=exports.MemoryDispatcher=exports.AbstractComparableEPDispatcher=exports.FeedView=exports.Reset=exports.DeleteOdd=exports.UpdateOdd=exports.InsertOdd=exports.DeleteEvent=exports.UpdateEvent=exports.InsertEvent=exports.DeleteMatch=exports.UpdateMatch=exports.InsertMatch=void 0;var dispatch_1=require("./dispatch"),codec_1=require("./codec"),core_1=require("./core"),delivery=__importStar(require("@jayesol/jayeson.lib.delivery")),jayeson_lib_delivery_1=require("@jayesol/jayeson.lib.delivery"),Collections=__importStar(require("typescript-collections")),T=__importStar(require("ts-promise")),data_structure_1=require("./data_structure"),receive_1=require("./receive"),message_class_1=require("./message_class");require("reflect-metadata");var injection_js_1=require("injection-js"),InsertMatch=function(){function t(t,e){this._after=t,this._get=e}return t.prototype.after=function(){return this._after},t.prototype.get=function(){return this._get},t}();exports.InsertMatch=InsertMatch;var UpdateMatch=function(){function t(t,e){this._after=t,this._get=e}return t.prototype.after=function(){return this._after},t.prototype.get=function(){return this._get},t}();exports.UpdateMatch=UpdateMatch;var DeleteMatch=function(){function t(t,e){this._after=t,this._get=e}return t.prototype.after=function(){return this._after},t.prototype.get=function(){return this._get},t}();exports.DeleteMatch=DeleteMatch;var InsertEvent=function(){function t(t,e){this._after=t,this._get=e}return t.prototype.after=function(){return this._after},t.prototype.get=function(){return this._get},t}();exports.InsertEvent=InsertEvent;var UpdateEvent=function(){function t(t,e){this._after=t,this._get=e}return t.prototype.after=function(){return this._after},t.prototype.get=function(){return this._get},t}();exports.UpdateEvent=UpdateEvent;var DeleteEvent=function(){function t(t,e){this._after=t,this._get=e}return t.prototype.after=function(){return this._after},t.prototype.get=function(){return this._get},t}();exports.DeleteEvent=DeleteEvent;var InsertOdd=function(){function t(t,e){this._after=t,this._get=e}return t.prototype.after=function(){return this._after},t.prototype.get=function(){return this._get},t}();exports.InsertOdd=InsertOdd;var UpdateOdd=function(){function t(t,e){this._after=t,this._get=e}return t.prototype.after=function(){return this._after},t.prototype.get=function(){return this._get},t}();exports.UpdateOdd=UpdateOdd;var DeleteOdd=function(){function t(t,e){this._after=t,this._get=e}return t.prototype.after=function(){return this._after},t.prototype.get=function(){return this._get},t}();exports.DeleteOdd=DeleteOdd;var Reset=function(){function t(t,e){this._after=t,this._get=e}return t.prototype.after=function(){return this._after},t.prototype.get=function(){return this._get},t}();exports.Reset=Reset;var FeedView=function(){function t(t,e,r){this._epgm=t,this._fsRepo=e,this._grp=r,this._handlers=[]}return t.prototype.fsRepo=function(){return this._fsRepo},t.prototype.epgm=function(){return this._epgm},t.prototype.grp=function(){return this._grp},t.prototype.snapshot=function(){return this._fsRepo.getSnapshot("")},t.prototype.register=function(t){if(this.hasHandler(t))console.warn("Handler already registered.");else{var e=new MemoryDispatcher(this._fsRepo,this._grp,t);this._epgm.registerEPD(e),this._handlers.push(new HandlerDispatcherTuple(t,e))}},t.prototype.unregister=function(t){var e=this.removeHandler(t);null!=e&&this._epgm.deregisterEPD(e)},t.prototype.hasHandler=function(t){return this._handlers.some(function(e){return e.handler===t})},t.prototype.removeHandler=function(t){var e=this._handlers.find(function(e){return e.handler===t});if(void 0!==e){var r=this._handlers.indexOf(e);return this._handlers.splice(r,1),e.dispatch}return null},t.prototype.handlerSize=function(){return this._handlers.length},t.prototype.cleanUp=function(){var t,e,r=this._handlers.slice(0);try{for(var n=__values(r),o=n.next();!o.done;o=n.next()){var i=o.value;this.unregister(i.handler)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}},t=__decorate([(0,injection_js_1.Injectable)(),__param(0,(0,injection_js_1.Inject)(dispatch_1.EPGM_IMPL)),__param(1,(0,injection_js_1.Inject)(core_1.FSREPO_IMPL)),__metadata("design:paramtypes",[Object,Object,message_class_1.SportsFeedMessageGroup])],t)}();exports.FeedView=FeedView;var HandlerDispatcherTuple=function(t,e){this.handler=t,this.dispatch=e},AbstractComparableEPDispatcher=function(){function t(t,e){this._stream=t,this._grp=e}return t.prototype.id=function(){throw new Error("Method not implemented.")},t.prototype.submit=function(t){throw new Error("Method not implemented.")},t.prototype.onException=function(t){throw new Error("Method not implemented.")},t.prototype.stream=function(){return this._stream},t.prototype.grp=function(){return this._grp},t.prototype.isInitialized=function(){return null},t.prototype.readyToDispatch=function(){this._readyToDispatch=!0},t.prototype.isReadyToDispatch=function(){return this._readyToDispatch},t}();exports.AbstractComparableEPDispatcher=AbstractComparableEPDispatcher;var MemoryDispatcher=function(t){function e(e,n,o){var i=t.call(this,r.MEMORY_STREAM,n)||this;return i._fsRepo=e,i.lastPushedSs=data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT,i._grp=n,i._handler=o,i._id=delivery.generateUUID(),i}var r;return __extends(e,t),r=e,e.prototype.grp=function(){return this._grp},e.prototype.handler=function(){return this._handler},e.prototype.id=function(){return this._id},e.prototype.submit=function(t){this.isInitialized().isFulfilled()&&this.isInitialized().value()&&this.handleMessage(t)},e.prototype.onException=function(t){console.error("Exception when dispatching outgoing messages to dispatchers:"+t)},e.prototype.handleMessage=function(t){if(this.grp().isIndicatorMessage(t.msgType()))if(t.msgType()==this._grp.SWITCH_FILTER_START()){var e=Number(t.msg());this.pushSwitchFilterStart(e)}else if(t.msgType()==this._grp.SWITCH_FILTER_END())this.pushSwitchFilterEnd();else if(t.msgType()==this._grp.FULLSNAPSHOT_START())this.pushFullSnapshotStart();else if(t.msgType()==this._grp.FULLSNAPSHOT_END())this.pushFullSnapshotEnd();else if(t.msgType()==this._grp.SWITCH_FILTER_FAIL()){e=Number(t.msg());this.pushSwitchFilterFail(e)}else t.msgType()==this._grp.TTL_RESTORE_START()?this.pushFullSnapshotStart():t.msgType()==this._grp.TTL_RESTORE_END()&&this.pushFullSnapshotEnd();else{var r=t;this.isSame(r.msgType(),this._grp.DATA_INSERT_MATCH())?this.pushInsertMatch(r):this.isSame(r.msgType(),this._grp.DATA_INSERT_EVENT())?this.pushInsertEvent(r):this.isSame(r.msgType(),this._grp.DATA_INSERT_ODD())?this.pushInsertOdd(r):this.isSame(r.msgType(),this._grp.DATA_UPDATE_MATCH())?this.pushUpdateMatch(r):this.isSame(r.msgType(),this._grp.DATA_UPDATE_EVENT())?this.pushUpdateEvent(r):this.isSame(r.msgType(),this._grp.DATA_UPDATE_ODD())?this.pushUpdateOdd(r):this.isSame(r.msgType(),this._grp.DATA_DELETE_MATCH())?this.pushDeleteMatch(r):this.isSame(r.msgType(),this._grp.DATA_DELETE_EVENT())?this.pushDeleteEvent(r):this.isSame(r.msgType(),this._grp.DATA_DELETE_ODD())?this.pushDeleteOdd(r):this.isSame(r.msgType(),this._grp.DATA_RESET())&&this.pushReset(r)}},e.prototype.pushSwitchFilterStart=function(t){this._handler.onSwitchFilterStart(t)},e.prototype.pushSwitchFilterEnd=function(){this._handler.onSwitchFilterEnd()},e.prototype.pushFullSnapshotStart=function(){this._handler.onFullSnapshotStart()},e.prototype.pushFullSnapshotEnd=function(){this._handler.onFullSnapshotEnd()},e.prototype.pushSwitchFilterFail=function(t){this._handler.onSwitchFilterFail(t)},e.prototype.pushInsertMatch=function(t){var e,r,n=[],o=[];try{for(var i=__values(t.delta().matches()),s=i.next();!s.done;s=i.next()){var a=s.value;t.before().hasMatch(a.id())?o.push(a):n.push(a)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}if(0!=n.length){var p=new InsertMatch(t.after(),n);this._handler.onInsertMatch(p)}if(0!=o.length){var h=new UpdateMatch(t.after(),o);this._handler.onUpdateMatch(h)}},e.prototype.pushInsertEvent=function(t){var e,r,n=[],o=[];try{for(var i=__values(this.events(t.delta().matches())),s=i.next();!s.done;s=i.next()){var a=s.value,p=t.before().match(a.matchId());null!=p&&p.hasEvent(a.id())?o.push(a):n.push(a)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}if(0!=n.length){var h=new InsertEvent(t.after(),n);this._handler.onInsertEvent(h)}if(o.length>0){var c=new UpdateEvent(t.after(),o);this._handler.onUpdateEvent(c)}},e.prototype.pushInsertOdd=function(t){var e=this.records(this.events(t.delta().matches()));if(e.length>0){var r=new InsertOdd(t.after(),e);this._handler.onInsertOdd(r)}},e.prototype.pushUpdateMatch=function(t){var e=t.delta().matches();if(e.length>0){var r=new UpdateMatch(t.after(),e);this._handler.onUpdateMatch(r)}},e.prototype.pushUpdateEvent=function(t){var e=this.events(t.delta().matches());if(e.length>0){var r=new UpdateEvent(t.after(),e);this._handler.onUpdateEvent(r)}},e.prototype.pushUpdateOdd=function(t){var e=this.records(this.events(t.delta().matches()));if(e.length>0){var r=new UpdateOdd(t.after(),e);this._handler.onUpdateOdd(r)}},e.prototype.pushDeleteMatch=function(t){var e,r,n=[],o=[];try{for(var i=__values(t.delta().matches()),s=i.next();!s.done;s=i.next()){var a=s.value;t.after().hasMatch(a.id())?n.push(a):o.push(a)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}if(0!=o.length){var p=new DeleteMatch(t.after(),o);this._handler.onDeleteMatch(p)}if(0!=n.length){var h=new UpdateMatch(t.after(),n);this._handler.onUpdateMatch(h)}},e.prototype.pushDeleteEvent=function(t){var e,r,n=[],o=[];try{for(var i=__values(this.events(t.delta().matches())),s=i.next();!s.done;s=i.next()){var a=s.value,p=t.after().match(a.matchId());null!=p&&p.hasEvent(a.id())?n.push(a):o.push(a)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}if(0!=o.length){var h=new DeleteEvent(t.after(),o);this._handler.onDeleteEvent(h)}if(0!=n.length){var c=new UpdateEvent(t.after(),n);this._handler.onUpdateEvent(c)}},e.prototype.pushDeleteOdd=function(t){var e=this.records(this.events(t.delta().matches()));if(e.length>0){var r=new DeleteOdd(t.after(),e);this._handler.onDeleteOdd(r)}},e.prototype.pushReset=function(t){var e=t.delta().getPartitions().toArray(),r=new Reset(t.after(),e);this._handler.onReset(r)},e.prototype.events=function(t){var e,r,n,o,i=[];try{for(var s=__values(t),a=s.next();!a.done;a=s.next()){var p=a.value;try{for(var h=(n=void 0,__values(p.events())),c=h.next();!c.done;c=h.next()){var u=c.value;i.push(u)}}catch(t){n={error:t}}finally{try{c&&!c.done&&(o=h.return)&&o.call(h)}finally{if(n)throw n.error}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}return i},e.prototype.records=function(t){var e,r,n,o,i=[];try{for(var s=__values(t),a=s.next();!a.done;a=s.next()){var p=a.value;try{for(var h=(n=void 0,__values(p.records())),c=h.next();!c.done;c=h.next()){var u=c.value;i.push(u)}}catch(t){n={error:t}}finally{try{c&&!c.done&&(o=h.return)&&o.call(h)}finally{if(n)throw n.error}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}return i},e.prototype.states=function(t){var e,r,n,o,i=[];try{for(var s=__values(t),a=s.next();!a.done;a=s.next()){var p=a.value;try{for(var h=(n=void 0,__values(p.eventStates())),c=h.next();!c.done;c=h.next()){var u=c.value;i.push(u)}}catch(t){n={error:t}}finally{try{c&&!c.done&&(o=h.return)&&o.call(h)}finally{if(n)throw n.error}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}return i},e.prototype.isSame=function(t,e){return t.id()==e.id()},e.prototype.isInitialized=function(){return this._fsRepo.isReady(this.stream())},e.MEMORY_STREAM="MEMORY_AGGREGATED_STREAM",e=r=__decorate([(0,injection_js_1.Injectable)(),__metadata("design:paramtypes",[Object,message_class_1.SportsFeedMessageGroup,Object])],e)}(AbstractComparableEPDispatcher);exports.MemoryDispatcher=MemoryDispatcher;var SportsFeedClient=function(){function t(t,e,r,n,o,i){this._subscriber=n,this._epgm=r,this._eventHandler=o,this.configureEventHandler(o),this._fsRepo=e,this._grp=t,this._views=new Set,this._viewTemplate=this.view(),this._viewTemplate.register(this);this.resolverMap=new Collections.Dictionary,this.filterRequestCounter=0,i.startTtlVerification()}return t.prototype.subscriber=function(){return this._subscriber},t.prototype.epgm=function(){return this._epgm},t.prototype.InEndPointEventHandler=function(){return this._eventHandler},t.prototype.fsRepo=function(){return this._fsRepo},t.prototype.grp=function(){return this._grp},t.prototype.eventHandler=function(){return this._eventHandler},t.prototype.eventListener=function(t){var e,r,n,o;if(t instanceof jayeson_lib_delivery_1.Subscriber.Event.ConsumptionStart){var i=t;try{for(var s=__values(i.streams),a=s.next();!a.done;a=s.next()){var p=a.value;console.log("ConsumptionsStartEvent for streams "+p+" from "+t.endPoint)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}}else if(t instanceof jayeson_lib_delivery_1.Subscriber.Event.ConsumptionError){i=t;try{for(var h=__values(i.streams),c=h.next();!c.done;c=h.next()){p=c.value;console.log("ConsumptionsStartEvent for streams "+p)}}catch(t){n={error:t}}finally{try{c&&!c.done&&(o=h.return)&&o.call(h)}finally{if(n)throw n.error}}}else console.log("Received event "+t+" from "+t.endPoint)},t.prototype.configureEventHandler=function(t){this._subscriber.attachListener(t)},t.prototype.setUpStreamFilter=function(t){var e=this;if(0===Object.keys(this._eventHandler.streamSources()).length){var r=new codec_1.FilterRequest(codec_1.FilterRequest.IGNORED_REQUEST_ID,t);this._eventHandler.updateFilter(r);var n=null,o=new T.Promise(function(t,e){n=t});return n(!0),o}var i=this.filterRequestCounter++,s=new codec_1.FilterRequest(i,t),a=new T.Promise(function(t,r){e.resolverMap.setValue(i,t)});return this._eventHandler.updateFilter(s),a},t.prototype.getSubscriber=function(){return this._subscriber},t.prototype.start=function(){this.getSubscriber().start()},t.prototype.view=function(){var t=new FeedView(this._epgm,this._fsRepo,this._grp);return this._views.add(t),t},t.prototype.removeView=function(t){this._views.has(t)&&(t.cleanUp(),this._views.delete(t))},t.prototype.onSwitchFilterFail=function(t){t!=codec_1.FilterRequest.IGNORED_REQUEST_ID&&this.resolverMap.remove(t)(!1)},t.prototype.onSwitchFilterStart=function(t){t!=codec_1.FilterRequest.IGNORED_REQUEST_ID&&this.resolverMap.remove(t)(!0)},t.prototype.onInsertMatch=function(t){},t.prototype.onUpdateMatch=function(t){},t.prototype.onDeleteMatch=function(t){},t.prototype.onInsertEvent=function(t){},t.prototype.onUpdateEvent=function(t){},t.prototype.onDeleteEvent=function(t){},t.prototype.onInsertOdd=function(t){},t.prototype.onUpdateOdd=function(t){},t.prototype.onDeleteOdd=function(t){},t.prototype.onReset=function(t){},t.prototype.onSwitchFilterEnd=function(){},t.prototype.onFullSnapshotStart=function(){},t.prototype.onFullSnapshotEnd=function(){},t=__decorate([(0,injection_js_1.Injectable)(),__param(1,(0,injection_js_1.Inject)(core_1.FSREPO_IMPL)),__param(2,(0,injection_js_1.Inject)(dispatch_1.EPGM_IMPL)),__metadata("design:paramtypes",[message_class_1.SportsFeedMessageGroup,Object,Object,jayeson_lib_delivery_1.Subscriber,receive_1.InEndPointEventHandler,receive_1.SportsFeedInProcessor])],t)}();exports.SportsFeedClient=SportsFeedClient;
package/lib/codec.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Util=exports.FilterRequest=exports.CodecHelper=exports.EncodeAction=void 0;var EncodeAction,tslib_1=require("tslib"),mutable_1=require("./mutable");!function(t){t[t.INSERT=0]="INSERT",t[t.UPDATE=1]="UPDATE",t[t.DELETE=2]="DELETE"}(EncodeAction=exports.EncodeAction||(exports.EncodeAction={}));var CodecHelper=function(){function t(){}return t.prototype.coerceInt64=function(t){return t.toNumber?t.toNumber():t},t.prototype.populatePKIntoMetaInfo=function(t,e){return t[mutable_1.Const.AGGREGATE_KEY]=e.toString(),t},t.prototype.formatRate=function(t){return Math.round(1e4*t)/1e4},t}();exports.CodecHelper=CodecHelper;var FilterRequest=function(){function t(t,e){this._requestId=t,this._ruleCombination=e}return t.prototype.getRequestId=function(){return this._requestId},t.prototype.getFilterData=function(){return this._ruleCombination},t.prototype.toJSON=function(){return{requestId:this.getRequestId(),namespace:this._ruleCombination.namespace,filterRules:this._ruleCombination.filterRules}},t.IGNORED_REQUEST_ID=-1,t}();exports.FilterRequest=FilterRequest;var Util=function(){function t(){}return t.addKey=function(e,r){if(-1!=r.search(t.SEPARATOR))throw new TypeError("Incoming String cannot contain Separator: "+t.SEPARATOR+" Incoming: "+r);return 0==e.length?r:-1===e.indexOf(r)?e+t.SEPARATOR+r:e},t.removeKey=function(e,r){var n,o,i=e.split(t.SEPARATOR),u=r.split(t.SEPARATOR);i.sort();try{for(var c=tslib_1.__values(u),l=c.next();!l.done;l=c.next()){var a=l.value,s=i.indexOf(a);if(!(s<0)&&(i.splice(s,1),0==i.length))return""}}catch(t){n={error:t}}finally{try{l&&!l.done&&(o=c.return)&&o.call(c)}finally{if(n)throw n.error}}for(var p=i[0],f=1;f<i.length;f++)p=t.addKey(p,i[f]);return p},t.containsKey=function(e,r){if(null==e)return!1;if(-1!=r.search(t.SEPARATOR))throw new TypeError("Incoming String cannot contain Separator: "+t.SEPARATOR+" Incoming: "+r);return!(e.split(t.SEPARATOR).indexOf(r)<0)},t.SEPARATOR=",",t}();exports.Util=Util;
1
+ "use strict";var __values=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Util=exports.FilterRequest=exports.CodecHelper=exports.EncodeAction=void 0;var EncodeAction,mutable_1=require("./mutable");!function(e){e[e.INSERT=0]="INSERT",e[e.UPDATE=1]="UPDATE",e[e.DELETE=2]="DELETE"}(EncodeAction=exports.EncodeAction||(exports.EncodeAction={}));var CodecHelper=function(){function e(){}return e.prototype.coerceInt64=function(e){return e.toNumber?e.toNumber():e},e.prototype.populatePKIntoMetaInfo=function(e,t){return e[mutable_1.Const.AGGREGATE_KEY]=t.toString(),e},e.prototype.formatRate=function(e){return Math.round(1e4*e)/1e4},e}();exports.CodecHelper=CodecHelper;var FilterRequest=function(){function e(e,t){this._requestId=e,this._ruleCombination=t}return e.prototype.getRequestId=function(){return this._requestId},e.prototype.getFilterData=function(){return this._ruleCombination},e.prototype.toJSON=function(){return{requestId:this.getRequestId(),namespace:this._ruleCombination.namespace,filterRules:this._ruleCombination.filterRules}},e.IGNORED_REQUEST_ID=-1,e}();exports.FilterRequest=FilterRequest;var Util=function(){function e(){}return e.addKey=function(t,r){if(-1!=r.search(e.SEPARATOR))throw new TypeError("Incoming String cannot contain Separator: "+e.SEPARATOR+" Incoming: "+r);return 0==t.length?r:-1===t.indexOf(r)?t+e.SEPARATOR+r:t},e.removeKey=function(t,r){var n,o,i=t.split(e.SEPARATOR),u=r.split(e.SEPARATOR);i.sort();try{for(var c=__values(u),a=c.next();!a.done;a=c.next()){var l=a.value,s=i.indexOf(l);if(!(s<0)&&(i.splice(s,1),0==i.length))return""}}catch(e){n={error:e}}finally{try{a&&!a.done&&(o=c.return)&&o.call(c)}finally{if(n)throw n.error}}for(var p=i[0],f=1;f<i.length;f++)p=e.addKey(p,i[f]);return p},e.containsKey=function(t,r){if(null==t)return!1;if(-1!=r.search(e.SEPARATOR))throw new TypeError("Incoming String cannot contain Separator: "+e.SEPARATOR+" Incoming: "+r);return!(t.split(e.SEPARATOR).indexOf(r)<0)},e.SEPARATOR=",",e}();exports.Util=Util;
package/lib/core.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RecycleBin=exports.TTLRemoveCheck=exports.TTLRestoreCheck=exports.TTLCheck=exports.TTLOutgoing=exports.TTLType=exports.TTLConfig=exports.Delta=exports.FSRepoImpl=exports.AbstractFSRepo=exports.FSREPO_IMPL=void 0;var tslib_1=require("tslib"),data_structure_1=require("./data_structure"),Collections=tslib_1.__importStar(require("typescript-collections")),T=tslib_1.__importStar(require("ts-promise"));require("reflect-metadata");var injection_js_1=require("injection-js"),jayeson_lib_record_1=require("@jayesol/jayeson.lib.record"),message_class_1=require("./message_class"),mutable_1=require("./mutable"),merge_1=require("./merge"),data_structure_2=require("./data_structure");exports.FSREPO_IMPL=new injection_js_1.InjectionToken("FSRepoInstance");var AbstractFSRepo=function(){function t(){this._handlers=new Collections.Set}return t.prototype.handlers=function(){return this._handlers},t.prototype.appendSnapshot=function(t,e){throw new Error("appendSnapshot is not implemented")},t.prototype.getSnapshot=function(t){throw new Error("getSnapshot is not implemented")},t.prototype.registerSnapshotHandler=function(t){this.handlers().add(t)},t.prototype.deRegisterSnapshotHandler=function(t){this.handlers().remove(t)},t.prototype.getRegisteredHandlers=function(){return this.handlers().toArray()},t.prototype.push=function(t){throw new Error("push is not implemented")},t.prototype.isReady=function(t){return null},t=tslib_1.__decorate([(0,injection_js_1.Injectable)(),tslib_1.__metadata("design:paramtypes",[])],t)}();exports.AbstractFSRepo=AbstractFSRepo;var FSRepoImpl=function(t){function e(e,r){var n=t.call(this)||this;n.outputStreamName=e,n.sportsGroup=r,n._head=null;var o=n;return n.fssEndReceived=new T.Promise(function(t,e){o.promiseResolver=t,o.promiseRejector=e}),n}var r;return tslib_1.__extends(e,t),r=e,e.prototype.head=function(){return this._head},e.prototype.appendSnapshot=function(t,e){return null==this._head?(this.result=e.apply(null),this._head=this.result.getAfter()):(this.result=e.apply(this._head),this._head=this.result.getAfter()),this.result.getDeltaOut()},e.prototype.getSnapshot=function(t){return void 0===t&&(t=""),null==this._head?data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT:this._head},e.prototype.getTtlRemoveSnapshot=function(){return null==this._head?[]:[new TTLRemoveCheck(null,this._head.getPartitions().toArray(),this.outputStreamName)]},e.prototype.push=function(t){if(t.msgType()==this.sportsGroup.FULLSNAPSHOT_START());else if(t.msgType()==this.sportsGroup.FULLSNAPSHOT_END())this.promiseResolver(!0);else{var e=this;this._handlers.forEach(function(r){r.process(e.outputStreamName,t)})}},e.prototype.isReady=function(t){return this.fssEndReceived},e.outputStream=new injection_js_1.InjectionToken("aggregatedStreamName"),e=r=tslib_1.__decorate([(0,injection_js_1.Injectable)(),tslib_1.__param(0,(0,injection_js_1.Inject)(r.outputStream)),tslib_1.__metadata("design:paramtypes",[String,message_class_1.SportsFeedMessageGroup])],e)}(AbstractFSRepo);exports.FSRepoImpl=FSRepoImpl;var Delta=function(){function t(t,e,r){this._incoming=t,this._after=e,this._before=r}return t.prototype.incoming=function(){return this._incoming},t.prototype.msgType=function(){return this._incoming.msgType()},t.prototype.after=function(){return this._after},t.prototype.delta=function(){return this._incoming.data()},t.prototype.before=function(){return this._before},t}();exports.Delta=Delta;var TTLType,TTLConfig=function(){function t(){this.livettl=18e4,this.todayttl=18e4,this.earlyttl=18e4,this.enableTtl=!0}return t.prototype.getLivettl=function(){return this.livettl},t.prototype.setLivettl=function(t){this.livettl=t},t.prototype.getTodayttl=function(){return this.todayttl},t.prototype.setTodayttl=function(t){this.todayttl=t},t.prototype.getEarlyttl=function(){return this.earlyttl},t.prototype.setEarlyttl=function(t){this.earlyttl=t},t.prototype.getRunInterval=function(){if(!this.enableTtl)return-1;var t=this.getLivettl(),e=this.getTodayttl(),r=this.getEarlyttl(),n=Math.min(t,e,r)/2;return n<1e3?1e4:n},t.prototype.isEnableTtl=function(){return this.enableTtl},t.prototype.setEnableTtl=function(t){this.enableTtl=t},t=tslib_1.__decorate([(0,injection_js_1.Injectable)()],t)}();exports.TTLConfig=TTLConfig,function(t){t[t.REMOVE=0]="REMOVE",t[t.RESTORE=1]="RESTORE"}(TTLType=exports.TTLType||(exports.TTLType={}));var TTLOutgoing=function(t){function e(e,r,n,o){var s=t.call(this,r,n,o)||this;return s.ttlType=e,s}return tslib_1.__extends(e,t),e.prototype.getTtlType=function(){return this.ttlType},e}(Delta);exports.TTLOutgoing=TTLOutgoing;var TTLCheck=function(){function t(t,e,r,n){this.ttlType=t,this.recycleBin=e,this.keys=r,this.stream=n}return t.prototype.getKeys=function(){return this.keys},t.prototype.getKeysMapping=function(){var t=new Collections.Dictionary;return this.keys.forEach(function(e){t.setValue(e,(new Date).getTime())}),t},t.prototype.getTtlType=function(){return this.ttlType},t.prototype.getRecycleBin=function(){return this.recycleBin},t.prototype.setRecycleBin=function(t){this.recycleBin=t},t.prototype.getStream=function(){return this.stream},t}();exports.TTLCheck=TTLCheck;var TTLRestoreCheck=function(t){function e(e,r,n){return t.call(this,TTLType.RESTORE,e,r,n)||this}return tslib_1.__extends(e,t),e.prototype.apply=function(t){var e=this,r=t,n=!1,o=new Collections.Dictionary,s={},i=[];this.getKeys().forEach(function(t,a){if(e.getRecycleBin().containData(t)){n=!0;var p=(new Date).getTime();o.setValue(t,p),s=e.getRecycleBin().copyData(t,s),e.ttlRestoreWrapper=e.getRecycleBin().restoreData(new data_structure_2.TTLWrapper,r,t,p),r=e.ttlRestoreWrapper.getRemainingSs(),i.push(e.ttlRestoreWrapper.getRestoredSs())}});var a=[],p=new data_structure_2.MergeableWrapper;if(p.setAfter(r),n)return console.log("restore -----\x3e"+JSON.stringify(o.keys())),merge_1.DeltaTransformingLogicImpl.transformTTLRestore(i,this.getRecycleBin().getGrp(),this.getStream(),t,r,s,o);var l=new data_structure_1.Incoming(this.getRecycleBin().getGrp().ADMIN_REFRESH(),this.getStream(),new data_structure_1.IndexedSnapshotImpl(s,this.getKeysMapping()));return a.push(new TTLOutgoing(this.getTtlType(),l,r,t)),p.setDeltaOut(a),p},e}(TTLCheck);exports.TTLRestoreCheck=TTLRestoreCheck;var TTLRemoveCheck=function(t){function e(e,r,n){return t.call(this,TTLType.REMOVE,e,r,n)||this}return tslib_1.__extends(e,t),e.prototype.apply=function(t){var e,r,n=t.getPartitionMap(),o=new Collections.Dictionary,s=t,i=[],a=this.getRecycleBin().getTtlConfig(),p=!1;try{for(var l=tslib_1.__values(this.getKeys()),c=l.next();!c.done;c=l.next()){var u=c.value,h=0;if(n.containsKey(u)){switch(u.oddType()){case jayeson_lib_record_1.OddType.LIVE:h=n.getValue(u)+a.getLivettl();break;case jayeson_lib_record_1.OddType.TODAY:h=n.getValue(u)+a.getTodayttl();break;case jayeson_lib_record_1.OddType.EARLY:h=n.getValue(u)+a.getEarlyttl()}h<(new Date).getTime()&&(p=!0,o.setValue(u,n.getValue(u)),this.ttlRemoveWrapper=this.getRecycleBin().removeData(new data_structure_2.TTLWrapper,s,u),s=this.ttlRemoveWrapper.getRemainingSs(),i.push(this.ttlRemoveWrapper.getRemovedSs()))}}}catch(t){e={error:t}}finally{try{c&&!c.done&&(r=l.return)&&r.call(l)}finally{if(e)throw e.error}}var g=[];if(p)return console.log("reseting -----\x3e"+JSON.stringify(o.keys())),merge_1.DeltaTransformingLogicImpl.transformTTLRemove(i,this.getRecycleBin().getGrp(),this.getStream(),t,s,o);var _=new data_structure_2.MergeableWrapper,T=new data_structure_1.Incoming(this.getRecycleBin().getGrp().ADMIN_REFRESH(),this.getStream(),new data_structure_1.IndexedSnapshotImpl({},this.getKeysMapping()));return g.push(new TTLOutgoing(this.getTtlType(),T,s,t)),_.setDeltaOut(g),_.setAfter(s),_},e}(TTLCheck);exports.TTLRemoveCheck=TTLRemoveCheck;var RecycleBin=function(){function t(t,e,r){this.ttlConfig=t,this.grp=e,this.fsRepo=r,this.expiredMatches=new Collections.Dictionary,this.ttlStatus=new Collections.Set}return t.prototype.removeData=function(t,e,r){if(!e.getPartitions().contains(r))return t.setRemainingSs(e),t.setRemovedSs(null),t;var n=mutable_1.BuilderProvider.getSnapshotBuilder(e),o=n.reset(r).build(),s=n.build();return this.expiredMatches.setValue(r,o),t.setRemovedSs(o),t.setRemainingSs(s),t},t.prototype.restoreData=function(t,e,r,n){var o=this.expiredMatches.getValue(r);if(null==o)return t.setRemainingSs(e),t.setRestoredSs(null),t;(new Collections.Dictionary).setValue(r,n);var s=mutable_1.BuilderProvider.getSnapshotBuilder(o);return s.markPartitionAsUpdated(r,n),o=s.build(),e=merge_1.SnapshotUtil.combineSnapshots(this.getGrp().DATA_INSERT_MATCH(),o,e).getAfterSs(),e=merge_1.SnapshotUtil.combineSnapshots(this.getGrp().DATA_INSERT_EVENT(),o,e).getAfterSs(),e=merge_1.SnapshotUtil.combineSnapshots(this.getGrp().DATA_INSERT_ODD(),o,e).getAfterSs(),t.setRestoredSs(o),t.setRemainingSs(e),this.expiredMatches.remove(r),t},t.prototype.clearBin=function(t){this.expiredMatches.remove(t),this.ttlStatus.remove(t)},t.prototype.containData=function(t){return this.expiredMatches.containsKey(t)},t.prototype.getTtlConfig=function(){return this.ttlConfig},t.prototype.getFsRepo=function(){return this.fsRepo},t.prototype.getTtlRestoreSnapshot=function(t){var e=this,r=null;return this.ttlStatus.isEmpty()||(this.getGrp().DATA_RESET().id()==t.msgType().id()?t.data().getPartitions().forEach(function(t){console.log("Dropping partition "+t),e.expiredMatches.remove(t)}):t.data().getPartitionMap().forEach(function(n,o){var s=[];e.ttlStatus.contains(n)&&(e.ttlStatus.remove(n),s.push(n)),s.length>0&&(r=new TTLRestoreCheck(e,s,t.stream()))})),r},t.prototype.getTtlRemoveSnapshot=function(){var t=this,e=this.getFsRepo().getTtlRemoveSnapshot();return e.forEach(function(e){e.setRecycleBin(t),e.getKeys().forEach(function(e){t.ttlStatus.add(e)})}),e},t.prototype.copyData=function(t,e){var r=this.expiredMatches.getValue(t);if(void 0===r)return e;var n=new data_structure_1.IndexedSnapshotImpl(e);return n=merge_1.SnapshotUtil.combineSnapshots(this.getGrp().DATA_INSERT_MATCH(),r,n).getAfterSs(),n=merge_1.SnapshotUtil.combineSnapshots(this.getGrp().DATA_INSERT_EVENT(),r,n).getAfterSs(),(n=merge_1.SnapshotUtil.combineSnapshots(this.getGrp().DATA_INSERT_ODD(),r,n).getAfterSs()).matchesSport},t.prototype.getGrp=function(){return this.grp},t=tslib_1.__decorate([(0,injection_js_1.Injectable)(),tslib_1.__metadata("design:paramtypes",[TTLConfig,message_class_1.SportsFeedMessageGroup,AbstractFSRepo])],t)}();exports.RecycleBin=RecycleBin;
1
+ "use strict";var __extends=this&&this.__extends||function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),__createBinding=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),__decorate=this&&this.__decorate||function(t,e,r,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s},__importStar=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&__createBinding(e,t,r);return __setModuleDefault(e,t),e},__metadata=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},__param=this&&this.__param||function(t,e){return function(r,n){e(r,n,t)}},__values=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(exports,"__esModule",{value:!0}),exports.RecycleBin=exports.TTLRemoveCheck=exports.TTLRestoreCheck=exports.TTLCheck=exports.TTLOutgoing=exports.TTLType=exports.TTLConfig=exports.Delta=exports.FSRepoImpl=exports.AbstractFSRepo=exports.FSREPO_IMPL=void 0;var data_structure_1=require("./data_structure"),Collections=__importStar(require("typescript-collections")),T=__importStar(require("ts-promise"));require("reflect-metadata");var injection_js_1=require("injection-js"),jayeson_lib_record_1=require("@jayesol/jayeson.lib.record"),message_class_1=require("./message_class"),mutable_1=require("./mutable"),merge_1=require("./merge"),data_structure_2=require("./data_structure");exports.FSREPO_IMPL=new injection_js_1.InjectionToken("FSRepoInstance");var AbstractFSRepo=function(){function t(){this._handlers=new Collections.Set}return t.prototype.handlers=function(){return this._handlers},t.prototype.appendSnapshot=function(t,e){throw new Error("appendSnapshot is not implemented")},t.prototype.getSnapshot=function(t){throw new Error("getSnapshot is not implemented")},t.prototype.registerSnapshotHandler=function(t){this.handlers().add(t)},t.prototype.deRegisterSnapshotHandler=function(t){this.handlers().remove(t)},t.prototype.getRegisteredHandlers=function(){return this.handlers().toArray()},t.prototype.push=function(t){throw new Error("push is not implemented")},t.prototype.isReady=function(t){return null},t=__decorate([(0,injection_js_1.Injectable)(),__metadata("design:paramtypes",[])],t)}();exports.AbstractFSRepo=AbstractFSRepo;var FSRepoImpl=function(t){function e(e,r){var n=t.call(this)||this;n.outputStreamName=e,n.sportsGroup=r,n._head=null;var o=n;return n.fssEndReceived=new T.Promise(function(t,e){o.promiseResolver=t,o.promiseRejector=e}),n}var r;return __extends(e,t),r=e,e.prototype.head=function(){return this._head},e.prototype.appendSnapshot=function(t,e){return null==this._head?(this.result=e.apply(null),this._head=this.result.getAfter()):(this.result=e.apply(this._head),this._head=this.result.getAfter()),this.result.getDeltaOut()},e.prototype.getSnapshot=function(t){return void 0===t&&(t=""),null==this._head?data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT:this._head},e.prototype.getTtlRemoveSnapshot=function(){return null==this._head?[]:[new TTLRemoveCheck(null,this._head.getPartitions().toArray(),this.outputStreamName)]},e.prototype.push=function(t){if(t.msgType()==this.sportsGroup.FULLSNAPSHOT_START());else if(t.msgType()==this.sportsGroup.FULLSNAPSHOT_END())this.promiseResolver(!0);else{var e=this;this._handlers.forEach(function(r){r.process(e.outputStreamName,t)})}},e.prototype.isReady=function(t){return this.fssEndReceived},e.outputStream=new injection_js_1.InjectionToken("aggregatedStreamName"),e=r=__decorate([(0,injection_js_1.Injectable)(),__param(0,(0,injection_js_1.Inject)(r.outputStream)),__metadata("design:paramtypes",[String,message_class_1.SportsFeedMessageGroup])],e)}(AbstractFSRepo);exports.FSRepoImpl=FSRepoImpl;var Delta=function(){function t(t,e,r){this._incoming=t,this._after=e,this._before=r}return t.prototype.incoming=function(){return this._incoming},t.prototype.msgType=function(){return this._incoming.msgType()},t.prototype.after=function(){return this._after},t.prototype.delta=function(){return this._incoming.data()},t.prototype.before=function(){return this._before},t}();exports.Delta=Delta;var TTLType,TTLConfig=function(){function t(){this.livettl=18e4,this.todayttl=18e4,this.earlyttl=18e4,this.enableTtl=!0}return t.prototype.getLivettl=function(){return this.livettl},t.prototype.setLivettl=function(t){this.livettl=t},t.prototype.getTodayttl=function(){return this.todayttl},t.prototype.setTodayttl=function(t){this.todayttl=t},t.prototype.getEarlyttl=function(){return this.earlyttl},t.prototype.setEarlyttl=function(t){this.earlyttl=t},t.prototype.getRunInterval=function(){if(!this.enableTtl)return-1;var t=this.getLivettl(),e=this.getTodayttl(),r=this.getEarlyttl(),n=Math.min(t,e,r)/2;return n<1e3?1e4:n},t.prototype.isEnableTtl=function(){return this.enableTtl},t.prototype.setEnableTtl=function(t){this.enableTtl=t},t=__decorate([(0,injection_js_1.Injectable)()],t)}();exports.TTLConfig=TTLConfig,function(t){t[t.REMOVE=0]="REMOVE",t[t.RESTORE=1]="RESTORE"}(TTLType=exports.TTLType||(exports.TTLType={}));var TTLOutgoing=function(t){function e(e,r,n,o){var i=t.call(this,r,n,o)||this;return i.ttlType=e,i}return __extends(e,t),e.prototype.getTtlType=function(){return this.ttlType},e}(Delta);exports.TTLOutgoing=TTLOutgoing;var TTLCheck=function(){function t(t,e,r,n){this.ttlType=t,this.recycleBin=e,this.keys=r,this.stream=n}return t.prototype.getKeys=function(){return this.keys},t.prototype.getKeysMapping=function(){var t=new Collections.Dictionary;return this.keys.forEach(function(e){t.setValue(e,(new Date).getTime())}),t},t.prototype.getTtlType=function(){return this.ttlType},t.prototype.getRecycleBin=function(){return this.recycleBin},t.prototype.setRecycleBin=function(t){this.recycleBin=t},t.prototype.getStream=function(){return this.stream},t}();exports.TTLCheck=TTLCheck;var TTLRestoreCheck=function(t){function e(e,r,n){return t.call(this,TTLType.RESTORE,e,r,n)||this}return __extends(e,t),e.prototype.apply=function(t){var e=this,r=t,n=!1,o=new Collections.Dictionary,i={},s=[];this.getKeys().forEach(function(t,a){if(e.getRecycleBin().containData(t)){n=!0;var p=(new Date).getTime();o.setValue(t,p),i=e.getRecycleBin().copyData(t,i),e.ttlRestoreWrapper=e.getRecycleBin().restoreData(new data_structure_2.TTLWrapper,r,t,p),r=e.ttlRestoreWrapper.getRemainingSs(),s.push(e.ttlRestoreWrapper.getRestoredSs())}});var a=[],p=new data_structure_2.MergeableWrapper;if(p.setAfter(r),n)return console.log("restore -----\x3e"+JSON.stringify(o.keys())),merge_1.DeltaTransformingLogicImpl.transformTTLRestore(s,this.getRecycleBin().getGrp(),this.getStream(),t,r,i,o);var c=new data_structure_1.Incoming(this.getRecycleBin().getGrp().ADMIN_REFRESH(),this.getStream(),new data_structure_1.IndexedSnapshotImpl(i,this.getKeysMapping()));return a.push(new TTLOutgoing(this.getTtlType(),c,r,t)),p.setDeltaOut(a),p},e}(TTLCheck);exports.TTLRestoreCheck=TTLRestoreCheck;var TTLRemoveCheck=function(t){function e(e,r,n){return t.call(this,TTLType.REMOVE,e,r,n)||this}return __extends(e,t),e.prototype.apply=function(t){var e,r,n=t.getPartitionMap(),o=new Collections.Dictionary,i=t,s=[],a=this.getRecycleBin().getTtlConfig(),p=!1;try{for(var c=__values(this.getKeys()),u=c.next();!u.done;u=c.next()){var l=u.value,h=0;if(n.containsKey(l)){switch(l.oddType()){case jayeson_lib_record_1.OddType.LIVE:h=n.getValue(l)+a.getLivettl();break;case jayeson_lib_record_1.OddType.TODAY:h=n.getValue(l)+a.getTodayttl();break;case jayeson_lib_record_1.OddType.EARLY:h=n.getValue(l)+a.getEarlyttl()}h<(new Date).getTime()&&(p=!0,o.setValue(l,n.getValue(l)),this.ttlRemoveWrapper=this.getRecycleBin().removeData(new data_structure_2.TTLWrapper,i,l),i=this.ttlRemoveWrapper.getRemainingSs(),s.push(this.ttlRemoveWrapper.getRemovedSs()))}}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=c.return)&&r.call(c)}finally{if(e)throw e.error}}var _=[];if(p)return console.log("reseting -----\x3e"+JSON.stringify(o.keys())),merge_1.DeltaTransformingLogicImpl.transformTTLRemove(s,this.getRecycleBin().getGrp(),this.getStream(),t,i,o);var f=new data_structure_2.MergeableWrapper,g=new data_structure_1.Incoming(this.getRecycleBin().getGrp().ADMIN_REFRESH(),this.getStream(),new data_structure_1.IndexedSnapshotImpl({},this.getKeysMapping()));return _.push(new TTLOutgoing(this.getTtlType(),g,i,t)),f.setDeltaOut(_),f.setAfter(i),f},e}(TTLCheck);exports.TTLRemoveCheck=TTLRemoveCheck;var RecycleBin=function(){function t(t,e,r){this.ttlConfig=t,this.grp=e,this.fsRepo=r,this.expiredMatches=new Collections.Dictionary,this.ttlStatus=new Collections.Set}return t.prototype.removeData=function(t,e,r){if(!e.getPartitions().contains(r))return t.setRemainingSs(e),t.setRemovedSs(null),t;var n=mutable_1.BuilderProvider.getSnapshotBuilder(e),o=n.reset(r).build(),i=n.build();return this.expiredMatches.setValue(r,o),t.setRemovedSs(o),t.setRemainingSs(i),t},t.prototype.restoreData=function(t,e,r,n){var o=this.expiredMatches.getValue(r);if(null==o)return t.setRemainingSs(e),t.setRestoredSs(null),t;(new Collections.Dictionary).setValue(r,n);var i=mutable_1.BuilderProvider.getSnapshotBuilder(o);return i.markPartitionAsUpdated(r,n),o=i.build(),e=merge_1.SnapshotUtil.combineSnapshots(this.getGrp().DATA_INSERT_MATCH(),o,e).getAfterSs(),e=merge_1.SnapshotUtil.combineSnapshots(this.getGrp().DATA_INSERT_EVENT(),o,e).getAfterSs(),e=merge_1.SnapshotUtil.combineSnapshots(this.getGrp().DATA_INSERT_ODD(),o,e).getAfterSs(),t.setRestoredSs(o),t.setRemainingSs(e),this.expiredMatches.remove(r),t},t.prototype.clearBin=function(t){this.expiredMatches.remove(t),this.ttlStatus.remove(t)},t.prototype.containData=function(t){return this.expiredMatches.containsKey(t)},t.prototype.getTtlConfig=function(){return this.ttlConfig},t.prototype.getFsRepo=function(){return this.fsRepo},t.prototype.getTtlRestoreSnapshot=function(t){var e=this,r=null;return this.ttlStatus.isEmpty()||(this.getGrp().DATA_RESET().id()==t.msgType().id()?t.data().getPartitions().forEach(function(t){console.log("Dropping partition "+t),e.expiredMatches.remove(t)}):t.data().getPartitionMap().forEach(function(n,o){var i=[];e.ttlStatus.contains(n)&&(e.ttlStatus.remove(n),i.push(n)),i.length>0&&(r=new TTLRestoreCheck(e,i,t.stream()))})),r},t.prototype.getTtlRemoveSnapshot=function(){var t=this,e=this.getFsRepo().getTtlRemoveSnapshot();return e.forEach(function(e){e.setRecycleBin(t),e.getKeys().forEach(function(e){t.ttlStatus.add(e)})}),e},t.prototype.copyData=function(t,e){var r=this.expiredMatches.getValue(t);if(void 0===r)return e;var n=new data_structure_1.IndexedSnapshotImpl(e);return n=merge_1.SnapshotUtil.combineSnapshots(this.getGrp().DATA_INSERT_MATCH(),r,n).getAfterSs(),n=merge_1.SnapshotUtil.combineSnapshots(this.getGrp().DATA_INSERT_EVENT(),r,n).getAfterSs(),(n=merge_1.SnapshotUtil.combineSnapshots(this.getGrp().DATA_INSERT_ODD(),r,n).getAfterSs()).matchesSport},t.prototype.getGrp=function(){return this.grp},t=__decorate([(0,injection_js_1.Injectable)(),__metadata("design:paramtypes",[TTLConfig,message_class_1.SportsFeedMessageGroup,AbstractFSRepo])],t)}();exports.RecycleBin=RecycleBin;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TTLWrapper=exports.MergeableWrapper=exports.ConvertedMsg=exports.MessageBeforeTransform=exports.DeltaOutgoingImpl=exports.OutgoingImpl=exports.IndexedSnapshotImpl=exports.Incoming=void 0;var tslib_1=require("tslib"),Collections=tslib_1.__importStar(require("typescript-collections")),jayeson_lib_record_1=require("@jayesol/jayeson.lib.record"),Incoming=function(){function t(t,e,r){this._msgType=t,this._stream=e,this._data=r}return t.prototype.msgType=function(){return this._msgType},t.prototype.stream=function(){return this._stream},t.prototype.data=function(){return this._data},t}();exports.Incoming=Incoming;var IndexedSnapshotImpl=function(t){function e(e,r){void 0===e&&(e={}),void 0===r&&(r=new Collections.Dictionary);var n=t.call(this,e)||this;return n.partitions=r,n}return tslib_1.__extends(e,t),e.prototype.getPartitions=function(){var t,e,r=new Collections.Set;try{for(var n=tslib_1.__values(this.partitions.keys()),o=n.next();!o.done;o=n.next()){var s=o.value;r.add(s)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}return r},e.prototype.getPartitionMap=function(){return this.partitions},e.EMPTY_SNAPSHOT=new e,e}(jayeson_lib_record_1.Snapshot);exports.IndexedSnapshotImpl=IndexedSnapshotImpl;var OutgoingImpl=function(){function t(t,e){this._msgType=t,this._msg=e}return t.prototype.msgType=function(){return this._msgType},t.prototype.msg=function(){return this._msg},t}();exports.OutgoingImpl=OutgoingImpl;var DeltaOutgoingImpl=function(t){function e(e,r,n,o){var s=t.call(this,e,r)||this;return s._delta=r,s._after=n,s._before=o,s}return tslib_1.__extends(e,t),e.prototype.after=function(){return this._after},e.prototype.delta=function(){return this._delta},e.prototype.before=function(){return this._before},e}(OutgoingImpl);exports.DeltaOutgoingImpl=DeltaOutgoingImpl;var ConvertedMsg,MessageBeforeTransform=function(){function t(){this.transformEvent=[],this.suppressMatch=[],this.insertMatch=[],this.deleteMatch=[],this.insertEvent=[],this.deleteEvent=[],this.afterSs=IndexedSnapshotImpl.EMPTY_SNAPSHOT,this.beforeSs=IndexedSnapshotImpl.EMPTY_SNAPSHOT}return t.prototype.getTransformEvent=function(){return this.transformEvent},t.prototype.setTransformEvent=function(t){this.transformEvent.push(t)},t.prototype.getSuppressMatch=function(){return this.suppressMatch},t.prototype.setSuppressMatch=function(t){this.suppressMatch.push(t)},t.prototype.setAfterSs=function(t){this.afterSs=t},t.prototype.getAfterSs=function(){return this.afterSs},t.prototype.setBeforeSs=function(t){this.beforeSs=t},t.prototype.getBeforeSs=function(){return this.beforeSs},t.prototype.setInsertEvent=function(t){this.insertEvent.push(t)},t.prototype.getInsertEvent=function(){return this.insertEvent},t.prototype.setDeleteEvent=function(t){this.deleteEvent.push(t)},t.prototype.getDeleteEvent=function(){return this.deleteEvent},t.prototype.setInsertMatch=function(t){this.insertMatch.push(t)},t.prototype.getInsertMatch=function(){return this.insertMatch},t.prototype.setDeleteMatch=function(t){this.deleteMatch.push(t)},t.prototype.getDeleteMatch=function(){return this.deleteMatch},t}();exports.MessageBeforeTransform=MessageBeforeTransform,function(t){t[t.INSERT_EVENT_TO_UPDATE=0]="INSERT_EVENT_TO_UPDATE",t[t.DELETE_EVENT_TO_UPDATE=1]="DELETE_EVENT_TO_UPDATE",t[t.INSERT_MATCH_SUPPRESS=2]="INSERT_MATCH_SUPPRESS",t[t.DELETE_MATCH_SUPPRESS=3]="DELETE_MATCH_SUPPRESS",t[t.ORIGINAL=4]="ORIGINAL"}(ConvertedMsg=exports.ConvertedMsg||(exports.ConvertedMsg={}));var MergeableWrapper=function(){function t(){this.snap=IndexedSnapshotImpl.EMPTY_SNAPSHOT}return t.prototype.setDeltaOut=function(t){this.deltaOut=t},t.prototype.setAfter=function(t){this.snap=t},t.prototype.getDeltaOut=function(){return this.deltaOut},t.prototype.getAfter=function(){return this.snap},t}();exports.MergeableWrapper=MergeableWrapper;var TTLWrapper=function(){function t(){}return t.prototype._RemovedKey=function(){this.removedSs=IndexedSnapshotImpl.EMPTY_SNAPSHOT,this.remainingSs=IndexedSnapshotImpl.EMPTY_SNAPSHOT,this.restoredSs=IndexedSnapshotImpl.EMPTY_SNAPSHOT},t.prototype.setRemovedSs=function(t){this.removedSs=t},t.prototype.getRemovedSs=function(){return this.removedSs},t.prototype.setRemainingSs=function(t){this.remainingSs=t},t.prototype.getRemainingSs=function(){return this.remainingSs},t.prototype.getRestoredSs=function(){return this.restoredSs},t.prototype.setRestoredSs=function(t){this.restoredSs=t},t}();exports.TTLWrapper=TTLWrapper;
1
+ "use strict";var __extends=this&&this.__extends||function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),__createBinding=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),__importStar=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&__createBinding(e,t,r);return __setModuleDefault(e,t),e},__values=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(exports,"__esModule",{value:!0}),exports.TTLWrapper=exports.MergeableWrapper=exports.ConvertedMsg=exports.MessageBeforeTransform=exports.DeltaOutgoingImpl=exports.OutgoingImpl=exports.IndexedSnapshotImpl=exports.Incoming=void 0;var Collections=__importStar(require("typescript-collections")),jayeson_lib_record_1=require("@jayesol/jayeson.lib.record"),Incoming=function(){function t(t,e,r){this._msgType=t,this._stream=e,this._data=r}return t.prototype.msgType=function(){return this._msgType},t.prototype.stream=function(){return this._stream},t.prototype.data=function(){return this._data},t}();exports.Incoming=Incoming;var IndexedSnapshotImpl=function(t){function e(e,r){void 0===e&&(e={}),void 0===r&&(r=new Collections.Dictionary);var n=t.call(this,e)||this;return n.partitions=r,n}return __extends(e,t),e.prototype.getPartitions=function(){var t,e,r=new Collections.Set;try{for(var n=__values(this.partitions.keys()),o=n.next();!o.done;o=n.next()){var s=o.value;r.add(s)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}return r},e.prototype.getPartitionMap=function(){return this.partitions},e.EMPTY_SNAPSHOT=new e,e}(jayeson_lib_record_1.Snapshot);exports.IndexedSnapshotImpl=IndexedSnapshotImpl;var OutgoingImpl=function(){function t(t,e){this._msgType=t,this._msg=e}return t.prototype.msgType=function(){return this._msgType},t.prototype.msg=function(){return this._msg},t}();exports.OutgoingImpl=OutgoingImpl;var DeltaOutgoingImpl=function(t){function e(e,r,n,o){var s=t.call(this,e,r)||this;return s._delta=r,s._after=n,s._before=o,s}return __extends(e,t),e.prototype.after=function(){return this._after},e.prototype.delta=function(){return this._delta},e.prototype.before=function(){return this._before},e}(OutgoingImpl);exports.DeltaOutgoingImpl=DeltaOutgoingImpl;var ConvertedMsg,MessageBeforeTransform=function(){function t(){this.transformEvent=[],this.suppressMatch=[],this.insertMatch=[],this.deleteMatch=[],this.insertEvent=[],this.deleteEvent=[],this.afterSs=IndexedSnapshotImpl.EMPTY_SNAPSHOT,this.beforeSs=IndexedSnapshotImpl.EMPTY_SNAPSHOT}return t.prototype.getTransformEvent=function(){return this.transformEvent},t.prototype.setTransformEvent=function(t){this.transformEvent.push(t)},t.prototype.getSuppressMatch=function(){return this.suppressMatch},t.prototype.setSuppressMatch=function(t){this.suppressMatch.push(t)},t.prototype.setAfterSs=function(t){this.afterSs=t},t.prototype.getAfterSs=function(){return this.afterSs},t.prototype.setBeforeSs=function(t){this.beforeSs=t},t.prototype.getBeforeSs=function(){return this.beforeSs},t.prototype.setInsertEvent=function(t){this.insertEvent.push(t)},t.prototype.getInsertEvent=function(){return this.insertEvent},t.prototype.setDeleteEvent=function(t){this.deleteEvent.push(t)},t.prototype.getDeleteEvent=function(){return this.deleteEvent},t.prototype.setInsertMatch=function(t){this.insertMatch.push(t)},t.prototype.getInsertMatch=function(){return this.insertMatch},t.prototype.setDeleteMatch=function(t){this.deleteMatch.push(t)},t.prototype.getDeleteMatch=function(){return this.deleteMatch},t}();exports.MessageBeforeTransform=MessageBeforeTransform,function(t){t[t.INSERT_EVENT_TO_UPDATE=0]="INSERT_EVENT_TO_UPDATE",t[t.DELETE_EVENT_TO_UPDATE=1]="DELETE_EVENT_TO_UPDATE",t[t.INSERT_MATCH_SUPPRESS=2]="INSERT_MATCH_SUPPRESS",t[t.DELETE_MATCH_SUPPRESS=3]="DELETE_MATCH_SUPPRESS",t[t.ORIGINAL=4]="ORIGINAL"}(ConvertedMsg=exports.ConvertedMsg||(exports.ConvertedMsg={}));var MergeableWrapper=function(){function t(){this.snap=IndexedSnapshotImpl.EMPTY_SNAPSHOT}return t.prototype.setDeltaOut=function(t){this.deltaOut=t},t.prototype.setAfter=function(t){this.snap=t},t.prototype.getDeltaOut=function(){return this.deltaOut},t.prototype.getAfter=function(){return this.snap},t}();exports.MergeableWrapper=MergeableWrapper;var TTLWrapper=function(){function t(){}return t.prototype._RemovedKey=function(){this.removedSs=IndexedSnapshotImpl.EMPTY_SNAPSHOT,this.remainingSs=IndexedSnapshotImpl.EMPTY_SNAPSHOT,this.restoredSs=IndexedSnapshotImpl.EMPTY_SNAPSHOT},t.prototype.setRemovedSs=function(t){this.removedSs=t},t.prototype.getRemovedSs=function(){return this.removedSs},t.prototype.setRemainingSs=function(t){this.remainingSs=t},t.prototype.getRemainingSs=function(){return this.remainingSs},t.prototype.getRestoredSs=function(){return this.restoredSs},t.prototype.setRestoredSs=function(t){this.restoredSs=t},t}();exports.TTLWrapper=TTLWrapper;
package/lib/dispatch.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RelayEPG=exports.AbstractEPG=exports.DispatchersGroup=exports.EndPointGroupManager=exports.EPDispatcherException=exports.IndicatorWrapper=exports.PartialSnapshotWrapper=exports.FullSnapshotWrapper=exports.WrapperImpl=exports.EPGM_IMPL=void 0;var tslib_1=require("tslib"),data_structure_1=require("./data_structure"),core_1=require("./core"),message_class_1=require("./message_class"),injection_js_1=require("injection-js");exports.EPGM_IMPL=new injection_js_1.InjectionToken("EpgmInstance");var WrapperImpl=function(){function t(t,e){this.__epg=t,this.__stream=e}return t.prototype.epg=function(){return this.__epg},t.prototype.stream=function(){return this.__stream},t}();exports.WrapperImpl=WrapperImpl;var FullSnapshotWrapper=function(t){function e(e,r,s,o){var p=t.call(this,e,r)||this;return p._epg=e,p._stream=r,p._epd=s,p.fullSnapshot=o,p}return tslib_1.__extends(e,t),e.prototype.epg=function(){return this._epg},e.prototype.stream=function(){return this._stream},e.prototype.epd=function(){return this._epd},e.prototype.process=function(){this._epd.readyToDispatch();var t=this._epg.generateFull(this);if(null!=t)for(var e=0;e<t.length;e++){var r=t[e];this._epd.submit(r)}},e.prototype.getFullSnapshot=function(){return this.fullSnapshot},e.prototype.setFullSnapshot=function(t){this.fullSnapshot=t},e}(WrapperImpl);exports.FullSnapshotWrapper=FullSnapshotWrapper;var PartialSnapshotWrapper=function(t){function e(e,r,s){var o=t.call(this,r,s)||this;return o._delta=e,o._epg=r,o._stream=s,o}return tslib_1.__extends(e,t),e.prototype.epg=function(){return this._epg},e.prototype.stream=function(){return this._stream},e.prototype.delta=function(){return this._delta},e.prototype.process=function(){for(var t=this._epg.generatePartial(this),e=this._epg.getEPDs(this._stream),r=0;r<e.length;r++)for(var s=e[r],o=0;o<t.length;o++)if(s.isReadyToDispatch()){var p=t[o];s.submit(p)}},e}(WrapperImpl);exports.PartialSnapshotWrapper=PartialSnapshotWrapper;var IndicatorWrapper=function(t){function e(e,r,s){var o=t.call(this,r,s)||this;return o._delta=e,o._epg=r,o._stream=s,o}return tslib_1.__extends(e,t),e.prototype.process=function(){for(var t=this._epg.getEPDs(this._stream),e=0;e<t.length;e++){t[e].submit(this._delta)}},e}(WrapperImpl);exports.IndicatorWrapper=IndicatorWrapper;var EPDispatcherException=function(t){function e(e){return t.call(this,e)||this}return tslib_1.__extends(e,t),e}(Error);exports.EPDispatcherException=EPDispatcherException;var EndPointGroupManager=function(){function t(t,e){this._fsRepo=t,this._grp=e,this.relayEPG=new RelayEPG(e),this.relayEPG.startGetingDeltaSnapshot(t)}return t.prototype.fsRepo=function(){return this._fsRepo},t.prototype.grp=function(){return this._grp},t.prototype.pushFullSnapshotWrapper=function(t,e){var r=this,s=e.stream();e.isInitialized().then(function(o){if(o){var p=r._fsRepo.getSnapshot(s),n=new FullSnapshotWrapper(t,s,e,p);t.submitForProcess(n)}})},t.prototype.registerEPD=function(t){if(this.relayEPG.hasEPD(t.stream(),t.id()))throw new EPDispatcherException("EPD already exists in a group.Id: "+t.id+" Stream: "+t.stream);this.relayEPG.addEPD(t),this.pushFullSnapshotWrapper(this.relayEPG,t)},t.prototype.deregisterEPD=function(t){this.relayEPG.removeEPD(t)},t=tslib_1.__decorate([(0,injection_js_1.Injectable)(),tslib_1.__param(0,(0,injection_js_1.Inject)(core_1.FSREPO_IMPL)),tslib_1.__metadata("design:paramtypes",[Object,message_class_1.SportsFeedMessageGroup])],t)}();exports.EndPointGroupManager=EndPointGroupManager;var DispatchersGroup=function(){function t(t){this.streamName=t,this.dispatchers={}}return t.prototype.addEpd=function(t){this.dispatchers[t.id()]=t},t.prototype.removeEpd=function(t){var e=this.dispatchers[t.id()];return delete this.dispatchers[t.id()],e},t.prototype.get=function(t){return this.dispatchers[t]},t.prototype.getAll=function(){var t=this;return Object.keys(this.dispatchers).map(function(e){return t.dispatchers[e]})},t.prototype.isEmpty=function(){return 0==Object.keys(this.dispatchers).length},t}();exports.DispatchersGroup=DispatchersGroup;var AbstractEPG=function(){function t(t){this.sportsFeedGroup=t,this.dispatchers={}}return t.prototype.hasEPD=function(t,e){var r=this.dispatchers[t];return void 0!==r&&void 0!==r.get(e)},t.prototype.addEPD=function(t){void 0===this.dispatchers[t.stream()]&&(this.dispatchers[t.stream()]=new DispatchersGroup(t.stream())),this.dispatchers[t.stream()].addEpd(t)},t.prototype.removeEPD=function(t){var e=this.dispatchers[t.stream()];void 0!==e&&(e.removeEpd(t),e.isEmpty()&&delete this.dispatchers[t.stream()])},t.prototype.isEmpty=function(){return 0==Object.keys(this.dispatchers).length},t.prototype.getEPDs=function(t){var e=this.dispatchers[t];return void 0!==e?e.getAll():[]},t.prototype.getStreams=function(){return Object.keys(this.dispatchers)},t.prototype.startGetingDeltaSnapshot=function(t){t.registerSnapshotHandler(this)},t.prototype.stopGetingDeltaSnapshot=function(t){t.deRegisterSnapshotHandler(this)},t.prototype.process=function(t,e){if(this.sportsFeedGroup.isIndicatorMessage(e.msgType())){var r=new IndicatorWrapper(e,this,t);this.submitForProcess(r)}else{var s=new PartialSnapshotWrapper(e,this,t);this.submitForProcess(s)}},t.prototype.getSportsFeedGrp=function(){return this.sportsFeedGroup},t.prototype.generateFull=function(t){throw new Error("Method not implemented.")},t.prototype.generatePartial=function(t){throw new Error("Method not implemented.")},t}();exports.AbstractEPG=AbstractEPG;var RelayEPG=function(t){function e(e){var r=t.call(this,e)||this;return r._sportsFeedGroup=e,r}return tslib_1.__extends(e,t),e.prototype.submitForProcess=function(t){t.process()},e.prototype.onException=function(t){return console.error("Exception when dispatching snapshots to EPDs from RelayEPG. ",t),null},e.prototype.generateFull=function(t){var e=t.getFullSnapshot();return[new data_structure_1.OutgoingImpl(this._sportsFeedGroup.FULLSNAPSHOT_START(),new Object),new data_structure_1.DeltaOutgoingImpl(this._sportsFeedGroup.DATA_RESET(),e,e,data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT),new data_structure_1.DeltaOutgoingImpl(this._sportsFeedGroup.DATA_INSERT_MATCH(),e,e,data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT),new data_structure_1.DeltaOutgoingImpl(this._sportsFeedGroup.DATA_INSERT_EVENT(),e,e,data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT),new data_structure_1.DeltaOutgoingImpl(this._sportsFeedGroup.DATA_INSERT_ODD(),e,e,data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT),new data_structure_1.OutgoingImpl(this._sportsFeedGroup.FULLSNAPSHOT_END(),new Object)]},e.prototype.generatePartial=function(t){var e=t.delta();return"TTLOutgoing"==e.constructor.name?this.generateTtl(e):[e]},e.prototype.generateTtl=function(t){return this.isSameFormat(t.msgType(),this._sportsFeedGroup.ADMIN_REFRESH())?[]:t.getTtlType()==core_1.TTLType.REMOVE?[t]:this.generateTtlRestore(t)},e.prototype.generateTtlRestore=function(t){return[new data_structure_1.DeltaOutgoingImpl(this._sportsFeedGroup.DATA_INSERT_MATCH(),t.delta(),t.delta(),data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT),new data_structure_1.DeltaOutgoingImpl(this._sportsFeedGroup.DATA_INSERT_EVENT(),t.delta(),t.delta(),data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT),new data_structure_1.DeltaOutgoingImpl(this._sportsFeedGroup.DATA_INSERT_ODD(),t.delta(),t.delta(),data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT)]},e.prototype.isSameFormat=function(t,e){return t.instanceClass()==e.instanceClass()&&t.constructor.name==e.constructor.name},e=tslib_1.__decorate([(0,injection_js_1.Injectable)(),tslib_1.__metadata("design:paramtypes",[message_class_1.SportsFeedMessageGroup])],e)}(AbstractEPG);exports.RelayEPG=RelayEPG;
1
+ "use strict";var __extends=this&&this.__extends||function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function s(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(s.prototype=r.prototype,new s)}}(),__decorate=this&&this.__decorate||function(t,e,r,s){var o,n=arguments.length,p=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)p=Reflect.decorate(t,e,r,s);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(p=(n<3?o(p):n>3?o(e,r,p):o(e,r))||p);return n>3&&p&&Object.defineProperty(e,r,p),p},__metadata=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},__param=this&&this.__param||function(t,e){return function(r,s){e(r,s,t)}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.RelayEPG=exports.AbstractEPG=exports.DispatchersGroup=exports.EndPointGroupManager=exports.EPDispatcherException=exports.IndicatorWrapper=exports.PartialSnapshotWrapper=exports.FullSnapshotWrapper=exports.WrapperImpl=exports.EPGM_IMPL=void 0;var data_structure_1=require("./data_structure"),core_1=require("./core"),message_class_1=require("./message_class"),injection_js_1=require("injection-js");exports.EPGM_IMPL=new injection_js_1.InjectionToken("EpgmInstance");var WrapperImpl=function(){function t(t,e){this.__epg=t,this.__stream=e}return t.prototype.epg=function(){return this.__epg},t.prototype.stream=function(){return this.__stream},t}();exports.WrapperImpl=WrapperImpl;var FullSnapshotWrapper=function(t){function e(e,r,s,o){var n=t.call(this,e,r)||this;return n._epg=e,n._stream=r,n._epd=s,n.fullSnapshot=o,n}return __extends(e,t),e.prototype.epg=function(){return this._epg},e.prototype.stream=function(){return this._stream},e.prototype.epd=function(){return this._epd},e.prototype.process=function(){this._epd.readyToDispatch();var t=this._epg.generateFull(this);if(null!=t)for(var e=0;e<t.length;e++){var r=t[e];this._epd.submit(r)}},e.prototype.getFullSnapshot=function(){return this.fullSnapshot},e.prototype.setFullSnapshot=function(t){this.fullSnapshot=t},e}(WrapperImpl);exports.FullSnapshotWrapper=FullSnapshotWrapper;var PartialSnapshotWrapper=function(t){function e(e,r,s){var o=t.call(this,r,s)||this;return o._delta=e,o._epg=r,o._stream=s,o}return __extends(e,t),e.prototype.epg=function(){return this._epg},e.prototype.stream=function(){return this._stream},e.prototype.delta=function(){return this._delta},e.prototype.process=function(){for(var t=this._epg.generatePartial(this),e=this._epg.getEPDs(this._stream),r=0;r<e.length;r++)for(var s=e[r],o=0;o<t.length;o++)if(s.isReadyToDispatch()){var n=t[o];s.submit(n)}},e}(WrapperImpl);exports.PartialSnapshotWrapper=PartialSnapshotWrapper;var IndicatorWrapper=function(t){function e(e,r,s){var o=t.call(this,r,s)||this;return o._delta=e,o._epg=r,o._stream=s,o}return __extends(e,t),e.prototype.process=function(){for(var t=this._epg.getEPDs(this._stream),e=0;e<t.length;e++){t[e].submit(this._delta)}},e}(WrapperImpl);exports.IndicatorWrapper=IndicatorWrapper;var EPDispatcherException=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e}(Error);exports.EPDispatcherException=EPDispatcherException;var EndPointGroupManager=function(){function t(t,e){this._fsRepo=t,this._grp=e,this.relayEPG=new RelayEPG(e),this.relayEPG.startGetingDeltaSnapshot(t)}return t.prototype.fsRepo=function(){return this._fsRepo},t.prototype.grp=function(){return this._grp},t.prototype.pushFullSnapshotWrapper=function(t,e){var r=this,s=e.stream();e.isInitialized().then(function(o){if(o){var n=r._fsRepo.getSnapshot(s),p=new FullSnapshotWrapper(t,s,e,n);t.submitForProcess(p)}})},t.prototype.registerEPD=function(t){if(this.relayEPG.hasEPD(t.stream(),t.id()))throw new EPDispatcherException("EPD already exists in a group.Id: "+t.id+" Stream: "+t.stream);this.relayEPG.addEPD(t),this.pushFullSnapshotWrapper(this.relayEPG,t)},t.prototype.deregisterEPD=function(t){this.relayEPG.removeEPD(t)},t=__decorate([(0,injection_js_1.Injectable)(),__param(0,(0,injection_js_1.Inject)(core_1.FSREPO_IMPL)),__metadata("design:paramtypes",[Object,message_class_1.SportsFeedMessageGroup])],t)}();exports.EndPointGroupManager=EndPointGroupManager;var DispatchersGroup=function(){function t(t){this.streamName=t,this.dispatchers={}}return t.prototype.addEpd=function(t){this.dispatchers[t.id()]=t},t.prototype.removeEpd=function(t){var e=this.dispatchers[t.id()];return delete this.dispatchers[t.id()],e},t.prototype.get=function(t){return this.dispatchers[t]},t.prototype.getAll=function(){var t=this;return Object.keys(this.dispatchers).map(function(e){return t.dispatchers[e]})},t.prototype.isEmpty=function(){return 0==Object.keys(this.dispatchers).length},t}();exports.DispatchersGroup=DispatchersGroup;var AbstractEPG=function(){function t(t){this.sportsFeedGroup=t,this.dispatchers={}}return t.prototype.hasEPD=function(t,e){var r=this.dispatchers[t];return void 0!==r&&void 0!==r.get(e)},t.prototype.addEPD=function(t){void 0===this.dispatchers[t.stream()]&&(this.dispatchers[t.stream()]=new DispatchersGroup(t.stream())),this.dispatchers[t.stream()].addEpd(t)},t.prototype.removeEPD=function(t){var e=this.dispatchers[t.stream()];void 0!==e&&(e.removeEpd(t),e.isEmpty()&&delete this.dispatchers[t.stream()])},t.prototype.isEmpty=function(){return 0==Object.keys(this.dispatchers).length},t.prototype.getEPDs=function(t){var e=this.dispatchers[t];return void 0!==e?e.getAll():[]},t.prototype.getStreams=function(){return Object.keys(this.dispatchers)},t.prototype.startGetingDeltaSnapshot=function(t){t.registerSnapshotHandler(this)},t.prototype.stopGetingDeltaSnapshot=function(t){t.deRegisterSnapshotHandler(this)},t.prototype.process=function(t,e){if(this.sportsFeedGroup.isIndicatorMessage(e.msgType())){var r=new IndicatorWrapper(e,this,t);this.submitForProcess(r)}else{var s=new PartialSnapshotWrapper(e,this,t);this.submitForProcess(s)}},t.prototype.getSportsFeedGrp=function(){return this.sportsFeedGroup},t.prototype.generateFull=function(t){throw new Error("Method not implemented.")},t.prototype.generatePartial=function(t){throw new Error("Method not implemented.")},t}();exports.AbstractEPG=AbstractEPG;var RelayEPG=function(t){function e(e){var r=t.call(this,e)||this;return r._sportsFeedGroup=e,r}return __extends(e,t),e.prototype.submitForProcess=function(t){t.process()},e.prototype.onException=function(t){return console.error("Exception when dispatching snapshots to EPDs from RelayEPG. ",t),null},e.prototype.generateFull=function(t){var e=t.getFullSnapshot();return[new data_structure_1.OutgoingImpl(this._sportsFeedGroup.FULLSNAPSHOT_START(),new Object),new data_structure_1.DeltaOutgoingImpl(this._sportsFeedGroup.DATA_RESET(),e,e,data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT),new data_structure_1.DeltaOutgoingImpl(this._sportsFeedGroup.DATA_INSERT_MATCH(),e,e,data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT),new data_structure_1.DeltaOutgoingImpl(this._sportsFeedGroup.DATA_INSERT_EVENT(),e,e,data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT),new data_structure_1.DeltaOutgoingImpl(this._sportsFeedGroup.DATA_INSERT_ODD(),e,e,data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT),new data_structure_1.OutgoingImpl(this._sportsFeedGroup.FULLSNAPSHOT_END(),new Object)]},e.prototype.generatePartial=function(t){var e=t.delta();return"TTLOutgoing"==e.constructor.name?this.generateTtl(e):[e]},e.prototype.generateTtl=function(t){return this.isSameFormat(t.msgType(),this._sportsFeedGroup.ADMIN_REFRESH())?[]:t.getTtlType()==core_1.TTLType.REMOVE?[t]:this.generateTtlRestore(t)},e.prototype.generateTtlRestore=function(t){return[new data_structure_1.DeltaOutgoingImpl(this._sportsFeedGroup.DATA_INSERT_MATCH(),t.delta(),t.delta(),data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT),new data_structure_1.DeltaOutgoingImpl(this._sportsFeedGroup.DATA_INSERT_EVENT(),t.delta(),t.delta(),data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT),new data_structure_1.DeltaOutgoingImpl(this._sportsFeedGroup.DATA_INSERT_ODD(),t.delta(),t.delta(),data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT)]},e.prototype.isSameFormat=function(t,e){return t.instanceClass()==e.instanceClass()&&t.constructor.name==e.constructor.name},e=__decorate([(0,injection_js_1.Injectable)(),__metadata("design:paramtypes",[message_class_1.SportsFeedMessageGroup])],e)}(AbstractEPG);exports.RelayEPG=RelayEPG;
package/lib/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tslib_1=require("tslib");tslib_1.__exportStar(require("./basketball_codec"),exports),tslib_1.__exportStar(require("./client"),exports),tslib_1.__exportStar(require("./codec"),exports),tslib_1.__exportStar(require("./core"),exports),tslib_1.__exportStar(require("./data_structure"),exports),tslib_1.__exportStar(require("./dispatch"),exports),tslib_1.__exportStar(require("./message_class"),exports),tslib_1.__exportStar(require("./module"),exports),tslib_1.__exportStar(require("./receive"),exports),tslib_1.__exportStar(require("./soccer_codec"),exports),tslib_1.__exportStar(require("./tennis_codec"),exports);
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,o){void 0===o&&(o=t);var _=Object.getOwnPropertyDescriptor(r,t);_&&!("get"in _?!r.__esModule:_.writable||_.configurable)||(_={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,o,_)}:function(e,r,t,o){void 0===o&&(o=t),e[o]=r[t]}),__exportStar=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||__createBinding(r,e,t)};Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(require("./basketball_codec"),exports),__exportStar(require("./client"),exports),__exportStar(require("./codec"),exports),__exportStar(require("./core"),exports),__exportStar(require("./data_structure"),exports),__exportStar(require("./dispatch"),exports),__exportStar(require("./message_class"),exports),__exportStar(require("./module"),exports),__exportStar(require("./receive"),exports),__exportStar(require("./soccer_codec"),exports),__exportStar(require("./tennis_codec"),exports);
package/lib/merge.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DeltaTransformingLogicImpl=exports.SnapshotUtil=exports.MsgType=void 0;var MsgType,tslib_1=require("tslib"),data_structure_1=require("./data_structure"),message_class_1=require("./message_class"),mutable_1=require("./mutable"),core_1=require("./core"),data_structure_2=require("./data_structure");!function(e){e[e.INSERT=0]="INSERT",e[e.UPDATE=1]="UPDATE",e[e.DELETE=2]="DELETE"}(MsgType=exports.MsgType||(exports.MsgType={}));var SnapshotUtil=function(){function e(){}return e.combineSnapshots=function(r,t,a){if(r.group().id()!=e.SPORTS_GROUP.id())return console.error("FATAL: Received non feed message group's class %s.Shouldnt come here",r),(l=new data_structure_1.MessageBeforeTransform).setAfterSs(a),l;switch(r.id()){case e.SPORTS_GROUP.DATA_INSERT_MATCH().id():return e.processMatches(MsgType.INSERT,t,a);case e.SPORTS_GROUP.DATA_UPDATE_MATCH().id():return e.processMatches(MsgType.UPDATE,t,a);case e.SPORTS_GROUP.DATA_DELETE_MATCH().id():return e.processMatches(MsgType.DELETE,t,a);case e.SPORTS_GROUP.DATA_INSERT_EVENT().id():return e.processEvents(MsgType.INSERT,t,a);case e.SPORTS_GROUP.DATA_UPDATE_EVENT().id():return e.processEvents(MsgType.UPDATE,t,a);case e.SPORTS_GROUP.DATA_DELETE_EVENT().id():return e.processEvents(MsgType.DELETE,t,a);case e.SPORTS_GROUP.DATA_INSERT_ODD().id():return e.processOdds(MsgType.INSERT,t,a);case e.SPORTS_GROUP.DATA_UPDATE_ODD().id():return e.processOdds(MsgType.UPDATE,t,a);case e.SPORTS_GROUP.DATA_DELETE_ODD().id():return e.processOdds(MsgType.DELETE,t,a);case e.SPORTS_GROUP.DATA_RESET().id():return e.processReset(t,a);case e.SPORTS_GROUP.ADMIN_REFRESH().id():return e.processRefresh(t,a);default:var l;return console.error("FATAL: Received non data message class %s.Shouldnt come here",r),(l=new data_structure_1.MessageBeforeTransform).setAfterSs(a),l}},e.processRefresh=function(e,r){var t,a,l=mutable_1.BuilderProvider.getSnapshotBuilder(r),n=new data_structure_1.MessageBeforeTransform,i=e.getPartitions().toArray();try{for(var s=tslib_1.__values(i),o=s.next();!o.done;o=s.next()){var u=o.value,d=e.getPartitionMap().getValue(u);l.markPartitionAsUpdated(u,d)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(a=s.return)&&a.call(s)}finally{if(t)throw t.error}}return n.setAfterSs(l.build()),n},e.processReset=function(e,r){var t,a,l=mutable_1.BuilderProvider.getSnapshotBuilder(r),n=new data_structure_1.MessageBeforeTransform,i=e.getPartitions().toArray();try{for(var s=tslib_1.__values(i),o=s.next();!o.done;o=s.next()){var u=o.value;l.reset(u);var d=e.getPartitionMap().getValue(u);l.markPartitionAsUpdated(u,d)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(a=s.return)&&a.call(s)}finally{if(t)throw t.error}}return n.setAfterSs(l.build()),n},e.processMatches=function(e,r,t){var a,l,n,i,s=mutable_1.BuilderProvider.getSnapshotBuilder(t),o=new data_structure_1.MessageBeforeTransform,u=null;try{for(var d=tslib_1.__values(r.matches()),c=d.next();!c.done;c=d.next()){var _=c.value;switch(u=null,e){case MsgType.INSERT:null!=(u=s.insertChild(_))?o.setSuppressMatch(u):o.setInsertMatch(_.id());break;case MsgType.UPDATE:s.updateChild(_);break;case MsgType.DELETE:null!=(u=s.deleteChild(_))?o.setSuppressMatch(u):o.setDeleteMatch(_.id());break;default:console.error("[Match] FATAL: Shouldn't come here")}}}catch(e){a={error:e}}finally{try{c&&!c.done&&(l=d.return)&&l.call(d)}finally{if(a)throw a.error}}var v=r.getPartitions().toArray();try{for(var h=tslib_1.__values(v),f=h.next();!f.done;f=h.next()){var T=f.value,p=r.getPartitionMap().getValue(T);s.markPartitionAsUpdated(T,p)}}catch(e){n={error:e}}finally{try{f&&!f.done&&(i=h.return)&&i.call(h)}finally{if(n)throw n.error}}return o.setAfterSs(s.build()),o},e.processEvents=function(e,r,t){var a,l,n,i,s,o,u=mutable_1.BuilderProvider.getSnapshotBuilder(t),d=new data_structure_1.MessageBeforeTransform;try{for(var c=tslib_1.__values(r.matches()),_=c.next();!_.done;_=c.next()){var v=_.value,h=t.match(v.id());if(null!=h){var f=mutable_1.BuilderProvider.getMatchBuilder(h);try{for(var T=(n=void 0,tslib_1.__values(v.events())),p=T.next();!p.done;p=T.next()){var g=p.value;switch(e){case MsgType.INSERT:null!=f.insertChild(g)?d.setTransformEvent(g.matchId()+"_"+g.id()):d.setInsertEvent(g.matchId()+"_"+g.id());break;case MsgType.UPDATE:f.updateChild(g);break;case MsgType.DELETE:null!=f.deleteChild(g)?d.setTransformEvent(g.matchId()+"_"+g.id()):d.setDeleteEvent(g.matchId()+"_"+g.id());break;default:console.error("[Event] FATAL: Shouldn't come here")}}}catch(e){n={error:e}}finally{try{p&&!p.done&&(i=T.return)&&i.call(T)}finally{if(n)throw n.error}}u.replaceMatch(f.build())}else console.error("Cannot find Match %s while processing %s",v.id(),MsgType)}}catch(e){a={error:e}}finally{try{_&&!_.done&&(l=c.return)&&l.call(c)}finally{if(a)throw a.error}}var E=r.getPartitions().toArray();try{for(var y=tslib_1.__values(E),m=y.next();!m.done;m=y.next()){var A=m.value,S=r.getPartitionMap().getValue(A);u.markPartitionAsUpdated(A,S)}}catch(e){s={error:e}}finally{try{m&&!m.done&&(o=y.return)&&o.call(y)}finally{if(s)throw s.error}}return d.setAfterSs(u.build()),d.setBeforeSs(t),d},e.processOdds=function(e,r,t){var a,l,n,i,s,o,u,d,c=mutable_1.BuilderProvider.getSnapshotBuilder(t),_=new data_structure_1.MessageBeforeTransform;try{for(var v=tslib_1.__values(r.matches()),h=v.next();!h.done;h=v.next()){var f=h.value,T=t.match(f.id());if(null!=T){var p=mutable_1.BuilderProvider.getMatchBuilder(T);try{for(var g=(n=void 0,tslib_1.__values(f.events())),E=g.next();!E.done;E=g.next()){var y=E.value,m=T.event(y.id());if(null!=m){var A=mutable_1.BuilderProvider.getEventBuilder(m);try{for(var S=(s=void 0,tslib_1.__values(y.records())),b=S.next();!b.done;b=S.next()){var M=b.value;switch(e){case MsgType.INSERT:A.insertChild(M);break;case MsgType.UPDATE:A.updateChild(M);break;case MsgType.DELETE:A.deleteChild(M);break;default:console.error("[Record] FATAL: Shouldn't come here")}}}catch(e){s={error:e}}finally{try{b&&!b.done&&(o=S.return)&&o.call(S)}finally{if(s)throw s.error}}p.replaceEvent(A.build())}else console.error("Cannot find Event %s_%s while processing %s",f.id(),y.id(),e)}}catch(e){n={error:e}}finally{try{E&&!E.done&&(i=g.return)&&i.call(g)}finally{if(n)throw n.error}}c.replaceMatch(p.build())}else console.error("Cannot find Match %s while processing %s",f.id(),e)}}catch(e){a={error:e}}finally{try{h&&!h.done&&(l=v.return)&&l.call(v)}finally{if(a)throw a.error}}var P=r.getPartitions().toArray();try{for(var D=tslib_1.__values(P),B=D.next();!B.done;B=D.next()){var x=B.value,w=r.getPartitionMap().getValue(x);c.markPartitionAsUpdated(x,w)}}catch(e){u={error:e}}finally{try{B&&!B.done&&(d=D.return)&&d.call(D)}finally{if(u)throw u.error}}return _.setAfterSs(c.build()),_},e.SPORTS_GROUP=new message_class_1.SportsFeedMessageGroup,e}();exports.SnapshotUtil=SnapshotUtil;var DeltaTransformingLogicImpl=function(){function e(){}return e.transform=function(e,r,t,a,l){switch(t.id()){case e.DATA_INSERT_MATCH().id():return this.suppressInsertMatch(l,e,t,r,a,[]);case e.DATA_DELETE_MATCH().id():return this.suppressDeleteMatch(l,e,t,r,a,[]);case e.DATA_INSERT_EVENT().id():return this.suppressInsertEvent(l,e,t,r,a,[]);case e.DATA_DELETE_EVENT().id():return this.suppressDeleteEvent(l,e,t,r,a,[]);case e.DATA_UPDATE_EVENT().id():return this.combineEventState(l,e,t,r,a,[])}var n=[];return n.push(new data_structure_1.Incoming(t,r,a)),n},e.combineEventState=function(e,r,t,a,l,n){var i,s,o,u,d=mutable_1.BuilderProvider.getSnapshotBuilder(l);try{for(var c=tslib_1.__values(l.matches()),_=c.next();!_.done;_=c.next()){var v=_.value,h=mutable_1.BuilderProvider.getMatchBuilder(v);try{for(var f=(o=void 0,tslib_1.__values(v.events())),T=f.next();!T.done;T=f.next()){var p=T.value,g=mutable_1.BuilderProvider.getEventBuilder(p);g.aggregateInsert(e.getAfterSs().match(v.id()).event(p.id())),h.replaceEvent(g.build())}}catch(e){o={error:e}}finally{try{T&&!T.done&&(u=f.return)&&u.call(f)}finally{if(o)throw o.error}}d.replaceMatch(h.build())}}catch(e){i={error:e}}finally{try{_&&!_.done&&(s=c.return)&&s.call(c)}finally{if(i)throw i.error}}return n.push(new data_structure_1.Incoming(r.DATA_UPDATE_EVENT(),a,d.build())),n},e.suppressInsertEvent=function(e,r,t,a,l,n){var i,s,o,u,d,c,_=mutable_1.BuilderProvider.getSnapshotBuilder(l),v=mutable_1.BuilderProvider.getSnapshotBuilder(l);if(0!=l.matches().length){if(0!=e.getInsertEvent().length){var h={};try{for(var f=tslib_1.__values(e.getTransformEvent()),T=f.next();!T.done;T=f.next()){var p=(D=T.value).split("_")[0],g=D.split("_")[1],E=l.match(p),y=h[p];void 0===y&&(y=mutable_1.BuilderProvider.getMatchBuilder(E),h[p]=y),y.deleteChild(E.event(g))}}catch(e){i={error:e}}finally{try{T&&!T.done&&(s=f.return)&&s.call(f)}finally{if(i)throw i.error}}for(var p in h)_.replaceMatch(h[p].build());n.push(new data_structure_1.Incoming(r.DATA_INSERT_EVENT(),a,_.build()))}if(0!=e.getTransformEvent().length){var m={};try{for(var A=tslib_1.__values(e.getInsertEvent()),S=A.next();!S.done;S=A.next()){p=(D=S.value).split("_")[0],g=D.split("_")[1],E=l.match(p);var b=m[p];void 0===b&&(b=mutable_1.BuilderProvider.getMatchBuilder(E),m[p]=b),b.deleteChild(E.event(g))}}catch(e){o={error:e}}finally{try{S&&!S.done&&(u=A.return)&&u.call(A)}finally{if(o)throw o.error}}try{for(var M=tslib_1.__values(e.getTransformEvent()),P=M.next();!P.done;P=M.next()){p=(D=P.value).split("_")[0],g=D.split("_")[1],E=l.match(p);var D,B=m[p];void 0===B&&(B=mutable_1.BuilderProvider.getMatchBuilder(E),m[p]=B);var x=mutable_1.BuilderProvider.getEventBuilder(E.event(g));x.aggregateInsert(e.getAfterSs().match(p).event(g)),B.replaceEvent(x.build())}}catch(e){d={error:e}}finally{try{P&&!P.done&&(c=M.return)&&c.call(M)}finally{if(d)throw d.error}}for(var p in m)v.replaceMatch(m[p].build());n.push(new data_structure_1.Incoming(r.DATA_UPDATE_EVENT(),a,v.build()))}}return n},e.transformTTLRestore=function(r,t,a,l,n,i,s){var o,u,d,c,_,v,h=data_structure_2.IndexedSnapshotImpl.EMPTY_SNAPSHOT,f=new data_structure_1.MergeableWrapper;try{for(var T=tslib_1.__values(r),p=T.next();!p.done;p=T.next()){var g=p.value;h=SnapshotUtil.combineSnapshots(t.DATA_INSERT_MATCH(),g,h).getAfterSs(),h=SnapshotUtil.combineSnapshots(t.DATA_INSERT_EVENT(),g,h).getAfterSs(),h=SnapshotUtil.combineSnapshots(t.DATA_INSERT_ODD(),g,h).getAfterSs()}}catch(e){o={error:e}}finally{try{p&&!p.done&&(u=T.return)&&u.call(T)}finally{if(o)throw o.error}}var E=this.breakdownTTL(t,a,new data_structure_2.IndexedSnapshotImpl(h.matchesSport,s)),y=l,m=[];try{for(var A=tslib_1.__values(E),S=A.next();!S.done;S=A.next()){var b=S.value,M=SnapshotUtil.combineSnapshots(b.msgType(),b.data(),y);if(b.msgType().id()==t.DATA_INSERT_MATCH().id()||b.msgType().id()==t.DATA_INSERT_EVENT().id()){var P=e.transform(t,a,b.msgType(),b.data(),M);try{for(var D=(_=void 0,tslib_1.__values(P)),B=D.next();!B.done;B=D.next()){var x=B.value,w=new core_1.Delta(x,M.getAfterSs(),y);m.push(w),y=M.getAfterSs()}}catch(e){_={error:e}}finally{try{B&&!B.done&&(v=D.return)&&v.call(D)}finally{if(_)throw _.error}}}else{w=new core_1.Delta(b,M.getAfterSs(),l);m.push(w)}}}catch(e){d={error:e}}finally{try{S&&!S.done&&(c=A.return)&&c.call(A)}finally{if(d)throw d.error}}return f.setAfter(n),f.setDeltaOut(m),f},e.transformTTLRemove=function(r,t,a,l,n,i){var s,o,u,d,c,_,v,h=new data_structure_1.MergeableWrapper,f=data_structure_2.IndexedSnapshotImpl.EMPTY_SNAPSHOT;try{for(var T=tslib_1.__values(r),p=T.next();!p.done;p=T.next()){var g=p.value;f=SnapshotUtil.combineSnapshots(t.DATA_INSERT_MATCH(),g,f).getAfterSs(),f=SnapshotUtil.combineSnapshots(t.DATA_INSERT_EVENT(),g,f).getAfterSs(),f=SnapshotUtil.combineSnapshots(t.DATA_INSERT_ODD(),g,f).getAfterSs()}}catch(e){s={error:e}}finally{try{p&&!p.done&&(o=T.return)&&o.call(T)}finally{if(s)throw s.error}}var E=e.breakdownReset(t,a,f);v=l;var y=[];try{for(var m=tslib_1.__values(E),A=m.next();!A.done;A=m.next()){var S=A.value,b=SnapshotUtil.combineSnapshots(S.msgType(),S.data(),v);if(S.msgType().id()==t.DATA_DELETE_MATCH().id()||S.msgType().id()==t.DATA_DELETE_EVENT().id()){var M=e.transform(t,a,S.msgType(),S.data(),b);try{for(var P=(c=void 0,tslib_1.__values(M)),D=P.next();!D.done;D=P.next()){var B=D.value,x=new core_1.Delta(B,b.getAfterSs(),v);y.push(x),v=b.getAfterSs()}}catch(e){c={error:e}}finally{try{D&&!D.done&&(_=P.return)&&_.call(P)}finally{if(c)throw c.error}}}else{x=new core_1.Delta(S,b.getAfterSs(),l);y.push(x)}}}catch(e){u={error:e}}finally{try{A&&!A.done&&(d=m.return)&&d.call(m)}finally{if(u)throw u.error}}return h.setDeltaOut(y),h.setAfter(n),h},e.breakdownTTL=function(e,r,t){var a,l,n,i,s,o,u=data_structure_2.IndexedSnapshotImpl.EMPTY_SNAPSHOT,d=data_structure_2.IndexedSnapshotImpl.EMPTY_SNAPSHOT,c=mutable_1.BuilderProvider.getSnapshotBuilder(t),_=mutable_1.BuilderProvider.getSnapshotBuilder(t);try{for(var v=tslib_1.__values(t.matches()),h=v.next();!h.done;h=v.next()){var f=h.value,T=mutable_1.BuilderProvider.getMatchBuilder(f),p=mutable_1.BuilderProvider.getMatchBuilder(f);try{for(var g=(n=void 0,tslib_1.__values(f.events())),E=g.next();!E.done;E=g.next()){var y=E.value;T.deleteChild(y);var m=mutable_1.BuilderProvider.getEventBuilder(y);try{for(var A=(s=void 0,tslib_1.__values(y.records())),S=A.next();!S.done;S=A.next()){var b=S.value;m.deleteChild(b)}}catch(e){s={error:e}}finally{try{S&&!S.done&&(o=A.return)&&o.call(A)}finally{if(s)throw s.error}}p.replaceEvent(m.build())}}catch(e){n={error:e}}finally{try{E&&!E.done&&(i=g.return)&&i.call(g)}finally{if(n)throw n.error}}c.replaceMatch(T.build()),_.replaceMatch(p.build())}}catch(e){a={error:e}}finally{try{h&&!h.done&&(l=v.return)&&l.call(v)}finally{if(a)throw a.error}}u=c.build(),d=_.build();var M=[];return M.push(new data_structure_1.Incoming(e.DATA_INSERT_MATCH(),r,u)),M.push(new data_structure_1.Incoming(e.DATA_INSERT_EVENT(),r,d)),M.push(new data_structure_1.Incoming(e.DATA_INSERT_ODD(),r,t)),M},e.breakdownReset=function(e,r,t){var a,l,n,i,s,o,u=data_structure_2.IndexedSnapshotImpl.EMPTY_SNAPSHOT,d=data_structure_2.IndexedSnapshotImpl.EMPTY_SNAPSHOT,c=mutable_1.BuilderProvider.getSnapshotBuilder(t),_=mutable_1.BuilderProvider.getSnapshotBuilder(t);try{for(var v=tslib_1.__values(t.matches()),h=v.next();!h.done;h=v.next()){var f=h.value,T=mutable_1.BuilderProvider.getMatchBuilder(f),p=mutable_1.BuilderProvider.getMatchBuilder(f);try{for(var g=(n=void 0,tslib_1.__values(f.events())),E=g.next();!E.done;E=g.next()){var y=E.value;T.deleteChild(y);var m=mutable_1.BuilderProvider.getEventBuilder(y);try{for(var A=(s=void 0,tslib_1.__values(y.records())),S=A.next();!S.done;S=A.next()){var b=S.value;m.deleteChild(b)}}catch(e){s={error:e}}finally{try{S&&!S.done&&(o=A.return)&&o.call(A)}finally{if(s)throw s.error}}p.replaceEvent(m.build())}}catch(e){n={error:e}}finally{try{E&&!E.done&&(i=g.return)&&i.call(g)}finally{if(n)throw n.error}}c.replaceMatch(T.build()),_.replaceMatch(p.build())}}catch(e){a={error:e}}finally{try{h&&!h.done&&(l=v.return)&&l.call(v)}finally{if(a)throw a.error}}u=c.build(),d=_.build();var M=[];return M.push(new data_structure_1.Incoming(e.DATA_DELETE_ODD(),r,t)),M.push(new data_structure_1.Incoming(e.DATA_DELETE_EVENT(),r,d)),M.push(new data_structure_1.Incoming(e.DATA_DELETE_MATCH(),r,u)),M},e.suppressInsertMatch=function(e,r,t,a,l,n){var i,s,o,u,d=mutable_1.BuilderProvider.getSnapshotBuilder(l),c=mutable_1.BuilderProvider.getSnapshotBuilder(l);if(0!=e.getSuppressMatch().length)try{for(var _=tslib_1.__values(e.getSuppressMatch()),v=_.next();!v.done;v=_.next()){var h=v.value,f=mutable_1.BuilderProvider.getMatchBuilder(l.match(h.split("_")[0]));d.deleteChild(f.build())}}catch(e){i={error:e}}finally{try{v&&!v.done&&(s=_.return)&&s.call(_)}finally{if(i)throw i.error}}if(0!=e.getInsertMatch().length)try{for(var T=tslib_1.__values(e.getInsertMatch()),p=T.next();!p.done;p=T.next()){h=p.value,f=mutable_1.BuilderProvider.getMatchBuilder(l.match(h.split("_")[0]));c.deleteChild(f.build())}}catch(e){o={error:e}}finally{try{p&&!p.done&&(u=T.return)&&u.call(T)}finally{if(o)throw o.error}}return 0!=d.build().matches().length&&n.push(new data_structure_1.Incoming(r.DATA_INSERT_MATCH(),a,d.build())),n},e.suppressDeleteEvent=function(e,r,t,a,l,n){var i,s,o,u,d,c,_=mutable_1.BuilderProvider.getSnapshotBuilder(l),v=mutable_1.BuilderProvider.getSnapshotBuilder(l);if(0!=e.getDeleteEvent().length){var h={};try{for(var f=tslib_1.__values(e.getTransformEvent()),T=f.next();!T.done;T=f.next()){var p=(D=T.value).split("_")[0],g=D.split("_")[1],E=e.getBeforeSs().match(p),y=h[p];void 0===y&&(y=mutable_1.BuilderProvider.getMatchBuilder(E),h[p]=y),y.deleteChild(E.event(g))}}catch(e){i={error:e}}finally{try{T&&!T.done&&(s=f.return)&&s.call(f)}finally{if(i)throw i.error}}for(var p in h)_.replaceMatch(h[p].build());n.push(new data_structure_1.Incoming(r.DATA_DELETE_EVENT(),a,_.build()))}if(0!=e.getTransformEvent().length){var m={};try{for(var A=tslib_1.__values(e.getDeleteEvent()),S=A.next();!S.done;S=A.next()){p=(D=S.value).split("_")[0],g=D.split("_")[1],E=e.getBeforeSs().match(p);var b=m[p];void 0===b&&(b=mutable_1.BuilderProvider.getMatchBuilder(E),m[p]=b),b.deleteChild(E.event(g))}}catch(e){o={error:e}}finally{try{S&&!S.done&&(u=A.return)&&u.call(A)}finally{if(o)throw o.error}}try{for(var M=tslib_1.__values(e.getTransformEvent()),P=M.next();!P.done;P=M.next()){p=(D=P.value).split("_")[0],g=D.split("_")[1];var D,B=m[p];void 0===B&&(B=mutable_1.BuilderProvider.getMatchBuilder(e.getBeforeSs().match(p)),m[p]=B);var x=mutable_1.BuilderProvider.getEventBuilder(B.build().event(g));x.aggregateDelete(l.match(p).event(g)),B.replaceEvent(x.build())}}catch(e){d={error:e}}finally{try{P&&!P.done&&(c=M.return)&&c.call(M)}finally{if(d)throw d.error}}for(var p in m)v.replaceMatch(m[p].build());n.push(new data_structure_1.Incoming(r.DATA_UPDATE_EVENT(),a,v.build()))}return n},e.suppressDeleteMatch=function(e,r,t,a,l,n){var i,s,o,u,d=mutable_1.BuilderProvider.getSnapshotBuilder(l),c=mutable_1.BuilderProvider.getSnapshotBuilder(l);if(0!=e.getSuppressMatch().length)try{for(var _=tslib_1.__values(e.getSuppressMatch()),v=_.next();!v.done;v=_.next()){var h=v.value,f=mutable_1.BuilderProvider.getMatchBuilder(l.match(h.split("_")[0]));d.deleteChild(f.build())}}catch(e){i={error:e}}finally{try{v&&!v.done&&(s=_.return)&&s.call(_)}finally{if(i)throw i.error}}if(0!=e.getDeleteMatch().length)try{for(var T=tslib_1.__values(e.getDeleteMatch()),p=T.next();!p.done;p=T.next()){h=p.value,f=mutable_1.BuilderProvider.getMatchBuilder(l.match(h.split("_")[0]));c.deleteChild(f.build())}}catch(e){o={error:e}}finally{try{p&&!p.done&&(u=T.return)&&u.call(T)}finally{if(o)throw o.error}}return 0!=d.build().matches().length&&n.push(new data_structure_1.Incoming(r.DATA_DELETE_MATCH(),a,d.build())),n},e}();exports.DeltaTransformingLogicImpl=DeltaTransformingLogicImpl;
1
+ "use strict";var __values=this&&this.__values||function(e){var r="function"==typeof Symbol&&Symbol.iterator,t=r&&e[r],a=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(exports,"__esModule",{value:!0}),exports.DeltaTransformingLogicImpl=exports.SnapshotUtil=exports.MsgType=void 0;var MsgType,data_structure_1=require("./data_structure"),message_class_1=require("./message_class"),mutable_1=require("./mutable"),core_1=require("./core"),data_structure_2=require("./data_structure");!function(e){e[e.INSERT=0]="INSERT",e[e.UPDATE=1]="UPDATE",e[e.DELETE=2]="DELETE"}(MsgType=exports.MsgType||(exports.MsgType={}));var SnapshotUtil=function(){function e(){}return e.combineSnapshots=function(r,t,a){if(r.group().id()!=e.SPORTS_GROUP.id())return console.error("FATAL: Received non feed message group's class %s.Shouldnt come here",r),(l=new data_structure_1.MessageBeforeTransform).setAfterSs(a),l;switch(r.id()){case e.SPORTS_GROUP.DATA_INSERT_MATCH().id():return e.processMatches(MsgType.INSERT,t,a);case e.SPORTS_GROUP.DATA_UPDATE_MATCH().id():return e.processMatches(MsgType.UPDATE,t,a);case e.SPORTS_GROUP.DATA_DELETE_MATCH().id():return e.processMatches(MsgType.DELETE,t,a);case e.SPORTS_GROUP.DATA_INSERT_EVENT().id():return e.processEvents(MsgType.INSERT,t,a);case e.SPORTS_GROUP.DATA_UPDATE_EVENT().id():return e.processEvents(MsgType.UPDATE,t,a);case e.SPORTS_GROUP.DATA_DELETE_EVENT().id():return e.processEvents(MsgType.DELETE,t,a);case e.SPORTS_GROUP.DATA_INSERT_ODD().id():return e.processOdds(MsgType.INSERT,t,a);case e.SPORTS_GROUP.DATA_UPDATE_ODD().id():return e.processOdds(MsgType.UPDATE,t,a);case e.SPORTS_GROUP.DATA_DELETE_ODD().id():return e.processOdds(MsgType.DELETE,t,a);case e.SPORTS_GROUP.DATA_RESET().id():return e.processReset(t,a);case e.SPORTS_GROUP.ADMIN_REFRESH().id():return e.processRefresh(t,a);default:var l;return console.error("FATAL: Received non data message class %s.Shouldnt come here",r),(l=new data_structure_1.MessageBeforeTransform).setAfterSs(a),l}},e.processRefresh=function(e,r){var t,a,l=mutable_1.BuilderProvider.getSnapshotBuilder(r),n=new data_structure_1.MessageBeforeTransform,o=e.getPartitions().toArray();try{for(var i=__values(o),s=i.next();!s.done;s=i.next()){var u=s.value,d=e.getPartitionMap().getValue(u);l.markPartitionAsUpdated(u,d)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(a=i.return)&&a.call(i)}finally{if(t)throw t.error}}return n.setAfterSs(l.build()),n},e.processReset=function(e,r){var t,a,l=mutable_1.BuilderProvider.getSnapshotBuilder(r),n=new data_structure_1.MessageBeforeTransform,o=e.getPartitions().toArray();try{for(var i=__values(o),s=i.next();!s.done;s=i.next()){var u=s.value;l.reset(u);var d=e.getPartitionMap().getValue(u);l.markPartitionAsUpdated(u,d)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(a=i.return)&&a.call(i)}finally{if(t)throw t.error}}return n.setAfterSs(l.build()),n},e.processMatches=function(e,r,t){var a,l,n,o,i=mutable_1.BuilderProvider.getSnapshotBuilder(t),s=new data_structure_1.MessageBeforeTransform,u=null;try{for(var d=__values(r.matches()),c=d.next();!c.done;c=d.next()){var _=c.value;switch(u=null,e){case MsgType.INSERT:null!=(u=i.insertChild(_))?s.setSuppressMatch(u):s.setInsertMatch(_.id());break;case MsgType.UPDATE:i.updateChild(_);break;case MsgType.DELETE:null!=(u=i.deleteChild(_))?s.setSuppressMatch(u):s.setDeleteMatch(_.id());break;default:console.error("[Match] FATAL: Shouldn't come here")}}}catch(e){a={error:e}}finally{try{c&&!c.done&&(l=d.return)&&l.call(d)}finally{if(a)throw a.error}}var v=r.getPartitions().toArray();try{for(var h=__values(v),f=h.next();!f.done;f=h.next()){var p=f.value,T=r.getPartitionMap().getValue(p);i.markPartitionAsUpdated(p,T)}}catch(e){n={error:e}}finally{try{f&&!f.done&&(o=h.return)&&o.call(h)}finally{if(n)throw n.error}}return s.setAfterSs(i.build()),s},e.processEvents=function(e,r,t){var a,l,n,o,i,s,u=mutable_1.BuilderProvider.getSnapshotBuilder(t),d=new data_structure_1.MessageBeforeTransform;try{for(var c=__values(r.matches()),_=c.next();!_.done;_=c.next()){var v=_.value,h=t.match(v.id());if(null!=h){var f=mutable_1.BuilderProvider.getMatchBuilder(h);try{for(var p=(n=void 0,__values(v.events())),T=p.next();!T.done;T=p.next()){var g=T.value;switch(e){case MsgType.INSERT:null!=f.insertChild(g)?d.setTransformEvent(g.matchId()+"_"+g.id()):d.setInsertEvent(g.matchId()+"_"+g.id());break;case MsgType.UPDATE:f.updateChild(g);break;case MsgType.DELETE:null!=f.deleteChild(g)?d.setTransformEvent(g.matchId()+"_"+g.id()):d.setDeleteEvent(g.matchId()+"_"+g.id());break;default:console.error("[Event] FATAL: Shouldn't come here")}}}catch(e){n={error:e}}finally{try{T&&!T.done&&(o=p.return)&&o.call(p)}finally{if(n)throw n.error}}u.replaceMatch(f.build())}else console.error("Cannot find Match %s while processing %s",v.id(),MsgType)}}catch(e){a={error:e}}finally{try{_&&!_.done&&(l=c.return)&&l.call(c)}finally{if(a)throw a.error}}var y=r.getPartitions().toArray();try{for(var E=__values(y),m=E.next();!m.done;m=E.next()){var S=m.value,A=r.getPartitionMap().getValue(S);u.markPartitionAsUpdated(S,A)}}catch(e){i={error:e}}finally{try{m&&!m.done&&(s=E.return)&&s.call(E)}finally{if(i)throw i.error}}return d.setAfterSs(u.build()),d.setBeforeSs(t),d},e.processOdds=function(e,r,t){var a,l,n,o,i,s,u,d,c=mutable_1.BuilderProvider.getSnapshotBuilder(t),_=new data_structure_1.MessageBeforeTransform;try{for(var v=__values(r.matches()),h=v.next();!h.done;h=v.next()){var f=h.value,p=t.match(f.id());if(null!=p){var T=mutable_1.BuilderProvider.getMatchBuilder(p);try{for(var g=(n=void 0,__values(f.events())),y=g.next();!y.done;y=g.next()){var E=y.value,m=p.event(E.id());if(null!=m){var S=mutable_1.BuilderProvider.getEventBuilder(m);try{for(var A=(i=void 0,__values(E.records())),b=A.next();!b.done;b=A.next()){var M=b.value;switch(e){case MsgType.INSERT:S.insertChild(M);break;case MsgType.UPDATE:S.updateChild(M);break;case MsgType.DELETE:S.deleteChild(M);break;default:console.error("[Record] FATAL: Shouldn't come here")}}}catch(e){i={error:e}}finally{try{b&&!b.done&&(s=A.return)&&s.call(A)}finally{if(i)throw i.error}}T.replaceEvent(S.build())}else console.error("Cannot find Event %s_%s while processing %s",f.id(),E.id(),e)}}catch(e){n={error:e}}finally{try{y&&!y.done&&(o=g.return)&&o.call(g)}finally{if(n)throw n.error}}c.replaceMatch(T.build())}else console.error("Cannot find Match %s while processing %s",f.id(),e)}}catch(e){a={error:e}}finally{try{h&&!h.done&&(l=v.return)&&l.call(v)}finally{if(a)throw a.error}}var P=r.getPartitions().toArray();try{for(var D=__values(P),B=D.next();!B.done;B=D.next()){var x=B.value,w=r.getPartitionMap().getValue(x);c.markPartitionAsUpdated(x,w)}}catch(e){u={error:e}}finally{try{B&&!B.done&&(d=D.return)&&d.call(D)}finally{if(u)throw u.error}}return _.setAfterSs(c.build()),_},e.SPORTS_GROUP=new message_class_1.SportsFeedMessageGroup,e}();exports.SnapshotUtil=SnapshotUtil;var DeltaTransformingLogicImpl=function(){function e(){}return e.transform=function(e,r,t,a,l){switch(t.id()){case e.DATA_INSERT_MATCH().id():return this.suppressInsertMatch(l,e,t,r,a,[]);case e.DATA_DELETE_MATCH().id():return this.suppressDeleteMatch(l,e,t,r,a,[]);case e.DATA_INSERT_EVENT().id():return this.suppressInsertEvent(l,e,t,r,a,[]);case e.DATA_DELETE_EVENT().id():return this.suppressDeleteEvent(l,e,t,r,a,[]);case e.DATA_UPDATE_EVENT().id():return this.combineEventState(l,e,t,r,a,[])}var n=[];return n.push(new data_structure_1.Incoming(t,r,a)),n},e.combineEventState=function(e,r,t,a,l,n){var o,i,s,u,d=mutable_1.BuilderProvider.getSnapshotBuilder(l);try{for(var c=__values(l.matches()),_=c.next();!_.done;_=c.next()){var v=_.value,h=mutable_1.BuilderProvider.getMatchBuilder(v);try{for(var f=(s=void 0,__values(v.events())),p=f.next();!p.done;p=f.next()){var T=p.value,g=mutable_1.BuilderProvider.getEventBuilder(T);g.aggregateInsert(e.getAfterSs().match(v.id()).event(T.id())),h.replaceEvent(g.build())}}catch(e){s={error:e}}finally{try{p&&!p.done&&(u=f.return)&&u.call(f)}finally{if(s)throw s.error}}d.replaceMatch(h.build())}}catch(e){o={error:e}}finally{try{_&&!_.done&&(i=c.return)&&i.call(c)}finally{if(o)throw o.error}}return n.push(new data_structure_1.Incoming(r.DATA_UPDATE_EVENT(),a,d.build())),n},e.suppressInsertEvent=function(e,r,t,a,l,n){var o,i,s,u,d,c,_=mutable_1.BuilderProvider.getSnapshotBuilder(l),v=mutable_1.BuilderProvider.getSnapshotBuilder(l);if(0!=l.matches().length){if(0!=e.getInsertEvent().length){var h={};try{for(var f=__values(e.getTransformEvent()),p=f.next();!p.done;p=f.next()){var T=(D=p.value).split("_")[0],g=D.split("_")[1],y=l.match(T),E=h[T];void 0===E&&(E=mutable_1.BuilderProvider.getMatchBuilder(y),h[T]=E),E.deleteChild(y.event(g))}}catch(e){o={error:e}}finally{try{p&&!p.done&&(i=f.return)&&i.call(f)}finally{if(o)throw o.error}}for(var T in h)_.replaceMatch(h[T].build());n.push(new data_structure_1.Incoming(r.DATA_INSERT_EVENT(),a,_.build()))}if(0!=e.getTransformEvent().length){var m={};try{for(var S=__values(e.getInsertEvent()),A=S.next();!A.done;A=S.next()){T=(D=A.value).split("_")[0],g=D.split("_")[1],y=l.match(T);var b=m[T];void 0===b&&(b=mutable_1.BuilderProvider.getMatchBuilder(y),m[T]=b),b.deleteChild(y.event(g))}}catch(e){s={error:e}}finally{try{A&&!A.done&&(u=S.return)&&u.call(S)}finally{if(s)throw s.error}}try{for(var M=__values(e.getTransformEvent()),P=M.next();!P.done;P=M.next()){T=(D=P.value).split("_")[0],g=D.split("_")[1],y=l.match(T);var D,B=m[T];void 0===B&&(B=mutable_1.BuilderProvider.getMatchBuilder(y),m[T]=B);var x=mutable_1.BuilderProvider.getEventBuilder(y.event(g));x.aggregateInsert(e.getAfterSs().match(T).event(g)),B.replaceEvent(x.build())}}catch(e){d={error:e}}finally{try{P&&!P.done&&(c=M.return)&&c.call(M)}finally{if(d)throw d.error}}for(var T in m)v.replaceMatch(m[T].build());n.push(new data_structure_1.Incoming(r.DATA_UPDATE_EVENT(),a,v.build()))}}return n},e.transformTTLRestore=function(r,t,a,l,n,o,i){var s,u,d,c,_,v,h=data_structure_2.IndexedSnapshotImpl.EMPTY_SNAPSHOT,f=new data_structure_1.MergeableWrapper;try{for(var p=__values(r),T=p.next();!T.done;T=p.next()){var g=T.value;h=SnapshotUtil.combineSnapshots(t.DATA_INSERT_MATCH(),g,h).getAfterSs(),h=SnapshotUtil.combineSnapshots(t.DATA_INSERT_EVENT(),g,h).getAfterSs(),h=SnapshotUtil.combineSnapshots(t.DATA_INSERT_ODD(),g,h).getAfterSs()}}catch(e){s={error:e}}finally{try{T&&!T.done&&(u=p.return)&&u.call(p)}finally{if(s)throw s.error}}var y=this.breakdownTTL(t,a,new data_structure_2.IndexedSnapshotImpl(h.matchesSport,i)),E=l,m=[];try{for(var S=__values(y),A=S.next();!A.done;A=S.next()){var b=A.value,M=SnapshotUtil.combineSnapshots(b.msgType(),b.data(),E);if(b.msgType().id()==t.DATA_INSERT_MATCH().id()||b.msgType().id()==t.DATA_INSERT_EVENT().id()){var P=e.transform(t,a,b.msgType(),b.data(),M);try{for(var D=(_=void 0,__values(P)),B=D.next();!B.done;B=D.next()){var x=B.value,w=new core_1.Delta(x,M.getAfterSs(),E);m.push(w),E=M.getAfterSs()}}catch(e){_={error:e}}finally{try{B&&!B.done&&(v=D.return)&&v.call(D)}finally{if(_)throw _.error}}}else{w=new core_1.Delta(b,M.getAfterSs(),l);m.push(w)}}}catch(e){d={error:e}}finally{try{A&&!A.done&&(c=S.return)&&c.call(S)}finally{if(d)throw d.error}}return f.setAfter(n),f.setDeltaOut(m),f},e.transformTTLRemove=function(r,t,a,l,n,o){var i,s,u,d,c,_,v,h=new data_structure_1.MergeableWrapper,f=data_structure_2.IndexedSnapshotImpl.EMPTY_SNAPSHOT;try{for(var p=__values(r),T=p.next();!T.done;T=p.next()){var g=T.value;f=SnapshotUtil.combineSnapshots(t.DATA_INSERT_MATCH(),g,f).getAfterSs(),f=SnapshotUtil.combineSnapshots(t.DATA_INSERT_EVENT(),g,f).getAfterSs(),f=SnapshotUtil.combineSnapshots(t.DATA_INSERT_ODD(),g,f).getAfterSs()}}catch(e){i={error:e}}finally{try{T&&!T.done&&(s=p.return)&&s.call(p)}finally{if(i)throw i.error}}var y=e.breakdownReset(t,a,f);v=l;var E=[];try{for(var m=__values(y),S=m.next();!S.done;S=m.next()){var A=S.value,b=SnapshotUtil.combineSnapshots(A.msgType(),A.data(),v);if(A.msgType().id()==t.DATA_DELETE_MATCH().id()||A.msgType().id()==t.DATA_DELETE_EVENT().id()){var M=e.transform(t,a,A.msgType(),A.data(),b);try{for(var P=(c=void 0,__values(M)),D=P.next();!D.done;D=P.next()){var B=D.value,x=new core_1.Delta(B,b.getAfterSs(),v);E.push(x),v=b.getAfterSs()}}catch(e){c={error:e}}finally{try{D&&!D.done&&(_=P.return)&&_.call(P)}finally{if(c)throw c.error}}}else{x=new core_1.Delta(A,b.getAfterSs(),l);E.push(x)}}}catch(e){u={error:e}}finally{try{S&&!S.done&&(d=m.return)&&d.call(m)}finally{if(u)throw u.error}}return h.setDeltaOut(E),h.setAfter(n),h},e.breakdownTTL=function(e,r,t){var a,l,n,o,i,s,u=data_structure_2.IndexedSnapshotImpl.EMPTY_SNAPSHOT,d=data_structure_2.IndexedSnapshotImpl.EMPTY_SNAPSHOT,c=mutable_1.BuilderProvider.getSnapshotBuilder(t),_=mutable_1.BuilderProvider.getSnapshotBuilder(t);try{for(var v=__values(t.matches()),h=v.next();!h.done;h=v.next()){var f=h.value,p=mutable_1.BuilderProvider.getMatchBuilder(f),T=mutable_1.BuilderProvider.getMatchBuilder(f);try{for(var g=(n=void 0,__values(f.events())),y=g.next();!y.done;y=g.next()){var E=y.value;p.deleteChild(E);var m=mutable_1.BuilderProvider.getEventBuilder(E);try{for(var S=(i=void 0,__values(E.records())),A=S.next();!A.done;A=S.next()){var b=A.value;m.deleteChild(b)}}catch(e){i={error:e}}finally{try{A&&!A.done&&(s=S.return)&&s.call(S)}finally{if(i)throw i.error}}T.replaceEvent(m.build())}}catch(e){n={error:e}}finally{try{y&&!y.done&&(o=g.return)&&o.call(g)}finally{if(n)throw n.error}}c.replaceMatch(p.build()),_.replaceMatch(T.build())}}catch(e){a={error:e}}finally{try{h&&!h.done&&(l=v.return)&&l.call(v)}finally{if(a)throw a.error}}u=c.build(),d=_.build();var M=[];return M.push(new data_structure_1.Incoming(e.DATA_INSERT_MATCH(),r,u)),M.push(new data_structure_1.Incoming(e.DATA_INSERT_EVENT(),r,d)),M.push(new data_structure_1.Incoming(e.DATA_INSERT_ODD(),r,t)),M},e.breakdownReset=function(e,r,t){var a,l,n,o,i,s,u=data_structure_2.IndexedSnapshotImpl.EMPTY_SNAPSHOT,d=data_structure_2.IndexedSnapshotImpl.EMPTY_SNAPSHOT,c=mutable_1.BuilderProvider.getSnapshotBuilder(t),_=mutable_1.BuilderProvider.getSnapshotBuilder(t);try{for(var v=__values(t.matches()),h=v.next();!h.done;h=v.next()){var f=h.value,p=mutable_1.BuilderProvider.getMatchBuilder(f),T=mutable_1.BuilderProvider.getMatchBuilder(f);try{for(var g=(n=void 0,__values(f.events())),y=g.next();!y.done;y=g.next()){var E=y.value;p.deleteChild(E);var m=mutable_1.BuilderProvider.getEventBuilder(E);try{for(var S=(i=void 0,__values(E.records())),A=S.next();!A.done;A=S.next()){var b=A.value;m.deleteChild(b)}}catch(e){i={error:e}}finally{try{A&&!A.done&&(s=S.return)&&s.call(S)}finally{if(i)throw i.error}}T.replaceEvent(m.build())}}catch(e){n={error:e}}finally{try{y&&!y.done&&(o=g.return)&&o.call(g)}finally{if(n)throw n.error}}c.replaceMatch(p.build()),_.replaceMatch(T.build())}}catch(e){a={error:e}}finally{try{h&&!h.done&&(l=v.return)&&l.call(v)}finally{if(a)throw a.error}}u=c.build(),d=_.build();var M=[];return M.push(new data_structure_1.Incoming(e.DATA_DELETE_ODD(),r,t)),M.push(new data_structure_1.Incoming(e.DATA_DELETE_EVENT(),r,d)),M.push(new data_structure_1.Incoming(e.DATA_DELETE_MATCH(),r,u)),M},e.suppressInsertMatch=function(e,r,t,a,l,n){var o,i,s,u,d=mutable_1.BuilderProvider.getSnapshotBuilder(l),c=mutable_1.BuilderProvider.getSnapshotBuilder(l);if(0!=e.getSuppressMatch().length)try{for(var _=__values(e.getSuppressMatch()),v=_.next();!v.done;v=_.next()){var h=v.value,f=mutable_1.BuilderProvider.getMatchBuilder(l.match(h.split("_")[0]));d.deleteChild(f.build())}}catch(e){o={error:e}}finally{try{v&&!v.done&&(i=_.return)&&i.call(_)}finally{if(o)throw o.error}}if(0!=e.getInsertMatch().length)try{for(var p=__values(e.getInsertMatch()),T=p.next();!T.done;T=p.next()){h=T.value,f=mutable_1.BuilderProvider.getMatchBuilder(l.match(h.split("_")[0]));c.deleteChild(f.build())}}catch(e){s={error:e}}finally{try{T&&!T.done&&(u=p.return)&&u.call(p)}finally{if(s)throw s.error}}return 0!=d.build().matches().length&&n.push(new data_structure_1.Incoming(r.DATA_INSERT_MATCH(),a,d.build())),n},e.suppressDeleteEvent=function(e,r,t,a,l,n){var o,i,s,u,d,c,_=mutable_1.BuilderProvider.getSnapshotBuilder(l),v=mutable_1.BuilderProvider.getSnapshotBuilder(l);if(0!=e.getDeleteEvent().length){var h={};try{for(var f=__values(e.getTransformEvent()),p=f.next();!p.done;p=f.next()){var T=(D=p.value).split("_")[0],g=D.split("_")[1],y=e.getBeforeSs().match(T),E=h[T];void 0===E&&(E=mutable_1.BuilderProvider.getMatchBuilder(y),h[T]=E),E.deleteChild(y.event(g))}}catch(e){o={error:e}}finally{try{p&&!p.done&&(i=f.return)&&i.call(f)}finally{if(o)throw o.error}}for(var T in h)_.replaceMatch(h[T].build());n.push(new data_structure_1.Incoming(r.DATA_DELETE_EVENT(),a,_.build()))}if(0!=e.getTransformEvent().length){var m={};try{for(var S=__values(e.getDeleteEvent()),A=S.next();!A.done;A=S.next()){T=(D=A.value).split("_")[0],g=D.split("_")[1],y=e.getBeforeSs().match(T);var b=m[T];void 0===b&&(b=mutable_1.BuilderProvider.getMatchBuilder(y),m[T]=b),b.deleteChild(y.event(g))}}catch(e){s={error:e}}finally{try{A&&!A.done&&(u=S.return)&&u.call(S)}finally{if(s)throw s.error}}try{for(var M=__values(e.getTransformEvent()),P=M.next();!P.done;P=M.next()){T=(D=P.value).split("_")[0],g=D.split("_")[1];var D,B=m[T];void 0===B&&(B=mutable_1.BuilderProvider.getMatchBuilder(e.getBeforeSs().match(T)),m[T]=B);var x=mutable_1.BuilderProvider.getEventBuilder(B.build().event(g));x.aggregateDelete(l.match(T).event(g)),B.replaceEvent(x.build())}}catch(e){d={error:e}}finally{try{P&&!P.done&&(c=M.return)&&c.call(M)}finally{if(d)throw d.error}}for(var T in m)v.replaceMatch(m[T].build());n.push(new data_structure_1.Incoming(r.DATA_UPDATE_EVENT(),a,v.build()))}return n},e.suppressDeleteMatch=function(e,r,t,a,l,n){var o,i,s,u,d=mutable_1.BuilderProvider.getSnapshotBuilder(l),c=mutable_1.BuilderProvider.getSnapshotBuilder(l);if(0!=e.getSuppressMatch().length)try{for(var _=__values(e.getSuppressMatch()),v=_.next();!v.done;v=_.next()){var h=v.value,f=mutable_1.BuilderProvider.getMatchBuilder(l.match(h.split("_")[0]));d.deleteChild(f.build())}}catch(e){o={error:e}}finally{try{v&&!v.done&&(i=_.return)&&i.call(_)}finally{if(o)throw o.error}}if(0!=e.getDeleteMatch().length)try{for(var p=__values(e.getDeleteMatch()),T=p.next();!T.done;T=p.next()){h=T.value,f=mutable_1.BuilderProvider.getMatchBuilder(l.match(h.split("_")[0]));c.deleteChild(f.build())}}catch(e){s={error:e}}finally{try{T&&!T.done&&(u=p.return)&&u.call(p)}finally{if(s)throw s.error}}return 0!=d.build().matches().length&&n.push(new data_structure_1.Incoming(r.DATA_DELETE_MATCH(),a,d.build())),n},e}();exports.DeltaTransformingLogicImpl=DeltaTransformingLogicImpl;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SportsFeedMessageGroup=exports.RefreshMessageClass=exports.StartSubscribeFeed=exports.SwitchFilterFailMessageClass=exports.SwitchFilterEndMessageClass=exports.SwitchFilterStartMessageClass=exports.TTLRestoreMessageClass=exports.TTLRemoveMessageClass=exports.ResetMessageClass=exports.DeleteOddMessageClass=exports.DeleteEventMessageClass=exports.DeleteMatchMessageClass=exports.UpdateOddMessageClass=exports.UpdateEventMessageClass=exports.UpdateMatchMessageClass=exports.InsertOddMessageClass=exports.InsertEventMessageClass=exports.InsertMatchMessageClass=exports.PartitionCodec=exports.SportsCodecs=exports.FilterMessageClass=exports.AbstractMessageClass=void 0;var tslib_1=require("tslib"),deliver=require("@jayesol/jayeson.lib.delivery"),jayeson_lib_record_1=require("@jayesol/jayeson.lib.record"),data_structure_1=require("./data_structure"),proto=tslib_1.__importStar(require("./protobuf_bundle")),Collections=tslib_1.__importStar(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(e){function s(s,t,r,a,o){var n=e.call(this,s,t,r)||this;return n._msgGroup=s,n._id=t,n._instanceClass=r,n._sportCodecs=a,n._partitionCodec=o,n.unpack=function(e){var s=proto.DataMessage.decode(e.message);e.message=new data_structure_1.IndexedSnapshotImpl({});var t=s.stringPool,r=s.feedKey;if(void 0!==r){var a=n.asSportType(r.sport);if(null!=a){var o=n._sportCodecs.getCodec(a);if(null!=o){var _=n._partitionCodec.decode(new proto.PartitionKey(r),t),i=n.read(s,o,t,_),c={};c[a]=i;var p=new Collections.Dictionary;p.setValue(_,(new Date).getTime()),e.message=new data_structure_1.IndexedSnapshotImpl(c,p)}}}},n}return tslib_1.__extends(s,e),s.prototype.id=function(){return this._id},s.prototype.SportsFeedMessageGroup=function(){return this._msgGroup},s.prototype.instanceClass=function(){return this._instanceClass},s.prototype.sportCodecs=function(){return this._sportCodecs},s.prototype.partitionCodec=function(){return this._partitionCodec},s.prototype.inHandlers=function(){return[{unpack:this.unpack}]},s.prototype.outHandlers=function(){return[]},s.prototype.asSportType=function(e){var s=proto.SportType[e];return jayeson_lib_record_1.SportType[s]},s}(deliver.IMessageClass);exports.AbstractMessageClass=AbstractMessageClass;var FilterMessageClass=function(e){function s(s,t){return e.call(this,s,t,codec_1.FilterRequest)||this}return tslib_1.__extends(s,e),s}(deliver.JSonMessageClass);exports.FilterMessageClass=FilterMessageClass;var SportsCodecs=function(){function e(e){void 0===e&&(e=void 0),this.sportsMappings=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}();exports.SportsCodecs=SportsCodecs;var PartitionCodec=function(){function e(){}return e.prototype.decode=function(e,s){var t=jayeson_lib_record_1.OddType.LIVE;switch(e.oddType){case proto.OddType.LIVE:t=jayeson_lib_record_1.OddType.LIVE;break;case proto.OddType.TODAY:t=jayeson_lib_record_1.OddType.TODAY;break;case proto.OddType.EARLY:t=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(s[e.source],t,r)},e}();exports.PartitionCodec=PartitionCodec;var InsertMatchMessageClass=function(e){function s(s,t,r,a){return e.call(this,s,t,data_structure_1.IndexedSnapshotImpl,r,a)||this}return tslib_1.__extends(s,e),s.prototype.read=function(e,s,t,r){var a=e.matches.matches.map(function(e){return new proto.BaseMatch(e)});return s.decodeMatch(a,t,codec_1.EncodeAction.INSERT,r)},s}(AbstractMessageClass);exports.InsertMatchMessageClass=InsertMatchMessageClass;var InsertEventMessageClass=function(e){function s(s,t,r,a){return e.call(this,s,t,data_structure_1.IndexedSnapshotImpl,r,a)||this}return tslib_1.__extends(s,e),s.prototype.read=function(e,s,t,r){var a=e.events.events.map(function(e){return new proto.BaseEvent(e)});return s.decodeEvent(a,t,codec_1.EncodeAction.INSERT,r)},s}(AbstractMessageClass);exports.InsertEventMessageClass=InsertEventMessageClass;var InsertOddMessageClass=function(e){function s(s,t,r,a){return e.call(this,s,t,data_structure_1.IndexedSnapshotImpl,r,a)||this}return tslib_1.__extends(s,e),s.prototype.read=function(e,s,t,r){var a=e.odds.odds.map(function(e){return new proto.BaseRecord(e)});return s.decodeRecord(a,t,codec_1.EncodeAction.INSERT,r)},s}(AbstractMessageClass);exports.InsertOddMessageClass=InsertOddMessageClass;var UpdateMatchMessageClass=function(e){function s(s,t,r,a){return e.call(this,s,t,data_structure_1.IndexedSnapshotImpl,r,a)||this}return tslib_1.__extends(s,e),s.prototype.read=function(e,s,t,r){var a=e.matches.matches.map(function(e){return new proto.BaseMatch(e)});return s.decodeMatch(a,t,codec_1.EncodeAction.UPDATE,r)},s}(AbstractMessageClass);exports.UpdateMatchMessageClass=UpdateMatchMessageClass;var UpdateEventMessageClass=function(e){function s(s,t,r,a){return e.call(this,s,t,data_structure_1.IndexedSnapshotImpl,r,a)||this}return tslib_1.__extends(s,e),s.prototype.read=function(e,s,t,r){var a=e.events.events.map(function(e){return new proto.BaseEvent(e)});return s.decodeEvent(a,t,codec_1.EncodeAction.UPDATE,r)},s}(AbstractMessageClass);exports.UpdateEventMessageClass=UpdateEventMessageClass;var UpdateOddMessageClass=function(e){function s(s,t,r,a){return e.call(this,s,t,data_structure_1.IndexedSnapshotImpl,r,a)||this}return tslib_1.__extends(s,e),s.prototype.read=function(e,s,t,r){var a=e.odds.odds.map(function(e){return new proto.BaseRecord(e)});return s.decodeRecord(a,t,codec_1.EncodeAction.UPDATE,r)},s}(AbstractMessageClass);exports.UpdateOddMessageClass=UpdateOddMessageClass;var DeleteMatchMessageClass=function(e){function s(s,t,r,a){return e.call(this,s,t,data_structure_1.IndexedSnapshotImpl,r,a)||this}return tslib_1.__extends(s,e),s.prototype.read=function(e,s,t,r){var a=e.matches.matches.map(function(e){return new proto.BaseMatch(e)});return s.decodeMatch(a,t,codec_1.EncodeAction.DELETE,r)},s}(AbstractMessageClass);exports.DeleteMatchMessageClass=DeleteMatchMessageClass;var DeleteEventMessageClass=function(e){function s(s,t,r,a){return e.call(this,s,t,data_structure_1.IndexedSnapshotImpl,r,a)||this}return tslib_1.__extends(s,e),s.prototype.read=function(e,s,t,r){var a=e.events.events.map(function(e){return new proto.BaseEvent(e)});return s.decodeEvent(a,t,codec_1.EncodeAction.DELETE,r)},s}(AbstractMessageClass);exports.DeleteEventMessageClass=DeleteEventMessageClass;var DeleteOddMessageClass=function(e){function s(s,t,r,a){return e.call(this,s,t,data_structure_1.IndexedSnapshotImpl,r,a)||this}return tslib_1.__extends(s,e),s.prototype.read=function(e,s,t,r){var a=e.odds.odds.map(function(e){return new proto.BaseRecord(e)});return s.decodeRecord(a,t,codec_1.EncodeAction.DELETE,r)},s}(AbstractMessageClass);exports.DeleteOddMessageClass=DeleteOddMessageClass;var ResetMessageClass=function(e){function s(s,t,r,a){return e.call(this,s,t,data_structure_1.IndexedSnapshotImpl,r,a)||this}return tslib_1.__extends(s,e),s.prototype.read=function(e,s,t,r){return[]},s}(AbstractMessageClass);exports.ResetMessageClass=ResetMessageClass;var TTLRemoveMessageClass=function(e){function s(s,t,r,a){return e.call(this,s,t,data_structure_1.IndexedSnapshotImpl,r,a)||this}return tslib_1.__extends(s,e),s.prototype.read=function(e,s,t,r){return[]},s}(AbstractMessageClass);exports.TTLRemoveMessageClass=TTLRemoveMessageClass;var TTLRestoreMessageClass=function(e){function s(s,t,r,a){return e.call(this,s,t,data_structure_1.IndexedSnapshotImpl,r,a)||this}return tslib_1.__extends(s,e),s.prototype.read=function(e,s,t,r){return[]},s}(AbstractMessageClass);exports.TTLRestoreMessageClass=TTLRestoreMessageClass;var SwitchFilterStartMessageClass=function(e){function s(s,t){return e.call(this,s,t)||this}return tslib_1.__extends(s,e),s}(deliver.EmptyMessageClass);exports.SwitchFilterStartMessageClass=SwitchFilterStartMessageClass;var SwitchFilterEndMessageClass=function(e){function s(s,t){return e.call(this,s,t)||this}return tslib_1.__extends(s,e),s}(deliver.EmptyMessageClass);exports.SwitchFilterEndMessageClass=SwitchFilterEndMessageClass;var SwitchFilterFailMessageClass=function(e){function s(s,t){return e.call(this,s,t)||this}return tslib_1.__extends(s,e),s}(deliver.EmptyMessageClass);exports.SwitchFilterFailMessageClass=SwitchFilterFailMessageClass;var StartSubscribeFeed=function(e,s){this.exclude=e,this.wireFormat=s};exports.StartSubscribeFeed=StartSubscribeFeed;var RefreshMessage=function(){},RefreshMessageClass=function(e){function s(s,t){var r=e.call(this,s,t,RefreshMessage)||this;return r.unpack=function(e){var s=e.message,t=new Collections.Dictionary;s.partitionKeys.forEach(function(e){t.setValue(jayeson_lib_record_1.PartitionKey.fromString(e),(new Date).getTime())}),e.message=new data_structure_1.IndexedSnapshotImpl({},t)},r}return tslib_1.__extends(s,e),s.prototype.inHandlers=function(){return e.prototype.inHandlers.call(this).concat([{unpack:this.unpack}])},s}(deliver.JSonMessageClass);exports.RefreshMessageClass=RefreshMessageClass;var SportsFeedMessageGroup=function(e){function s(s,t){void 0===s&&(s=new SportsCodecs),void 0===t&&(t=new PartitionCodec);var r=e.call(this,70)||this;return r._DATA_RESET=new ResetMessageClass(r,0,s,t),r._DATA_INSERT_ODD=new InsertOddMessageClass(r,1,s,t),r._DATA_UPDATE_ODD=new UpdateOddMessageClass(r,2,s,t),r._DATA_DELETE_ODD=new DeleteOddMessageClass(r,3,s,t),r._DATA_INSERT_EVENT=new InsertEventMessageClass(r,4,s,t),r._DATA_UPDATE_EVENT=new UpdateEventMessageClass(r,5,s,t),r._DATA_DELETE_EVENT=new DeleteEventMessageClass(r,6,s,t),r._DATA_INSERT_MATCH=new InsertMatchMessageClass(r,7,s,t),r._DATA_UPDATE_MATCH=new UpdateMatchMessageClass(r,8,s,t),r._DATA_DELETE_MATCH=new DeleteMatchMessageClass(r,9,s,t),r._TTL_RESTORE=new TTLRestoreMessageClass(r,10,s,t),r._TTL_REMOVE=new TTLRestoreMessageClass(r,11,s,t),r._FILTER_REMOVE=new deliver.StringMessageClass(r,13),r._FILTER_SET=new FilterMessageClass(r,14),r._ADMIN_START_SUBSCRIBE_FEED=new deliver.JSonMessageClass(r,16,StartSubscribeFeed),r._ADMIN_REFRESH=new RefreshMessageClass(r,17),r._SWITCH_FILTER_START=new deliver.StringMessageClass(r,18),r._SWITCH_FILTER_END=new deliver.EmptyMessageClass(r,19),r._FULLSNAPSHOT_START=new deliver.EmptyMessageClass(r,20),r._FULLSNAPSHOT_END=new deliver.EmptyMessageClass(r,21),r._SWITCH_FILTER_FAIL=new deliver.StringMessageClass(r,22),r._TTL_RESTORE_START=new TTLRestoreMessageClass(r,23,s,t),r._TTL_RESTORE_END=new deliver.EmptyMessageClass(r,24),[r._DATA_RESET,r._DATA_INSERT_ODD,r._DATA_UPDATE_ODD,r._DATA_DELETE_ODD,r._DATA_INSERT_EVENT,r._DATA_UPDATE_EVENT,r._DATA_DELETE_EVENT,r._DATA_INSERT_MATCH,r._DATA_UPDATE_MATCH,r._DATA_DELETE_MATCH,r._TTL_RESTORE,r._TTL_REMOVE,r._FILTER_REMOVE,r._FILTER_SET,r._ADMIN_START_SUBSCRIBE_FEED,r._ADMIN_REFRESH,r._SWITCH_FILTER_START,r._SWITCH_FILTER_END,r._FULLSNAPSHOT_START,r._FULLSNAPSHOT_END,r._SWITCH_FILTER_FAIL,r._TTL_RESTORE_START,r._TTL_RESTORE_END].forEach(function(e){r._classes[e.id()]=e}),r}return tslib_1.__extends(s,e),s.prototype.DATA_RESET=function(){return this._DATA_RESET},s.prototype.DATA_INSERT_ODD=function(){return this._DATA_INSERT_ODD},s.prototype.DATA_UPDATE_ODD=function(){return this._DATA_UPDATE_ODD},s.prototype.DATA_DELETE_ODD=function(){return this._DATA_DELETE_ODD},s.prototype.DATA_INSERT_EVENT=function(){return this._DATA_INSERT_EVENT},s.prototype.DATA_UPDATE_EVENT=function(){return this._DATA_UPDATE_EVENT},s.prototype.DATA_DELETE_EVENT=function(){return this._DATA_DELETE_EVENT},s.prototype.TTL_REMOVE=function(){return this._TTL_REMOVE},s.prototype.TTL_RESTORE=function(){return this._TTL_RESTORE},s.prototype.TTL_RESTORE_START=function(){return this._TTL_RESTORE_START},s.prototype.TTL_RESTORE_END=function(){return this._TTL_RESTORE_END},s.prototype.DATA_INSERT_MATCH=function(){return this._DATA_INSERT_MATCH},s.prototype.DATA_UPDATE_MATCH=function(){return this._DATA_UPDATE_MATCH},s.prototype.DATA_DELETE_MATCH=function(){return this._DATA_DELETE_MATCH},s.prototype.FILTER_REMOVE=function(){return this._FILTER_REMOVE},s.prototype.FILTER_SET=function(){return this._FILTER_SET},s.prototype.ADMIN_START_SUBSCRIBE_FEED=function(){return this._ADMIN_START_SUBSCRIBE_FEED},s.prototype.ADMIN_REFRESH=function(){return this._ADMIN_REFRESH},s.prototype.SWITCH_FILTER_START=function(){return this._SWITCH_FILTER_START},s.prototype.SWITCH_FILTER_END=function(){return this._SWITCH_FILTER_END},s.prototype.FULLSNAPSHOT_START=function(){return this._FULLSNAPSHOT_START},s.prototype.FULLSNAPSHOT_END=function(){return this._FULLSNAPSHOT_END},s.prototype.SWITCH_FILTER_FAIL=function(){return this._SWITCH_FILTER_FAIL},s.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()},s.prototype.isSwitchFilterStatusMsg=function(e){return e==this.SWITCH_FILTER_START()||e==this.SWITCH_FILTER_FAIL()},s}(deliver.IMessageGroup);exports.SportsFeedMessageGroup=SportsFeedMessageGroup;
1
+ "use strict";var __extends=this&&this.__extends||function(){var e=function(t,s){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])},e(t,s)};return function(t,s){if("function"!=typeof s&&null!==s)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");function r(){this.constructor=t}e(t,s),t.prototype=null===s?Object.create(s):(r.prototype=s.prototype,new r)}}(),__createBinding=this&&this.__createBinding||(Object.create?function(e,t,s,r){void 0===r&&(r=s);var o=Object.getOwnPropertyDescriptor(t,s);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,r,o)}:function(e,t,s,r){void 0===r&&(r=s),e[r]=t[s]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s in e)"default"!==s&&Object.prototype.hasOwnProperty.call(e,s)&&__createBinding(t,e,s);return __setModuleDefault(t,e),t};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SportsFeedMessageGroup=exports.RefreshMessageClass=exports.StartSubscribeFeed=exports.SwitchFilterFailMessageClass=exports.SwitchFilterEndMessageClass=exports.SwitchFilterStartMessageClass=exports.TTLRestoreMessageClass=exports.TTLRemoveMessageClass=exports.ResetMessageClass=exports.DeleteOddMessageClass=exports.DeleteEventMessageClass=exports.DeleteMatchMessageClass=exports.UpdateOddMessageClass=exports.UpdateEventMessageClass=exports.UpdateMatchMessageClass=exports.InsertOddMessageClass=exports.InsertEventMessageClass=exports.InsertMatchMessageClass=exports.PartitionCodec=exports.SportsCodecs=exports.FilterMessageClass=exports.AbstractMessageClass=void 0;var deliver=require("@jayesol/jayeson.lib.delivery"),jayeson_lib_record_1=require("@jayesol/jayeson.lib.record"),data_structure_1=require("./data_structure"),proto=__importStar(require("./protobuf_bundle")),Collections=__importStar(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(e){function t(t,s,r,o,n){var a=e.call(this,t,s,r)||this;return a._msgGroup=t,a._id=s,a._instanceClass=r,a._sportCodecs=o,a._partitionCodec=n,a.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 o=a.asSportType(r.sport);if(null!=o){var n=a._sportCodecs.getCodec(o);if(null!=n){var _=a._partitionCodec.decode(new proto.PartitionKey(r),s),i=a.read(t,n,s,_),c={};c[o]=i;var p=new Collections.Dictionary;p.setValue(_,(new Date).getTime()),e.message=new data_structure_1.IndexedSnapshotImpl(c,p)}}}},a}return __extends(t,e),t.prototype.id=function(){return this._id},t.prototype.SportsFeedMessageGroup=function(){return this._msgGroup},t.prototype.instanceClass=function(){return this._instanceClass},t.prototype.sportCodecs=function(){return this._sportCodecs},t.prototype.partitionCodec=function(){return this._partitionCodec},t.prototype.inHandlers=function(){return[{unpack:this.unpack}]},t.prototype.outHandlers=function(){return[]},t.prototype.asSportType=function(e){var t=proto.SportType[e];return jayeson_lib_record_1.SportType[t]},t}(deliver.IMessageClass);exports.AbstractMessageClass=AbstractMessageClass;var FilterMessageClass=function(e){function t(t,s){return e.call(this,t,s,codec_1.FilterRequest)||this}return __extends(t,e),t}(deliver.JSonMessageClass);exports.FilterMessageClass=FilterMessageClass;var SportsCodecs=function(){function e(e){void 0===e&&(e=void 0),this.sportsMappings=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}();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(e){function t(t,s,r,o){return e.call(this,t,s,data_structure_1.IndexedSnapshotImpl,r,o)||this}return __extends(t,e),t.prototype.read=function(e,t,s,r){var o=e.matches.matches.map(function(e){return new proto.BaseMatch(e)});return t.decodeMatch(o,s,codec_1.EncodeAction.INSERT,r)},t}(AbstractMessageClass);exports.InsertMatchMessageClass=InsertMatchMessageClass;var InsertEventMessageClass=function(e){function t(t,s,r,o){return e.call(this,t,s,data_structure_1.IndexedSnapshotImpl,r,o)||this}return __extends(t,e),t.prototype.read=function(e,t,s,r){var o=e.events.events.map(function(e){return new proto.BaseEvent(e)});return t.decodeEvent(o,s,codec_1.EncodeAction.INSERT,r)},t}(AbstractMessageClass);exports.InsertEventMessageClass=InsertEventMessageClass;var InsertOddMessageClass=function(e){function t(t,s,r,o){return e.call(this,t,s,data_structure_1.IndexedSnapshotImpl,r,o)||this}return __extends(t,e),t.prototype.read=function(e,t,s,r){var o=e.odds.odds.map(function(e){return new proto.BaseRecord(e)});return t.decodeRecord(o,s,codec_1.EncodeAction.INSERT,r)},t}(AbstractMessageClass);exports.InsertOddMessageClass=InsertOddMessageClass;var UpdateMatchMessageClass=function(e){function t(t,s,r,o){return e.call(this,t,s,data_structure_1.IndexedSnapshotImpl,r,o)||this}return __extends(t,e),t.prototype.read=function(e,t,s,r){var o=e.matches.matches.map(function(e){return new proto.BaseMatch(e)});return t.decodeMatch(o,s,codec_1.EncodeAction.UPDATE,r)},t}(AbstractMessageClass);exports.UpdateMatchMessageClass=UpdateMatchMessageClass;var UpdateEventMessageClass=function(e){function t(t,s,r,o){return e.call(this,t,s,data_structure_1.IndexedSnapshotImpl,r,o)||this}return __extends(t,e),t.prototype.read=function(e,t,s,r){var o=e.events.events.map(function(e){return new proto.BaseEvent(e)});return t.decodeEvent(o,s,codec_1.EncodeAction.UPDATE,r)},t}(AbstractMessageClass);exports.UpdateEventMessageClass=UpdateEventMessageClass;var UpdateOddMessageClass=function(e){function t(t,s,r,o){return e.call(this,t,s,data_structure_1.IndexedSnapshotImpl,r,o)||this}return __extends(t,e),t.prototype.read=function(e,t,s,r){var o=e.odds.odds.map(function(e){return new proto.BaseRecord(e)});return t.decodeRecord(o,s,codec_1.EncodeAction.UPDATE,r)},t}(AbstractMessageClass);exports.UpdateOddMessageClass=UpdateOddMessageClass;var DeleteMatchMessageClass=function(e){function t(t,s,r,o){return e.call(this,t,s,data_structure_1.IndexedSnapshotImpl,r,o)||this}return __extends(t,e),t.prototype.read=function(e,t,s,r){var o=e.matches.matches.map(function(e){return new proto.BaseMatch(e)});return t.decodeMatch(o,s,codec_1.EncodeAction.DELETE,r)},t}(AbstractMessageClass);exports.DeleteMatchMessageClass=DeleteMatchMessageClass;var DeleteEventMessageClass=function(e){function t(t,s,r,o){return e.call(this,t,s,data_structure_1.IndexedSnapshotImpl,r,o)||this}return __extends(t,e),t.prototype.read=function(e,t,s,r){var o=e.events.events.map(function(e){return new proto.BaseEvent(e)});return t.decodeEvent(o,s,codec_1.EncodeAction.DELETE,r)},t}(AbstractMessageClass);exports.DeleteEventMessageClass=DeleteEventMessageClass;var DeleteOddMessageClass=function(e){function t(t,s,r,o){return e.call(this,t,s,data_structure_1.IndexedSnapshotImpl,r,o)||this}return __extends(t,e),t.prototype.read=function(e,t,s,r){var o=e.odds.odds.map(function(e){return new proto.BaseRecord(e)});return t.decodeRecord(o,s,codec_1.EncodeAction.DELETE,r)},t}(AbstractMessageClass);exports.DeleteOddMessageClass=DeleteOddMessageClass;var ResetMessageClass=function(e){function t(t,s,r,o){return e.call(this,t,s,data_structure_1.IndexedSnapshotImpl,r,o)||this}return __extends(t,e),t.prototype.read=function(e,t,s,r){return[]},t}(AbstractMessageClass);exports.ResetMessageClass=ResetMessageClass;var TTLRemoveMessageClass=function(e){function t(t,s,r,o){return e.call(this,t,s,data_structure_1.IndexedSnapshotImpl,r,o)||this}return __extends(t,e),t.prototype.read=function(e,t,s,r){return[]},t}(AbstractMessageClass);exports.TTLRemoveMessageClass=TTLRemoveMessageClass;var TTLRestoreMessageClass=function(e){function t(t,s,r,o){return e.call(this,t,s,data_structure_1.IndexedSnapshotImpl,r,o)||this}return __extends(t,e),t.prototype.read=function(e,t,s,r){return[]},t}(AbstractMessageClass);exports.TTLRestoreMessageClass=TTLRestoreMessageClass;var SwitchFilterStartMessageClass=function(e){function t(t,s){return e.call(this,t,s)||this}return __extends(t,e),t}(deliver.EmptyMessageClass);exports.SwitchFilterStartMessageClass=SwitchFilterStartMessageClass;var SwitchFilterEndMessageClass=function(e){function t(t,s){return e.call(this,t,s)||this}return __extends(t,e),t}(deliver.EmptyMessageClass);exports.SwitchFilterEndMessageClass=SwitchFilterEndMessageClass;var SwitchFilterFailMessageClass=function(e){function t(t,s){return e.call(this,t,s)||this}return __extends(t,e),t}(deliver.EmptyMessageClass);exports.SwitchFilterFailMessageClass=SwitchFilterFailMessageClass;var StartSubscribeFeed=function(e,t){this.exclude=e,this.wireFormat=t};exports.StartSubscribeFeed=StartSubscribeFeed;var RefreshMessage=function(){},RefreshMessageClass=function(e){function t(t,s){var r=e.call(this,t,s,RefreshMessage)||this;return r.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)},r}return __extends(t,e),t.prototype.inHandlers=function(){return e.prototype.inHandlers.call(this).concat([{unpack:this.unpack}])},t}(deliver.JSonMessageClass);exports.RefreshMessageClass=RefreshMessageClass;var SportsFeedMessageGroup=function(e){function t(t,s){void 0===t&&(t=new SportsCodecs),void 0===s&&(s=new PartitionCodec);var r=e.call(this,70)||this;return r._DATA_RESET=new ResetMessageClass(r,0,t,s),r._DATA_INSERT_ODD=new InsertOddMessageClass(r,1,t,s),r._DATA_UPDATE_ODD=new UpdateOddMessageClass(r,2,t,s),r._DATA_DELETE_ODD=new DeleteOddMessageClass(r,3,t,s),r._DATA_INSERT_EVENT=new InsertEventMessageClass(r,4,t,s),r._DATA_UPDATE_EVENT=new UpdateEventMessageClass(r,5,t,s),r._DATA_DELETE_EVENT=new DeleteEventMessageClass(r,6,t,s),r._DATA_INSERT_MATCH=new InsertMatchMessageClass(r,7,t,s),r._DATA_UPDATE_MATCH=new UpdateMatchMessageClass(r,8,t,s),r._DATA_DELETE_MATCH=new DeleteMatchMessageClass(r,9,t,s),r._TTL_RESTORE=new TTLRestoreMessageClass(r,10,t,s),r._TTL_REMOVE=new TTLRestoreMessageClass(r,11,t,s),r._FILTER_REMOVE=new deliver.StringMessageClass(r,13),r._FILTER_SET=new FilterMessageClass(r,14),r._ADMIN_START_SUBSCRIBE_FEED=new deliver.JSonMessageClass(r,16,StartSubscribeFeed),r._ADMIN_REFRESH=new RefreshMessageClass(r,17),r._SWITCH_FILTER_START=new deliver.StringMessageClass(r,18),r._SWITCH_FILTER_END=new deliver.EmptyMessageClass(r,19),r._FULLSNAPSHOT_START=new deliver.EmptyMessageClass(r,20),r._FULLSNAPSHOT_END=new deliver.EmptyMessageClass(r,21),r._SWITCH_FILTER_FAIL=new deliver.StringMessageClass(r,22),r._TTL_RESTORE_START=new TTLRestoreMessageClass(r,23,t,s),r._TTL_RESTORE_END=new deliver.EmptyMessageClass(r,24),[r._DATA_RESET,r._DATA_INSERT_ODD,r._DATA_UPDATE_ODD,r._DATA_DELETE_ODD,r._DATA_INSERT_EVENT,r._DATA_UPDATE_EVENT,r._DATA_DELETE_EVENT,r._DATA_INSERT_MATCH,r._DATA_UPDATE_MATCH,r._DATA_DELETE_MATCH,r._TTL_RESTORE,r._TTL_REMOVE,r._FILTER_REMOVE,r._FILTER_SET,r._ADMIN_START_SUBSCRIBE_FEED,r._ADMIN_REFRESH,r._SWITCH_FILTER_START,r._SWITCH_FILTER_END,r._FULLSNAPSHOT_START,r._FULLSNAPSHOT_END,r._SWITCH_FILTER_FAIL,r._TTL_RESTORE_START,r._TTL_RESTORE_END].forEach(function(e){r._classes[e.id()]=e}),r}return __extends(t,e),t.prototype.DATA_RESET=function(){return this._DATA_RESET},t.prototype.DATA_INSERT_ODD=function(){return this._DATA_INSERT_ODD},t.prototype.DATA_UPDATE_ODD=function(){return this._DATA_UPDATE_ODD},t.prototype.DATA_DELETE_ODD=function(){return this._DATA_DELETE_ODD},t.prototype.DATA_INSERT_EVENT=function(){return this._DATA_INSERT_EVENT},t.prototype.DATA_UPDATE_EVENT=function(){return this._DATA_UPDATE_EVENT},t.prototype.DATA_DELETE_EVENT=function(){return this._DATA_DELETE_EVENT},t.prototype.TTL_REMOVE=function(){return this._TTL_REMOVE},t.prototype.TTL_RESTORE=function(){return this._TTL_RESTORE},t.prototype.TTL_RESTORE_START=function(){return this._TTL_RESTORE_START},t.prototype.TTL_RESTORE_END=function(){return this._TTL_RESTORE_END},t.prototype.DATA_INSERT_MATCH=function(){return this._DATA_INSERT_MATCH},t.prototype.DATA_UPDATE_MATCH=function(){return this._DATA_UPDATE_MATCH},t.prototype.DATA_DELETE_MATCH=function(){return this._DATA_DELETE_MATCH},t.prototype.FILTER_REMOVE=function(){return this._FILTER_REMOVE},t.prototype.FILTER_SET=function(){return this._FILTER_SET},t.prototype.ADMIN_START_SUBSCRIBE_FEED=function(){return this._ADMIN_START_SUBSCRIBE_FEED},t.prototype.ADMIN_REFRESH=function(){return this._ADMIN_REFRESH},t.prototype.SWITCH_FILTER_START=function(){return this._SWITCH_FILTER_START},t.prototype.SWITCH_FILTER_END=function(){return this._SWITCH_FILTER_END},t.prototype.FULLSNAPSHOT_START=function(){return this._FULLSNAPSHOT_START},t.prototype.FULLSNAPSHOT_END=function(){return this._FULLSNAPSHOT_END},t.prototype.SWITCH_FILTER_FAIL=function(){return this._SWITCH_FILTER_FAIL},t.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()},t.prototype.isSwitchFilterStatusMsg=function(e){return e==this.SWITCH_FILTER_START()||e==this.SWITCH_FILTER_FAIL()},t}(deliver.IMessageGroup);exports.SportsFeedMessageGroup=SportsFeedMessageGroup;
package/lib/module.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SportsFeedCoreService=exports.SportsFeedCoreComponentModule=void 0;var tslib_1=require("tslib"),D=tslib_1.__importStar(require("@jayesol/jayeson.lib.delivery")),injection_js_1=require("injection-js"),message_class_1=require("./message_class"),receive_1=require("./receive"),core_1=require("./core"),dispatch_1=require("./dispatch"),client_1=require("./client"),SportsFeedCoreComponentModule=function(){function e(){}return e.getBindingArray=function(e,r,o){return void 0===e&&(e=[]),void 0===r&&(r=""),void 0===o&&(o=client_1.MemoryDispatcher.MEMORY_STREAM),[{provide:message_class_1.StartSubscribeFeed,useValue:new message_class_1.StartSubscribeFeed(e,r)},{provide:message_class_1.SportsFeedMessageGroup,useValue:new message_class_1.SportsFeedMessageGroup},{provide:D.StreamNameCode,useClass:D.StreamNameCode},{provide:receive_1.InEndPointEventHandler,useClass: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;var SportsFeedCoreService=function(){function e(e,r){var o=injection_js_1.ReflectiveInjector.resolveAndCreate(SportsFeedCoreComponentModule.getBindingArray().concat([{provide:D.Subscriber,useFactory:function(o){var s=new D.SubscriberConfig;return s.streamFinder=e,s.discoveryPattern={70:[".*"]},s.processors={70:o},s.schemes=["ws","http","https","wss"],s.feedScope=r,new D.Subscriber(s)},deps:[receive_1.SportsFeedInProcessor]}]));this.client=o.get(client_1.SportsFeedClient),this.subscriber=o.get(D.Subscriber)}return e.prototype.getClient=function(){return this.client},e.prototype.getSubscriber=function(){return this.subscriber},e}();exports.SportsFeedCoreService=SportsFeedCoreService;
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,o){void 0===o&&(o=t);var i=Object.getOwnPropertyDescriptor(r,t);i&&!("get"in i?!r.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,o,i)}:function(e,r,t,o){void 0===o&&(o=t),e[o]=r[t]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,r){Object.defineProperty(e,"default",{enumerable:!0,value:r})}:function(e,r){e.default=r}),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)"default"!==t&&Object.prototype.hasOwnProperty.call(e,t)&&__createBinding(r,e,t);return __setModuleDefault(r,e),r};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SportsFeedCoreService=exports.SportsFeedCoreComponentModule=void 0;var D=__importStar(require("@jayesol/jayeson.lib.delivery")),injection_js_1=require("injection-js"),message_class_1=require("./message_class"),receive_1=require("./receive"),core_1=require("./core"),dispatch_1=require("./dispatch"),client_1=require("./client"),SportsFeedCoreComponentModule=function(){function e(){}return e.getBindingArray=function(e,r,t){return void 0===e&&(e=[]),void 0===r&&(r=""),void 0===t&&(t=client_1.MemoryDispatcher.MEMORY_STREAM),[{provide:message_class_1.StartSubscribeFeed,useValue:new message_class_1.StartSubscribeFeed(e,r)},{provide:message_class_1.SportsFeedMessageGroup,useValue:new message_class_1.SportsFeedMessageGroup},{provide:D.StreamNameCode,useClass:D.StreamNameCode},{provide:receive_1.InEndPointEventHandler,useClass:receive_1.InEndPointEventHandler},{provide:core_1.FSRepoImpl.outputStream,useValue:t},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;var SportsFeedCoreService=function(){function e(e,r){var t=injection_js_1.ReflectiveInjector.resolveAndCreate(SportsFeedCoreComponentModule.getBindingArray().concat([{provide:D.Subscriber,useFactory:function(t){var o=new D.SubscriberConfig;return o.streamFinder=e,o.discoveryPattern={70:[".*"]},o.processors={70:t},o.schemes=["ws","http","https","wss"],o.feedScope=r,new D.Subscriber(o)},deps:[receive_1.SportsFeedInProcessor]}]));this.client=t.get(client_1.SportsFeedClient),this.subscriber=t.get(D.Subscriber)}return e.prototype.getClient=function(){return this.client},e.prototype.getSubscriber=function(){return this.subscriber},e}();exports.SportsFeedCoreService=SportsFeedCoreService;
package/lib/mutable.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BuilderProvider=exports.B2RecordBuilder=exports.Const=void 0;var tslib_1=require("tslib"),jayeson_lib_record_1=require("@jayesol/jayeson.lib.record"),data_structure_1=require("./data_structure"),codec_1=require("./codec"),Collections=tslib_1.__importStar(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){var e,r,i,n;if(this._matches={},this._partitions=new Collections.Dictionary,null!=t){try{for(var o=tslib_1.__values(t.matches()),s=o.next();!s.done;s=o.next()){var a=s.value;this._matches[a.id()]=a}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}try{for(var u=tslib_1.__values(t.getPartitionMap().keys()),c=u.next();!c.done;c=u.next()){var d=c.value;this._partitions.setValue(d,t.getPartitionMap().getValue(d))}}catch(t){i={error:t}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(i)throw i.error}}}}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 n in r.setPartitionValue(t,i),this._matches){var o=this._matches[n],s=BuilderProvider.getMatchBuilder(o),a=s.reset(t);null==a||a.isEmpty()||r.insertChild(a.build()),s.isEmpty()?delete e[o.id()]:e[o.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){var e,r;for(var i in this._startTime=t.startTime(),this._id=t.id(),this._league=t.league(),this._sport=t.sportType(),this._meta={},t.meta())this._meta[i]=t.meta()[i];if(null!=t.events())try{for(var n=tslib_1.__values(t.events()),o=n.next();!o.done;o=n.next()){var s=o.value;this._events[s.id()]=s}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}var a=t;this._p1=a.participantOne(),this._p2=a.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()),n=codec_1.Util.removeKey(r,e);this._meta[Const.AGGREGATE_KEY]=n,i._meta[Const.AGGREGATE_KEY]=e;var o={};for(var s in i._events={},this._events){var a=this._events[s],u=BuilderProvider.getEventBuilder(a),c=u.reset(t);null==c||c.isEmpty()||i.insertChild(c.build()),u.isEmpty()?delete o[a.id()]:o[a.id()]=u.build()}return this._events=o,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,""===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,r,i=t;if(this._id=t.id(),null!=t.records())try{for(var n=tslib_1.__values(i.records()),o=n.next();!o.done;o=n.next()){var s=o.value,a=Const.generateKey(s);this._records[a]=s}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}for(var a in this.setStates(i.eventStates()),this._matchId=t.matchId(),this._eventType=t.eventType(),this._meta={},t.meta())this._meta[a]=t.meta()[a]},t.prototype.setStates=function(t){var e,r;if(null!=t)try{for(var i=tslib_1.__values(t),n=i.next();!n.done;n=i.next()){var o=n.value;this._states[o.partitionKey().toString()]=o}}catch(t){e={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}},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){var e,r;if(null==this._states[t.toString()])return null;var i=BuilderProvider.getEventBuilder(this.build());i._states={},i._records={};var n=this._states[t.toString()];i._states[t.toString()]=n,delete this._states[t.toString()];var o=Object.keys(this._records);try{for(var s=tslib_1.__values(o),a=s.next();!a.done;a=s.next()){var u=a.value,c=this._records[u];c.source()===t.source()&&this.getOddTypeInt(c.oddType())===this.getOddTypeInt(t.oddType())&&(i.insertChild(c),delete this._records[u])}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}return i},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=function(t){function e(e){return t.call(this,e)||this}return tslib_1.__extends(e,t),e}(IndexedSnapshotBuilder);t.Snapshot=e}(Builder||(Builder={})),function(t){!function(t){var e=function(t){function e(e){return t.call(this,e)||this}return tslib_1.__extends(e,t),e.prototype.setGender=function(t){this.gender=t},e.prototype.setCountry=function(t){this.country=t},e.prototype.mergeFrom=function(e){t.prototype.mergeFrom.call(this,e);var r=e;this.setGender(r.gender()),this.setCountry(r.country())},e.prototype.build=function(){var t,e,r=[];try{for(var i=tslib_1.__values(Object.keys(this._events)),n=i.next();!n.done;n=i.next()){var o=n.value;r.push(this._events[o])}}catch(e){t={error:e}}finally{try{n&&!n.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}return new jayeson_lib_record_1.TennisMatchImpl(this._p1,this._p2,this._startTime,r,this._id,this._league,this.gender,this.country,this._meta)},e}(B2MatchBuilder);t.Tennis=e;var r=function(t){function e(e){return t.call(this,e)||this}return tslib_1.__extends(e,t),e.prototype.leagueType=function(){return this._leagueType},e.prototype.gender=function(){return this._gender},e.prototype.country=function(){return this._country},e.prototype.setLeagueType=function(t){this._leagueType=t},e.prototype.setGender=function(t){this._gender=t},e.prototype.setCountry=function(t){this._country=t},e.prototype.mergeFrom=function(e){t.prototype.mergeFrom.call(this,e);var r=e;this.setLeagueType(r.leagueType()),this.setCountry(e.country()),this.setGender(r.gender())},e.prototype.build=function(){var t,e,r=[];try{for(var i=tslib_1.__values(Object.keys(this._events)),n=i.next();!n.done;n=i.next()){var o=n.value;r.push(this._events[o])}}catch(e){t={error:e}}finally{try{n&&!n.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}return new jayeson_lib_record_1.SoccerMatchImpl(this._p1,this._p2,this._startTime,r,this._id,this._league,this._meta,this._leagueType,this._gender,this._country)},e}(B2MatchBuilder);t.Soccer=r;var i=function(t){function e(e){return t.call(this,e)||this}return tslib_1.__extends(e,t),e.prototype.gender=function(){return this._gender},e.prototype.country=function(){return this._country},e.prototype.setGender=function(t){this._gender=t},e.prototype.setCountry=function(t){this._country=t},e.prototype.build=function(){var t,e,r=[];try{for(var i=tslib_1.__values(Object.keys(this._events)),n=i.next();!n.done;n=i.next()){var o=n.value;r.push(this._events[o])}}catch(e){t={error:e}}finally{try{n&&!n.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}return new jayeson_lib_record_1.BasketballMatchImpl(this._p1,this._p2,this._startTime,r,this._id,this._league,this._gender,this._country,this._meta)},e.prototype.mergeFrom=function(e){t.prototype.mergeFrom.call(this,e);var r=e;this.setGender(r.gender()),this.setCountry(r.country())},e}(B2MatchBuilder);t.Basketball=i}(t.Match||(t.Match={}))}(Builder||(Builder={})),function(t){!function(t){var e=function(t){function e(e){return t.call(this,e)||this}return tslib_1.__extends(e,t),e.prototype.build=function(){var t,e,r,i,n=[];try{for(var o=tslib_1.__values(Object.keys(this._records)),s=o.next();!s.done;s=o.next()){var a=s.value;n.push(this._records[a])}}catch(e){t={error:e}}finally{try{s&&!s.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}var u=[];try{for(var c=tslib_1.__values(Object.keys(this._states)),d=c.next();!d.done;d=c.next()){var h=d.value;u.push(this._states[h])}}catch(t){r={error:t}}finally{try{d&&!d.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}return new jayeson_lib_record_1.TennisEventImpl(this._id,n,u,this._matchId,this._eventType,this._meta)},e}(B2EventBuilder);t.Tennis=e;var r=function(t){function e(e){return t.call(this,e)||this}return tslib_1.__extends(e,t),e.prototype.build=function(){var t,e,r,i,n=[];try{for(var o=tslib_1.__values(Object.keys(this._records)),s=o.next();!s.done;s=o.next()){var a=s.value;n.push(this._records[a])}}catch(e){t={error:e}}finally{try{s&&!s.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}var u=[];try{for(var c=tslib_1.__values(Object.keys(this._states)),d=c.next();!d.done;d=c.next()){var h=d.value;u.push(this._states[h])}}catch(t){r={error:t}}finally{try{d&&!d.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}return new jayeson_lib_record_1.SoccerEventImpl(this._id,n,u,this._matchId,this._eventType,this._meta)},e}(B2EventBuilder);t.Soccer=r;var i=function(t){function e(e){return t.call(this,e)||this}return tslib_1.__extends(e,t),e.prototype.build=function(){var t,e,r,i,n=[];try{for(var o=tslib_1.__values(Object.keys(this._records)),s=o.next();!s.done;s=o.next()){var a=s.value;n.push(this._records[a])}}catch(e){t={error:e}}finally{try{s&&!s.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}var u=[];try{for(var c=tslib_1.__values(Object.keys(this._states)),d=c.next();!d.done;d=c.next()){var h=d.value;u.push(this._states[h])}}catch(t){r={error:t}}finally{try{d&&!d.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}return new jayeson_lib_record_1.BasketballEventImpl(this._id,n,u,this._matchId,this._eventType,this._meta)},e}(B2EventBuilder);t.Basketball=i}(t.Event||(t.Event={}))}(Builder||(Builder={})),function(t){!function(t){var e=function(t){function e(e){return t.call(this,e)||this}return tslib_1.__extends(e,t),e.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)},e}(B2RecordBuilder);t.Tennis=e;var r=function(t){function e(e){return t.call(this,e)||this}return tslib_1.__extends(e,t),e.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)},e}(B2RecordBuilder);t.Soccer=r;var i=function(t){function e(e){return t.call(this,e)||this}return tslib_1.__extends(e,t),e.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)},e}(B2RecordBuilder);t.Basketball=i}(t.Record||(t.Record={}))}(Builder||(Builder={})),function(t){!function(t){var e=function(t){function e(e){return t.call(this,e)||this}return tslib_1.__extends(e,t),e.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)},e.prototype.setHostScore=function(t){var e=this._statsOne.getScores();e[0]=t,this._statsOne.setScores(e)},e.prototype.setHostCard=function(t){var e=this._statsOne.getScores();e[1]=t,this._statsOne.setScores(e)},e.prototype.setGuestScore=function(t){var e=this._statsTwo.getScores();e[0]=t,this._statsTwo.setScores(e)},e.prototype.setGuestCard=function(t){var e=this._statsTwo.getScores();e[1]=t,this._statsTwo.setScores(e)},e.prototype.setSegment=function(t){this.segment=t},e.prototype.setBookPriority=function(t){this.bookPriority=t},e.prototype.mergeFrom=function(e){t.prototype.mergeFrom.call(this,e);var r=e;this.setHostCard(r.hostCard()),this.setGuestCard(r.guestCard()),this.setHostScore(r.hostScore()),this.setGuestScore(r.guestScore()),this.setSegment(r.segment()),this.setBookPriority(r.bookPriority())},e.prototype.merge=function(e){t.prototype.merge.call(this,e);var r=e;null!=r.segment&&this.setSegment(r.segment())},e}(B2EventStateBuilder);t.Soccer=e;var r=function(t){function e(e){return t.call(this,e)||this}return tslib_1.__extends(e,t),e.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)},e.prototype.setSet=function(t){this.setScore=t},e.prototype.setGame=function(t){this.game=t},e.prototype.setBookPriority=function(t){this.bookPriority=t},e.prototype.mergeFrom=function(e){t.prototype.mergeFrom.call(this,e);var r=e;this.setSet(r.set()),this.setGame(r.game()),this.setBookPriority(r.bookPriority())},e}(B2EventStateBuilder);t.Tennis=r;var i=function(t){function e(e){return t.call(this,e)||this}return tslib_1.__extends(e,t),e.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)},e.prototype.setSegment=function(t){this.segment=t},e.prototype.setBookPriority=function(t){this.bookPriority=t},e.prototype.setTimeout=function(t){this.isTimeout=t},e.prototype.mergeFrom=function(e){t.prototype.mergeFrom.call(this,e)},e}(B2EventStateBuilder);t.Basketball=i}(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
+ "use strict";var __extends=this&&this.__extends||function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),__createBinding=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),__importStar=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&__createBinding(e,t,r);return __setModuleDefault(e,t),e},__values=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(exports,"__esModule",{value:!0}),exports.BuilderProvider=exports.B2RecordBuilder=exports.Const=void 0;var jayeson_lib_record_1=require("@jayesol/jayeson.lib.record"),data_structure_1=require("./data_structure"),codec_1=require("./codec"),Collections=__importStar(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){var e,r,n,i;if(this._matches={},this._partitions=new Collections.Dictionary,null!=t){try{for(var o=__values(t.matches()),s=o.next();!s.done;s=o.next()){var a=s.value;this._matches[a.id()]=a}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}try{for(var u=__values(t.getPartitionMap().keys()),c=u.next();!c.done;c=u.next()){var d=c.value;this._partitions.setValue(d,t.getPartitionMap().getValue(d))}}catch(t){n={error:t}}finally{try{c&&!c.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}}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 n=this.removePartitionKey(t);for(var i in r.setPartitionValue(t,n),this._matches){var o=this._matches[i],s=BuilderProvider.getMatchBuilder(o),a=s.reset(t);null==a||a.isEmpty()||r.insertChild(a.build()),s.isEmpty()?delete e[o.id()]:e[o.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 n=BuilderProvider.getMatchBuilder(e);n.aggregateInsert(t),this._matches[t.id()]=n.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 n=BuilderProvider.getMatchBuilder(e);return n.aggregateDelete(t)?delete this._matches[t.id()]:(this._matches[t.id()]=n.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],n=t[r.sportType()];null==n&&(n=[],t[r.sportType()]=n),n.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){var e,r;for(var n in this._startTime=t.startTime(),this._id=t.id(),this._league=t.league(),this._sport=t.sportType(),this._meta={},t.meta())this._meta[n]=t.meta()[n];if(null!=t.events())try{for(var i=__values(t.events()),o=i.next();!o.done;o=i.next()){var s=o.value;this._events[s.id()]=s}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}var a=t;this._p1=a.participantOne(),this._p2=a.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 n=BuilderProvider.getMatchBuilder(this.build()),i=codec_1.Util.removeKey(r,e);this._meta[Const.AGGREGATE_KEY]=i,n._meta[Const.AGGREGATE_KEY]=e;var o={};for(var s in n._events={},this._events){var a=this._events[s],u=BuilderProvider.getEventBuilder(a),c=u.reset(t);null==c||c.isEmpty()||n.insertChild(c.build()),u.isEmpty()?delete o[a.id()]:o[a.id()]=u.build()}return this._events=o,n},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],n=this._meta[Const.AGGREGATE_KEY];this._meta[Const.AGGREGATE_KEY]=codec_1.Util.addKey(n,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],n=codec_1.Util.removeKey(r,e);return this._meta[Const.AGGREGATE_KEY]=n,""===n},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 n=BuilderProvider.getEventBuilder(e);n.aggregateInsert(t),this._events[t.id()]=n.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 n=BuilderProvider.getEventBuilder(e);return n.aggregateDelete(t)?delete this._events[t.id()]:(r=t.id(),this._events[t.id()]=n.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,r,n=t;if(this._id=t.id(),null!=t.records())try{for(var i=__values(n.records()),o=i.next();!o.done;o=i.next()){var s=o.value,a=Const.generateKey(s);this._records[a]=s}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}for(var a in this.setStates(n.eventStates()),this._matchId=t.matchId(),this._eventType=t.eventType(),this._meta={},t.meta())this._meta[a]=t.meta()[a]},t.prototype.setStates=function(t){var e,r;if(null!=t)try{for(var n=__values(t),i=n.next();!i.done;i=n.next()){var o=i.value;this._states[o.partitionKey().toString()]=o}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}},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){var e,r;if(null==this._states[t.toString()])return null;var n=BuilderProvider.getEventBuilder(this.build());n._states={},n._records={};var i=this._states[t.toString()];n._states[t.toString()]=i,delete this._states[t.toString()];var o=Object.keys(this._records);try{for(var s=__values(o),a=s.next();!a.done;a=s.next()){var u=a.value,c=this._records[u];c.source()===t.source()&&this.getOddTypeInt(c.oddType())===this.getOddTypeInt(t.oddType())&&(n.insertChild(c),delete this._records[u])}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}return n},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=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e}(IndexedSnapshotBuilder);t.Snapshot=e}(Builder||(Builder={})),function(t){!function(t){var e=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e.prototype.setGender=function(t){this.gender=t},e.prototype.setCountry=function(t){this.country=t},e.prototype.mergeFrom=function(e){t.prototype.mergeFrom.call(this,e);var r=e;this.setGender(r.gender()),this.setCountry(r.country())},e.prototype.build=function(){var t,e,r=[];try{for(var n=__values(Object.keys(this._events)),i=n.next();!i.done;i=n.next()){var o=i.value;r.push(this._events[o])}}catch(e){t={error:e}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}return new jayeson_lib_record_1.TennisMatchImpl(this._p1,this._p2,this._startTime,r,this._id,this._league,this.gender,this.country,this._meta)},e}(B2MatchBuilder);t.Tennis=e;var r=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e.prototype.leagueType=function(){return this._leagueType},e.prototype.gender=function(){return this._gender},e.prototype.country=function(){return this._country},e.prototype.setLeagueType=function(t){this._leagueType=t},e.prototype.setGender=function(t){this._gender=t},e.prototype.setCountry=function(t){this._country=t},e.prototype.mergeFrom=function(e){t.prototype.mergeFrom.call(this,e);var r=e;this.setLeagueType(r.leagueType()),this.setCountry(e.country()),this.setGender(r.gender())},e.prototype.build=function(){var t,e,r=[];try{for(var n=__values(Object.keys(this._events)),i=n.next();!i.done;i=n.next()){var o=i.value;r.push(this._events[o])}}catch(e){t={error:e}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}return new jayeson_lib_record_1.SoccerMatchImpl(this._p1,this._p2,this._startTime,r,this._id,this._league,this._meta,this._leagueType,this._gender,this._country)},e}(B2MatchBuilder);t.Soccer=r;var n=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e.prototype.gender=function(){return this._gender},e.prototype.country=function(){return this._country},e.prototype.setGender=function(t){this._gender=t},e.prototype.setCountry=function(t){this._country=t},e.prototype.build=function(){var t,e,r=[];try{for(var n=__values(Object.keys(this._events)),i=n.next();!i.done;i=n.next()){var o=i.value;r.push(this._events[o])}}catch(e){t={error:e}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}return new jayeson_lib_record_1.BasketballMatchImpl(this._p1,this._p2,this._startTime,r,this._id,this._league,this._gender,this._country,this._meta)},e.prototype.mergeFrom=function(e){t.prototype.mergeFrom.call(this,e);var r=e;this.setGender(r.gender()),this.setCountry(r.country())},e}(B2MatchBuilder);t.Basketball=n}(t.Match||(t.Match={}))}(Builder||(Builder={})),function(t){!function(t){var e=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e.prototype.build=function(){var t,e,r,n,i=[];try{for(var o=__values(Object.keys(this._records)),s=o.next();!s.done;s=o.next()){var a=s.value;i.push(this._records[a])}}catch(e){t={error:e}}finally{try{s&&!s.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}var u=[];try{for(var c=__values(Object.keys(this._states)),d=c.next();!d.done;d=c.next()){var h=d.value;u.push(this._states[h])}}catch(t){r={error:t}}finally{try{d&&!d.done&&(n=c.return)&&n.call(c)}finally{if(r)throw r.error}}return new jayeson_lib_record_1.TennisEventImpl(this._id,i,u,this._matchId,this._eventType,this._meta)},e}(B2EventBuilder);t.Tennis=e;var r=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e.prototype.build=function(){var t,e,r,n,i=[];try{for(var o=__values(Object.keys(this._records)),s=o.next();!s.done;s=o.next()){var a=s.value;i.push(this._records[a])}}catch(e){t={error:e}}finally{try{s&&!s.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}var u=[];try{for(var c=__values(Object.keys(this._states)),d=c.next();!d.done;d=c.next()){var h=d.value;u.push(this._states[h])}}catch(t){r={error:t}}finally{try{d&&!d.done&&(n=c.return)&&n.call(c)}finally{if(r)throw r.error}}return new jayeson_lib_record_1.SoccerEventImpl(this._id,i,u,this._matchId,this._eventType,this._meta)},e}(B2EventBuilder);t.Soccer=r;var n=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e.prototype.build=function(){var t,e,r,n,i=[];try{for(var o=__values(Object.keys(this._records)),s=o.next();!s.done;s=o.next()){var a=s.value;i.push(this._records[a])}}catch(e){t={error:e}}finally{try{s&&!s.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}var u=[];try{for(var c=__values(Object.keys(this._states)),d=c.next();!d.done;d=c.next()){var h=d.value;u.push(this._states[h])}}catch(t){r={error:t}}finally{try{d&&!d.done&&(n=c.return)&&n.call(c)}finally{if(r)throw r.error}}return new jayeson_lib_record_1.BasketballEventImpl(this._id,i,u,this._matchId,this._eventType,this._meta)},e}(B2EventBuilder);t.Basketball=n}(t.Event||(t.Event={}))}(Builder||(Builder={})),function(t){!function(t){var e=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e.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)},e}(B2RecordBuilder);t.Tennis=e;var r=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e.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)},e}(B2RecordBuilder);t.Soccer=r;var n=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e.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)},e}(B2RecordBuilder);t.Basketball=n}(t.Record||(t.Record={}))}(Builder||(Builder={})),function(t){!function(t){var e=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e.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)},e.prototype.setHostScore=function(t){var e=this._statsOne.getScores();e[0]=t,this._statsOne.setScores(e)},e.prototype.setHostCard=function(t){var e=this._statsOne.getScores();e[1]=t,this._statsOne.setScores(e)},e.prototype.setGuestScore=function(t){var e=this._statsTwo.getScores();e[0]=t,this._statsTwo.setScores(e)},e.prototype.setGuestCard=function(t){var e=this._statsTwo.getScores();e[1]=t,this._statsTwo.setScores(e)},e.prototype.setSegment=function(t){this.segment=t},e.prototype.setBookPriority=function(t){this.bookPriority=t},e.prototype.mergeFrom=function(e){t.prototype.mergeFrom.call(this,e);var r=e;this.setHostCard(r.hostCard()),this.setGuestCard(r.guestCard()),this.setHostScore(r.hostScore()),this.setGuestScore(r.guestScore()),this.setSegment(r.segment()),this.setBookPriority(r.bookPriority())},e.prototype.merge=function(e){t.prototype.merge.call(this,e);var r=e;null!=r.segment&&this.setSegment(r.segment())},e}(B2EventStateBuilder);t.Soccer=e;var r=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e.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)},e.prototype.setSet=function(t){this.setScore=t},e.prototype.setGame=function(t){this.game=t},e.prototype.setBookPriority=function(t){this.bookPriority=t},e.prototype.mergeFrom=function(e){t.prototype.mergeFrom.call(this,e);var r=e;this.setSet(r.set()),this.setGame(r.game()),this.setBookPriority(r.bookPriority())},e}(B2EventStateBuilder);t.Tennis=r;var n=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e.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)},e.prototype.setSegment=function(t){this.segment=t},e.prototype.setBookPriority=function(t){this.bookPriority=t},e.prototype.setTimeout=function(t){this.isTimeout=t},e.prototype.mergeFrom=function(e){t.prototype.mergeFrom.call(this,e)},e}(B2EventStateBuilder);t.Basketball=n}(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;
package/lib/receive.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MergeableIncoming=exports.SportsFeedInProcessor=exports.StreamCommandProcessor=exports.InEndPointEventHandler=void 0;var tslib_1=require("tslib"),D=tslib_1.__importStar(require("@jayesol/jayeson.lib.delivery")),Collections=tslib_1.__importStar(require("typescript-collections")),core_1=require("./core"),message_class_1=require("./message_class"),merge_1=require("./merge"),data_structure_1=require("./data_structure"),circular=require("circular-json");require("reflect-metadata");var injection_js_1=require("injection-js"),codec_1=require("./codec"),InEndPointEventHandler=function(){function e(e,s,t){this._streamSources={},this._filterData=null,this._startMessage=e,this._sportsMsgGrp=s,this._streamNameCode=t,this._exclude=e.exclude,this._wireFormat=e.wireFormat}return e.prototype.setfilterData=function(e){this._filterData=e},e.prototype.streamSources=function(){return this._streamSources},e.prototype.exclude=function(){return this._exclude},e.prototype.wireFormat=function(){return this._wireFormat},e.prototype.startMessage=function(){return this._startMessage},e.prototype.sportsMsgGrp=function(){return this._sportsMsgGrp},e.prototype.streamNameCode=function(){return this._streamNameCode},e.prototype.filterData=function(){return this._filterData},e.prototype.onEvent=function(e){if(e instanceof D.Subscriber.Event.ConsumptionStart){for(var s in e.streams)if(e.streams.hasOwnProperty(s))for(var t=0;t<e.streams[s].length;t++){if(parseInt(s)==this.sportsMsgGrp().id()){var r=e.streams[s][t];this._streamSources[r]=e.endPoint;var a=new codec_1.FilterRequest(codec_1.FilterRequest.IGNORED_REQUEST_ID,this.filterData());this.sendFilter(a,r),console.log("Sending Start Message to stream : '"+r+"'");var o=new D.MessageWrapper(this._startMessage,this._sportsMsgGrp.ADMIN_START_SUBSCRIBE_FEED());this.sendMessage(r,o)}}}else if(e instanceof D.Subscriber.Event.ConsumptionError){var n=e.client.config.url+" has errors on consumption: ";for(var s in e.streams)if(e.streams.hasOwnProperty(s)){n+="\n"+s+":[";for(t=0;t<e.streams[s].length;t++)n+=e.streams[s][t]+",";n=n.substring(1,n.length-1),n+="]"}console.log(n)}else console.log("Unidentified event received by onEvent: "+circular.stringify(e))},e.prototype.sendMessage=function(e,s){s.addMetaInfo(this._streamNameCode.code(),e);var t=this._streamSources[e];null==t?console.log("No Endpoint present corresponding to stream '"+e+"'. Unable to send message"):t.send(s)},e.prototype.updateFilter=function(e){this._filterData=e.getFilterData(),this.sendFilter(e)},e.prototype.sendFilter=function(e,s){if(void 0===s&&(s=null),null!==s)this._sendFilter(e,s);else for(var t in this._streamSources)this._streamSources.hasOwnProperty(t)&&this._sendFilter(e,t)},e.prototype._sendFilter=function(e,s){var t=e.getFilterData(),r=null;null!=t?(r=new D.MessageWrapper(e,this._sportsMsgGrp.FILTER_SET()),console.log("Sending FILTER_SET to stream: '"+s+"' with filter data: "+JSON.stringify(t))):(r=new D.MessageWrapper(e.getRequestId().toString(),this._sportsMsgGrp.FILTER_REMOVE()),console.log("Sending FILTER_REMOVE to stream: '"+s+"'")),this.sendMessage(s,r)},e=tslib_1.__decorate([(0,injection_js_1.Injectable)(),tslib_1.__metadata("design:paramtypes",[message_class_1.StartSubscribeFeed,message_class_1.SportsFeedMessageGroup,D.StreamNameCode])],e)}();exports.InEndPointEventHandler=InEndPointEventHandler;var StreamCommandProcessor=function(){function e(e,s){this._fsRepo=e,this._sportsGrp=s,this.messageClassName={0:"DATA_RESET",1:"DATA_INSERT_ODD",2:"DATA_UPDATE_ODD",3:"DATA_DELETE_ODD",4:"DATA_INSERT_EVENT",5:"DATA_UPDATE_EVENT",6:"DATA_DELETE_EVENT",7:"DATA_INSERT_MATCH",8:"DATA_UPDATE_MATCH",9:"DATA_DELETE_MATCH",10:"TTL_REMOVE",11:"TTL_RESTORE",13:"FILTER_REMOVE",14:"FILTER_SET",16:"ADMIN_START_SUBSCRIBE_FEED",17:"ADMIN_REFRESH"}}return e.prototype.process=function(e,s,t){var r,a;if(void 0===t&&(t=null),null!=s&&s instanceof data_structure_1.Incoming){var o=s,n=this.messageClassName[o.msgType().id()];console.debug("SCP processing: "+n)}if(null==t){var i=this._fsRepo.appendSnapshot(e,s);try{for(var c=tslib_1.__values(i),l=c.next();!l.done;l=c.next()){var p=l.value;this._fsRepo.push(p)}}catch(e){r={error:e}}finally{try{l&&!l.done&&(a=c.return)&&a.call(c)}finally{if(r)throw r.error}}}else this._fsRepo.push(t)},e.prototype.fsRepo=function(){return this._fsRepo},e.prototype.sportsGrp=function(){return this._sportsGrp},e.prototype.printMessage=function(e){var s=this.getClassName(e),t=e.delta();switch(this.printPartitionKeys(s,t),e.msgType().id()){case this._sportsGrp.DATA_INSERT_MATCH().id():case this._sportsGrp.DATA_UPDATE_MATCH().id():case this._sportsGrp.DATA_DELETE_MATCH().id():this.printMatch(s,t);break;case this._sportsGrp.DATA_INSERT_ODD().id():case this._sportsGrp.DATA_UPDATE_ODD().id():case this._sportsGrp.DATA_DELETE_ODD().id():this.printRecord(s,t)}},e.prototype.getClassName=function(e){return e instanceof core_1.TTLOutgoing?e.getTtlType()==core_1.TTLType.REMOVE?"TTL_REM":"TTL_RES":this.messageClassName[e.msgType().id()]},e.prototype.printMatch=function(e,s){for(var t=s.matches(),r=0;r<t.length;r++)console.log("[".concat(e,"] ").concat(t[r].id()))},e.prototype.printRecord=function(e,s){for(var t=s.matches(),r=0;r<t.length;r++)for(var a=t[r].events(),o=0;o<a.length;o++)for(var n=a[o].records(),i=0;i<n.length;i++){var c=n[i];console.log("[".concat(e,"] ").concat(c.matchId(),"_").concat(c.eventId(),"_").concat(c.id(),"_").concat(c.source(),"_").concat(c.oddType(),"_").concat(c.oddFormat()))}},e.prototype.printPartitionKeys=function(e,s){var t=s.getPartitions().toString();console.log("[".concat(e,"][PK]").concat(t))},e=tslib_1.__decorate([(0,injection_js_1.Injectable)(),tslib_1.__param(0,(0,injection_js_1.Inject)(core_1.FSREPO_IMPL)),tslib_1.__metadata("design:paramtypes",[Object,message_class_1.SportsFeedMessageGroup])],e)}();exports.StreamCommandProcessor=StreamCommandProcessor;var SportsFeedInProcessor=function(e){function s(s,t,r,a){var o=e.call(this,t)||this;return o.scp=s,o.sportsFeedMsgGroup=t,o.snCode=r,o.recycleBin=a,o}return tslib_1.__extends(s,e),s.prototype.process=function(e){var s=e.getMetaInfo(this.snCode.code());if(null!=s&&""!==s)if(this.isFeedMessage(e))if(this.sportsFeedMsgGroup.isIndicatorMessage(e.messageClass)){var t=this.processIndicatorMessage(e);this.scp.process(s,null,t)}else{var r=new MergeableIncoming(this.sportsFeedMsgGroup,e.messageClass,s,e.message,this.recycleBin);this.triggerTtlRestoreIfApplicable(r),this.scp.process(r.stream(),r)}else console.log("SportsFeedInProcessor received unknown messageclass: "+circular.stringify(e.messageClass)+". Ignoring");else console.log("SportsFeedInProcessor received messagewrapper with no StreamName. Ignoring.")},s.prototype.processIndicatorMessage=function(e){var s=this;return e.messageClass==this.sportsFeedMsgGroup.TTL_RESTORE_START()&&e.message.getPartitions().forEach(function(e){s.recycleBin.clearBin(e)}),new data_structure_1.OutgoingImpl(e.messageClass,e.message)},s.prototype.triggerTtlRestoreIfApplicable=function(e){if(null!=this.getRecycleBin()&&null!=this.getRecycleBin().getTtlConfig()&&this.getRecycleBin().getTtlConfig().isEnableTtl()){var s=this.getRecycleBin().getTtlRestoreSnapshot(e);null!=s&&this.scp.process(s.getStream(),s)}},s.prototype.triggerTtlRemove=function(){var e=this;null!=this.getRecycleBin()&&this.getRecycleBin().getTtlRemoveSnapshot().forEach(function(s){e.scp.process(s.getStream(),s)})},s.prototype.startTtlVerification=function(){var e=this;if(null!=this.getRecycleBin()){var s=this.getRecycleBin().getTtlConfig();if(null!=s&&s.isEnableTtl()){var t=s.getRunInterval();setInterval(function(){return e.triggerTtlRemove()},t),console.log("Scheduled TTLCheck with interval of "+t)}else console.log("No TTL set. Not scheduling any TTL.")}},s.prototype.isFeedMessage=function(e){var s=e.messageClass;return s instanceof message_class_1.InsertOddMessageClass||s instanceof message_class_1.UpdateOddMessageClass||s instanceof message_class_1.DeleteOddMessageClass||s instanceof message_class_1.InsertEventMessageClass||s instanceof message_class_1.UpdateEventMessageClass||s instanceof message_class_1.DeleteEventMessageClass||s instanceof message_class_1.InsertMatchMessageClass||s instanceof message_class_1.UpdateMatchMessageClass||s instanceof message_class_1.DeleteMatchMessageClass||s instanceof message_class_1.RefreshMessageClass||s instanceof message_class_1.TTLRemoveMessageClass||s instanceof message_class_1.TTLRestoreMessageClass||s instanceof message_class_1.ResetMessageClass||s instanceof message_class_1.SwitchFilterStartMessageClass||s instanceof message_class_1.SwitchFilterFailMessageClass||s==this.sportsFeedMsgGroup.SWITCH_FILTER_START()||s==this.sportsFeedMsgGroup.SWITCH_FILTER_END()||s==this.sportsFeedMsgGroup.FULLSNAPSHOT_START()||s==this.sportsFeedMsgGroup.FULLSNAPSHOT_END()||s==this.sportsFeedMsgGroup.SWITCH_FILTER_FAIL()||s==this.sportsFeedMsgGroup.TTL_RESTORE_START()||s==this.sportsFeedMsgGroup.TTL_RESTORE_END()},s.prototype.getScp=function(){return this.scp},s.prototype.getRecycleBin=function(){return this.recycleBin},s=tslib_1.__decorate([(0,injection_js_1.Injectable)(),tslib_1.__metadata("design:paramtypes",[StreamCommandProcessor,message_class_1.SportsFeedMessageGroup,D.StreamNameCode,core_1.RecycleBin])],s)}(D.IMessageGroupProcessor);exports.SportsFeedInProcessor=SportsFeedInProcessor;var MergeableIncoming=function(e){function s(s,t,r,a,o){var n=e.call(this,t,r,a)||this;return n.sportsGrp=s,n.bin=o,n}return tslib_1.__extends(s,e),s.prototype.apply=function(e){var s,t,r,a,o,n;null==e&&(e=data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT);var i=[];this.beforeSnap=e;var c=new data_structure_1.MergeableWrapper;if(this.msgType()instanceof message_class_1.InsertMatchMessageClass||this.msgType()instanceof message_class_1.InsertEventMessageClass||this.msgType()instanceof message_class_1.DeleteMatchMessageClass||this.msgType()instanceof message_class_1.DeleteEventMessageClass||this.msgType()instanceof message_class_1.UpdateEventMessageClass){var l=merge_1.SnapshotUtil.combineSnapshots(this.msgType(),this.data(),e),p=merge_1.DeltaTransformingLogicImpl.transform(this.sportsGrp,this.stream(),this.msgType(),this.data(),l);try{for(var _=tslib_1.__values(p),g=_.next();!g.done;g=_.next()){var u=g.value,m=new core_1.Delta(u,l.getAfterSs(),this.beforeSnap);i.push(m),this.beforeSnap=l.getAfterSs()}}catch(e){s={error:e}}finally{try{g&&!g.done&&(t=_.return)&&t.call(_)}finally{if(s)throw s.error}}c.setAfter(l.getAfterSs()),c.setDeltaOut(i)}else if(this.msgType()instanceof message_class_1.TTLRemoveMessageClass){var h=null,f=e,d=new Collections.Dictionary,T=[],y=!1,S=e.getPartitionMap();try{for(var E=tslib_1.__values(this.data().getPartitions().toArray()),v=E.next();!v.done;v=E.next()){var M=v.value;console.log("removing keys from upstream "+JSON.stringify(M)),S.containsKey(M)&&(y=!0,d.setValue(M,S.getValue(M)),f=(h=this.bin.removeData(new data_structure_1.TTLWrapper,f,M)).getRemainingSs(),T.push(h.getRemovedSs()))}}catch(e){r={error:e}}finally{try{v&&!v.done&&(a=E.return)&&a.call(E)}finally{if(r)throw r.error}}y?(console.log("reseting -----\x3e"+JSON.stringify(d.keys())),c=merge_1.DeltaTransformingLogicImpl.transformTTLRemove(T,this.bin.getGrp(),this.stream(),e,f,d)):(c.setDeltaOut([]),c.setAfter(e))}else if(this.msgType()instanceof message_class_1.TTLRestoreMessageClass){h=null,f=e;var D=new Collections.Dictionary,R=!1,I={},A=[];try{for(var C=tslib_1.__values(this.data().getPartitions().toArray()),F=C.next();!F.done;F=C.next()){M=F.value;if(console.log("restoring keys from upstream "+JSON.stringify(M)),this.bin.containData(M)){R=!0;var b=(new Date).getTime();D.setValue(M,b),I=this.bin.copyData(M,I),f=(h=this.bin.restoreData(new data_structure_1.TTLWrapper,f,M,b)).getRemainingSs(),A.push(h.getRestoredSs())}}}catch(e){o={error:e}}finally{try{F&&!F.done&&(n=C.return)&&n.call(C)}finally{if(o)throw o.error}}R?(console.log("restoring -----\x3e"+JSON.stringify(D.keys())),c=merge_1.DeltaTransformingLogicImpl.transformTTLRestore(A,this.bin.getGrp(),this.stream(),e,f,I,D)):(c.setAfter(e),c.setDeltaOut([]))}else{l=merge_1.SnapshotUtil.combineSnapshots(this.msgType(),this.data(),e),m=new core_1.Delta(this,l.getAfterSs(),e);i.push(m),c.setDeltaOut(i),c.setAfter(l.getAfterSs())}return c},s}(data_structure_1.Incoming);exports.MergeableIncoming=MergeableIncoming;
1
+ "use strict";var __extends=this&&this.__extends||function(){var e=function(t,s){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])},e(t,s)};return function(t,s){if("function"!=typeof s&&null!==s)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");function r(){this.constructor=t}e(t,s),t.prototype=null===s?Object.create(s):(r.prototype=s.prototype,new r)}}(),__createBinding=this&&this.__createBinding||(Object.create?function(e,t,s,r){void 0===r&&(r=s);var n=Object.getOwnPropertyDescriptor(t,s);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,r,n)}:function(e,t,s,r){void 0===r&&(r=s),e[r]=t[s]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__decorate=this&&this.__decorate||function(e,t,s,r){var n,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,s,r);else for(var i=e.length-1;i>=0;i--)(n=e[i])&&(a=(o<3?n(a):o>3?n(t,s,a):n(t,s))||a);return o>3&&a&&Object.defineProperty(t,s,a),a},__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s in e)"default"!==s&&Object.prototype.hasOwnProperty.call(e,s)&&__createBinding(t,e,s);return __setModuleDefault(t,e),t},__metadata=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},__param=this&&this.__param||function(e,t){return function(s,r){t(s,r,e)}},__values=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,s=t&&e[t],r=0;if(s)return s.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(exports,"__esModule",{value:!0}),exports.MergeableIncoming=exports.SportsFeedInProcessor=exports.StreamCommandProcessor=exports.InEndPointEventHandler=void 0;var D=__importStar(require("@jayesol/jayeson.lib.delivery")),Collections=__importStar(require("typescript-collections")),core_1=require("./core"),message_class_1=require("./message_class"),merge_1=require("./merge"),data_structure_1=require("./data_structure"),circular=require("circular-json");require("reflect-metadata");var injection_js_1=require("injection-js"),codec_1=require("./codec"),InEndPointEventHandler=function(){function e(e,t,s){this._streamSources={},this._filterData=null,this._startMessage=e,this._sportsMsgGrp=t,this._streamNameCode=s,this._exclude=e.exclude,this._wireFormat=e.wireFormat}return e.prototype.setfilterData=function(e){this._filterData=e},e.prototype.streamSources=function(){return this._streamSources},e.prototype.exclude=function(){return this._exclude},e.prototype.wireFormat=function(){return this._wireFormat},e.prototype.startMessage=function(){return this._startMessage},e.prototype.sportsMsgGrp=function(){return this._sportsMsgGrp},e.prototype.streamNameCode=function(){return this._streamNameCode},e.prototype.filterData=function(){return this._filterData},e.prototype.onEvent=function(e){if(e instanceof D.Subscriber.Event.ConsumptionStart){for(var t in e.streams)if(e.streams.hasOwnProperty(t))for(var s=0;s<e.streams[t].length;s++){if(parseInt(t)==this.sportsMsgGrp().id()){var r=e.streams[t][s];this._streamSources[r]=e.endPoint;var n=new codec_1.FilterRequest(codec_1.FilterRequest.IGNORED_REQUEST_ID,this.filterData());this.sendFilter(n,r),console.log("Sending Start Message to stream : '"+r+"'");var o=new D.MessageWrapper(this._startMessage,this._sportsMsgGrp.ADMIN_START_SUBSCRIBE_FEED());this.sendMessage(r,o)}}}else if(e instanceof D.Subscriber.Event.ConsumptionError){var a=e.client.config.url+" has errors on consumption: ";for(var t in e.streams)if(e.streams.hasOwnProperty(t)){a+="\n"+t+":[";for(s=0;s<e.streams[t].length;s++)a+=e.streams[t][s]+",";a=a.substring(1,a.length-1),a+="]"}console.log(a)}else console.log("Unidentified event received by onEvent: "+circular.stringify(e))},e.prototype.sendMessage=function(e,t){t.addMetaInfo(this._streamNameCode.code(),e);var s=this._streamSources[e];null==s?console.log("No Endpoint present corresponding to stream '"+e+"'. Unable to send message"):s.send(t)},e.prototype.updateFilter=function(e){this._filterData=e.getFilterData(),this.sendFilter(e)},e.prototype.sendFilter=function(e,t){if(void 0===t&&(t=null),null!==t)this._sendFilter(e,t);else for(var s in this._streamSources)this._streamSources.hasOwnProperty(s)&&this._sendFilter(e,s)},e.prototype._sendFilter=function(e,t){var s=e.getFilterData(),r=null;null!=s?(r=new D.MessageWrapper(e,this._sportsMsgGrp.FILTER_SET()),console.log("Sending FILTER_SET to stream: '"+t+"' with filter data: "+JSON.stringify(s))):(r=new D.MessageWrapper(e.getRequestId().toString(),this._sportsMsgGrp.FILTER_REMOVE()),console.log("Sending FILTER_REMOVE to stream: '"+t+"'")),this.sendMessage(t,r)},e=__decorate([(0,injection_js_1.Injectable)(),__metadata("design:paramtypes",[message_class_1.StartSubscribeFeed,message_class_1.SportsFeedMessageGroup,D.StreamNameCode])],e)}();exports.InEndPointEventHandler=InEndPointEventHandler;var StreamCommandProcessor=function(){function e(e,t){this._fsRepo=e,this._sportsGrp=t,this.messageClassName={0:"DATA_RESET",1:"DATA_INSERT_ODD",2:"DATA_UPDATE_ODD",3:"DATA_DELETE_ODD",4:"DATA_INSERT_EVENT",5:"DATA_UPDATE_EVENT",6:"DATA_DELETE_EVENT",7:"DATA_INSERT_MATCH",8:"DATA_UPDATE_MATCH",9:"DATA_DELETE_MATCH",10:"TTL_REMOVE",11:"TTL_RESTORE",13:"FILTER_REMOVE",14:"FILTER_SET",16:"ADMIN_START_SUBSCRIBE_FEED",17:"ADMIN_REFRESH"}}return e.prototype.process=function(e,t,s){var r,n;if(void 0===s&&(s=null),null!=t&&t instanceof data_structure_1.Incoming){var o=t,a=this.messageClassName[o.msgType().id()];console.debug("SCP processing: "+a)}if(null==s){var i=this._fsRepo.appendSnapshot(e,t);try{for(var c=__values(i),l=c.next();!l.done;l=c.next()){var p=l.value;this._fsRepo.push(p)}}catch(e){r={error:e}}finally{try{l&&!l.done&&(n=c.return)&&n.call(c)}finally{if(r)throw r.error}}}else this._fsRepo.push(s)},e.prototype.fsRepo=function(){return this._fsRepo},e.prototype.sportsGrp=function(){return this._sportsGrp},e.prototype.printMessage=function(e){var t=this.getClassName(e),s=e.delta();switch(this.printPartitionKeys(t,s),e.msgType().id()){case this._sportsGrp.DATA_INSERT_MATCH().id():case this._sportsGrp.DATA_UPDATE_MATCH().id():case this._sportsGrp.DATA_DELETE_MATCH().id():this.printMatch(t,s);break;case this._sportsGrp.DATA_INSERT_ODD().id():case this._sportsGrp.DATA_UPDATE_ODD().id():case this._sportsGrp.DATA_DELETE_ODD().id():this.printRecord(t,s)}},e.prototype.getClassName=function(e){return e instanceof core_1.TTLOutgoing?e.getTtlType()==core_1.TTLType.REMOVE?"TTL_REM":"TTL_RES":this.messageClassName[e.msgType().id()]},e.prototype.printMatch=function(e,t){for(var s=t.matches(),r=0;r<s.length;r++)console.log("[".concat(e,"] ").concat(s[r].id()))},e.prototype.printRecord=function(e,t){for(var s=t.matches(),r=0;r<s.length;r++)for(var n=s[r].events(),o=0;o<n.length;o++)for(var a=n[o].records(),i=0;i<a.length;i++){var c=a[i];console.log("[".concat(e,"] ").concat(c.matchId(),"_").concat(c.eventId(),"_").concat(c.id(),"_").concat(c.source(),"_").concat(c.oddType(),"_").concat(c.oddFormat()))}},e.prototype.printPartitionKeys=function(e,t){var s=t.getPartitions().toString();console.log("[".concat(e,"][PK]").concat(s))},e=__decorate([(0,injection_js_1.Injectable)(),__param(0,(0,injection_js_1.Inject)(core_1.FSREPO_IMPL)),__metadata("design:paramtypes",[Object,message_class_1.SportsFeedMessageGroup])],e)}();exports.StreamCommandProcessor=StreamCommandProcessor;var SportsFeedInProcessor=function(e){function t(t,s,r,n){var o=e.call(this,s)||this;return o.scp=t,o.sportsFeedMsgGroup=s,o.snCode=r,o.recycleBin=n,o}return __extends(t,e),t.prototype.process=function(e){var t=e.getMetaInfo(this.snCode.code());if(null!=t&&""!==t)if(this.isFeedMessage(e))if(this.sportsFeedMsgGroup.isIndicatorMessage(e.messageClass)){var s=this.processIndicatorMessage(e);this.scp.process(t,null,s)}else{var r=new MergeableIncoming(this.sportsFeedMsgGroup,e.messageClass,t,e.message,this.recycleBin);this.triggerTtlRestoreIfApplicable(r),this.scp.process(r.stream(),r)}else console.log("SportsFeedInProcessor received unknown messageclass: "+circular.stringify(e.messageClass)+". Ignoring");else console.log("SportsFeedInProcessor received messagewrapper with no StreamName. Ignoring.")},t.prototype.processIndicatorMessage=function(e){var t=this;return e.messageClass==this.sportsFeedMsgGroup.TTL_RESTORE_START()&&e.message.getPartitions().forEach(function(e){t.recycleBin.clearBin(e)}),new data_structure_1.OutgoingImpl(e.messageClass,e.message)},t.prototype.triggerTtlRestoreIfApplicable=function(e){if(null!=this.getRecycleBin()&&null!=this.getRecycleBin().getTtlConfig()&&this.getRecycleBin().getTtlConfig().isEnableTtl()){var t=this.getRecycleBin().getTtlRestoreSnapshot(e);null!=t&&this.scp.process(t.getStream(),t)}},t.prototype.triggerTtlRemove=function(){var e=this;null!=this.getRecycleBin()&&this.getRecycleBin().getTtlRemoveSnapshot().forEach(function(t){e.scp.process(t.getStream(),t)})},t.prototype.startTtlVerification=function(){var e=this;if(null!=this.getRecycleBin()){var t=this.getRecycleBin().getTtlConfig();if(null!=t&&t.isEnableTtl()){var s=t.getRunInterval();setInterval(function(){return e.triggerTtlRemove()},s),console.log("Scheduled TTLCheck with interval of "+s)}else console.log("No TTL set. Not scheduling any TTL.")}},t.prototype.isFeedMessage=function(e){var t=e.messageClass;return t instanceof message_class_1.InsertOddMessageClass||t instanceof message_class_1.UpdateOddMessageClass||t instanceof message_class_1.DeleteOddMessageClass||t instanceof message_class_1.InsertEventMessageClass||t instanceof message_class_1.UpdateEventMessageClass||t instanceof message_class_1.DeleteEventMessageClass||t instanceof message_class_1.InsertMatchMessageClass||t instanceof message_class_1.UpdateMatchMessageClass||t instanceof message_class_1.DeleteMatchMessageClass||t instanceof message_class_1.RefreshMessageClass||t instanceof message_class_1.TTLRemoveMessageClass||t instanceof message_class_1.TTLRestoreMessageClass||t instanceof message_class_1.ResetMessageClass||t instanceof message_class_1.SwitchFilterStartMessageClass||t instanceof message_class_1.SwitchFilterFailMessageClass||t==this.sportsFeedMsgGroup.SWITCH_FILTER_START()||t==this.sportsFeedMsgGroup.SWITCH_FILTER_END()||t==this.sportsFeedMsgGroup.FULLSNAPSHOT_START()||t==this.sportsFeedMsgGroup.FULLSNAPSHOT_END()||t==this.sportsFeedMsgGroup.SWITCH_FILTER_FAIL()||t==this.sportsFeedMsgGroup.TTL_RESTORE_START()||t==this.sportsFeedMsgGroup.TTL_RESTORE_END()},t.prototype.getScp=function(){return this.scp},t.prototype.getRecycleBin=function(){return this.recycleBin},t=__decorate([(0,injection_js_1.Injectable)(),__metadata("design:paramtypes",[StreamCommandProcessor,message_class_1.SportsFeedMessageGroup,D.StreamNameCode,core_1.RecycleBin])],t)}(D.IMessageGroupProcessor);exports.SportsFeedInProcessor=SportsFeedInProcessor;var MergeableIncoming=function(e){function t(t,s,r,n,o){var a=e.call(this,s,r,n)||this;return a.sportsGrp=t,a.bin=o,a}return __extends(t,e),t.prototype.apply=function(e){var t,s,r,n,o,a;null==e&&(e=data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT);var i=[];this.beforeSnap=e;var c=new data_structure_1.MergeableWrapper;if(this.msgType()instanceof message_class_1.InsertMatchMessageClass||this.msgType()instanceof message_class_1.InsertEventMessageClass||this.msgType()instanceof message_class_1.DeleteMatchMessageClass||this.msgType()instanceof message_class_1.DeleteEventMessageClass||this.msgType()instanceof message_class_1.UpdateEventMessageClass){var l=merge_1.SnapshotUtil.combineSnapshots(this.msgType(),this.data(),e),p=merge_1.DeltaTransformingLogicImpl.transform(this.sportsGrp,this.stream(),this.msgType(),this.data(),l);try{for(var _=__values(p),g=_.next();!g.done;g=_.next()){var u=g.value,f=new core_1.Delta(u,l.getAfterSs(),this.beforeSnap);i.push(f),this.beforeSnap=l.getAfterSs()}}catch(e){t={error:e}}finally{try{g&&!g.done&&(s=_.return)&&s.call(_)}finally{if(t)throw t.error}}c.setAfter(l.getAfterSs()),c.setDeltaOut(i)}else if(this.msgType()instanceof message_class_1.TTLRemoveMessageClass){var h=null,d=e,m=new Collections.Dictionary,T=[],y=!1,v=e.getPartitionMap();try{for(var S=__values(this.data().getPartitions().toArray()),E=S.next();!E.done;E=S.next()){var M=E.value;console.log("removing keys from upstream "+JSON.stringify(M)),v.containsKey(M)&&(y=!0,m.setValue(M,v.getValue(M)),d=(h=this.bin.removeData(new data_structure_1.TTLWrapper,d,M)).getRemainingSs(),T.push(h.getRemovedSs()))}}catch(e){r={error:e}}finally{try{E&&!E.done&&(n=S.return)&&n.call(S)}finally{if(r)throw r.error}}y?(console.log("reseting -----\x3e"+JSON.stringify(m.keys())),c=merge_1.DeltaTransformingLogicImpl.transformTTLRemove(T,this.bin.getGrp(),this.stream(),e,d,m)):(c.setDeltaOut([]),c.setAfter(e))}else if(this.msgType()instanceof message_class_1.TTLRestoreMessageClass){h=null,d=e;var D=new Collections.Dictionary,R=!1,I={},A=[];try{for(var C=__values(this.data().getPartitions().toArray()),b=C.next();!b.done;b=C.next()){M=b.value;if(console.log("restoring keys from upstream "+JSON.stringify(M)),this.bin.containData(M)){R=!0;var F=(new Date).getTime();D.setValue(M,F),I=this.bin.copyData(M,I),d=(h=this.bin.restoreData(new data_structure_1.TTLWrapper,d,M,F)).getRemainingSs(),A.push(h.getRestoredSs())}}}catch(e){o={error:e}}finally{try{b&&!b.done&&(a=C.return)&&a.call(C)}finally{if(o)throw o.error}}R?(console.log("restoring -----\x3e"+JSON.stringify(D.keys())),c=merge_1.DeltaTransformingLogicImpl.transformTTLRestore(A,this.bin.getGrp(),this.stream(),e,d,I,D)):(c.setAfter(e),c.setDeltaOut([]))}else{l=merge_1.SnapshotUtil.combineSnapshots(this.msgType(),this.data(),e),f=new core_1.Delta(this,l.getAfterSs(),e);i.push(f),c.setDeltaOut(i),c.setAfter(l.getAfterSs())}return c},t}(data_structure_1.Incoming);exports.MergeableIncoming=MergeableIncoming;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SoccerCodec=void 0;var tslib_1=require("tslib"),rec=tslib_1.__importStar(require("@jayesol/jayeson.lib.record")),proto=tslib_1.__importStar(require("./protobuf_bundle")),codec_1=require("./codec"),SoccerCodec=function(){function e(){this.codecHelper=new codec_1.CodecHelper}return e.prototype.getMatch=function(e,t,r,c,o,n,a,l,i,p){return new rec.SoccerMatchImpl(r,c,o,t,e,n,p,i,a,l)},e.prototype.getEvent=function(e,t,r,c,o,n){return new rec.SoccerEventImpl(e,t,r,c,o,n)},e.prototype.decodeMatch=function(e,t,r,c){var o=this,n=[];return e.forEach(function(e){var r=t[e.id],a={};null!=e.metaInfo&&(a=e.metaInfo);var l=t[e.participants[0]],i=t[e.participants[1]],p=o.codecHelper.coerceInt64(e.startTime),u=t[e.league],s=rec.SoccerGender[e.soccerMatch.gender.toString()],d=t[e.country],v=rec.LeagueType[e.soccerMatch.leagueType.toString()];a=o.codecHelper.populatePKIntoMetaInfo(a,c);var S=o.getMatch(r,[],l,i,p,u,s,d,v,a);n.push(S)}),n},e.prototype.decodeEvent=function(e,t,r,c){var o=this,n=[];return e.forEach(function(e){var a,l=t[e.id],i=[],p=null;switch(proto.SoccerEvent.Type[e.eventType.soccerEventType]){case"NONE":p=rec.SoccerEventType.NONE;break;case"NEXT_CORNER":p=rec.SoccerEventType.NEXT_CORNER;break;case"TOTAL_CORNER":p=rec.SoccerEventType.TOTAL_CORNER;break;case"BOOKING":p=rec.SoccerEventType.BOOKING;break;case"UNCATEGORIZED_SPECIAL":p=rec.SoccerEventType.UNCATEGORIZED_SPECIAL}a=e.metaInfo;var u=t[e.matchId],s=o.decodeState(u,l,e.state,t,r,c);i.push(s);var d=o.getEvent(l,[],i,u,p,a),v=o.getMatch(t[e.matchId],[d],null,null,0,null,null,null,null,null);n.push(v)}),n},e.prototype.decodeRecord=function(e,t,r,c){var o=this,n=[],a={};for(var l in e.forEach(function(e){var r=o.codecHelper.coerceInt64(e.id),c=null,n=t[e.source],l=t[e.matchId],i=t[e.eventId],p=rec.OddType[e.oddType.toString()],u=rec.LBType[e.lbType.toString()],s=e.timeType.soccerTimeType;switch(proto.SoccerTimeType.SettleOn[s.settle.toString()]){case"FT":c=rec.SoccerTimeType.FT;break;case"HT":c=rec.SoccerTimeType.HT}var d=rec.OddFormat[e.format.toString()],v=e.metaInfo,S=o.codecHelper.formatRate(e.rates[0]),T=o.codecHelper.formatRate(e.rates[1]),E=o.codecHelper.formatRate(e.rates[2]),y=e.pivotValue,h=rec.PivotBias[e.pivotBias.toString()],f=rec.PivotType[e.pivotType.toString()],g=t[e.rateIds[0]],m=t[e.rateIds[1]],I=t[e.rateIds[2]],O=new rec.SoccerRecord(l,i,r,p,u,c,n,d,v,S,T,E,y,f,h,g,m,I,!1);void 0===a[l]&&(a[l]={}),void 0===a[l][i]&&(a[l][i]=[]),a[l][i].push(O)}),a){var i=a[l],p=[];for(var u in i){var s=this.getEvent(u,i[u],null,l,null,null);p.push(s)}var d=this.getMatch(l,p,null,null,0,null,null,null,null,null);n.push(d)}return n},e.prototype.decodeState=function(e,t,r,c,o,n,a){void 0===a&&(a=Date.now());var l=r.participantStats[0].scores[0],i=r.participantStats[0].scores[1],p=r.participantStats[1].scores[0],u=r.participantStats[1].scores[1],s=r.duration,d=rec.SoccerSegment[r.soccerEventState.segment.toString()],v=r.soccerEventState.bookPriority,S=new rec.SoccerEventState(s,n,e,t,a,l,p,i,u,d,v),T=this.getEvent(t,null,[S],e,null,{});this.getMatch(e,[T],null,null,0,null,null,null,null,{});return new rec.SoccerEventState(s,n,e,t,a,l,p,i,u,d,v)},e}();exports.SoccerCodec=SoccerCodec;
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,r,c){void 0===c&&(c=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,c,o)}:function(e,t,r,c){void 0===c&&(c=r),e[c]=t[r]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&__createBinding(t,e,r);return __setModuleDefault(t,e),t};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SoccerCodec=void 0;var rec=__importStar(require("@jayesol/jayeson.lib.record")),proto=__importStar(require("./protobuf_bundle")),codec_1=require("./codec"),SoccerCodec=function(){function e(){this.codecHelper=new codec_1.CodecHelper}return e.prototype.getMatch=function(e,t,r,c,o,n,a,i,l,u){return new rec.SoccerMatchImpl(r,c,o,t,e,n,u,l,a,i)},e.prototype.getEvent=function(e,t,r,c,o,n){return new rec.SoccerEventImpl(e,t,r,c,o,n)},e.prototype.decodeMatch=function(e,t,r,c){var o=this,n=[];return e.forEach(function(e){var r=t[e.id],a={};null!=e.metaInfo&&(a=e.metaInfo);var i=t[e.participants[0]],l=t[e.participants[1]],u=o.codecHelper.coerceInt64(e.startTime),p=t[e.league],s=rec.SoccerGender[e.soccerMatch.gender.toString()],d=t[e.country],v=rec.LeagueType[e.soccerMatch.leagueType.toString()];a=o.codecHelper.populatePKIntoMetaInfo(a,c);var S=o.getMatch(r,[],i,l,u,p,s,d,v,a);n.push(S)}),n},e.prototype.decodeEvent=function(e,t,r,c){var o=this,n=[];return e.forEach(function(e){var a,i=t[e.id],l=[],u=null;switch(proto.SoccerEvent.Type[e.eventType.soccerEventType]){case"NONE":u=rec.SoccerEventType.NONE;break;case"NEXT_CORNER":u=rec.SoccerEventType.NEXT_CORNER;break;case"TOTAL_CORNER":u=rec.SoccerEventType.TOTAL_CORNER;break;case"BOOKING":u=rec.SoccerEventType.BOOKING;break;case"UNCATEGORIZED_SPECIAL":u=rec.SoccerEventType.UNCATEGORIZED_SPECIAL}a=e.metaInfo;var p=t[e.matchId],s=o.decodeState(p,i,e.state,t,r,c);l.push(s);var d=o.getEvent(i,[],l,p,u,a),v=o.getMatch(t[e.matchId],[d],null,null,0,null,null,null,null,null);n.push(v)}),n},e.prototype.decodeRecord=function(e,t,r,c){var o=this,n=[],a={};for(var i in e.forEach(function(e){var r=o.codecHelper.coerceInt64(e.id),c=null,n=t[e.source],i=t[e.matchId],l=t[e.eventId],u=rec.OddType[e.oddType.toString()],p=rec.LBType[e.lbType.toString()],s=e.timeType.soccerTimeType;switch(proto.SoccerTimeType.SettleOn[s.settle.toString()]){case"FT":c=rec.SoccerTimeType.FT;break;case"HT":c=rec.SoccerTimeType.HT}var d=rec.OddFormat[e.format.toString()],v=e.metaInfo,S=o.codecHelper.formatRate(e.rates[0]),f=o.codecHelper.formatRate(e.rates[1]),h=o.codecHelper.formatRate(e.rates[2]),T=e.pivotValue,y=rec.PivotBias[e.pivotBias.toString()],_=rec.PivotType[e.pivotType.toString()],E=t[e.rateIds[0]],g=t[e.rateIds[1]],m=t[e.rateIds[2]],O=new rec.SoccerRecord(i,l,r,u,p,c,n,d,v,S,f,h,T,_,y,E,g,m,!1);void 0===a[i]&&(a[i]={}),void 0===a[i][l]&&(a[i][l]=[]),a[i][l].push(O)}),a){var l=a[i],u=[];for(var p in l){var s=this.getEvent(p,l[p],null,i,null,null);u.push(s)}var d=this.getMatch(i,u,null,null,0,null,null,null,null,null);n.push(d)}return n},e.prototype.decodeState=function(e,t,r,c,o,n,a){void 0===a&&(a=Date.now());var i=r.participantStats[0].scores[0],l=r.participantStats[0].scores[1],u=r.participantStats[1].scores[0],p=r.participantStats[1].scores[1],s=r.duration,d=rec.SoccerSegment[r.soccerEventState.segment.toString()],v=r.soccerEventState.bookPriority,S=new rec.SoccerEventState(s,n,e,t,a,i,u,l,p,d,v),f=this.getEvent(t,null,[S],e,null,{});this.getMatch(e,[f],null,null,0,null,null,null,null,{});return new rec.SoccerEventState(s,n,e,t,a,i,u,l,p,d,v)},e}();exports.SoccerCodec=SoccerCodec;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TennisCodec=void 0;var tslib_1=require("tslib"),rec=tslib_1.__importStar(require("@jayesol/jayeson.lib.record")),proto=tslib_1.__importStar(require("./protobuf_bundle")),codec_1=require("./codec"),TennisCodec=function(){function e(){this.codecHelper=new codec_1.CodecHelper}return e.prototype.getMatch=function(e,t,n,r,o,a,c,i,s){return new rec.TennisMatchImpl(n,r,o,t,e,a,c,i,s)},e.prototype.getEvent=function(e,t,n,r,o,a){return new rec.TennisEventImpl(e,t,n,r,o,a)},e.prototype.decodeMatch=function(e,t,n,r){var o=this,a=[];return e.forEach(function(e){var n=t[e.id],c=t[e.participants[0]],i=t[e.participants[1]],s=o.codecHelper.coerceInt64(e.startTime),p=t[e.league],l=rec.TennisGender[e.tennisMatch.gender.toString()],u=e.metaInfo,d=t[e.country];u=o.codecHelper.populatePKIntoMetaInfo(u,r);var v=o.getMatch(n,[],c,i,s,p,l,d,u);a.push(v)}),a},e.prototype.decodeEvent=function(e,t,n,r){var o=this,a=[],c={};for(var i in e.forEach(function(e){var a,i=t[e.id],s=null;switch(proto.TennisEvent.Type[e.eventType.tennisEventType]){case"NONE":s=rec.TennisEventType.NONE;break;case"GAME":s=rec.TennisEventType.GAME;break;case"SET":s=rec.TennisEventType.SET;break;case"POINT":s=rec.TennisEventType.POINT;break;case"HOME_GAME":s=rec.TennisEventType.HOME_GAME;break;case"AWAY_GAME":s=rec.TennisEventType.AWAY_GAME}a=e.metaInfo;var p=[];null!=e.state&&p.push(o.decodeState(t[e.matchId],i,e.state,t,n,r));var l=t[e.matchId],u=o.getEvent(i,[],p,l,s,a);void 0===c[l]&&(c[l]=[]),c[l].push(u)}),c){var s=this.getMatch(i,c[i],null,null,0,null,null,null,null);a.push(s)}return a},e.prototype.decodeRecord=function(e,t,n,r){var o=this,a=[],c={};for(var i in e.forEach(function(e){var n=o.codecHelper.coerceInt64(e.id),r=t[e.source],a=t[e.matchId],i=t[e.eventId],s=rec.OddType[e.oddType.toString()],p=rec.LBType[e.lbType.toString()],l=e.timeType.tennisTimeType,u=new rec.TennisTimeType(l.match,l.set,l.game),d=rec.OddFormat[e.format.toString()],v=e.metaInfo,T=o.codecHelper.formatRate(e.rates[0]),h=o.codecHelper.formatRate(e.rates[1]),E=o.codecHelper.formatRate(e.rates[2]),f=e.pivotValue,y=rec.PivotBias[e.pivotBias.toString()],m=rec.PivotType[e.pivotType.toString()],g=t[e.rateIds[0]],S=t[e.rateIds[1]],I=t[e.rateIds[2]],M=new rec.TennisRecord(a,i,n,s,p,u,r,d,v,T,h,E,f,m,y,g,S,I,!1);void 0===c[a]&&(c[a]={}),void 0===c[a][i]&&(c[a][i]=[]),c[a][i].push(M)}),c){var s=c[i],p=[];for(var l in s){var u=this.getEvent(l,s[l],null,i,null,null);p.push(u)}var d=this.getMatch(i,p,null,null,0,null,null,null,null);a.push(d)}return a},e.prototype.decodeState=function(e,t,n,r,o,a,c){void 0===c&&(c=Date.now());var i=n.participantStats[0].scores,s=n.participantStats[1].scores;if(i.length<10)for(var p=i.length,l=0;p+l<10;l++)i.push(-1);if(s.length<10){var u=s.length;for(l=0;u+l<10;l++)s.push(-1)}var d=new rec.TennisStats(i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8],i[9]),v=new rec.TennisStats(s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],s[9]),T=n.duration,h=n.tennisEventState.set,E=n.tennisEventState.game,f=n.tennisEventState.bookPriority;return new rec.TennisEventState(d,v,T,a,e,t,f,c,h,E)},e}();exports.TennisCodec=TennisCodec;
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&__createBinding(t,e,n);return __setModuleDefault(t,e),t};Object.defineProperty(exports,"__esModule",{value:!0}),exports.TennisCodec=void 0;var rec=__importStar(require("@jayesol/jayeson.lib.record")),proto=__importStar(require("./protobuf_bundle")),codec_1=require("./codec"),TennisCodec=function(){function e(){this.codecHelper=new codec_1.CodecHelper}return e.prototype.getMatch=function(e,t,n,r,o,i,a,c,s){return new rec.TennisMatchImpl(n,r,o,t,e,i,a,c,s)},e.prototype.getEvent=function(e,t,n,r,o,i){return new rec.TennisEventImpl(e,t,n,r,o,i)},e.prototype.decodeMatch=function(e,t,n,r){var o=this,i=[];return e.forEach(function(e){var n=t[e.id],a=t[e.participants[0]],c=t[e.participants[1]],s=o.codecHelper.coerceInt64(e.startTime),u=t[e.league],p=rec.TennisGender[e.tennisMatch.gender.toString()],l=e.metaInfo,d=t[e.country];l=o.codecHelper.populatePKIntoMetaInfo(l,r);var v=o.getMatch(n,[],a,c,s,u,p,d,l);i.push(v)}),i},e.prototype.decodeEvent=function(e,t,n,r){var o=this,i=[],a={};for(var c in e.forEach(function(e){var i,c=t[e.id],s=null;switch(proto.TennisEvent.Type[e.eventType.tennisEventType]){case"NONE":s=rec.TennisEventType.NONE;break;case"GAME":s=rec.TennisEventType.GAME;break;case"SET":s=rec.TennisEventType.SET;break;case"POINT":s=rec.TennisEventType.POINT;break;case"HOME_GAME":s=rec.TennisEventType.HOME_GAME;break;case"AWAY_GAME":s=rec.TennisEventType.AWAY_GAME}i=e.metaInfo;var u=[];null!=e.state&&u.push(o.decodeState(t[e.matchId],c,e.state,t,n,r));var p=t[e.matchId],l=o.getEvent(c,[],u,p,s,i);void 0===a[p]&&(a[p]=[]),a[p].push(l)}),a){var s=this.getMatch(c,a[c],null,null,0,null,null,null,null);i.push(s)}return i},e.prototype.decodeRecord=function(e,t,n,r){var o=this,i=[],a={};for(var c in e.forEach(function(e){var n=o.codecHelper.coerceInt64(e.id),r=t[e.source],i=t[e.matchId],c=t[e.eventId],s=rec.OddType[e.oddType.toString()],u=rec.LBType[e.lbType.toString()],p=e.timeType.tennisTimeType,l=new rec.TennisTimeType(p.match,p.set,p.game),d=rec.OddFormat[e.format.toString()],v=e.metaInfo,f=o.codecHelper.formatRate(e.rates[0]),T=o.codecHelper.formatRate(e.rates[1]),h=o.codecHelper.formatRate(e.rates[2]),y=e.pivotValue,_=rec.PivotBias[e.pivotBias.toString()],E=rec.PivotType[e.pivotType.toString()],g=t[e.rateIds[0]],m=t[e.rateIds[1]],M=t[e.rateIds[2]],S=new rec.TennisRecord(i,c,n,s,u,l,r,d,v,f,T,h,y,E,_,g,m,M,!1);void 0===a[i]&&(a[i]={}),void 0===a[i][c]&&(a[i][c]=[]),a[i][c].push(S)}),a){var s=a[c],u=[];for(var p in s){var l=this.getEvent(p,s[p],null,c,null,null);u.push(l)}var d=this.getMatch(c,u,null,null,0,null,null,null,null);i.push(d)}return i},e.prototype.decodeState=function(e,t,n,r,o,i,a){void 0===a&&(a=Date.now());var c=n.participantStats[0].scores,s=n.participantStats[1].scores;if(c.length<10)for(var u=c.length,p=0;u+p<10;p++)c.push(-1);if(s.length<10){var l=s.length;for(p=0;l+p<10;p++)s.push(-1)}var d=new rec.TennisStats(c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7],c[8],c[9]),v=new rec.TennisStats(s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],s[9]),f=n.duration,T=n.tennisEventState.set,h=n.tennisEventState.game,y=n.tennisEventState.bookPriority;return new rec.TennisEventState(d,v,f,i,e,t,y,a,T,h)},e}();exports.TennisCodec=TennisCodec;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayesol/jayeson.lib.sports",
3
- "version": "2.2.7-beta5",
3
+ "version": "2.2.7-beta6",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {