@jayesol/jayeson.lib.sports 2.2.4 → 2.2.5-beta.1205v2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +113 -77
- package/package.json +49 -57
- package/lib/basketball_codec.d.ts +0 -11
- package/lib/basketball_codec.js +0 -1
- package/lib/client.d.ts +0 -202
- package/lib/client.js +0 -1
- package/lib/codec.d.ts +0 -57
- package/lib/codec.js +0 -1
- package/lib/core.d.ts +0 -159
- package/lib/core.js +0 -1
- package/lib/data_structure.d.ts +0 -113
- package/lib/data_structure.js +0 -1
- package/lib/dispatch.d.ts +0 -126
- package/lib/dispatch.js +0 -1
- package/lib/index.d.ts +0 -11
- package/lib/index.js +0 -1
- package/lib/merge.d.ts +0 -33
- package/lib/merge.js +0 -1
- package/lib/message_class.d.ts +0 -152
- package/lib/message_class.js +0 -1
- package/lib/module.d.ts +0 -3
- package/lib/module.js +0 -1
- package/lib/mutable.d.ts +0 -118
- package/lib/mutable.js +0 -1
- package/lib/protobuf_bundle.d.ts +0 -3398
- package/lib/protobuf_bundle.js +0 -1
- package/lib/receive.d.ts +0 -88
- package/lib/receive.js +0 -1
- package/lib/soccer_codec.d.ts +0 -13
- package/lib/soccer_codec.js +0 -1
- package/lib/tennis_codec.d.ts +0 -13
- package/lib/tennis_codec.js +0 -1
package/README.md
CHANGED
|
@@ -1,77 +1,113 @@
|
|
|
1
|
-
###
|
|
2
|
-
|
|
3
|
-
#### Packaging Structure
|
|
4
|
-
- Packages are classified into **"levels"**; **each vertical is a level. Veiwed from left to right**
|
|
5
|
-
- Arrows define dependency. E:g A -> B means A depend on B
|
|
6
|
-
- Any class can only depend on classes within it's package or classes from packages in previous levels
|
|
7
|
-
- There cannot be any dependency among packages of same level
|
|
8
|
-
|
|
9
|
-
#### Package-Info
|
|
10
|
-
- `jayeson.lib.sports.protobuf` - Classes generated by protobuf
|
|
11
|
-
- `jayeson.lib.sports.datastructure` - Core datastructure used across all classes
|
|
12
|
-
- `jayeson.lib.sports.filter` - Abstractions around IDataFilter combined with sport's datastructure
|
|
13
|
-
- `jayeson.lib.sports.mutable` - Provide Mutable builder's for jayeson.lib.record's datastructure
|
|
14
|
-
- `jayeson.lib.sports.util` - Static utility functions
|
|
15
|
-
- `jayeson.lib.sports.codec` - Definition of various message classes and logic to serialize data structure to Protibuf and vice versa
|
|
16
|
-
- `jayeson.lib.sports.core` - Core components used across whole library
|
|
17
|
-
- `jayeson.lib.sports.receive` - Implementation of logic to receive data from upstream
|
|
18
|
-
- `jayeson.lib.sports.receive.memory` - Implementation of logic to receive data in memory(E:g Bot)
|
|
19
|
-
- `jayeson.lib.sports.dispatch` - Abstractions for pushing received data downstream
|
|
20
|
-
- `jayeson.lib.sports.dispatch.relayer` - Abstratction to push data without any post-processing
|
|
21
|
-
- `jayeson.lib.sports.dispatch.
|
|
22
|
-
- `jayeson.lib.sports.dispatch.network` - Abstraction and logic to push data via network
|
|
23
|
-
- `jayeson.lib.sports.client` - Abstrations for end under to consume data
|
|
24
|
-
- `jayesib.lib.sports.module` - Various module bindings
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
+-------------------------------------------------------------------------------+
|
|
31
|
-
| |
|
|
32
|
-
| +-------------+ |
|
|
33
|
-
| | client +---------------------+ v
|
|
34
|
-
| +-------------+ | +-----------+
|
|
35
|
-
| +----+ | | filter +----------------+
|
|
36
|
-
| +---------------------+ | | | +-----------+ |
|
|
37
|
-
+--+ dispatch.
|
|
38
|
-
+---------------------+ +-------------+ +----------+ +-----------------+
|
|
39
|
-
+->| dispatch +---->| core +----+ +-----------+ | datastructure |
|
|
40
|
-
+--------------------+ | +-------------+ +----------+ |---->| mutable | +-----------------+
|
|
41
|
-
| dispatch.network +---+ | ^ ^ | +-----------+ ^
|
|
42
|
-
+--------------------+ | | | | | |
|
|
43
|
-
+--+ | | | +------------+
|
|
44
|
-
+-----------------+ +------------------+ | | | +-----------+ |
|
|
45
|
-
| | | dispatch.relayer +-------------------+ | |---->| util +-----+---+
|
|
46
|
-
| Module | +------------------+ | | +-----------+ | | +-----------------+
|
|
47
|
-
+-----------------+ | | | +-->| protobuf |
|
|
48
|
-
| | | +-----------------+
|
|
49
|
-
+-----------------+ +-------------+ | | +-----------+ |
|
|
50
|
-
| receive.memory +----------->| receive +------------> +---->| codec +-----+
|
|
51
|
-
+-----------------+ +-------------+ +-----------+
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
#### Message
|
|
55
|
-
|
|
56
|
-
Picture show how message gets
|
|
57
|
-
|
|
58
|
-

|
|
68
|
-
|
|
69
|
-
- Publish for non prod repo:
|
|
70
|
-
```
|
|
71
|
-
publish: snapshot
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
- Publish for production repo:
|
|
75
|
-
```
|
|
76
|
-
publish: prod
|
|
77
|
-
```
|
|
1
|
+
### Sportrelayereed
|
|
2
|
+
|
|
3
|
+
#### Packaging Structure
|
|
4
|
+
- Packages are classified into **"levels"**; **each vertical is a level. Veiwed from left to right**
|
|
5
|
+
- Arrows define dependency. E:g A -> B means A depend on B
|
|
6
|
+
- Any class can only depend on classes within it's package or classes from packages in previous levels
|
|
7
|
+
- There cannot be any dependency among packages of same level
|
|
8
|
+
|
|
9
|
+
#### Package-Info
|
|
10
|
+
- `jayeson.lib.sports.protobuf` - Classes generated by protobuf
|
|
11
|
+
- `jayeson.lib.sports.datastructure` - Core datastructure used across all classes
|
|
12
|
+
- `jayeson.lib.sports.filter` - Abstractions around IDataFilter combined with sport's datastructure
|
|
13
|
+
- `jayeson.lib.sports.mutable` - Provide Mutable builder's for jayeson.lib.record's datastructure
|
|
14
|
+
- `jayeson.lib.sports.util` - Static utility functions
|
|
15
|
+
- `jayeson.lib.sports.codec` - Definition of various message classes and logic to serialize data structure to Protibuf and vice versa
|
|
16
|
+
- `jayeson.lib.sports.core` - Core components used across whole library
|
|
17
|
+
- `jayeson.lib.sports.receive` - Implementation of logic to receive data from upstream
|
|
18
|
+
- `jayeson.lib.sports.receive.memory` - Implementation of logic to receive data in memory(E:g Bot)
|
|
19
|
+
- `jayeson.lib.sports.dispatch` - Abstractions for pushing received data downstream
|
|
20
|
+
- `jayeson.lib.sports.dispatch.relayer` - Abstratction to push data without any post-processing
|
|
21
|
+
- `jayeson.lib.sports.dispatch.tranrelayerorm` - Abstraction and logic to push data with post processing
|
|
22
|
+
- `jayeson.lib.sports.dispatch.network` - Abstraction and logic to push data via network
|
|
23
|
+
- `jayeson.lib.sports.client` - Abstrations for end under to consume data
|
|
24
|
+
- `jayesib.lib.sports.module` - Various module bindings
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
+-------------------------------------------------------------------------------+
|
|
31
|
+
| |
|
|
32
|
+
| +-------------+ |
|
|
33
|
+
| | client +---------------------+ v
|
|
34
|
+
| +-------------+ | +-----------+
|
|
35
|
+
| +----+ | | filter +----------------+
|
|
36
|
+
| +---------------------+ | | | +-----------+ |
|
|
37
|
+
+--+ dispatch.tranrelayerorm +-----+ v v v
|
|
38
|
+
+---------------------+ +-------------+ +----------+ +-----------------+
|
|
39
|
+
+->| dispatch +---->| core +----+ +-----------+ | datastructure |
|
|
40
|
+
+--------------------+ | +-------------+ +----------+ |---->| mutable | +-----------------+
|
|
41
|
+
| dispatch.network +---+ | ^ ^ | +-----------+ ^
|
|
42
|
+
+--------------------+ | | | | | |
|
|
43
|
+
+--+ | | | +------------+
|
|
44
|
+
+-----------------+ +------------------+ | | | +-----------+ |
|
|
45
|
+
| | | dispatch.relayer +-------------------+ | |---->| util +-----+---+
|
|
46
|
+
| Module | +------------------+ | | +-----------+ | | +-----------------+
|
|
47
|
+
+-----------------+ | | | +-->| protobuf |
|
|
48
|
+
| | | +-----------------+
|
|
49
|
+
+-----------------+ +-------------+ | | +-----------+ |
|
|
50
|
+
| receive.memory +----------->| receive +------------> +---->| codec +-----+
|
|
51
|
+
+-----------------+ +-------------+ +-----------+
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
#### Message Tranrelayerormation Flow
|
|
55
|
+
|
|
56
|
+
Picture show how message gets tranrelayerormed when they are passed from one component to other
|
|
57
|
+
|
|
58
|
+

|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
PS: Drawn using Gliffy. Get source diagram from jayeson's gliffy account
|
|
62
|
+
|
|
63
|
+
#### CI/CD guideline
|
|
64
|
+
|
|
65
|
+
##### Publish
|
|
66
|
+
|
|
67
|
+
Guideline: [CI/CD guideline](https://docs.jayeson.com.sg/ops/operations/gitlab-cicd/usage#how-to-use)
|
|
68
|
+
|
|
69
|
+
- Publish for non prod repo:
|
|
70
|
+
```
|
|
71
|
+
publish: snapshot
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
- Publish for production repo:
|
|
75
|
+
```
|
|
76
|
+
publish: prod
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
##### Deployment
|
|
81
|
+
|
|
82
|
+
Deploy to:
|
|
83
|
+
|
|
84
|
+
- **MyTest**
|
|
85
|
+
```
|
|
86
|
+
deploy: myTestUnity # For deploy to relayer of Unity in MyUnity environment
|
|
87
|
+
or
|
|
88
|
+
deploy: myTestVodds # For deploy to relayer of Vodds in MyVodds environment
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
- **Staging** environment:
|
|
94
|
+
```
|
|
95
|
+
deploy: stagUnity # For deploy to relayer of Unity in Staging Unity environment
|
|
96
|
+
or
|
|
97
|
+
deploy: stagVodds # For deploy to relayer of Vodds in Staging Vodds environment
|
|
98
|
+
or
|
|
99
|
+
deploy: stagFeed # For deploy to relayer of Vodds in Staging Feed environment
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
- **Production** environment:
|
|
104
|
+
```
|
|
105
|
+
deploy: prodUnity # For deploy to relayer of Unity in Production Unity environment
|
|
106
|
+
or
|
|
107
|
+
deploy: prodVodds # For deploy to relayer of Vodds in Production Vodds environment
|
|
108
|
+
or
|
|
109
|
+
deploy: prodFeed # For deploy to relayer of Vodds in Production Vodds environment
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
Note: To deploy to Kubernetes (k8s), need to add the parameter k8s: 1.
|
|
113
|
+
|
package/package.json
CHANGED
|
@@ -1,57 +1,49 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@jayesol/jayeson.lib.sports",
|
|
3
|
-
"version": "2.2.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "lib/index.js",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"gulp
|
|
36
|
-
"gulp-
|
|
37
|
-
"gulp-
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"typescript": "^
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
"type": "git"
|
|
51
|
-
},
|
|
52
|
-
"author": "",
|
|
53
|
-
"license": "ISC",
|
|
54
|
-
"directories": {
|
|
55
|
-
"lib": "lib"
|
|
56
|
-
}
|
|
57
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@jayesol/jayeson.lib.sports",
|
|
3
|
+
"version": "2.2.5-beta.1205v2",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "gulp compile",
|
|
8
|
+
"clean": "gulp clean",
|
|
9
|
+
"clean:all": "rm -rf node_modules dist",
|
|
10
|
+
"test": "gulp test",
|
|
11
|
+
"full-build": "npm run clean:all && npm install && npm run build"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@jayesol/jayeson.lib.delivery": "2.0.7-beta.0",
|
|
15
|
+
"@jayesol/jayeson.lib.record": "2.1.0-beta.1202",
|
|
16
|
+
"@jayesol/jayeson.lib.streamfinder": "2.0.0",
|
|
17
|
+
"@jayesol/jayeson.model": "2.1.0-beta.1205v2",
|
|
18
|
+
"circular-json": "^0.4.0",
|
|
19
|
+
"estraverse": "^5.3.0",
|
|
20
|
+
"injection-js": "^2.2.0",
|
|
21
|
+
"long": "^4.0.0",
|
|
22
|
+
"protobufjs": "^7.2.4",
|
|
23
|
+
"reflect-metadata": "^0.1.13",
|
|
24
|
+
"ts-promise": "^1.0.0",
|
|
25
|
+
"typescript-collections": "^1.3.3",
|
|
26
|
+
"underscore": "^1.13.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/jasmine": "^4.3.0",
|
|
30
|
+
"@types/node": "^20.19.24",
|
|
31
|
+
"chai": "^4.3.0",
|
|
32
|
+
"del": "^6.1.1",
|
|
33
|
+
"eventemitter3": "^5.0.0",
|
|
34
|
+
"glob": "^7.2.3",
|
|
35
|
+
"gulp": "^4.0.2",
|
|
36
|
+
"gulp-install": "^1.1.0",
|
|
37
|
+
"gulp-jasmine": "^4.0.0",
|
|
38
|
+
"gulp-jspm-builder": "^1.1.1",
|
|
39
|
+
"gulp-rename": "^2.0.0",
|
|
40
|
+
"gulp-run": "^1.7.1",
|
|
41
|
+
"gulp-typescript": "^5.0.1",
|
|
42
|
+
"gulp-uglify": "^3.0.2",
|
|
43
|
+
"jasmine": "^4.5.0",
|
|
44
|
+
"merge-stream": "^2.0.0",
|
|
45
|
+
"protobufjs-cli": "^1.1.3",
|
|
46
|
+
"semver": "^7.5.0",
|
|
47
|
+
"typescript": "^4.9.0"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { IBetMatch, BasketballMatchImpl, BasketballEventState, PartitionKey } from '@jayesol/jayeson.lib.record';
|
|
2
|
-
import * as proto from './protobuf_bundle';
|
|
3
|
-
import { ICodec, EncodeAction, CodecHelper } from './codec';
|
|
4
|
-
export declare class BasketballCodec implements ICodec {
|
|
5
|
-
private codecHelper;
|
|
6
|
-
constructor(codecHelper?: CodecHelper);
|
|
7
|
-
decodeMatch(input: proto.BaseMatch[], pool: string[], action: EncodeAction, key: PartitionKey): BasketballMatchImpl[];
|
|
8
|
-
decodeEvent(input: proto.BaseEvent[], pool: string[], action: EncodeAction, key: PartitionKey): IBetMatch[];
|
|
9
|
-
decodeRecord(input: proto.BaseRecord[], pool: string[], action: EncodeAction, key: PartitionKey): BasketballMatchImpl[];
|
|
10
|
-
decodeState(matchId: string, eventId: string, state: proto.IBaseEventState, pool: string[], action: EncodeAction, key: PartitionKey, time?: number): BasketballEventState;
|
|
11
|
-
}
|
package/lib/basketball_codec.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jayeson_lib_record_1=require("@jayesol/jayeson.lib.record"),proto=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,b,a,i){var d=this;return e.map(function(e){var a=b[e.participants[0]],t=b[e.participants[1]],r=b[e.id],o=d.codecHelper.coerceInt64(e.startTime),l=b[e.league],s=b[e.country],n=null,_={};null!=e.metaInfo&&(_=e.metaInfo);var c=e.basketballMatch;if(c)switch(c.gender){case proto.BasketballMatch.Gender.MEN:n=jayeson_lib_record_1.BasketballGender.MEN;break;case proto.BasketballMatch.Gender.WOMEN:n=jayeson_lib_record_1.BasketballGender.WOMEN}return _=d.codecHelper.populatePKIntoMetaInfo(_,i),new jayeson_lib_record_1.BasketballMatchImpl(a,t,o,[],r,l,n,s,_)})},e.prototype.decodeEvent=function(e,n,_,c){var b=this,a=[],i={};for(var t in e.forEach(function(e){var a=n[e.id],t=e.metaInfo,r=jayeson_lib_record_1.BasketballEventType.NONE;switch(e.eventType.basketballEventType){case proto.BasketballEvent.Type.NONE:r=jayeson_lib_record_1.BasketballEventType.NONE;break;case proto.BasketballEvent.Type.FIRST_TO_20:r=jayeson_lib_record_1.BasketballEventType.FIRST_TO_20;break;case proto.BasketballEvent.Type.LAST_BASKET:r=jayeson_lib_record_1.BasketballEventType.LAST_BASKET;break;case proto.BasketballEvent.Type.TEAM_POINTS:r=jayeson_lib_record_1.BasketballEventType.TEAM_POINTS;break;case proto.BasketballEvent.Type.THREE_POINTERS:r=jayeson_lib_record_1.BasketballEventType.THREE_POINTERS;break;case proto.BasketballEvent.Type.HOME_POINT:r=jayeson_lib_record_1.BasketballEventType.HOME_POINT;break;case proto.BasketballEvent.Type.AWAY_POINT:r=jayeson_lib_record_1.BasketballEventType.AWAY_POINT}var o=n[e.matchId],l=[];null!=e.state&&l.push(b.decodeState(o,a,e.state,n,_,c));var s=new jayeson_lib_record_1.BasketballEventImpl(a,[],l,o,r,t);void 0===i[o]&&(i[o]=[]),i[o].push(s)}),i){var r=new jayeson_lib_record_1.BasketballMatchImpl("","",0,i[t],t,"",jayeson_lib_record_1.BasketballGender.MEN,"",{});a.push(r)}return a},e.prototype.decodeRecord=function(e,f,a,t){var h=this,r=[],I={};for(var o in e.forEach(function(e){var a=h.codecHelper.coerceInt64(e.id),t=jayeson_lib_record_1.OddType[e.oddType.toString()],r=jayeson_lib_record_1.LBType[e.lbType.toString()],o=null,l=e.timeType.basketballTimeType;switch(proto.BasketballTimeType.SettleOn[l.settle.toString()]){case"FT":o=jayeson_lib_record_1.BasketballTimeType.FT;break;case"H1":o=jayeson_lib_record_1.BasketballTimeType.H1;break;case"H2":o=jayeson_lib_record_1.BasketballTimeType.H2;break;case"Q1":o=jayeson_lib_record_1.BasketballTimeType.Q1;break;case"Q2":o=jayeson_lib_record_1.BasketballTimeType.Q2;break;case"Q3":o=jayeson_lib_record_1.BasketballTimeType.Q3;break;case"Q4":o=jayeson_lib_record_1.BasketballTimeType.Q4}var s=f[e.source],n=jayeson_lib_record_1.OddFormat[e.format.toString()],_=e.metaInfo,c=e.pivotValue,b=jayeson_lib_record_1.PivotType[e.pivotType.toString()],i=jayeson_lib_record_1.PivotBias[e.pivotBias.toString()],d=e.basketballRecord,p=!1;d&&(p=d.swapped);var y=h.codecHelper.formatRate(e.rates[0]),T=h.codecHelper.formatRate(e.rates[1]),k=h.codecHelper.formatRate(e.rates[2]);console.log("Base Record rates: "+e.rates[0]+"_"+e.rates[1]+"_"+e.rates[2]+" After Format: "+y+"_"+T+"_"+k);var v=f[e.rateIds[0]],B=f[e.rateIds[1]],E=f[e.rateIds[2]],u=f[e.eventId],j=f[e.matchId],m=new jayeson_lib_record_1.BasketballRecord(j,u,a,t,r,o,s,n,_,y,T,k,c,b,i,v,B,E,p);void 0===I[j]&&(I[j]={}),void 0===I[j][u]&&(I[j][u]=[]),I[j][u].push(m)}),I){var l=I[o],s=[];for(var n in l){var _=new jayeson_lib_record_1.BasketballEventImpl(n,l[n],[],o,jayeson_lib_record_1.BasketballEventType.NONE,{});s.push(_)}var c=new jayeson_lib_record_1.BasketballMatchImpl("","",0,s,o,"",jayeson_lib_record_1.BasketballGender.MEN,"",{});r.push(c)}return r},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()],b=_.timeout,i=t.participantStats[0].scores,d=t.participantStats[1].scores;if(i.length<7)for(var p=i.length,y=0;p+y<7;y++)i.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(i[0],i[1],i[2],i[3],i[4],i[5],i[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,b,B)},e}();exports.BasketballCodec=BasketballCodec;
|
package/lib/client.d.ts
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import { IBetEvent, IBetMatch, IBetRecord, IBetEventState, ISnapshot, PartitionKey } from '@jayesol/jayeson.lib.record';
|
|
2
|
-
import { IEndPointDispatcher, IEndPointGroupManager } from './dispatch';
|
|
3
|
-
import { FSRepo } from './core';
|
|
4
|
-
import { IMessageClass, Subscriber, EPEvent } from '@jayesol/jayeson.lib.delivery';
|
|
5
|
-
import * as T from 'ts-promise';
|
|
6
|
-
import { IndexedSnapshot, DeltaOutgoing, Outgoing, IndexedSnapshotImpl } from "./data_structure";
|
|
7
|
-
import { InEndPointEventHandler, SportsFeedInProcessor } from "./receive";
|
|
8
|
-
import { SportsFeedMessageGroup } from "./message_class";
|
|
9
|
-
import 'reflect-metadata';
|
|
10
|
-
import { RuleCombination } from '@jayesol/jayeson.model';
|
|
11
|
-
export declare class InsertMatch<M extends IBetMatch> {
|
|
12
|
-
private _after;
|
|
13
|
-
private _get;
|
|
14
|
-
constructor(_after: ISnapshot<IBetMatch>, _get: M[]);
|
|
15
|
-
after(): ISnapshot<IBetMatch>;
|
|
16
|
-
get(): M[];
|
|
17
|
-
}
|
|
18
|
-
export declare class UpdateMatch<M extends IBetMatch> {
|
|
19
|
-
private _after;
|
|
20
|
-
private _get;
|
|
21
|
-
constructor(_after: ISnapshot<IBetMatch>, _get: M[]);
|
|
22
|
-
after(): ISnapshot<IBetMatch>;
|
|
23
|
-
get(): M[];
|
|
24
|
-
}
|
|
25
|
-
export declare class DeleteMatch<M extends IBetMatch> {
|
|
26
|
-
private _after;
|
|
27
|
-
private _get;
|
|
28
|
-
constructor(_after: ISnapshot<IBetMatch>, _get: M[]);
|
|
29
|
-
after(): ISnapshot<IBetMatch>;
|
|
30
|
-
get(): M[];
|
|
31
|
-
}
|
|
32
|
-
export declare class InsertEvent<E extends IBetEvent> {
|
|
33
|
-
private _after;
|
|
34
|
-
private _get;
|
|
35
|
-
constructor(_after: ISnapshot<IBetMatch>, _get: E[]);
|
|
36
|
-
after(): ISnapshot<IBetMatch>;
|
|
37
|
-
get(): E[];
|
|
38
|
-
}
|
|
39
|
-
export declare class UpdateEvent<E extends IBetEvent> {
|
|
40
|
-
private _after;
|
|
41
|
-
private _get;
|
|
42
|
-
constructor(_after: ISnapshot<IBetMatch>, _get: E[]);
|
|
43
|
-
after(): ISnapshot<IBetMatch>;
|
|
44
|
-
get(): E[];
|
|
45
|
-
}
|
|
46
|
-
export declare class DeleteEvent<E extends IBetEvent> {
|
|
47
|
-
private _after;
|
|
48
|
-
private _get;
|
|
49
|
-
constructor(_after: ISnapshot<IBetMatch>, _get: E[]);
|
|
50
|
-
after(): ISnapshot<IBetMatch>;
|
|
51
|
-
get(): E[];
|
|
52
|
-
}
|
|
53
|
-
export declare class InsertOdd<R extends IBetRecord> {
|
|
54
|
-
private _after;
|
|
55
|
-
private _get;
|
|
56
|
-
constructor(_after: ISnapshot<IBetMatch>, _get: R[]);
|
|
57
|
-
after(): ISnapshot<IBetMatch>;
|
|
58
|
-
get(): R[];
|
|
59
|
-
}
|
|
60
|
-
export declare class UpdateOdd<R extends IBetRecord> {
|
|
61
|
-
private _after;
|
|
62
|
-
private _get;
|
|
63
|
-
constructor(_after: ISnapshot<IBetMatch>, _get: R[]);
|
|
64
|
-
after(): ISnapshot<IBetMatch>;
|
|
65
|
-
get(): R[];
|
|
66
|
-
}
|
|
67
|
-
export declare class DeleteOdd<R extends IBetRecord> {
|
|
68
|
-
private _after;
|
|
69
|
-
private _get;
|
|
70
|
-
constructor(_after: ISnapshot<IBetMatch>, _get: R[]);
|
|
71
|
-
after(): ISnapshot<IBetMatch>;
|
|
72
|
-
get(): R[];
|
|
73
|
-
}
|
|
74
|
-
export declare class Reset {
|
|
75
|
-
private _after;
|
|
76
|
-
private _get;
|
|
77
|
-
constructor(_after: ISnapshot<IBetMatch>, _get: PartitionKey[]);
|
|
78
|
-
after(): ISnapshot<IBetMatch>;
|
|
79
|
-
get(): PartitionKey[];
|
|
80
|
-
}
|
|
81
|
-
export interface DeltaEventHandler<M extends IBetMatch, E extends IBetEvent, R extends IBetRecord> {
|
|
82
|
-
onInsertMatch(insertMatch: InsertMatch<M>): void;
|
|
83
|
-
onUpdateMatch(updateMatch: UpdateMatch<M>): void;
|
|
84
|
-
onDeleteMatch(deleteMatch: DeleteMatch<M>): void;
|
|
85
|
-
onInsertEvent(insertEvent: InsertEvent<E>): void;
|
|
86
|
-
onUpdateEvent(updateEvent: UpdateEvent<E>): void;
|
|
87
|
-
onDeleteEvent(deleteEvent: DeleteEvent<E>): void;
|
|
88
|
-
onInsertOdd(insertOdd: InsertOdd<R>): void;
|
|
89
|
-
onUpdateOdd(updateOdd: UpdateOdd<R>): void;
|
|
90
|
-
onDeleteOdd(deleteOdd: DeleteOdd<R>): void;
|
|
91
|
-
onReset(resetKeys: Reset): void;
|
|
92
|
-
onSwitchFilterStart(requestId?: number): void;
|
|
93
|
-
onSwitchFilterEnd(): void;
|
|
94
|
-
onFullSnapshotStart(): void;
|
|
95
|
-
onFullSnapshotEnd(): void;
|
|
96
|
-
onSwitchFilterFail(requestId?: number): void;
|
|
97
|
-
}
|
|
98
|
-
export declare class FeedView<M extends IBetMatch> {
|
|
99
|
-
private _fsRepo;
|
|
100
|
-
private _epgm;
|
|
101
|
-
private _grp;
|
|
102
|
-
private _handlers;
|
|
103
|
-
constructor(manager: IEndPointGroupManager, repo: FSRepo, grp: SportsFeedMessageGroup);
|
|
104
|
-
fsRepo(): FSRepo;
|
|
105
|
-
epgm(): IEndPointGroupManager;
|
|
106
|
-
grp(): SportsFeedMessageGroup;
|
|
107
|
-
snapshot(): IndexedSnapshot;
|
|
108
|
-
register<E extends IBetEvent, R extends IBetRecord>(listener: DeltaEventHandler<M, E, R>): void;
|
|
109
|
-
unregister<E extends IBetEvent, R extends IBetRecord>(listener: DeltaEventHandler<M, E, R>): void;
|
|
110
|
-
private hasHandler;
|
|
111
|
-
private removeHandler;
|
|
112
|
-
handlerSize(): number;
|
|
113
|
-
cleanUp(): void;
|
|
114
|
-
}
|
|
115
|
-
export declare class AbstractComparableEPDispatcher implements IEndPointDispatcher {
|
|
116
|
-
private _stream;
|
|
117
|
-
id(): string;
|
|
118
|
-
submit(out: Outgoing): void;
|
|
119
|
-
onException(e: Error): void;
|
|
120
|
-
protected _grp: SportsFeedMessageGroup;
|
|
121
|
-
protected _readyToDispatch: boolean;
|
|
122
|
-
constructor(_stream: string, _grp: SportsFeedMessageGroup);
|
|
123
|
-
stream(): string;
|
|
124
|
-
grp(): SportsFeedMessageGroup;
|
|
125
|
-
isInitialized(): T.Promise<Boolean>;
|
|
126
|
-
readyToDispatch(): void;
|
|
127
|
-
isReadyToDispatch(): boolean;
|
|
128
|
-
}
|
|
129
|
-
export declare class MemoryDispatcher extends AbstractComparableEPDispatcher {
|
|
130
|
-
private _fsRepo;
|
|
131
|
-
private _handler;
|
|
132
|
-
static MEMORY_STREAM: string;
|
|
133
|
-
lastPushedSs: IndexedSnapshotImpl;
|
|
134
|
-
_id: string;
|
|
135
|
-
constructor(_fsRepo: FSRepo, _grp: SportsFeedMessageGroup, _handler: DeltaEventHandler<IBetMatch, IBetEvent, IBetRecord>);
|
|
136
|
-
grp(): SportsFeedMessageGroup;
|
|
137
|
-
handler(): DeltaEventHandler<IBetMatch, IBetEvent, IBetRecord>;
|
|
138
|
-
id(): string;
|
|
139
|
-
submit(out: Outgoing): void;
|
|
140
|
-
onException(e: Error): void;
|
|
141
|
-
handleMessage(msg: Outgoing): void;
|
|
142
|
-
protected pushSwitchFilterStart(requestId: number): void;
|
|
143
|
-
protected pushSwitchFilterEnd(): void;
|
|
144
|
-
protected pushFullSnapshotStart(): void;
|
|
145
|
-
protected pushFullSnapshotEnd(): void;
|
|
146
|
-
protected pushSwitchFilterFail(requestId: number): void;
|
|
147
|
-
protected pushInsertMatch(ds: DeltaOutgoing): void;
|
|
148
|
-
protected pushInsertEvent(ds: DeltaOutgoing): void;
|
|
149
|
-
protected pushInsertOdd(ds: DeltaOutgoing): void;
|
|
150
|
-
protected pushUpdateMatch(ds: DeltaOutgoing): void;
|
|
151
|
-
protected pushUpdateEvent(ds: DeltaOutgoing): void;
|
|
152
|
-
protected pushUpdateOdd(ds: DeltaOutgoing): void;
|
|
153
|
-
protected pushDeleteMatch(ds: DeltaOutgoing): void;
|
|
154
|
-
protected pushDeleteEvent(ds: DeltaOutgoing): void;
|
|
155
|
-
protected pushDeleteOdd(ds: DeltaOutgoing): void;
|
|
156
|
-
private pushReset;
|
|
157
|
-
protected events(matches: IBetMatch[]): IBetEvent[];
|
|
158
|
-
protected records(events: IBetEvent[]): IBetRecord[];
|
|
159
|
-
protected states(events: IBetEvent[]): IBetEventState[];
|
|
160
|
-
isSame(lhs: IMessageClass, rhs: IMessageClass): boolean;
|
|
161
|
-
isInitialized(): T.Promise<Boolean>;
|
|
162
|
-
}
|
|
163
|
-
export declare class SportsFeedClient implements DeltaEventHandler<IBetMatch, IBetEvent, IBetRecord> {
|
|
164
|
-
private _subscriber;
|
|
165
|
-
private _eventHandler;
|
|
166
|
-
private _viewTemplate;
|
|
167
|
-
private _epgm;
|
|
168
|
-
private _fsRepo;
|
|
169
|
-
private _grp;
|
|
170
|
-
private _views;
|
|
171
|
-
private filterRequestCounter;
|
|
172
|
-
private resolverMap;
|
|
173
|
-
constructor(grp: SportsFeedMessageGroup, fsRepo: FSRepo, epgm: IEndPointGroupManager, subscriber: Subscriber, eventHandler: InEndPointEventHandler, inProcessor: SportsFeedInProcessor);
|
|
174
|
-
subscriber(): Subscriber;
|
|
175
|
-
epgm(): IEndPointGroupManager;
|
|
176
|
-
InEndPointEventHandler(): InEndPointEventHandler;
|
|
177
|
-
fsRepo(): FSRepo;
|
|
178
|
-
grp(): SportsFeedMessageGroup;
|
|
179
|
-
eventHandler(): InEndPointEventHandler;
|
|
180
|
-
eventListener(event: EPEvent): void;
|
|
181
|
-
configureEventHandler(eventHandler: InEndPointEventHandler): void;
|
|
182
|
-
setUpStreamFilter(filterData: RuleCombination): T.Promise<Boolean>;
|
|
183
|
-
getSubscriber(): Subscriber;
|
|
184
|
-
start(): void;
|
|
185
|
-
view<M extends IBetMatch>(): FeedView<M>;
|
|
186
|
-
removeView<M extends IBetMatch>(view: FeedView<M>): void;
|
|
187
|
-
onSwitchFilterFail(requestId: number): void;
|
|
188
|
-
onSwitchFilterStart(requestId: number): void;
|
|
189
|
-
onInsertMatch(insertMatch: InsertMatch<IBetMatch>): void;
|
|
190
|
-
onUpdateMatch(updateMatch: UpdateMatch<IBetMatch>): void;
|
|
191
|
-
onDeleteMatch(deleteMatch: DeleteMatch<IBetMatch>): void;
|
|
192
|
-
onInsertEvent(insertEvent: InsertEvent<IBetEvent>): void;
|
|
193
|
-
onUpdateEvent(updateEvent: UpdateEvent<IBetEvent>): void;
|
|
194
|
-
onDeleteEvent(deleteEvent: DeleteEvent<IBetEvent>): void;
|
|
195
|
-
onInsertOdd(insertOdd: InsertOdd<IBetRecord>): void;
|
|
196
|
-
onUpdateOdd(updateOdd: UpdateOdd<IBetRecord>): void;
|
|
197
|
-
onDeleteOdd(deleteOdd: DeleteOdd<IBetRecord>): void;
|
|
198
|
-
onReset(resetKeys: Reset): void;
|
|
199
|
-
onSwitchFilterEnd(): void;
|
|
200
|
-
onFullSnapshotStart(): void;
|
|
201
|
-
onFullSnapshotEnd(): void;
|
|
202
|
-
}
|
package/lib/client.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var __extends=this&&this.__extends||function(){var n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),__decorate=this&&this.__decorate||function(t,e,r,n){var s,i=arguments.length,o=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;0<=a;a--)(s=t[a])&&(o=(i<3?s(o):3<i?s(e,r,o):s(e,r))||o);return 3<i&&o&&Object.defineProperty(e,r,o),o},__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(r,n){return function(t,e){n(t,e,r)}};Object.defineProperty(exports,"__esModule",{value:!0});var dispatch_1=require("./dispatch"),codec_1=require("./codec"),core_1=require("./core"),delivery=require("@jayesol/jayeson.lib.delivery"),jayeson_lib_delivery_1=require("@jayesol/jayeson.lib.delivery"),Collections=require("typescript-collections"),T=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(e){return this._handlers.some(function(t){return t.handler===e})},t.prototype.removeHandler=function(e){var t=this._handlers.find(function(t){return t.handler===e});if(void 0===t)return null;var r=this._handlers.indexOf(t);return this._handlers.splice(r,1),t.dispatch},t.prototype.handlerSize=function(){return this._handlers.length},t.prototype.cleanUp=function(){for(var t=0,e=this._handlers.slice(0);t<e.length;t++){var r=e[t];this.unregister(r.handler)}},t=__decorate([injection_js_1.Injectable(),__param(0,injection_js_1.Inject(dispatch_1.EPGM_IMPL)),__param(1,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}(),MemoryDispatcher=function(s){function t(t,e,r){var n=s.call(this,i.MEMORY_STREAM,e)||this;return n._fsRepo=t,n.lastPushedSs=data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT,n._grp=e,n._handler=r,n._id=delivery.generateUUID(),n}var i;return __extends(t,s),(i=t).prototype.grp=function(){return this._grp},t.prototype.handler=function(){return this._handler},t.prototype.id=function(){return this._id},t.prototype.submit=function(t){this.isInitialized().isFulfilled()&&this.isInitialized().value()&&this.handleMessage(t)},t.prototype.onException=function(t){console.error("Exception when dispatching outgoing messages to dispatchers:"+t)},t.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)}},t.prototype.pushSwitchFilterStart=function(t){this._handler.onSwitchFilterStart(t)},t.prototype.pushSwitchFilterEnd=function(){this._handler.onSwitchFilterEnd()},t.prototype.pushFullSnapshotStart=function(){this._handler.onFullSnapshotStart()},t.prototype.pushFullSnapshotEnd=function(){this._handler.onFullSnapshotEnd()},t.prototype.pushSwitchFilterFail=function(t){this._handler.onSwitchFilterFail(t)},t.prototype.pushInsertMatch=function(t){for(var e=[],r=[],n=0,s=t.delta().matches();n<s.length;n++){var i=s[n];t.before().hasMatch(i.id())?r.push(i):e.push(i)}if(0!=e.length){var o=new InsertMatch(t.after(),e);this._handler.onInsertMatch(o)}if(0!=r.length){var a=new UpdateMatch(t.after(),r);this._handler.onUpdateMatch(a)}},t.prototype.pushInsertEvent=function(t){for(var e=[],r=[],n=0,s=this.events(t.delta().matches());n<s.length;n++){var i=s[n],o=t.before().match(i.matchId());null!=o&&o.hasEvent(i.id())?r.push(i):e.push(i)}if(0!=e.length){var a=new InsertEvent(t.after(),e);this._handler.onInsertEvent(a)}if(0<r.length){var p=new UpdateEvent(t.after(),r);this._handler.onUpdateEvent(p)}},t.prototype.pushInsertOdd=function(t){var e=this.records(this.events(t.delta().matches()));if(0<e.length){var r=new InsertOdd(t.after(),e);this._handler.onInsertOdd(r)}},t.prototype.pushUpdateMatch=function(t){var e=t.delta().matches();if(0<e.length){var r=new UpdateMatch(t.after(),e);this._handler.onUpdateMatch(r)}},t.prototype.pushUpdateEvent=function(t){var e=this.events(t.delta().matches());if(0<e.length){var r=new UpdateEvent(t.after(),e);this._handler.onUpdateEvent(r)}},t.prototype.pushUpdateOdd=function(t){var e=this.records(this.events(t.delta().matches()));if(0<e.length){var r=new UpdateOdd(t.after(),e);this._handler.onUpdateOdd(r)}},t.prototype.pushDeleteMatch=function(t){for(var e=[],r=[],n=0,s=t.delta().matches();n<s.length;n++){var i=s[n];t.after().hasMatch(i.id())?e.push(i):r.push(i)}if(0!=r.length){var o=new DeleteMatch(t.after(),r);this._handler.onDeleteMatch(o)}if(0!=e.length){var a=new UpdateMatch(t.after(),e);this._handler.onUpdateMatch(a)}},t.prototype.pushDeleteEvent=function(t){for(var e=[],r=[],n=0,s=this.events(t.delta().matches());n<s.length;n++){var i=s[n],o=t.after().match(i.matchId());null!=o&&o.hasEvent(i.id())?e.push(i):r.push(i)}if(0!=r.length){var a=new DeleteEvent(t.after(),r);this._handler.onDeleteEvent(a)}if(0!=e.length){var p=new UpdateEvent(t.after(),e);this._handler.onUpdateEvent(p)}},t.prototype.pushDeleteOdd=function(t){var e=this.records(this.events(t.delta().matches()));if(0<e.length){var r=new DeleteOdd(t.after(),e);this._handler.onDeleteOdd(r)}},t.prototype.pushReset=function(t){var e=t.delta().getPartitions().toArray(),r=new Reset(t.after(),e);this._handler.onReset(r)},t.prototype.events=function(t){for(var e=[],r=0,n=t;r<n.length;r++)for(var s=0,i=n[r].events();s<i.length;s++){var o=i[s];e.push(o)}return e},t.prototype.records=function(t){for(var e=[],r=0,n=t;r<n.length;r++)for(var s=0,i=n[r].records();s<i.length;s++){var o=i[s];e.push(o)}return e},t.prototype.states=function(t){for(var e=[],r=0,n=t;r<n.length;r++)for(var s=0,i=n[r].eventStates();s<i.length;s++){var o=i[s];e.push(o)}return e},t.prototype.isSame=function(t,e){return t.id()==e.id()},t.prototype.isInitialized=function(){return this._fsRepo.isReady(this.stream())},t.MEMORY_STREAM="MEMORY_AGGREGATED_STREAM",t=i=__decorate([injection_js_1.Injectable(),__metadata("design:paramtypes",[Object,message_class_1.SportsFeedMessageGroup,Object])],t)}(exports.AbstractComparableEPDispatcher=AbstractComparableEPDispatcher);exports.MemoryDispatcher=MemoryDispatcher;var SportsFeedClient=function(){function t(t,e,r,n,s,i){this._subscriber=n,this._epgm=r,this._eventHandler=s,this.configureEventHandler(s),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){if(t instanceof jayeson_lib_delivery_1.Subscriber.Event.ConsumptionStart)for(var e=0,r=t.streams;e<r.length;e++){var n=r[e];console.log("ConsumptionsStartEvent for streams "+n+" from "+t.endPoint)}else if(t instanceof jayeson_lib_delivery_1.Subscriber.Event.ConsumptionError)for(var s=0,i=t.streams;s<i.length;s++){n=i[s];console.log("ConsumptionsStartEvent for streams "+n)}else console.log("Received event "+t+" from "+t.endPoint)},t.prototype.configureEventHandler=function(t){this._subscriber.attachListener(t)},t.prototype.setUpStreamFilter=function(t){var r=this;if(0===Object.keys(this._eventHandler.streamSources()).length){var e=new codec_1.FilterRequest(codec_1.FilterRequest.IGNORED_REQUEST_ID,t);this._eventHandler.updateFilter(e);var n=null,s=new T.Promise(function(t,e){n=t});return n(!0),s}var i=this.filterRequestCounter++,o=new codec_1.FilterRequest(i,t),a=new T.Promise(function(t,e){r.resolverMap.setValue(i,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=__decorate([injection_js_1.Injectable(),__param(1,injection_js_1.Inject(core_1.FSREPO_IMPL)),__param(2,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.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/// <reference types="long" />
|
|
2
|
-
import * as proto from "./protobuf_bundle";
|
|
3
|
-
import * as rec from "@jayesol/jayeson.lib.record";
|
|
4
|
-
import { RuleCombination } from "@jayesol/jayeson.model";
|
|
5
|
-
export declare enum EncodeAction {
|
|
6
|
-
INSERT = 0,
|
|
7
|
-
UPDATE = 1,
|
|
8
|
-
DELETE = 2
|
|
9
|
-
}
|
|
10
|
-
export interface ICodec {
|
|
11
|
-
decodeRecord(input: proto.BaseRecord[], pool: string[], action: EncodeAction, key: rec.PartitionKey): rec.IBetMatch[];
|
|
12
|
-
decodeEvent(input: proto.BaseEvent[], pool: string[], action: EncodeAction, key: rec.PartitionKey): rec.IBetMatch[];
|
|
13
|
-
decodeMatch(input: proto.BaseMatch[], pool: string[], action: EncodeAction, key: rec.PartitionKey): rec.IBetMatch[];
|
|
14
|
-
}
|
|
15
|
-
export declare class CodecHelper {
|
|
16
|
-
constructor();
|
|
17
|
-
coerceInt64(val: number | Long): number;
|
|
18
|
-
populatePKIntoMetaInfo(meta: rec.StringMap, key: rec.PartitionKey): rec.StringMap;
|
|
19
|
-
formatRate(num: number): number;
|
|
20
|
-
}
|
|
21
|
-
export declare class FilterRequest {
|
|
22
|
-
private _requestId;
|
|
23
|
-
private _ruleCombination;
|
|
24
|
-
static readonly IGNORED_REQUEST_ID: number;
|
|
25
|
-
constructor(_requestId: number, _ruleCombination: RuleCombination);
|
|
26
|
-
getRequestId(): number;
|
|
27
|
-
getFilterData(): RuleCombination;
|
|
28
|
-
toJSON(): any;
|
|
29
|
-
}
|
|
30
|
-
export declare class Util {
|
|
31
|
-
private static SEPARATOR;
|
|
32
|
-
/**
|
|
33
|
-
* Utility to Store array of String values as single String Also see
|
|
34
|
-
* {@link #removeKey(String, String)}
|
|
35
|
-
*
|
|
36
|
-
* @param existing
|
|
37
|
-
* "IBC_LIVE,CROWN_LIVE"
|
|
38
|
-
* @param incoming
|
|
39
|
-
* "SBO_LIVE"
|
|
40
|
-
* @return "IBC_LIVE,CROWN_LIVE,SBO_LIVE"
|
|
41
|
-
*
|
|
42
|
-
*/
|
|
43
|
-
static addKey(existing: string, incoming: string): string;
|
|
44
|
-
/**
|
|
45
|
-
* Utility to remove element from string values Stored as String Also see
|
|
46
|
-
* {@link #addKey(String, String)}
|
|
47
|
-
*
|
|
48
|
-
* @param existing
|
|
49
|
-
* "IBC_LIVE,CROWN_LIVE"
|
|
50
|
-
* @param incoming
|
|
51
|
-
* "IBC_LIVE"
|
|
52
|
-
* @return "CROWN_LIVE". return empty string if there are no more keys. Return
|
|
53
|
-
* existing string if incoming is not present in existing
|
|
54
|
-
*/
|
|
55
|
-
static removeKey(existing: string, incoming: string): string;
|
|
56
|
-
static containsKey(existing: string, incoming: string): boolean;
|
|
57
|
-
}
|
package/lib/codec.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var EncodeAction,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 l(){}return l.addKey=function(t,e){if(-1!=e.search(l.SEPARATOR))throw new TypeError("Incoming String cannot contain Separator: "+l.SEPARATOR+" Incoming: "+e);return 0==t.length?e:-1===t.indexOf(e)?t+l.SEPARATOR+e:t},l.removeKey=function(t,e){var n=t.split(l.SEPARATOR),r=e.split(l.SEPARATOR);n.sort();for(var o=0,i=r;o<i.length;o++){var u=i[o],c=n.indexOf(u);if(!(c<0)&&(n.splice(c,1),0==n.length))return""}for(var a=n[0],s=1;s<n.length;s++)a=l.addKey(a,n[s]);return a},l.containsKey=function(t,e){if(null==t)return!1;if(-1!=e.search(l.SEPARATOR))throw new TypeError("Incoming String cannot contain Separator: "+l.SEPARATOR+" Incoming: "+e);return!(t.split(l.SEPARATOR).indexOf(e)<0)},l.SEPARATOR=",",l}();exports.Util=Util;
|