@jayesol/jayeson.lib.sports 2.2.6-beta.1 → 2.2.6
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 -113
- package/package.json +49 -49
- package/lib/basketball_codec.d.ts +0 -11
- package/lib/basketball_codec.js +0 -209
- package/lib/client.d.ts +0 -202
- package/lib/client.js +0 -686
- package/lib/codec.d.ts +0 -57
- package/lib/codec.js +0 -129
- package/lib/core.d.ts +0 -159
- package/lib/core.js +0 -497
- package/lib/data_structure.d.ts +0 -113
- package/lib/data_structure.js +0 -208
- package/lib/dispatch.d.ts +0 -126
- package/lib/dispatch.js +0 -325
- package/lib/index.d.ts +0 -11
- package/lib/index.js +0 -27
- package/lib/merge.d.ts +0 -33
- package/lib/merge.js +0 -569
- package/lib/message_class.d.ts +0 -152
- package/lib/message_class.js +0 -466
- package/lib/module.d.ts +0 -12
- package/lib/module.js +0 -87
- package/lib/mutable.d.ts +0 -118
- package/lib/mutable.js +0 -1061
- package/lib/protobuf_bundle.d.ts +0 -3210
- package/lib/protobuf_bundle.js +0 -9683
- package/lib/receive.d.ts +0 -88
- package/lib/receive.js +0 -484
- package/lib/soccer_codec.d.ts +0 -13
- package/lib/soccer_codec.js +0 -168
- package/lib/tennis_codec.d.ts +0 -13
- package/lib/tennis_codec.js +0 -177
package/README.md
CHANGED
|
@@ -1,113 +1,113 @@
|
|
|
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
|
-
|
|
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,49 +1,49 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@jayesol/jayeson.lib.sports",
|
|
3
|
-
"version": "2.2.6
|
|
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
|
|
15
|
-
"@jayesol/jayeson.lib.record": "2.1.
|
|
16
|
-
"@jayesol/jayeson.lib.streamfinder": "2.0.0",
|
|
17
|
-
"@jayesol/jayeson.model": "2.
|
|
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
|
+
{
|
|
2
|
+
"name": "@jayesol/jayeson.lib.sports",
|
|
3
|
+
"version": "2.2.6",
|
|
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",
|
|
15
|
+
"@jayesol/jayeson.lib.record": "2.1.1",
|
|
16
|
+
"@jayesol/jayeson.lib.streamfinder": "2.0.0",
|
|
17
|
+
"@jayesol/jayeson.model": "2.1.1",
|
|
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.BaseEventState, pool: string[], action: EncodeAction, key: PartitionKey, time?: number): BasketballEventState;
|
|
11
|
-
}
|
package/lib/basketball_codec.js
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.BasketballCodec = void 0;
|
|
27
|
-
const jayeson_lib_record_1 = require("@jayesol/jayeson.lib.record");
|
|
28
|
-
const proto = __importStar(require("./protobuf_bundle"));
|
|
29
|
-
const codec_1 = require("./codec");
|
|
30
|
-
class BasketballCodec {
|
|
31
|
-
constructor(codecHelper = new codec_1.CodecHelper()) {
|
|
32
|
-
this.codecHelper = codecHelper;
|
|
33
|
-
}
|
|
34
|
-
decodeMatch(input, pool, action, key) {
|
|
35
|
-
return input.map(match => {
|
|
36
|
-
let host = pool[match.participants[0]];
|
|
37
|
-
let guest = pool[match.participants[1]];
|
|
38
|
-
let id = pool[match.id];
|
|
39
|
-
let startTime = this.codecHelper.coerceInt64(match.startTime);
|
|
40
|
-
let league = pool[match.league];
|
|
41
|
-
let country = pool[match.country];
|
|
42
|
-
let gender = null;
|
|
43
|
-
let meta = {};
|
|
44
|
-
if (match.metaInfo != null) {
|
|
45
|
-
meta = match.metaInfo;
|
|
46
|
-
}
|
|
47
|
-
let bballMatch = match.basketballMatch;
|
|
48
|
-
if (bballMatch) {
|
|
49
|
-
switch (bballMatch.gender) {
|
|
50
|
-
case proto.BasketballMatch.Gender.MEN:
|
|
51
|
-
gender = jayeson_lib_record_1.BasketballGender.MEN;
|
|
52
|
-
break;
|
|
53
|
-
case proto.BasketballMatch.Gender.WOMEN:
|
|
54
|
-
gender = jayeson_lib_record_1.BasketballGender.WOMEN;
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
meta = this.codecHelper.populatePKIntoMetaInfo(meta, key);
|
|
59
|
-
return new jayeson_lib_record_1.BasketballMatchImpl(host, guest, startTime, [], id, league, gender, country, meta);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
decodeEvent(input, pool, action, key) {
|
|
63
|
-
var result = [];
|
|
64
|
-
let matchIdToEvents = {};
|
|
65
|
-
input.forEach(event => {
|
|
66
|
-
let id = pool[event.id];
|
|
67
|
-
let meta = event.metaInfo;
|
|
68
|
-
let eType = jayeson_lib_record_1.BasketballEventType.NONE;
|
|
69
|
-
switch (event.eventType.basketballEventType) {
|
|
70
|
-
case proto.BasketballEvent.Type.NONE:
|
|
71
|
-
eType = jayeson_lib_record_1.BasketballEventType.NONE;
|
|
72
|
-
break;
|
|
73
|
-
case proto.BasketballEvent.Type.FIRST_TO_20:
|
|
74
|
-
eType = jayeson_lib_record_1.BasketballEventType.FIRST_TO_20;
|
|
75
|
-
break;
|
|
76
|
-
case proto.BasketballEvent.Type.LAST_BASKET:
|
|
77
|
-
eType = jayeson_lib_record_1.BasketballEventType.LAST_BASKET;
|
|
78
|
-
break;
|
|
79
|
-
case proto.BasketballEvent.Type.TEAM_POINTS:
|
|
80
|
-
eType = jayeson_lib_record_1.BasketballEventType.TEAM_POINTS;
|
|
81
|
-
break;
|
|
82
|
-
case proto.BasketballEvent.Type.THREE_POINTERS:
|
|
83
|
-
eType = jayeson_lib_record_1.BasketballEventType.THREE_POINTERS;
|
|
84
|
-
break;
|
|
85
|
-
case proto.BasketballEvent.Type.HOME_POINT:
|
|
86
|
-
eType = jayeson_lib_record_1.BasketballEventType.HOME_POINT;
|
|
87
|
-
break;
|
|
88
|
-
case proto.BasketballEvent.Type.AWAY_POINT:
|
|
89
|
-
eType = jayeson_lib_record_1.BasketballEventType.AWAY_POINT;
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
let mId = pool[event.matchId];
|
|
93
|
-
let states = [];
|
|
94
|
-
if (event.state != null) {
|
|
95
|
-
states.push(this.decodeState(mId, id, event.state, pool, action, key));
|
|
96
|
-
}
|
|
97
|
-
let ev = new jayeson_lib_record_1.BasketballEventImpl(id, [], states, mId, eType, meta);
|
|
98
|
-
if (matchIdToEvents[mId] === undefined) {
|
|
99
|
-
matchIdToEvents[mId] = [];
|
|
100
|
-
}
|
|
101
|
-
matchIdToEvents[mId].push(ev);
|
|
102
|
-
});
|
|
103
|
-
//add the matches
|
|
104
|
-
for (let matchId in matchIdToEvents) {
|
|
105
|
-
let currMatch = new jayeson_lib_record_1.BasketballMatchImpl('', '', 0, matchIdToEvents[matchId], matchId, '', jayeson_lib_record_1.BasketballGender.MEN, "", {});
|
|
106
|
-
result.push(currMatch);
|
|
107
|
-
}
|
|
108
|
-
return result;
|
|
109
|
-
}
|
|
110
|
-
decodeRecord(input, pool, action, key) {
|
|
111
|
-
let result = [];
|
|
112
|
-
let matchMap = {}; //map of match id to events array for that particular match
|
|
113
|
-
input.forEach(record => {
|
|
114
|
-
let id = this.codecHelper.coerceInt64(record.id);
|
|
115
|
-
let oddType = jayeson_lib_record_1.OddType[record.oddType.toString()];
|
|
116
|
-
let lbType = jayeson_lib_record_1.LBType[record.lbType.toString()];
|
|
117
|
-
let timeType = null;
|
|
118
|
-
let protoTimeType = record.timeType.basketballTimeType;
|
|
119
|
-
let str = proto.BasketballTimeType.SettleOn[protoTimeType.settle.toString()];
|
|
120
|
-
switch (str) {
|
|
121
|
-
case "FT":
|
|
122
|
-
timeType = jayeson_lib_record_1.BasketballTimeType.FT;
|
|
123
|
-
break;
|
|
124
|
-
case "H1":
|
|
125
|
-
timeType = jayeson_lib_record_1.BasketballTimeType.H1;
|
|
126
|
-
break;
|
|
127
|
-
case "H2":
|
|
128
|
-
timeType = jayeson_lib_record_1.BasketballTimeType.H2;
|
|
129
|
-
break;
|
|
130
|
-
case "Q1":
|
|
131
|
-
timeType = jayeson_lib_record_1.BasketballTimeType.Q1;
|
|
132
|
-
break;
|
|
133
|
-
case "Q2":
|
|
134
|
-
timeType = jayeson_lib_record_1.BasketballTimeType.Q2;
|
|
135
|
-
break;
|
|
136
|
-
case "Q3":
|
|
137
|
-
timeType = jayeson_lib_record_1.BasketballTimeType.Q3;
|
|
138
|
-
break;
|
|
139
|
-
case "Q4":
|
|
140
|
-
timeType = jayeson_lib_record_1.BasketballTimeType.Q4;
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
let source = pool[record.source];
|
|
144
|
-
let oddFormat = jayeson_lib_record_1.OddFormat[record.format.toString()];
|
|
145
|
-
let meta = record.metaInfo;
|
|
146
|
-
let pivotValue = record.pivotValue;
|
|
147
|
-
let pivotType = jayeson_lib_record_1.PivotType[record.pivotType.toString()];
|
|
148
|
-
let pivotBias = jayeson_lib_record_1.PivotBias[record.pivotBias.toString()];
|
|
149
|
-
let bballRec = record.basketballRecord;
|
|
150
|
-
let isSwapped = false;
|
|
151
|
-
if (bballRec) {
|
|
152
|
-
isSwapped = bballRec.swapped;
|
|
153
|
-
}
|
|
154
|
-
let rateOver = this.codecHelper.formatRate(record.rates[0]);
|
|
155
|
-
let rateUnder = this.codecHelper.formatRate(record.rates[1]);
|
|
156
|
-
let rateEqual = this.codecHelper.formatRate(record.rates[2]);
|
|
157
|
-
let rateOverId = pool[record.rateIds[0]];
|
|
158
|
-
let rateUnderId = pool[record.rateIds[1]];
|
|
159
|
-
let rateEqualId = pool[record.rateIds[2]];
|
|
160
|
-
let eId = pool[record.eventId];
|
|
161
|
-
let mId = pool[record.matchId];
|
|
162
|
-
let rec = new jayeson_lib_record_1.BasketballRecord(mId, eId, id, oddType, lbType, timeType, source, oddFormat, meta, rateOver, rateUnder, rateEqual, pivotValue, pivotType, pivotBias, rateOverId, rateUnderId, rateEqualId, isSwapped);
|
|
163
|
-
if (matchMap[mId] === undefined) {
|
|
164
|
-
matchMap[mId] = {};
|
|
165
|
-
}
|
|
166
|
-
if (matchMap[mId][eId] === undefined) {
|
|
167
|
-
matchMap[mId][eId] = [];
|
|
168
|
-
}
|
|
169
|
-
matchMap[mId][eId].push(rec);
|
|
170
|
-
});
|
|
171
|
-
for (let mId in matchMap) {
|
|
172
|
-
let eventMap = matchMap[mId];
|
|
173
|
-
let eventArray = [];
|
|
174
|
-
for (let eId in eventMap) {
|
|
175
|
-
let ev = new jayeson_lib_record_1.BasketballEventImpl(eId, eventMap[eId], [], mId, jayeson_lib_record_1.BasketballEventType.NONE, {});
|
|
176
|
-
eventArray.push(ev);
|
|
177
|
-
}
|
|
178
|
-
let match = new jayeson_lib_record_1.BasketballMatchImpl('', '', 0, eventArray, mId, '', jayeson_lib_record_1.BasketballGender.MEN, "", {});
|
|
179
|
-
result.push(match);
|
|
180
|
-
}
|
|
181
|
-
return result;
|
|
182
|
-
}
|
|
183
|
-
decodeState(matchId, eventId, state, pool, action, key, time = Date.now()) {
|
|
184
|
-
let duration = state.duration;
|
|
185
|
-
let bballState = state.basketballEventState;
|
|
186
|
-
let seg = jayeson_lib_record_1.BasketballSegment[state.basketballEventState.segment.toString()];
|
|
187
|
-
let timeout = bballState.timeout;
|
|
188
|
-
var hostStat = state.participantStats[0].scores;
|
|
189
|
-
var guestStat = state.participantStats[1].scores;
|
|
190
|
-
if (hostStat.length < 7) {
|
|
191
|
-
var hostLength = hostStat.length;
|
|
192
|
-
for (var i = 0; hostLength + i < 7; i++) {
|
|
193
|
-
hostStat.push(-1);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
if (guestStat.length < 7) {
|
|
197
|
-
var guestLength = guestStat.length;
|
|
198
|
-
for (var i = 0; guestLength + i < 7; i++) {
|
|
199
|
-
guestStat.push(-1);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
let p1Stat = new jayeson_lib_record_1.BasketballStats(hostStat[0], hostStat[1], hostStat[2], hostStat[3], hostStat[4], hostStat[5], hostStat[6]);
|
|
203
|
-
let p2Stat = new jayeson_lib_record_1.BasketballStats(guestStat[0], guestStat[1], guestStat[2], guestStat[3], guestStat[4], guestStat[5], guestStat[6]);
|
|
204
|
-
let bookPriority = bballState.bookPriority;
|
|
205
|
-
let s = new jayeson_lib_record_1.BasketballEventState(p1Stat, p2Stat, duration, key, matchId, eventId, time, seg, timeout, bookPriority);
|
|
206
|
-
return s;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
exports.BasketballCodec = BasketballCodec;
|