@jayesol/jayeson.lib.sports 2.2.7-beta2 → 2.2.7-beta3
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/lib/basketball_codec.js +1 -209
- package/lib/client.js +1 -686
- package/lib/codec.js +1 -129
- package/lib/core.js +1 -497
- package/lib/data_structure.js +1 -208
- package/lib/dispatch.js +1 -324
- package/lib/index.js +1 -27
- package/lib/merge.js +1 -569
- package/lib/message_class.js +1 -466
- package/lib/module.js +1 -87
- package/lib/mutable.js +1 -1061
- package/lib/protobuf_bundle.js +1 -9683
- package/lib/receive.js +1 -484
- package/lib/soccer_codec.js +1 -168
- package/lib/tennis_codec.js +1 -177
- package/package.json +4 -3
package/lib/mutable.js
CHANGED
|
@@ -1,1061 +1 @@
|
|
|
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.BuilderProvider = exports.B2RecordBuilder = exports.Const = void 0;
|
|
27
|
-
const jayeson_lib_record_1 = require("@jayesol/jayeson.lib.record");
|
|
28
|
-
const data_structure_1 = require("./data_structure");
|
|
29
|
-
const codec_1 = require("./codec");
|
|
30
|
-
const Collections = __importStar(require("typescript-collections"));
|
|
31
|
-
class Const {
|
|
32
|
-
static generateKey(rec) {
|
|
33
|
-
return rec.source() + this.SEPARATOR + rec.id();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.Const = Const;
|
|
37
|
-
Const.AGGREGATE_KEY = "AGGREGATE_KEY";
|
|
38
|
-
Const.SEPARATOR = "_";
|
|
39
|
-
class IndexedSnapshotBuilder {
|
|
40
|
-
constructor(input) {
|
|
41
|
-
this._matches = {};
|
|
42
|
-
this._partitions = new Collections.Dictionary();
|
|
43
|
-
if (input != null) {
|
|
44
|
-
for (let match of input.matches()) {
|
|
45
|
-
this._matches[match.id()] = match;
|
|
46
|
-
}
|
|
47
|
-
for (let key of input.getPartitionMap().keys()) {
|
|
48
|
-
this._partitions.setValue(key, input.getPartitionMap().getValue(key));
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
matches() {
|
|
53
|
-
return this._matches;
|
|
54
|
-
}
|
|
55
|
-
partitions() {
|
|
56
|
-
return this._partitions;
|
|
57
|
-
}
|
|
58
|
-
setPartition(partition) {
|
|
59
|
-
this._partitions = partition;
|
|
60
|
-
}
|
|
61
|
-
setPartitionValue(key, value) {
|
|
62
|
-
this._partitions.setValue(key, value);
|
|
63
|
-
}
|
|
64
|
-
removePartitionKey(key) {
|
|
65
|
-
return this._partitions.remove(key);
|
|
66
|
-
}
|
|
67
|
-
markPartitionAsUpdated(key, time) {
|
|
68
|
-
if (time == null) {
|
|
69
|
-
time = new Date().getMilliseconds();
|
|
70
|
-
}
|
|
71
|
-
this._partitions.setValue(key, time);
|
|
72
|
-
}
|
|
73
|
-
replaceMatch(match) {
|
|
74
|
-
this._matches[match.id()] = match;
|
|
75
|
-
}
|
|
76
|
-
reset(key) {
|
|
77
|
-
if (!this._partitions.containsKey(key)) {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
let updatedMatches = this._matches;
|
|
81
|
-
let removedDataSnapshotBuilder = BuilderProvider.getSnapshotBuilder(this.build());
|
|
82
|
-
removedDataSnapshotBuilder._matches = {};
|
|
83
|
-
removedDataSnapshotBuilder._partitions.clear();
|
|
84
|
-
// Transfer PK
|
|
85
|
-
let time = this.removePartitionKey(key);
|
|
86
|
-
removedDataSnapshotBuilder.setPartitionValue(key, time);
|
|
87
|
-
for (let matchId in this._matches) {
|
|
88
|
-
let match = this._matches[matchId];
|
|
89
|
-
let remainingMatchbuilder = BuilderProvider.getMatchBuilder(match);
|
|
90
|
-
let removedMatchBuilder = remainingMatchbuilder.reset(key);
|
|
91
|
-
if (removedMatchBuilder != null && !removedMatchBuilder.isEmpty()) {
|
|
92
|
-
removedDataSnapshotBuilder.insertChild(removedMatchBuilder.build());
|
|
93
|
-
}
|
|
94
|
-
if (!remainingMatchbuilder.isEmpty()) {
|
|
95
|
-
updatedMatches[match.id()] = remainingMatchbuilder.build();
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
delete updatedMatches[match.id()];
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
this._matches = updatedMatches;
|
|
102
|
-
return removedDataSnapshotBuilder;
|
|
103
|
-
}
|
|
104
|
-
insertChild(incoming) {
|
|
105
|
-
let existing = this._matches[incoming.id()];
|
|
106
|
-
let suppressMatch = null;
|
|
107
|
-
if (existing == null) {
|
|
108
|
-
this._matches[incoming.id()] = incoming;
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
// Clone the existing
|
|
112
|
-
suppressMatch = incoming.id();
|
|
113
|
-
let builder = BuilderProvider.getMatchBuilder(existing);
|
|
114
|
-
builder.aggregateInsert(incoming);
|
|
115
|
-
this._matches[incoming.id()] = builder.build();
|
|
116
|
-
}
|
|
117
|
-
return suppressMatch;
|
|
118
|
-
}
|
|
119
|
-
updateChild(incoming) {
|
|
120
|
-
let existing = this._matches[incoming.id()];
|
|
121
|
-
if (existing == null) {
|
|
122
|
-
console.error("[UpdateMatch] Cannot found matchId %s to execute update match from %s", incoming.id(), incoming.meta()[Const.AGGREGATE_KEY]);
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
let builder = BuilderProvider.getMatchBuilder(existing);
|
|
126
|
-
builder.aggregateUpdate(incoming);
|
|
127
|
-
this._matches[incoming.id()] = builder.build();
|
|
128
|
-
}
|
|
129
|
-
deleteChild(incoming) {
|
|
130
|
-
let existing = this._matches[incoming.id()];
|
|
131
|
-
let suppressMatch = null;
|
|
132
|
-
if (existing == null) {
|
|
133
|
-
console.error("[DeleteMatch] Cannot found matchId %s to execute delete match from %s", incoming.id(), incoming.meta()[Const.AGGREGATE_KEY]);
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
let builder = BuilderProvider.getMatchBuilder(existing);
|
|
137
|
-
let isEmpty = builder.aggregateDelete(incoming);
|
|
138
|
-
if (isEmpty) {
|
|
139
|
-
delete this._matches[incoming.id()];
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
this._matches[incoming.id()] = builder.build();
|
|
143
|
-
suppressMatch = incoming.id();
|
|
144
|
-
}
|
|
145
|
-
return suppressMatch;
|
|
146
|
-
}
|
|
147
|
-
build() {
|
|
148
|
-
//Consolidate matches by sport type
|
|
149
|
-
let matches = {};
|
|
150
|
-
for (let matchId in this._matches) {
|
|
151
|
-
let match = this._matches[matchId];
|
|
152
|
-
let arr = matches[match.sportType()];
|
|
153
|
-
if (arr == null) {
|
|
154
|
-
arr = [];
|
|
155
|
-
matches[match.sportType()] = arr;
|
|
156
|
-
}
|
|
157
|
-
arr.push(match);
|
|
158
|
-
}
|
|
159
|
-
return new data_structure_1.IndexedSnapshotImpl(matches, this._partitions);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
class B2MatchBuilder {
|
|
163
|
-
constructor(t) {
|
|
164
|
-
this._events = {};
|
|
165
|
-
this.mergeFrom(t);
|
|
166
|
-
}
|
|
167
|
-
meta() {
|
|
168
|
-
return this._meta;
|
|
169
|
-
}
|
|
170
|
-
startTime() {
|
|
171
|
-
return this._startTime;
|
|
172
|
-
}
|
|
173
|
-
events() {
|
|
174
|
-
return this._events;
|
|
175
|
-
}
|
|
176
|
-
id() {
|
|
177
|
-
return this._id;
|
|
178
|
-
}
|
|
179
|
-
league() {
|
|
180
|
-
return this._league;
|
|
181
|
-
}
|
|
182
|
-
sport() {
|
|
183
|
-
return this._sport;
|
|
184
|
-
}
|
|
185
|
-
meata() {
|
|
186
|
-
return this._meta;
|
|
187
|
-
}
|
|
188
|
-
p1() {
|
|
189
|
-
return this._p1;
|
|
190
|
-
}
|
|
191
|
-
p2() {
|
|
192
|
-
return this._p2;
|
|
193
|
-
}
|
|
194
|
-
setEvent(event) {
|
|
195
|
-
this._events = event;
|
|
196
|
-
}
|
|
197
|
-
mergeFrom(match) {
|
|
198
|
-
this._startTime = match.startTime();
|
|
199
|
-
this._id = match.id();
|
|
200
|
-
this._league = match.league();
|
|
201
|
-
this._sport = match.sportType();
|
|
202
|
-
this._meta = {};
|
|
203
|
-
for (let key in match.meta()) {
|
|
204
|
-
this._meta[key] = match.meta()[key];
|
|
205
|
-
}
|
|
206
|
-
if (match.events() != null) {
|
|
207
|
-
for (let evt of match.events()) {
|
|
208
|
-
this._events[evt.id()] = evt;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
let b2Match = match;
|
|
212
|
-
this._p1 = b2Match.participantOne();
|
|
213
|
-
this._p2 = b2Match.participantTwo();
|
|
214
|
-
}
|
|
215
|
-
replaceEvent(evt) {
|
|
216
|
-
this._events[evt.id()] = evt;
|
|
217
|
-
}
|
|
218
|
-
reset(key) {
|
|
219
|
-
// Check if you have state for this key
|
|
220
|
-
let incoming = key.toString();
|
|
221
|
-
let existing = this._meta[Const.AGGREGATE_KEY];
|
|
222
|
-
if (!codec_1.Util.containsKey(existing, incoming)) {
|
|
223
|
-
return null;
|
|
224
|
-
}
|
|
225
|
-
let removedDataMatchBuilder = BuilderProvider.getMatchBuilder(this.build());
|
|
226
|
-
// Remove Pkey from this and add it to removed eventbuilder
|
|
227
|
-
let removed = codec_1.Util.removeKey(existing, incoming);
|
|
228
|
-
this._meta[Const.AGGREGATE_KEY] = removed;
|
|
229
|
-
removedDataMatchBuilder._meta[Const.AGGREGATE_KEY] = incoming;
|
|
230
|
-
let updatedEvents = {};
|
|
231
|
-
removedDataMatchBuilder._events = {};
|
|
232
|
-
for (let eventId in this._events) {
|
|
233
|
-
let event = this._events[eventId];
|
|
234
|
-
let remainingEventbuilder = BuilderProvider.getEventBuilder(event);
|
|
235
|
-
let removedEventBldr = remainingEventbuilder.reset(key);
|
|
236
|
-
if (removedEventBldr != null && !removedEventBldr.isEmpty()) {
|
|
237
|
-
removedDataMatchBuilder.insertChild(removedEventBldr.build());
|
|
238
|
-
}
|
|
239
|
-
if (!remainingEventbuilder.isEmpty()) {
|
|
240
|
-
updatedEvents[event.id()] = remainingEventbuilder.build();
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
delete updatedEvents[event.id()];
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
this._events = updatedEvents;
|
|
247
|
-
return removedDataMatchBuilder;
|
|
248
|
-
}
|
|
249
|
-
aggregateInsert(match) {
|
|
250
|
-
for (let key in match.meta()) {
|
|
251
|
-
// Copy everything except Aggregated key
|
|
252
|
-
if (!(key === Const.AGGREGATE_KEY)) {
|
|
253
|
-
this._meta[key] = match.meta()[key];
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
// Copy aggregate key information as it specifies this insert is from which partition
|
|
257
|
-
let incoming = match.meta()[Const.AGGREGATE_KEY];
|
|
258
|
-
let existing = this._meta[Const.AGGREGATE_KEY];
|
|
259
|
-
this._meta[Const.AGGREGATE_KEY] = codec_1.Util.addKey(existing, incoming);
|
|
260
|
-
}
|
|
261
|
-
aggregateUpdate(match) {
|
|
262
|
-
for (let key in match.meta()) {
|
|
263
|
-
// Copy everything except Aggregated key
|
|
264
|
-
if (!(key === Const.AGGREGATE_KEY)) {
|
|
265
|
-
this._meta[key] = match.meta()[key];
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
aggregateDelete(match) {
|
|
270
|
-
let incoming = match.meta()[Const.AGGREGATE_KEY];
|
|
271
|
-
let existing = this._meta[Const.AGGREGATE_KEY];
|
|
272
|
-
let removed = codec_1.Util.removeKey(existing, incoming);
|
|
273
|
-
this._meta[Const.AGGREGATE_KEY] = removed;
|
|
274
|
-
return removed === "";
|
|
275
|
-
}
|
|
276
|
-
isEmpty() {
|
|
277
|
-
let existing = this._meta[Const.AGGREGATE_KEY];
|
|
278
|
-
if (existing == null || existing == "") {
|
|
279
|
-
return true;
|
|
280
|
-
}
|
|
281
|
-
return false;
|
|
282
|
-
}
|
|
283
|
-
insertChild(inputEvent) {
|
|
284
|
-
// If event doesnt exists this is the first insert
|
|
285
|
-
let exist = this._events[inputEvent.id()];
|
|
286
|
-
let suppressEvent = null;
|
|
287
|
-
if (exist == null) {
|
|
288
|
-
this._events[inputEvent.id()] = inputEvent;
|
|
289
|
-
}
|
|
290
|
-
else {
|
|
291
|
-
// Clone the existing
|
|
292
|
-
let builder = BuilderProvider.getEventBuilder(exist);
|
|
293
|
-
builder.aggregateInsert(inputEvent);
|
|
294
|
-
this._events[inputEvent.id()] = builder.build();
|
|
295
|
-
suppressEvent = inputEvent.id();
|
|
296
|
-
}
|
|
297
|
-
return suppressEvent;
|
|
298
|
-
}
|
|
299
|
-
updateChild(updateEvent) {
|
|
300
|
-
let existing = this._events[updateEvent.id()];
|
|
301
|
-
if (existing == null) {
|
|
302
|
-
console.error("[UpdateEvent] Cannot found eventId %s to execute update event from %s", updateEvent.id(), updateEvent.meta()[Const.AGGREGATE_KEY]);
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
let builder = BuilderProvider.getEventBuilder(existing);
|
|
306
|
-
builder.aggregateUpdate(updateEvent);
|
|
307
|
-
this._events[updateEvent.id()] = builder.build();
|
|
308
|
-
}
|
|
309
|
-
deleteChild(inputEvent) {
|
|
310
|
-
let existing = this._events[inputEvent.id()];
|
|
311
|
-
let suppressEvent = null;
|
|
312
|
-
if (existing == null) {
|
|
313
|
-
console.error("[DeleteEvent] Cannot found eventId %s to execute delete event from %s", inputEvent.id(), inputEvent.meta()[Const.AGGREGATE_KEY]);
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
let builder = BuilderProvider.getEventBuilder(existing);
|
|
317
|
-
let isEmpty = builder.aggregateDelete(inputEvent);
|
|
318
|
-
if (isEmpty) {
|
|
319
|
-
delete this._events[inputEvent.id()];
|
|
320
|
-
}
|
|
321
|
-
else {
|
|
322
|
-
suppressEvent = inputEvent.id();
|
|
323
|
-
this._events[inputEvent.id()] = builder.build();
|
|
324
|
-
}
|
|
325
|
-
return suppressEvent;
|
|
326
|
-
}
|
|
327
|
-
build() {
|
|
328
|
-
throw new TypeError("Not supported in Abstract class");
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
class B2EventBuilder {
|
|
332
|
-
constructor(event) {
|
|
333
|
-
this._records = {};
|
|
334
|
-
this._states = {};
|
|
335
|
-
this.mergeFrom(event);
|
|
336
|
-
}
|
|
337
|
-
id() {
|
|
338
|
-
return this._id;
|
|
339
|
-
}
|
|
340
|
-
records() {
|
|
341
|
-
return this._records;
|
|
342
|
-
}
|
|
343
|
-
matchId() {
|
|
344
|
-
return this._matchId;
|
|
345
|
-
}
|
|
346
|
-
eventType() {
|
|
347
|
-
return this._eventType;
|
|
348
|
-
}
|
|
349
|
-
meta() {
|
|
350
|
-
return this._meta;
|
|
351
|
-
}
|
|
352
|
-
states() {
|
|
353
|
-
return this._states;
|
|
354
|
-
}
|
|
355
|
-
mergeFrom(t) {
|
|
356
|
-
let event = t;
|
|
357
|
-
this._id = t.id();
|
|
358
|
-
if (t.records() != null) {
|
|
359
|
-
for (let record of event.records()) {
|
|
360
|
-
let key = Const.generateKey(record);
|
|
361
|
-
this._records[key] = record;
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
this.setStates(event.eventStates());
|
|
365
|
-
this._matchId = t.matchId();
|
|
366
|
-
this._eventType = t.eventType();
|
|
367
|
-
this._meta = {};
|
|
368
|
-
for (let key in t.meta()) {
|
|
369
|
-
this._meta[key] = t.meta()[key];
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
setStates(states) {
|
|
373
|
-
if (states != null) {
|
|
374
|
-
for (let state of states) {
|
|
375
|
-
this._states[state.partitionKey().toString()] = state;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
insertChild(rec) {
|
|
380
|
-
this._records[Const.generateKey(rec)] = rec;
|
|
381
|
-
return null;
|
|
382
|
-
}
|
|
383
|
-
updateChild(rec) {
|
|
384
|
-
let exist = this._records[Const.generateKey(rec)];
|
|
385
|
-
if (exist == null) {
|
|
386
|
-
console.error("[UpdateOdd] Cannot find record " + this._matchId + " " + this._id + " " + rec.source() + " " + rec.id());
|
|
387
|
-
return;
|
|
388
|
-
}
|
|
389
|
-
let builder = BuilderProvider.getRecordBuilder(exist);
|
|
390
|
-
builder.merge(rec);
|
|
391
|
-
this._records[Const.generateKey(exist)] = builder.build();
|
|
392
|
-
}
|
|
393
|
-
deleteChild(rec) {
|
|
394
|
-
delete this._records[Const.generateKey(rec)];
|
|
395
|
-
return null;
|
|
396
|
-
}
|
|
397
|
-
aggregateInsert(event) {
|
|
398
|
-
event.eventStates().forEach(state => {
|
|
399
|
-
this._states[state.partitionKey().toString()] = state;
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
|
-
aggregateUpdate(event) {
|
|
403
|
-
event.eventStates().forEach(state => {
|
|
404
|
-
this._states[state.partitionKey().toString()] = state;
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
aggregateDelete(event) {
|
|
408
|
-
event.eventStates().forEach(state => {
|
|
409
|
-
delete this._states[state.partitionKey().toString()];
|
|
410
|
-
});
|
|
411
|
-
return Object.keys(this._states).length == 0;
|
|
412
|
-
}
|
|
413
|
-
reset(key) {
|
|
414
|
-
if (this._states[key.toString()] == null) {
|
|
415
|
-
return null;
|
|
416
|
-
}
|
|
417
|
-
// Create remvoved event builder
|
|
418
|
-
let removedDataEventBuilder = BuilderProvider.getEventBuilder(this.build());
|
|
419
|
-
// Clear removed event's state
|
|
420
|
-
removedDataEventBuilder._states = {};
|
|
421
|
-
removedDataEventBuilder._records = {};
|
|
422
|
-
// Transfer Event State
|
|
423
|
-
let state = this._states[key.toString()];
|
|
424
|
-
removedDataEventBuilder._states[key.toString()] = state;
|
|
425
|
-
delete this._states[key.toString()];
|
|
426
|
-
// Remove records
|
|
427
|
-
let recKeys = Object.keys(this._records);
|
|
428
|
-
for (let recKey of recKeys) {
|
|
429
|
-
let rec = this._records[recKey];
|
|
430
|
-
if (rec.source() === key.source() && this.getOddTypeInt(rec.oddType()) === this.getOddTypeInt(key.oddType())) {
|
|
431
|
-
removedDataEventBuilder.insertChild(rec);
|
|
432
|
-
delete this._records[recKey];
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
return removedDataEventBuilder;
|
|
436
|
-
}
|
|
437
|
-
getOddTypeInt(oddType) {
|
|
438
|
-
if (isNaN(oddType)) {
|
|
439
|
-
return Number(jayeson_lib_record_1.OddType[oddType]);
|
|
440
|
-
}
|
|
441
|
-
else {
|
|
442
|
-
return Number(oddType);
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
isEmpty() {
|
|
446
|
-
if (this._states == null) {
|
|
447
|
-
return true;
|
|
448
|
-
}
|
|
449
|
-
return (Object.keys(this._states).length == 0);
|
|
450
|
-
}
|
|
451
|
-
build() {
|
|
452
|
-
throw new TypeError("Not Implemented for abstract class");
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
class B2EventStateBuilder {
|
|
456
|
-
constructor(state) {
|
|
457
|
-
this.mergeFrom(state);
|
|
458
|
-
}
|
|
459
|
-
statsOne() {
|
|
460
|
-
return this._statsOne;
|
|
461
|
-
}
|
|
462
|
-
stateTwo() {
|
|
463
|
-
return this._statsTwo;
|
|
464
|
-
}
|
|
465
|
-
duration() {
|
|
466
|
-
return this._duration;
|
|
467
|
-
}
|
|
468
|
-
key() {
|
|
469
|
-
return this._key;
|
|
470
|
-
}
|
|
471
|
-
matchId() {
|
|
472
|
-
return this._matchId;
|
|
473
|
-
}
|
|
474
|
-
eventId() {
|
|
475
|
-
return this._eventId;
|
|
476
|
-
}
|
|
477
|
-
createdTime() {
|
|
478
|
-
return this._createdTime;
|
|
479
|
-
}
|
|
480
|
-
build() {
|
|
481
|
-
throw new TypeError("UnSupported Operation in abstract class");
|
|
482
|
-
}
|
|
483
|
-
mergeFrom(state) {
|
|
484
|
-
let b2State = state;
|
|
485
|
-
this._statsOne = b2State.statsOne();
|
|
486
|
-
this._statsTwo = b2State.statsTwo();
|
|
487
|
-
this._duration = b2State.duration();
|
|
488
|
-
this._key = b2State.partitionKey();
|
|
489
|
-
this._matchId = b2State.matchId();
|
|
490
|
-
this._eventId = b2State.eventId();
|
|
491
|
-
this._createdTime = new Date().getMilliseconds();
|
|
492
|
-
}
|
|
493
|
-
merge(state) {
|
|
494
|
-
let b2State = state;
|
|
495
|
-
this.setStatsOne(b2State.statsOf(0));
|
|
496
|
-
this.setStatsTwo(b2State.statsOf(1));
|
|
497
|
-
this.setDuration(b2State.duration());
|
|
498
|
-
this.setEventId(b2State.eventId());
|
|
499
|
-
this.setMatchId(b2State.matchId());
|
|
500
|
-
this.setKey(b2State.partitionKey());
|
|
501
|
-
}
|
|
502
|
-
setStatsOne(stasOne) {
|
|
503
|
-
this._statsOne = stasOne;
|
|
504
|
-
}
|
|
505
|
-
setStatsTwo(stasTwo) {
|
|
506
|
-
this._statsTwo = stasTwo;
|
|
507
|
-
}
|
|
508
|
-
setDuration(duration) {
|
|
509
|
-
this._duration = duration;
|
|
510
|
-
}
|
|
511
|
-
setKey(key) {
|
|
512
|
-
this._key = key;
|
|
513
|
-
}
|
|
514
|
-
setMatchId(matchId) {
|
|
515
|
-
this._matchId = matchId;
|
|
516
|
-
}
|
|
517
|
-
setEventId(eventId) {
|
|
518
|
-
this._eventId = eventId;
|
|
519
|
-
}
|
|
520
|
-
setCreatedTime(createdTime) {
|
|
521
|
-
this._createdTime = createdTime;
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
class B2RecordBuilder {
|
|
525
|
-
constructor(rec) {
|
|
526
|
-
this.mergeFrom(rec);
|
|
527
|
-
}
|
|
528
|
-
eventId() {
|
|
529
|
-
return this._eventId;
|
|
530
|
-
}
|
|
531
|
-
matchId() {
|
|
532
|
-
return this._matchId;
|
|
533
|
-
}
|
|
534
|
-
id() {
|
|
535
|
-
return this._id;
|
|
536
|
-
}
|
|
537
|
-
oddType() {
|
|
538
|
-
return this._oddType;
|
|
539
|
-
}
|
|
540
|
-
lbType() {
|
|
541
|
-
return this._lbType;
|
|
542
|
-
}
|
|
543
|
-
timetype() {
|
|
544
|
-
return this._timetype;
|
|
545
|
-
}
|
|
546
|
-
sportbook() {
|
|
547
|
-
return this._sportbook;
|
|
548
|
-
}
|
|
549
|
-
meta() {
|
|
550
|
-
return this._meta;
|
|
551
|
-
}
|
|
552
|
-
oddFormat() {
|
|
553
|
-
return this._oddFormat;
|
|
554
|
-
}
|
|
555
|
-
rateOver() {
|
|
556
|
-
return this._rateOver;
|
|
557
|
-
}
|
|
558
|
-
rateUnder() {
|
|
559
|
-
return this._rateUnder;
|
|
560
|
-
}
|
|
561
|
-
rateEqual() {
|
|
562
|
-
return this._rateEqual;
|
|
563
|
-
}
|
|
564
|
-
pivotValue() {
|
|
565
|
-
return this._pivotValue;
|
|
566
|
-
}
|
|
567
|
-
pivotType() {
|
|
568
|
-
return this._pivotType;
|
|
569
|
-
}
|
|
570
|
-
pivotBias() {
|
|
571
|
-
return this._pivotBias;
|
|
572
|
-
}
|
|
573
|
-
rateOverId() {
|
|
574
|
-
return this._rateOverId;
|
|
575
|
-
}
|
|
576
|
-
rateUnderId() {
|
|
577
|
-
return this._rateUnderId;
|
|
578
|
-
}
|
|
579
|
-
rateEqualId() {
|
|
580
|
-
return this._rateEqualId;
|
|
581
|
-
}
|
|
582
|
-
isSwapped() {
|
|
583
|
-
return this._isSwapped;
|
|
584
|
-
}
|
|
585
|
-
setEventId(eventId) {
|
|
586
|
-
this._eventId = eventId;
|
|
587
|
-
}
|
|
588
|
-
setMatchId(matchId) {
|
|
589
|
-
this._matchId = matchId;
|
|
590
|
-
}
|
|
591
|
-
setId(id) {
|
|
592
|
-
this._id = id;
|
|
593
|
-
}
|
|
594
|
-
setOddType(oddType) {
|
|
595
|
-
this._oddType = oddType;
|
|
596
|
-
}
|
|
597
|
-
setLbType(lbType) {
|
|
598
|
-
this._lbType = lbType;
|
|
599
|
-
}
|
|
600
|
-
setTimeType(timetype) {
|
|
601
|
-
this._timetype = timetype;
|
|
602
|
-
}
|
|
603
|
-
setSportbook(sportbook) {
|
|
604
|
-
this._sportbook = sportbook;
|
|
605
|
-
}
|
|
606
|
-
setMeta(meta) {
|
|
607
|
-
this._meta = meta;
|
|
608
|
-
}
|
|
609
|
-
setOddFormat(oddFormat) {
|
|
610
|
-
this._oddFormat = oddFormat;
|
|
611
|
-
}
|
|
612
|
-
setRateOver(rateOver) {
|
|
613
|
-
this._rateOver = rateOver;
|
|
614
|
-
}
|
|
615
|
-
setRateUnder(rateUnder) {
|
|
616
|
-
this._rateUnder = rateUnder;
|
|
617
|
-
}
|
|
618
|
-
setRateEqual(rateEqual) {
|
|
619
|
-
this._rateEqual = rateEqual;
|
|
620
|
-
}
|
|
621
|
-
setPivotValue(pivotValue) {
|
|
622
|
-
this._pivotValue = pivotValue;
|
|
623
|
-
}
|
|
624
|
-
setPivotType(pivotType) {
|
|
625
|
-
this._pivotType = pivotType;
|
|
626
|
-
}
|
|
627
|
-
setPivotBias(pivotBias) {
|
|
628
|
-
this._pivotBias = pivotBias;
|
|
629
|
-
}
|
|
630
|
-
setRateOverId(rateOverId) {
|
|
631
|
-
this._rateOverId = rateOverId;
|
|
632
|
-
}
|
|
633
|
-
setRateUnderId(rateUnderId) {
|
|
634
|
-
this._rateUnderId = rateUnderId;
|
|
635
|
-
}
|
|
636
|
-
setRateEqualId(rateEqualId) {
|
|
637
|
-
this._rateEqualId = rateEqualId;
|
|
638
|
-
}
|
|
639
|
-
setSwapped(isSwapped) {
|
|
640
|
-
this._isSwapped = isSwapped;
|
|
641
|
-
}
|
|
642
|
-
build() {
|
|
643
|
-
throw new TypeError("UnSupported in Abstract class");
|
|
644
|
-
}
|
|
645
|
-
merge(rec) {
|
|
646
|
-
let b2Rec = rec;
|
|
647
|
-
this.setRateOver(b2Rec.rateOver());
|
|
648
|
-
this.setRateUnder(b2Rec.rateUnder());
|
|
649
|
-
this.setRateEqual(b2Rec.rateEqual());
|
|
650
|
-
if (b2Rec.rateOverId) {
|
|
651
|
-
this.setRateOverId(b2Rec.rateOverId());
|
|
652
|
-
}
|
|
653
|
-
if (b2Rec.rateUnderId) {
|
|
654
|
-
this.setRateOverId(b2Rec.rateUnderId());
|
|
655
|
-
}
|
|
656
|
-
if (b2Rec.rateEqualId) {
|
|
657
|
-
this.setRateOverId(b2Rec.rateEqualId());
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
mergeFrom(record) {
|
|
661
|
-
let rec = record;
|
|
662
|
-
this._eventId = rec.eventId();
|
|
663
|
-
this._matchId = rec.matchId();
|
|
664
|
-
this._id = rec.id();
|
|
665
|
-
this._oddType = rec.oddType();
|
|
666
|
-
this._lbType = rec.lbType();
|
|
667
|
-
this._timetype = rec.timeType();
|
|
668
|
-
this._sportbook = rec.source();
|
|
669
|
-
this._meta = rec.meta();
|
|
670
|
-
this._oddFormat = rec.oddFormat();
|
|
671
|
-
this._rateOver = rec.rateOver();
|
|
672
|
-
this._rateUnder = rec.rateUnder();
|
|
673
|
-
this._rateEqual = rec.rateEqual();
|
|
674
|
-
this._pivotValue = rec.pivotValue();
|
|
675
|
-
this._pivotType = rec.pivotType();
|
|
676
|
-
this._pivotBias = rec.pivotBias();
|
|
677
|
-
this._rateOverId = rec.rateOverId();
|
|
678
|
-
this._rateUnderId = rec.rateUnderId();
|
|
679
|
-
this._rateEqualId = rec.rateEqualId();
|
|
680
|
-
this._isSwapped = rec.isSwapped();
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
exports.B2RecordBuilder = B2RecordBuilder;
|
|
684
|
-
/*
|
|
685
|
-
* Builder is the "concrete" implementation of
|
|
686
|
-
* builders for every sport specific match event and record builders
|
|
687
|
-
*/
|
|
688
|
-
var Builder;
|
|
689
|
-
(function (Builder) {
|
|
690
|
-
class Snapshot extends IndexedSnapshotBuilder {
|
|
691
|
-
constructor(input) {
|
|
692
|
-
super(input);
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
Builder.Snapshot = Snapshot;
|
|
696
|
-
})(Builder || (Builder = {}));
|
|
697
|
-
(function (Builder) {
|
|
698
|
-
var Match;
|
|
699
|
-
(function (Match) {
|
|
700
|
-
class Tennis extends B2MatchBuilder {
|
|
701
|
-
constructor(t) {
|
|
702
|
-
super(t);
|
|
703
|
-
}
|
|
704
|
-
setGender(_gender) {
|
|
705
|
-
this.gender = _gender;
|
|
706
|
-
}
|
|
707
|
-
setCountry(_country) {
|
|
708
|
-
this.country = _country;
|
|
709
|
-
}
|
|
710
|
-
mergeFrom(t) {
|
|
711
|
-
super.mergeFrom(t);
|
|
712
|
-
let tm = t;
|
|
713
|
-
this.setGender(tm.gender());
|
|
714
|
-
this.setCountry(tm.country());
|
|
715
|
-
}
|
|
716
|
-
build() {
|
|
717
|
-
let events = [];
|
|
718
|
-
for (let evt of Object.keys(this._events)) {
|
|
719
|
-
events.push(this._events[evt]);
|
|
720
|
-
}
|
|
721
|
-
return new jayeson_lib_record_1.TennisMatchImpl(this._p1, this._p2, this._startTime, events, this._id, this._league, this.gender, this.country, this._meta);
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
Match.Tennis = Tennis;
|
|
725
|
-
class Soccer extends B2MatchBuilder {
|
|
726
|
-
constructor(t) {
|
|
727
|
-
super(t);
|
|
728
|
-
}
|
|
729
|
-
leagueType() {
|
|
730
|
-
return this._leagueType;
|
|
731
|
-
}
|
|
732
|
-
gender() {
|
|
733
|
-
return this._gender;
|
|
734
|
-
}
|
|
735
|
-
country() {
|
|
736
|
-
return this._country;
|
|
737
|
-
}
|
|
738
|
-
setLeagueType(leagueType) {
|
|
739
|
-
this._leagueType = leagueType;
|
|
740
|
-
}
|
|
741
|
-
setGender(gender) {
|
|
742
|
-
this._gender = gender;
|
|
743
|
-
}
|
|
744
|
-
setCountry(country) {
|
|
745
|
-
this._country = country;
|
|
746
|
-
}
|
|
747
|
-
mergeFrom(t) {
|
|
748
|
-
super.mergeFrom(t);
|
|
749
|
-
let sm = t;
|
|
750
|
-
this.setLeagueType(sm.leagueType());
|
|
751
|
-
this.setCountry(t.country());
|
|
752
|
-
this.setGender(sm.gender());
|
|
753
|
-
}
|
|
754
|
-
build() {
|
|
755
|
-
let events = [];
|
|
756
|
-
for (let evt of Object.keys(this._events)) {
|
|
757
|
-
events.push(this._events[evt]);
|
|
758
|
-
}
|
|
759
|
-
return new jayeson_lib_record_1.SoccerMatchImpl(this._p1, this._p2, this._startTime, events, this._id, this._league, this._meta, this._leagueType, this._gender, this._country);
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
Match.Soccer = Soccer;
|
|
763
|
-
class Basketball extends B2MatchBuilder {
|
|
764
|
-
constructor(t) {
|
|
765
|
-
super(t);
|
|
766
|
-
}
|
|
767
|
-
gender() {
|
|
768
|
-
return this._gender;
|
|
769
|
-
}
|
|
770
|
-
country() {
|
|
771
|
-
return this._country;
|
|
772
|
-
}
|
|
773
|
-
setGender(gender) {
|
|
774
|
-
this._gender = gender;
|
|
775
|
-
}
|
|
776
|
-
setCountry(country) {
|
|
777
|
-
this._country = country;
|
|
778
|
-
}
|
|
779
|
-
build() {
|
|
780
|
-
let events = [];
|
|
781
|
-
for (let evt of Object.keys(this._events)) {
|
|
782
|
-
events.push(this._events[evt]);
|
|
783
|
-
}
|
|
784
|
-
return new jayeson_lib_record_1.BasketballMatchImpl(this._p1, this._p2, this._startTime, events, this._id, this._league, this._gender, this._country, this._meta);
|
|
785
|
-
}
|
|
786
|
-
mergeFrom(match) {
|
|
787
|
-
super.mergeFrom(match);
|
|
788
|
-
let bm = match;
|
|
789
|
-
this.setGender(bm.gender());
|
|
790
|
-
this.setCountry(bm.country());
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
Match.Basketball = Basketball;
|
|
794
|
-
})(Match = Builder.Match || (Builder.Match = {}));
|
|
795
|
-
})(Builder || (Builder = {}));
|
|
796
|
-
/**
|
|
797
|
-
* TODO Fis the way records and states are generated before building
|
|
798
|
-
*/
|
|
799
|
-
(function (Builder) {
|
|
800
|
-
var Event;
|
|
801
|
-
(function (Event) {
|
|
802
|
-
class Tennis extends B2EventBuilder {
|
|
803
|
-
constructor(event) {
|
|
804
|
-
super(event);
|
|
805
|
-
}
|
|
806
|
-
build() {
|
|
807
|
-
let records = [];
|
|
808
|
-
for (let rec of Object.keys(this._records)) {
|
|
809
|
-
records.push(this._records[rec]);
|
|
810
|
-
}
|
|
811
|
-
let states = [];
|
|
812
|
-
for (let state of Object.keys(this._states)) {
|
|
813
|
-
states.push(this._states[state]);
|
|
814
|
-
}
|
|
815
|
-
return new jayeson_lib_record_1.TennisEventImpl(this._id, records, states, this._matchId, this._eventType, this._meta);
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
Event.Tennis = Tennis;
|
|
819
|
-
class Soccer extends B2EventBuilder {
|
|
820
|
-
constructor(event) {
|
|
821
|
-
super(event);
|
|
822
|
-
}
|
|
823
|
-
build() {
|
|
824
|
-
let records = [];
|
|
825
|
-
for (let rec of Object.keys(this._records)) {
|
|
826
|
-
records.push(this._records[rec]);
|
|
827
|
-
}
|
|
828
|
-
let states = [];
|
|
829
|
-
for (let state of Object.keys(this._states)) {
|
|
830
|
-
states.push(this._states[state]);
|
|
831
|
-
}
|
|
832
|
-
return new jayeson_lib_record_1.SoccerEventImpl(this._id, records, states, this._matchId, this._eventType, this._meta);
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
Event.Soccer = Soccer;
|
|
836
|
-
class Basketball extends B2EventBuilder {
|
|
837
|
-
constructor(event) {
|
|
838
|
-
super(event);
|
|
839
|
-
}
|
|
840
|
-
build() {
|
|
841
|
-
let records = [];
|
|
842
|
-
for (let rec of Object.keys(this._records)) {
|
|
843
|
-
records.push(this._records[rec]);
|
|
844
|
-
}
|
|
845
|
-
let states = [];
|
|
846
|
-
for (let state of Object.keys(this._states)) {
|
|
847
|
-
states.push(this._states[state]);
|
|
848
|
-
}
|
|
849
|
-
return new jayeson_lib_record_1.BasketballEventImpl(this._id, records, states, this._matchId, this._eventType, this._meta);
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
Event.Basketball = Basketball;
|
|
853
|
-
})(Event = Builder.Event || (Builder.Event = {}));
|
|
854
|
-
})(Builder || (Builder = {}));
|
|
855
|
-
(function (Builder) {
|
|
856
|
-
var Record;
|
|
857
|
-
(function (Record) {
|
|
858
|
-
class Tennis extends B2RecordBuilder {
|
|
859
|
-
constructor(rec) {
|
|
860
|
-
super(rec);
|
|
861
|
-
}
|
|
862
|
-
build() {
|
|
863
|
-
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);
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
Record.Tennis = Tennis;
|
|
867
|
-
class Soccer extends B2RecordBuilder {
|
|
868
|
-
constructor(rec) {
|
|
869
|
-
super(rec);
|
|
870
|
-
}
|
|
871
|
-
build() {
|
|
872
|
-
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);
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
Record.Soccer = Soccer;
|
|
876
|
-
class Basketball extends B2RecordBuilder {
|
|
877
|
-
constructor(rec) {
|
|
878
|
-
super(rec);
|
|
879
|
-
}
|
|
880
|
-
build() {
|
|
881
|
-
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);
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
Record.Basketball = Basketball;
|
|
885
|
-
})(Record = Builder.Record || (Builder.Record = {}));
|
|
886
|
-
})(Builder || (Builder = {}));
|
|
887
|
-
(function (Builder) {
|
|
888
|
-
var EventState;
|
|
889
|
-
(function (EventState) {
|
|
890
|
-
class Soccer extends B2EventStateBuilder {
|
|
891
|
-
constructor(state) {
|
|
892
|
-
super(state);
|
|
893
|
-
}
|
|
894
|
-
build() {
|
|
895
|
-
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);
|
|
896
|
-
}
|
|
897
|
-
setHostScore(hostScore) {
|
|
898
|
-
let list = this._statsOne.getScores();
|
|
899
|
-
list[0] = hostScore;
|
|
900
|
-
this._statsOne.setScores(list);
|
|
901
|
-
}
|
|
902
|
-
setHostCard(hostCard) {
|
|
903
|
-
let list = this._statsOne.getScores();
|
|
904
|
-
list[1] = hostCard;
|
|
905
|
-
this._statsOne.setScores(list);
|
|
906
|
-
}
|
|
907
|
-
setGuestScore(guestScore) {
|
|
908
|
-
let list = this._statsTwo.getScores();
|
|
909
|
-
list[0] = guestScore;
|
|
910
|
-
this._statsTwo.setScores(list);
|
|
911
|
-
}
|
|
912
|
-
setGuestCard(guestCard) {
|
|
913
|
-
let list = this._statsTwo.getScores();
|
|
914
|
-
list[1] = guestCard;
|
|
915
|
-
this._statsTwo.setScores(list);
|
|
916
|
-
}
|
|
917
|
-
setSegment(segment) {
|
|
918
|
-
this.segment = segment;
|
|
919
|
-
}
|
|
920
|
-
setBookPriority(bookPriority) {
|
|
921
|
-
this.bookPriority = bookPriority;
|
|
922
|
-
}
|
|
923
|
-
mergeFrom(eventState) {
|
|
924
|
-
super.mergeFrom(eventState);
|
|
925
|
-
let se = eventState;
|
|
926
|
-
this.setHostCard(se.hostCard());
|
|
927
|
-
this.setGuestCard(se.guestCard());
|
|
928
|
-
this.setHostScore(se.hostScore());
|
|
929
|
-
this.setGuestScore(se.guestScore());
|
|
930
|
-
this.setSegment(se.segment());
|
|
931
|
-
this.setBookPriority(se.bookPriority());
|
|
932
|
-
}
|
|
933
|
-
merge(state) {
|
|
934
|
-
super.merge(state);
|
|
935
|
-
let se = state;
|
|
936
|
-
if (se.segment != null) {
|
|
937
|
-
this.setSegment(se.segment());
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
EventState.Soccer = Soccer;
|
|
942
|
-
class Tennis extends B2EventStateBuilder {
|
|
943
|
-
constructor(state) {
|
|
944
|
-
super(state);
|
|
945
|
-
}
|
|
946
|
-
build() {
|
|
947
|
-
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);
|
|
948
|
-
}
|
|
949
|
-
setSet(setScore) {
|
|
950
|
-
this.setScore = setScore;
|
|
951
|
-
}
|
|
952
|
-
setGame(game) {
|
|
953
|
-
this.game = game;
|
|
954
|
-
}
|
|
955
|
-
setBookPriority(bookPriority) {
|
|
956
|
-
this.bookPriority = bookPriority;
|
|
957
|
-
}
|
|
958
|
-
mergeFrom(state) {
|
|
959
|
-
super.mergeFrom(state);
|
|
960
|
-
let st = state;
|
|
961
|
-
this.setSet(st.set());
|
|
962
|
-
this.setGame(st.game());
|
|
963
|
-
this.setBookPriority(st.bookPriority());
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
EventState.Tennis = Tennis;
|
|
967
|
-
class Basketball extends B2EventStateBuilder {
|
|
968
|
-
constructor(state) {
|
|
969
|
-
super(state);
|
|
970
|
-
}
|
|
971
|
-
build() {
|
|
972
|
-
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);
|
|
973
|
-
}
|
|
974
|
-
setSegment(segment) {
|
|
975
|
-
this.segment = segment;
|
|
976
|
-
}
|
|
977
|
-
setBookPriority(bookPriority) {
|
|
978
|
-
this.bookPriority = bookPriority;
|
|
979
|
-
}
|
|
980
|
-
setTimeout(isTimeout) {
|
|
981
|
-
this.isTimeout = isTimeout;
|
|
982
|
-
}
|
|
983
|
-
mergeFrom(state) {
|
|
984
|
-
super.mergeFrom(state);
|
|
985
|
-
//be: BasketballEventState = <BasketballEventState> state;
|
|
986
|
-
//TODO
|
|
987
|
-
//setSegment(be.getSegment());
|
|
988
|
-
//setTimeout(be.isTimeout());
|
|
989
|
-
//setBookPriority(be.bookPriority());
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
EventState.Basketball = Basketball;
|
|
993
|
-
})(EventState = Builder.EventState || (Builder.EventState = {}));
|
|
994
|
-
})(Builder || (Builder = {}));
|
|
995
|
-
/**
|
|
996
|
-
* TODO:
|
|
997
|
-
* Fix use SoccerMatch interface instead of
|
|
998
|
-
* Implementation to check type
|
|
999
|
-
*/
|
|
1000
|
-
class BuilderProvider {
|
|
1001
|
-
static getMatchBuilder(match) {
|
|
1002
|
-
if (match instanceof jayeson_lib_record_1.SoccerMatchImpl) {
|
|
1003
|
-
return new Builder.Match.Soccer(match);
|
|
1004
|
-
}
|
|
1005
|
-
else if (match instanceof jayeson_lib_record_1.TennisMatchImpl) {
|
|
1006
|
-
return new Builder.Match.Tennis(match);
|
|
1007
|
-
}
|
|
1008
|
-
else if (match instanceof jayeson_lib_record_1.BasketballMatchImpl) {
|
|
1009
|
-
return new Builder.Match.Basketball(match);
|
|
1010
|
-
}
|
|
1011
|
-
else {
|
|
1012
|
-
throw new TypeError("Cannot Create Builder for " + match.constructor.toString());
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
static getEventBuilder(event) {
|
|
1016
|
-
if (event instanceof jayeson_lib_record_1.SoccerEventImpl) {
|
|
1017
|
-
return new Builder.Event.Soccer(event);
|
|
1018
|
-
}
|
|
1019
|
-
else if (event instanceof jayeson_lib_record_1.TennisEventImpl) {
|
|
1020
|
-
return new Builder.Event.Tennis(event);
|
|
1021
|
-
}
|
|
1022
|
-
else if (event instanceof jayeson_lib_record_1.BasketballEventImpl) {
|
|
1023
|
-
return new Builder.Event.Basketball(event);
|
|
1024
|
-
}
|
|
1025
|
-
else {
|
|
1026
|
-
throw new TypeError("Cannot Create Builder for " + event.constructor.toString());
|
|
1027
|
-
}
|
|
1028
|
-
}
|
|
1029
|
-
static getRecordBuilder(record) {
|
|
1030
|
-
if (record instanceof jayeson_lib_record_1.SoccerRecord) {
|
|
1031
|
-
return new Builder.Record.Soccer(record);
|
|
1032
|
-
}
|
|
1033
|
-
else if (record instanceof jayeson_lib_record_1.TennisRecord) {
|
|
1034
|
-
return new Builder.Record.Tennis(record);
|
|
1035
|
-
}
|
|
1036
|
-
else if (record instanceof jayeson_lib_record_1.BasketballRecord) {
|
|
1037
|
-
return new Builder.Record.Basketball(record);
|
|
1038
|
-
}
|
|
1039
|
-
else {
|
|
1040
|
-
throw new TypeError("Cannot Create Builder for " + record.constructor.toString());
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
static getEventStateBuilder(state) {
|
|
1044
|
-
if (state instanceof jayeson_lib_record_1.SoccerEventState) {
|
|
1045
|
-
return new Builder.EventState.Soccer(state);
|
|
1046
|
-
}
|
|
1047
|
-
else if (state instanceof jayeson_lib_record_1.TennisEventState) {
|
|
1048
|
-
return new Builder.EventState.Tennis(state);
|
|
1049
|
-
}
|
|
1050
|
-
else if (state instanceof jayeson_lib_record_1.BasketballEventState) {
|
|
1051
|
-
return new Builder.EventState.Basketball(state);
|
|
1052
|
-
}
|
|
1053
|
-
else {
|
|
1054
|
-
throw new TypeError("Cannot Create Builder for " + state.constructor.toString());
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
static getSnapshotBuilder(parentSs) {
|
|
1058
|
-
return new Builder.Snapshot(parentSs);
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
exports.BuilderProvider = BuilderProvider;
|
|
1
|
+
var Builder,__createBinding=this&&this.__createBinding||(Object.create?function(t,e,r,s){void 0===s&&(s=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,s,i)}:function(t,e,r,s){t[s=void 0===s?r:s]=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};Object.defineProperty(exports,"__esModule",{value:!0}),exports.BuilderProvider=exports.B2RecordBuilder=exports.Const=void 0;let jayeson_lib_record_1=require("@jayesol/jayeson.lib.record"),data_structure_1=require("./data_structure"),codec_1=require("./codec"),Collections=__importStar(require("typescript-collections"));class Const{static generateKey(t){return t.source()+this.SEPARATOR+t.id()}}(exports.Const=Const).AGGREGATE_KEY="AGGREGATE_KEY",Const.SEPARATOR="_";class IndexedSnapshotBuilder{constructor(t){if(this._matches={},this._partitions=new Collections.Dictionary,null!=t){for(var e of t.matches())this._matches[e.id()]=e;for(var r of t.getPartitionMap().keys())this._partitions.setValue(r,t.getPartitionMap().getValue(r))}}matches(){return this._matches}partitions(){return this._partitions}setPartition(t){this._partitions=t}setPartitionValue(t,e){this._partitions.setValue(t,e)}removePartitionKey(t){return this._partitions.remove(t)}markPartitionAsUpdated(t,e){null==e&&(e=(new Date).getMilliseconds()),this._partitions.setValue(t,e)}replaceMatch(t){this._matches[t.id()]=t}reset(t){if(!this._partitions.containsKey(t))return null;var e,r=this._matches,s=BuilderProvider.getSnapshotBuilder(this.build()),i=(s._matches={},s._partitions.clear(),this.removePartitionKey(t));for(e in s.setPartitionValue(t,i),this._matches){var a=this._matches[e],n=BuilderProvider.getMatchBuilder(a),o=n.reset(t);null==o||o.isEmpty()||s.insertChild(o.build()),n.isEmpty()?delete r[a.id()]:r[a.id()]=n.build()}return this._matches=r,s}insertChild(t){var e=this._matches[t.id()];let r=null;return null==e?this._matches[t.id()]=t:(r=t.id(),(e=BuilderProvider.getMatchBuilder(e)).aggregateInsert(t),this._matches[t.id()]=e.build()),r}updateChild(t){var e=this._matches[t.id()];null==e?console.error("[UpdateMatch] Cannot found matchId %s to execute update match from %s",t.id(),t.meta()[Const.AGGREGATE_KEY]):((e=BuilderProvider.getMatchBuilder(e)).aggregateUpdate(t),this._matches[t.id()]=e.build())}deleteChild(t){var e=this._matches[t.id()];let r=null;if(null!=e)return(e=BuilderProvider.getMatchBuilder(e)).aggregateDelete(t)?delete this._matches[t.id()]:(this._matches[t.id()]=e.build(),r=t.id()),r;console.error("[DeleteMatch] Cannot found matchId %s to execute delete match from %s",t.id(),t.meta()[Const.AGGREGATE_KEY])}build(){var e,r={};for(e in this._matches){var s=this._matches[e];let t=r[s.sportType()];null==t&&(t=[],r[s.sportType()]=t),t.push(s)}return new data_structure_1.IndexedSnapshotImpl(r,this._partitions)}}class B2MatchBuilder{constructor(t){this._events={},this.mergeFrom(t)}meta(){return this._meta}startTime(){return this._startTime}events(){return this._events}id(){return this._id}league(){return this._league}sport(){return this._sport}meata(){return this._meta}p1(){return this._p1}p2(){return this._p2}setEvent(t){this._events=t}mergeFrom(t){for(var e in this._startTime=t.startTime(),this._id=t.id(),this._league=t.league(),this._sport=t.sportType(),this._meta={},t.meta())this._meta[e]=t.meta()[e];if(null!=t.events())for(var r of t.events())this._events[r.id()]=r;var s=t;this._p1=s.participantOne(),this._p2=s.participantTwo()}replaceEvent(t){this._events[t.id()]=t}reset(t){var e=t.toString(),r=this._meta[Const.AGGREGATE_KEY];if(!codec_1.Util.containsKey(r,e))return null;var s,i=BuilderProvider.getMatchBuilder(this.build()),r=codec_1.Util.removeKey(r,e),a=(this._meta[Const.AGGREGATE_KEY]=r,i._meta[Const.AGGREGATE_KEY]=e,{});for(s in i._events={},this._events){var n=this._events[s],o=BuilderProvider.getEventBuilder(n),d=o.reset(t);null==d||d.isEmpty()||i.insertChild(d.build()),o.isEmpty()?delete a[n.id()]:a[n.id()]=o.build()}return this._events=a,i}aggregateInsert(t){for(var e in t.meta())e!==Const.AGGREGATE_KEY&&(this._meta[e]=t.meta()[e]);var r=t.meta()[Const.AGGREGATE_KEY],s=this._meta[Const.AGGREGATE_KEY];this._meta[Const.AGGREGATE_KEY]=codec_1.Util.addKey(s,r)}aggregateUpdate(t){for(var e in t.meta())e!==Const.AGGREGATE_KEY&&(this._meta[e]=t.meta()[e])}aggregateDelete(t){var t=t.meta()[Const.AGGREGATE_KEY],e=this._meta[Const.AGGREGATE_KEY],e=codec_1.Util.removeKey(e,t);return""===(this._meta[Const.AGGREGATE_KEY]=e)}isEmpty(){var t=this._meta[Const.AGGREGATE_KEY];return null==t||""==t}insertChild(t){var e=this._events[t.id()];let r=null;return null==e?this._events[t.id()]=t:((e=BuilderProvider.getEventBuilder(e)).aggregateInsert(t),this._events[t.id()]=e.build(),r=t.id()),r}updateChild(t){var e=this._events[t.id()];null==e?console.error("[UpdateEvent] Cannot found eventId %s to execute update event from %s",t.id(),t.meta()[Const.AGGREGATE_KEY]):((e=BuilderProvider.getEventBuilder(e)).aggregateUpdate(t),this._events[t.id()]=e.build())}deleteChild(t){var e=this._events[t.id()];let r=null;if(null!=e)return(e=BuilderProvider.getEventBuilder(e)).aggregateDelete(t)?delete this._events[t.id()]:(r=t.id(),this._events[t.id()]=e.build()),r;console.error("[DeleteEvent] Cannot found eventId %s to execute delete event from %s",t.id(),t.meta()[Const.AGGREGATE_KEY])}build(){throw new TypeError("Not supported in Abstract class")}}class B2EventBuilder{constructor(t){this._records={},this._states={},this.mergeFrom(t)}id(){return this._id}records(){return this._records}matchId(){return this._matchId}eventType(){return this._eventType}meta(){return this._meta}states(){return this._states}mergeFrom(t){var e,r=t;if(this._id=t.id(),null!=t.records())for(var s of r.records()){var i=Const.generateKey(s);this._records[i]=s}for(e in this.setStates(r.eventStates()),this._matchId=t.matchId(),this._eventType=t.eventType(),this._meta={},t.meta())this._meta[e]=t.meta()[e]}setStates(t){if(null!=t)for(var e of t)this._states[e.partitionKey().toString()]=e}insertChild(t){return this._records[Const.generateKey(t)]=t,null}updateChild(t){var e,r=this._records[Const.generateKey(t)];null==r?console.error("[UpdateOdd] Cannot find record "+this._matchId+" "+this._id+" "+t.source()+" "+t.id()):((e=BuilderProvider.getRecordBuilder(r)).merge(t),this._records[Const.generateKey(r)]=e.build())}deleteChild(t){return delete this._records[Const.generateKey(t)],null}aggregateInsert(t){t.eventStates().forEach(t=>{this._states[t.partitionKey().toString()]=t})}aggregateUpdate(t){t.eventStates().forEach(t=>{this._states[t.partitionKey().toString()]=t})}aggregateDelete(t){return t.eventStates().forEach(t=>{delete this._states[t.partitionKey().toString()]}),0==Object.keys(this._states).length}reset(t){if(null==this._states[t.toString()])return null;var e,r=BuilderProvider.getEventBuilder(this.build()),s=(r._states={},r._records={},this._states[t.toString()]),s=(r._states[t.toString()]=s,delete this._states[t.toString()],Object.keys(this._records));for(e of s){var i=this._records[e];i.source()===t.source()&&this.getOddTypeInt(i.oddType())===this.getOddTypeInt(t.oddType())&&(r.insertChild(i),delete this._records[e])}return r}getOddTypeInt(t){return isNaN(t)?Number(jayeson_lib_record_1.OddType[t]):Number(t)}isEmpty(){return null==this._states||0==Object.keys(this._states).length}build(){throw new TypeError("Not Implemented for abstract class")}}class B2EventStateBuilder{constructor(t){this.mergeFrom(t)}statsOne(){return this._statsOne}stateTwo(){return this._statsTwo}duration(){return this._duration}key(){return this._key}matchId(){return this._matchId}eventId(){return this._eventId}createdTime(){return this._createdTime}build(){throw new TypeError("UnSupported Operation in abstract class")}mergeFrom(t){this._statsOne=t.statsOne(),this._statsTwo=t.statsTwo(),this._duration=t.duration(),this._key=t.partitionKey(),this._matchId=t.matchId(),this._eventId=t.eventId(),this._createdTime=(new Date).getMilliseconds()}merge(t){this.setStatsOne(t.statsOf(0)),this.setStatsTwo(t.statsOf(1)),this.setDuration(t.duration()),this.setEventId(t.eventId()),this.setMatchId(t.matchId()),this.setKey(t.partitionKey())}setStatsOne(t){this._statsOne=t}setStatsTwo(t){this._statsTwo=t}setDuration(t){this._duration=t}setKey(t){this._key=t}setMatchId(t){this._matchId=t}setEventId(t){this._eventId=t}setCreatedTime(t){this._createdTime=t}}class B2RecordBuilder{constructor(t){this.mergeFrom(t)}eventId(){return this._eventId}matchId(){return this._matchId}id(){return this._id}oddType(){return this._oddType}lbType(){return this._lbType}timetype(){return this._timetype}sportbook(){return this._sportbook}meta(){return this._meta}oddFormat(){return this._oddFormat}rateOver(){return this._rateOver}rateUnder(){return this._rateUnder}rateEqual(){return this._rateEqual}pivotValue(){return this._pivotValue}pivotType(){return this._pivotType}pivotBias(){return this._pivotBias}rateOverId(){return this._rateOverId}rateUnderId(){return this._rateUnderId}rateEqualId(){return this._rateEqualId}isSwapped(){return this._isSwapped}setEventId(t){this._eventId=t}setMatchId(t){this._matchId=t}setId(t){this._id=t}setOddType(t){this._oddType=t}setLbType(t){this._lbType=t}setTimeType(t){this._timetype=t}setSportbook(t){this._sportbook=t}setMeta(t){this._meta=t}setOddFormat(t){this._oddFormat=t}setRateOver(t){this._rateOver=t}setRateUnder(t){this._rateUnder=t}setRateEqual(t){this._rateEqual=t}setPivotValue(t){this._pivotValue=t}setPivotType(t){this._pivotType=t}setPivotBias(t){this._pivotBias=t}setRateOverId(t){this._rateOverId=t}setRateUnderId(t){this._rateUnderId=t}setRateEqualId(t){this._rateEqualId=t}setSwapped(t){this._isSwapped=t}build(){throw new TypeError("UnSupported in Abstract class")}merge(t){this.setRateOver(t.rateOver()),this.setRateUnder(t.rateUnder()),this.setRateEqual(t.rateEqual()),t.rateOverId&&this.setRateOverId(t.rateOverId()),t.rateUnderId&&this.setRateOverId(t.rateUnderId()),t.rateEqualId&&this.setRateOverId(t.rateEqualId())}mergeFrom(t){this._eventId=t.eventId(),this._matchId=t.matchId(),this._id=t.id(),this._oddType=t.oddType(),this._lbType=t.lbType(),this._timetype=t.timeType(),this._sportbook=t.source(),this._meta=t.meta(),this._oddFormat=t.oddFormat(),this._rateOver=t.rateOver(),this._rateUnder=t.rateUnder(),this._rateEqual=t.rateEqual(),this._pivotValue=t.pivotValue(),this._pivotType=t.pivotType(),this._pivotBias=t.pivotBias(),this._rateOverId=t.rateOverId(),this._rateUnderId=t.rateUnderId(),this._rateEqualId=t.rateEqualId(),this._isSwapped=t.isSwapped()}}exports.B2RecordBuilder=B2RecordBuilder,(t=>{class e extends IndexedSnapshotBuilder{constructor(t){super(t)}}t.Snapshot=e})(Builder=Builder||{}),(t=>{{t=t.Match||(t.Match={});class e extends B2MatchBuilder{constructor(t){super(t)}setGender(t){this.gender=t}setCountry(t){this.country=t}mergeFrom(t){super.mergeFrom(t);this.setGender(t.gender()),this.setCountry(t.country())}build(){var t,e=[];for(t of Object.keys(this._events))e.push(this._events[t]);return new jayeson_lib_record_1.TennisMatchImpl(this._p1,this._p2,this._startTime,e,this._id,this._league,this.gender,this.country,this._meta)}}t.Tennis=e;class r extends B2MatchBuilder{constructor(t){super(t)}leagueType(){return this._leagueType}gender(){return this._gender}country(){return this._country}setLeagueType(t){this._leagueType=t}setGender(t){this._gender=t}setCountry(t){this._country=t}mergeFrom(t){super.mergeFrom(t);var e=t;this.setLeagueType(e.leagueType()),this.setCountry(t.country()),this.setGender(e.gender())}build(){var t,e=[];for(t of Object.keys(this._events))e.push(this._events[t]);return new jayeson_lib_record_1.SoccerMatchImpl(this._p1,this._p2,this._startTime,e,this._id,this._league,this._meta,this._leagueType,this._gender,this._country)}}t.Soccer=r;class s extends B2MatchBuilder{constructor(t){super(t)}gender(){return this._gender}country(){return this._country}setGender(t){this._gender=t}setCountry(t){this._country=t}build(){var t,e=[];for(t of Object.keys(this._events))e.push(this._events[t]);return new jayeson_lib_record_1.BasketballMatchImpl(this._p1,this._p2,this._startTime,e,this._id,this._league,this._gender,this._country,this._meta)}mergeFrom(t){super.mergeFrom(t);this.setGender(t.gender()),this.setCountry(t.country())}}t.Basketball=s}})(Builder=Builder||{}),(t=>{{t=t.Event||(t.Event={});class e extends B2EventBuilder{constructor(t){super(t)}build(){var t,e=[];for(t of Object.keys(this._records))e.push(this._records[t]);var r,s=[];for(r of Object.keys(this._states))s.push(this._states[r]);return new jayeson_lib_record_1.TennisEventImpl(this._id,e,s,this._matchId,this._eventType,this._meta)}}t.Tennis=e;class r extends B2EventBuilder{constructor(t){super(t)}build(){var t,e=[];for(t of Object.keys(this._records))e.push(this._records[t]);var r,s=[];for(r of Object.keys(this._states))s.push(this._states[r]);return new jayeson_lib_record_1.SoccerEventImpl(this._id,e,s,this._matchId,this._eventType,this._meta)}}t.Soccer=r;class s extends B2EventBuilder{constructor(t){super(t)}build(){var t,e=[];for(t of Object.keys(this._records))e.push(this._records[t]);var r,s=[];for(r of Object.keys(this._states))s.push(this._states[r]);return new jayeson_lib_record_1.BasketballEventImpl(this._id,e,s,this._matchId,this._eventType,this._meta)}}t.Basketball=s}})(Builder=Builder||{}),(t=>{{t=t.Record||(t.Record={});class e extends B2RecordBuilder{constructor(t){super(t)}build(){return new jayeson_lib_record_1.TennisRecord(this._matchId,this._eventId,this._id,this._oddType,this._lbType,this._timetype,this._sportbook,this._oddFormat,this._meta,this._rateOver,this._rateUnder,this._rateEqual,this._pivotValue,this._pivotType,this._pivotBias,this._rateOverId,this._rateUnderId,this._rateEqualId,this._isSwapped)}}t.Tennis=e;class r extends B2RecordBuilder{constructor(t){super(t)}build(){return new jayeson_lib_record_1.SoccerRecord(this._matchId,this._eventId,this._id,this._oddType,this._lbType,this._timetype,this._sportbook,this._oddFormat,this._meta,this._rateOver,this._rateUnder,this._rateEqual,this._pivotValue,this._pivotType,this._pivotBias,this._rateOverId,this._rateUnderId,this._rateEqualId,this._isSwapped)}}t.Soccer=r;class s extends B2RecordBuilder{constructor(t){super(t)}build(){return new jayeson_lib_record_1.BasketballRecord(this._matchId,this._eventId,this._id,this._oddType,this._lbType,this._timetype,this._sportbook,this._oddFormat,this._meta,this._rateOver,this._rateUnder,this._rateEqual,this._pivotValue,this._pivotType,this._pivotBias,this._rateOverId,this._rateUnderId,this._rateEqualId,this._isSwapped)}}t.Basketball=s}})(Builder=Builder||{}),(t=>{{t=t.EventState||(t.EventState={});class e extends B2EventStateBuilder{constructor(t){super(t)}build(){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)}setHostScore(t){var e=this._statsOne.getScores();e[0]=t,this._statsOne.setScores(e)}setHostCard(t){var e=this._statsOne.getScores();e[1]=t,this._statsOne.setScores(e)}setGuestScore(t){var e=this._statsTwo.getScores();e[0]=t,this._statsTwo.setScores(e)}setGuestCard(t){var e=this._statsTwo.getScores();e[1]=t,this._statsTwo.setScores(e)}setSegment(t){this.segment=t}setBookPriority(t){this.bookPriority=t}mergeFrom(t){super.mergeFrom(t);this.setHostCard(t.hostCard()),this.setGuestCard(t.guestCard()),this.setHostScore(t.hostScore()),this.setGuestScore(t.guestScore()),this.setSegment(t.segment()),this.setBookPriority(t.bookPriority())}merge(t){super.merge(t);null!=t.segment&&this.setSegment(t.segment())}}t.Soccer=e;class r extends B2EventStateBuilder{constructor(t){super(t)}build(){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)}setSet(t){this.setScore=t}setGame(t){this.game=t}setBookPriority(t){this.bookPriority=t}mergeFrom(t){super.mergeFrom(t);this.setSet(t.set()),this.setGame(t.game()),this.setBookPriority(t.bookPriority())}}t.Tennis=r;class s extends B2EventStateBuilder{constructor(t){super(t)}build(){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)}setSegment(t){this.segment=t}setBookPriority(t){this.bookPriority=t}setTimeout(t){this.isTimeout=t}mergeFrom(t){super.mergeFrom(t)}}t.Basketball=s}})(Builder=Builder||{});class BuilderProvider{static getMatchBuilder(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())}static getEventBuilder(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())}static getRecordBuilder(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())}static getEventStateBuilder(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())}static getSnapshotBuilder(t){return new Builder.Snapshot(t)}}exports.BuilderProvider=BuilderProvider;
|