rategame-shared 1.1.488 → 1.1.489
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/dist/helpers/applyRatingTagCounts.d.ts +3 -0
- package/dist/helpers/applyRatingTagCounts.js +49 -0
- package/dist/helpers/ratingTags.d.ts +11 -0
- package/dist/helpers/ratingTags.js +72 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/models/game.d.ts +3 -1
- package/dist/schemas/game.d.ts +428 -0
- package/dist/schemas/game.js +8 -1
- package/dist/schemas/notification.d.ts +5 -0
- package/dist/schemas/pick.d.ts +924 -0
- package/dist/schemas/poll.d.ts +360 -0
- package/dist/schemas/rating.d.ts +3 -0
- package/dist/schemas/rating.js +2 -0
- package/dist/schemas/scorePrediction.d.ts +720 -0
- package/dist/schemas/voting.d.ts +156 -0
- package/package.json +1 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyRatingTagCountChanges = void 0;
|
|
4
|
+
function applyRatingTagCountChanges(currentCounts, oldTags, newTags) {
|
|
5
|
+
const nextCounts = { ...(currentCounts !== null && currentCounts !== void 0 ? currentCounts : {}) };
|
|
6
|
+
const oldSet = new Set(oldTags);
|
|
7
|
+
const newSet = new Set(newTags.map((tag) => tag.normalized));
|
|
8
|
+
for (const tag of oldSet) {
|
|
9
|
+
if (newSet.has(tag)) {
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
const existing = nextCounts[tag];
|
|
13
|
+
if (!existing) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
const nextCount = existing.count - 1;
|
|
17
|
+
if (nextCount <= 0) {
|
|
18
|
+
delete nextCounts[tag];
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
nextCounts[tag] = {
|
|
22
|
+
count: nextCount,
|
|
23
|
+
display: existing.display,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const added = new Set();
|
|
28
|
+
for (const tag of newTags) {
|
|
29
|
+
if (oldSet.has(tag.normalized) || added.has(tag.normalized)) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
added.add(tag.normalized);
|
|
33
|
+
const existing = nextCounts[tag.normalized];
|
|
34
|
+
if (existing) {
|
|
35
|
+
nextCounts[tag.normalized] = {
|
|
36
|
+
count: existing.count + 1,
|
|
37
|
+
display: existing.display,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
nextCounts[tag.normalized] = {
|
|
42
|
+
count: 1,
|
|
43
|
+
display: tag.display,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return nextCounts;
|
|
48
|
+
}
|
|
49
|
+
exports.applyRatingTagCountChanges = applyRatingTagCountChanges;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type ExtractedRatingTag = {
|
|
2
|
+
normalized: string;
|
|
3
|
+
display: string;
|
|
4
|
+
};
|
|
5
|
+
export type RatingTextPart = {
|
|
6
|
+
text: string;
|
|
7
|
+
isTag: boolean;
|
|
8
|
+
startOffset: number;
|
|
9
|
+
};
|
|
10
|
+
export declare function extractRatingTags(text: string): ExtractedRatingTag[];
|
|
11
|
+
export declare function parseRatingTextWithTags(text: string): RatingTextPart[];
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseRatingTextWithTags = exports.extractRatingTags = void 0;
|
|
4
|
+
const RATING_TAG_PATTERN = /(?:^|\s)(#[\p{L}\p{N}]+)/gu;
|
|
5
|
+
function normalizeRatingTag(display) {
|
|
6
|
+
return display.normalize("NFKC").toLowerCase();
|
|
7
|
+
}
|
|
8
|
+
function getRatingTagMatches(text) {
|
|
9
|
+
const matches = [];
|
|
10
|
+
const regex = new RegExp(RATING_TAG_PATTERN.source, RATING_TAG_PATTERN.flags);
|
|
11
|
+
let match;
|
|
12
|
+
while ((match = regex.exec(text)) !== null) {
|
|
13
|
+
const display = match[1];
|
|
14
|
+
matches.push({
|
|
15
|
+
display,
|
|
16
|
+
index: match.index + (match[0].length - display.length),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return matches;
|
|
20
|
+
}
|
|
21
|
+
function extractRatingTags(text) {
|
|
22
|
+
const tags = [];
|
|
23
|
+
const seen = new Set();
|
|
24
|
+
for (const match of getRatingTagMatches(text)) {
|
|
25
|
+
const normalized = normalizeRatingTag(match.display);
|
|
26
|
+
if (seen.has(normalized)) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
seen.add(normalized);
|
|
30
|
+
tags.push({
|
|
31
|
+
normalized,
|
|
32
|
+
display: match.display,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return tags;
|
|
36
|
+
}
|
|
37
|
+
exports.extractRatingTags = extractRatingTags;
|
|
38
|
+
function parseRatingTextWithTags(text) {
|
|
39
|
+
if (!text) {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
const matches = getRatingTagMatches(text);
|
|
43
|
+
if (matches.length === 0) {
|
|
44
|
+
return [{ text, isTag: false, startOffset: 0 }];
|
|
45
|
+
}
|
|
46
|
+
const parts = [];
|
|
47
|
+
let cursor = 0;
|
|
48
|
+
for (const match of matches) {
|
|
49
|
+
if (match.index > cursor) {
|
|
50
|
+
parts.push({
|
|
51
|
+
text: text.slice(cursor, match.index),
|
|
52
|
+
isTag: false,
|
|
53
|
+
startOffset: cursor,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
parts.push({
|
|
57
|
+
text: match.display,
|
|
58
|
+
isTag: true,
|
|
59
|
+
startOffset: match.index,
|
|
60
|
+
});
|
|
61
|
+
cursor = match.index + match.display.length;
|
|
62
|
+
}
|
|
63
|
+
if (cursor < text.length) {
|
|
64
|
+
parts.push({
|
|
65
|
+
text: text.slice(cursor),
|
|
66
|
+
isTag: false,
|
|
67
|
+
startOffset: cursor,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return parts;
|
|
71
|
+
}
|
|
72
|
+
exports.parseRatingTextWithTags = parseRatingTextWithTags;
|
package/dist/index.d.ts
CHANGED
|
@@ -44,6 +44,8 @@ export * from "./models/content";
|
|
|
44
44
|
export * from "./models/advertisement";
|
|
45
45
|
export * from "./helpers/index";
|
|
46
46
|
export * from "./helpers/containsFancyText";
|
|
47
|
+
export * from "./helpers/ratingTags";
|
|
48
|
+
export * from "./helpers/applyRatingTagCounts";
|
|
47
49
|
export * from "./models/player";
|
|
48
50
|
export * from "./models/voting";
|
|
49
51
|
export * from "./models/stadium";
|
package/dist/index.js
CHANGED
|
@@ -60,6 +60,8 @@ __exportStar(require("./models/content"), exports);
|
|
|
60
60
|
__exportStar(require("./models/advertisement"), exports);
|
|
61
61
|
__exportStar(require("./helpers/index"), exports);
|
|
62
62
|
__exportStar(require("./helpers/containsFancyText"), exports);
|
|
63
|
+
__exportStar(require("./helpers/ratingTags"), exports);
|
|
64
|
+
__exportStar(require("./helpers/applyRatingTagCounts"), exports);
|
|
63
65
|
__exportStar(require("./models/player"), exports);
|
|
64
66
|
__exportStar(require("./models/voting"), exports);
|
|
65
67
|
__exportStar(require("./models/stadium"), exports);
|
package/dist/models/game.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { basketballGameSchema, broadcastSchema, cfbGameSchema, commonGameSchema, creatorPickSchema, footballGameSchema, gameRatingAggregateSchema, gameSchema, gameTeamSchema, groupedRatingAggregateSchema, mlbGameSchema, nflGameSchema, nhlGameSchema, overviewSchema, searchGameSchema, unionGameSchema, weightedRatingAggregateOptionsSchema, weightedRatingAggregateSchema } from "../schemas/game";
|
|
2
|
+
import { basketballGameSchema, broadcastSchema, cfbGameSchema, commonGameSchema, creatorPickSchema, footballGameSchema, gameRatingAggregateSchema, gameSchema, gameTeamSchema, groupedRatingAggregateSchema, mlbGameSchema, nflGameSchema, nhlGameSchema, overviewSchema, ratingTagCountSchema, ratingTagCountsSchema, searchGameSchema, unionGameSchema, weightedRatingAggregateOptionsSchema, weightedRatingAggregateSchema } from "../schemas/game";
|
|
3
3
|
import { sportType } from "../schemas/sharedTypes";
|
|
4
4
|
export type Game = z.infer<typeof gameSchema>;
|
|
5
5
|
export type BasketballGame = z.infer<typeof basketballGameSchema>;
|
|
@@ -18,5 +18,7 @@ export type WeightedRatingAggregate = z.infer<typeof weightedRatingAggregateSche
|
|
|
18
18
|
export type WeightedRatingAggregateOptions = z.infer<typeof weightedRatingAggregateOptionsSchema>;
|
|
19
19
|
export type GroupedRatingsAggregate = z.infer<typeof groupedRatingAggregateSchema>;
|
|
20
20
|
export type OverviewStats = z.infer<typeof overviewSchema>;
|
|
21
|
+
export type RatingTagCount = z.infer<typeof ratingTagCountSchema>;
|
|
22
|
+
export type RatingTagCounts = z.infer<typeof ratingTagCountsSchema>;
|
|
21
23
|
export type SportType = z.infer<typeof sportType>;
|
|
22
24
|
export type CommonGame = z.infer<typeof commonGameSchema>;
|