rategame-shared 1.1.529 → 1.1.531
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.
|
@@ -390,7 +390,7 @@ const getPlayerGameStats = (stats, league, position) => {
|
|
|
390
390
|
return undefined;
|
|
391
391
|
const positionCode = (position || '').toUpperCase();
|
|
392
392
|
const selected = {};
|
|
393
|
-
const add = (key, limit =
|
|
393
|
+
const add = (key, limit = 5, includeZero = false) => {
|
|
394
394
|
const value = stats[key];
|
|
395
395
|
if (Object.keys(selected).length < limit &&
|
|
396
396
|
((typeof value === 'number' && (includeZero || value !== 0)) ||
|
|
@@ -401,7 +401,7 @@ const getPlayerGameStats = (stats, league, position) => {
|
|
|
401
401
|
selected[key] = value;
|
|
402
402
|
}
|
|
403
403
|
};
|
|
404
|
-
const addFrom = (keys, limit =
|
|
404
|
+
const addFrom = (keys, limit = 5) => {
|
|
405
405
|
keys.forEach((key) => add(key, limit));
|
|
406
406
|
};
|
|
407
407
|
if (league === 'mlb') {
|
|
@@ -591,7 +591,7 @@ const getPlayerGameStats = (stats, league, position) => {
|
|
|
591
591
|
'dribbles_completed',
|
|
592
592
|
]);
|
|
593
593
|
}
|
|
594
|
-
if (Object.keys(selected).length <
|
|
594
|
+
if (Object.keys(selected).length < 5 &&
|
|
595
595
|
typeof stats.passes_accurate === 'number' &&
|
|
596
596
|
typeof stats.passes_total === 'number' &&
|
|
597
597
|
stats.passes_total > 0) {
|
|
@@ -62,6 +62,14 @@ export declare const articleEntitySchema: z.ZodObject<{
|
|
|
62
62
|
} | null | undefined;
|
|
63
63
|
gameEntity?: any;
|
|
64
64
|
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Editors count article length after markdown images are removed. Hosted image
|
|
67
|
+
* URLs stay in the stored markdown, so the raw body can exceed the prose cap.
|
|
68
|
+
*/
|
|
69
|
+
export declare const ARTICLE_PROSE_MAX_LENGTH = 50000;
|
|
70
|
+
export declare const ARTICLE_BODY_MAX_LENGTH = 150000;
|
|
71
|
+
export declare const stripMarkdownImages: (markdown: string) => string;
|
|
72
|
+
export declare const articleBodySchema: z.ZodEffects<z.ZodString, string, string>;
|
|
65
73
|
/**
|
|
66
74
|
* Article document schema.
|
|
67
75
|
* A user-authored long-form post. The body is stored as Markdown (GFM) and
|
|
@@ -71,7 +79,7 @@ export declare const articleSchema: z.ZodObject<{
|
|
|
71
79
|
id: z.ZodString;
|
|
72
80
|
slug: z.ZodString;
|
|
73
81
|
title: z.ZodString;
|
|
74
|
-
body: z.ZodString
|
|
82
|
+
body: z.ZodEffects<z.ZodString, string, string>;
|
|
75
83
|
imageUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
76
84
|
imageUrlMedium: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
77
85
|
imageUrlSmall: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
@@ -1875,7 +1883,7 @@ export declare const articleSchema: z.ZodObject<{
|
|
|
1875
1883
|
export declare const createArticleSchema: z.ZodObject<{
|
|
1876
1884
|
id: z.ZodOptional<z.ZodString>;
|
|
1877
1885
|
title: z.ZodString;
|
|
1878
|
-
body: z.ZodString
|
|
1886
|
+
body: z.ZodEffects<z.ZodString, string, string>;
|
|
1879
1887
|
imageUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
1880
1888
|
entities: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1881
1889
|
type: z.ZodEnum<["team", "league", "stadium", "game", "player", "rategame"]>;
|
|
@@ -3643,7 +3651,7 @@ export declare const createArticleSchema: z.ZodObject<{
|
|
|
3643
3651
|
*/
|
|
3644
3652
|
export declare const updateArticleSchema: z.ZodObject<{
|
|
3645
3653
|
title: z.ZodOptional<z.ZodString>;
|
|
3646
|
-
body: z.ZodOptional<z.ZodString
|
|
3654
|
+
body: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
3647
3655
|
imageUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
3648
3656
|
entities: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
3649
3657
|
type: z.ZodEnum<["team", "league", "stadium", "game", "player", "rategame"]>;
|
package/dist/schemas/article.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.articleThreadCommentLikeSchema = exports.articleThreadCommentSchema = exports.searchArticleSchema = exports.updateArticleSchema = exports.createArticleSchema = exports.articleSchema = exports.articleEntitySchema = exports.articleEntityTypeSchema = void 0;
|
|
3
|
+
exports.articleThreadCommentLikeSchema = exports.articleThreadCommentSchema = exports.searchArticleSchema = exports.updateArticleSchema = exports.createArticleSchema = exports.articleSchema = exports.articleBodySchema = exports.stripMarkdownImages = exports.ARTICLE_BODY_MAX_LENGTH = exports.ARTICLE_PROSE_MAX_LENGTH = exports.articleEntitySchema = exports.articleEntityTypeSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const user_1 = require("./user");
|
|
6
6
|
const trivia_1 = require("./trivia");
|
|
@@ -37,6 +37,27 @@ exports.articleEntitySchema = zod_1.z.object({
|
|
|
37
37
|
// Full game document for game tags, typed as UnionGame on the consumer side.
|
|
38
38
|
gameEntity: zod_1.z.any().optional().nullable(),
|
|
39
39
|
});
|
|
40
|
+
/**
|
|
41
|
+
* Editors count article length after markdown images are removed. Hosted image
|
|
42
|
+
* URLs stay in the stored markdown, so the raw body can exceed the prose cap.
|
|
43
|
+
*/
|
|
44
|
+
exports.ARTICLE_PROSE_MAX_LENGTH = 50000;
|
|
45
|
+
exports.ARTICLE_BODY_MAX_LENGTH = 150000;
|
|
46
|
+
const stripMarkdownImages = (markdown) => {
|
|
47
|
+
if (!markdown) {
|
|
48
|
+
return "";
|
|
49
|
+
}
|
|
50
|
+
return markdown
|
|
51
|
+
.replace(/!\[[^\]]*\]\([^)]*\)/g, "")
|
|
52
|
+
.replace(/\n{3,}/g, "\n\n")
|
|
53
|
+
.trim();
|
|
54
|
+
};
|
|
55
|
+
exports.stripMarkdownImages = stripMarkdownImages;
|
|
56
|
+
exports.articleBodySchema = zod_1.z
|
|
57
|
+
.string()
|
|
58
|
+
.min(1)
|
|
59
|
+
.max(exports.ARTICLE_BODY_MAX_LENGTH)
|
|
60
|
+
.refine((body) => (0, exports.stripMarkdownImages)(body).length <= exports.ARTICLE_PROSE_MAX_LENGTH, `String must contain at most ${exports.ARTICLE_PROSE_MAX_LENGTH} characters`);
|
|
40
61
|
/**
|
|
41
62
|
* Article document schema.
|
|
42
63
|
* A user-authored long-form post. The body is stored as Markdown (GFM) and
|
|
@@ -47,8 +68,8 @@ exports.articleSchema = zod_1.z.object({
|
|
|
47
68
|
// URL-safe identifier used for SEO routes (`/articles/{slug}`).
|
|
48
69
|
slug: zod_1.z.string(),
|
|
49
70
|
title: zod_1.z.string().min(1).max(200),
|
|
50
|
-
// Markdown body (GFM).
|
|
51
|
-
body:
|
|
71
|
+
// Markdown body (GFM). Length is measured on prose, not image URLs.
|
|
72
|
+
body: exports.articleBodySchema,
|
|
52
73
|
imageUrl: zod_1.z.string().optional().nullable(),
|
|
53
74
|
// Resized WebP variants populated by the `resizeArticleImage` cloud function.
|
|
54
75
|
// Consumers should prefer the smallest variant that still looks crisp and fall
|
|
@@ -82,7 +103,7 @@ exports.articleSchema = zod_1.z.object({
|
|
|
82
103
|
exports.createArticleSchema = zod_1.z.object({
|
|
83
104
|
id: zod_1.z.string().min(1).max(120).optional(),
|
|
84
105
|
title: zod_1.z.string().min(1).max(200),
|
|
85
|
-
body:
|
|
106
|
+
body: exports.articleBodySchema,
|
|
86
107
|
imageUrl: zod_1.z.string().optional().nullable(),
|
|
87
108
|
entities: zod_1.z.array(exports.articleEntitySchema).max(10).optional(),
|
|
88
109
|
user: user_1.reducedUserSchema,
|
|
@@ -92,7 +113,7 @@ exports.createArticleSchema = zod_1.z.object({
|
|
|
92
113
|
*/
|
|
93
114
|
exports.updateArticleSchema = zod_1.z.object({
|
|
94
115
|
title: zod_1.z.string().min(1).max(200).optional(),
|
|
95
|
-
body:
|
|
116
|
+
body: exports.articleBodySchema.optional(),
|
|
96
117
|
imageUrl: zod_1.z.string().optional().nullable(),
|
|
97
118
|
entities: zod_1.z.array(exports.articleEntitySchema).max(10).optional(),
|
|
98
119
|
});
|
package/dist/schemas/chat.d.ts
CHANGED
|
@@ -1662,7 +1662,7 @@ export declare const chatMessageSchema: z.ZodObject<{
|
|
|
1662
1662
|
badge?: string | undefined;
|
|
1663
1663
|
}>;
|
|
1664
1664
|
lastPlay: z.ZodOptional<z.ZodBoolean>;
|
|
1665
|
-
type: z.ZodUnion<[z.ZodLiteral<"game">, z.ZodLiteral<"profile">, z.ZodLiteral<"list">, z.ZodLiteral<"gif">, z.ZodLiteral<"rating">, z.ZodLiteral<"trivia">, z.ZodLiteral<"article">, z.ZodLiteral<"experience">, z.ZodLiteral<"stadium">, z.ZodLiteral<"text">]>;
|
|
1665
|
+
type: z.ZodUnion<[z.ZodLiteral<"game">, z.ZodLiteral<"profile">, z.ZodLiteral<"list">, z.ZodLiteral<"gif">, z.ZodLiteral<"rating">, z.ZodLiteral<"trivia">, z.ZodLiteral<"article">, z.ZodLiteral<"experience">, z.ZodLiteral<"stadium">, z.ZodLiteral<"pickChallenge">, z.ZodLiteral<"pickChallengeInvite">, z.ZodLiteral<"text">]>;
|
|
1666
1666
|
itemId: z.ZodOptional<z.ZodString>;
|
|
1667
1667
|
gifUrl: z.ZodOptional<z.ZodString>;
|
|
1668
1668
|
parentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -3327,7 +3327,7 @@ export declare const chatMessageSchema: z.ZodObject<{
|
|
|
3327
3327
|
} & {
|
|
3328
3328
|
replyToMessage: z.ZodOptional<z.ZodNullable<z.ZodType<any, z.ZodTypeDef, any>>>;
|
|
3329
3329
|
}, "strip", z.ZodTypeAny, {
|
|
3330
|
-
type: "article" | "text" | "rating" | "stadium" | "profile" | "game" | "list" | "gif" | "trivia" | "experience";
|
|
3330
|
+
type: "article" | "text" | "rating" | "stadium" | "profile" | "game" | "list" | "gif" | "trivia" | "experience" | "pickChallenge" | "pickChallengeInvite";
|
|
3331
3331
|
id: string;
|
|
3332
3332
|
content: string;
|
|
3333
3333
|
user: {
|
|
@@ -3356,7 +3356,7 @@ export declare const chatMessageSchema: z.ZodObject<{
|
|
|
3356
3356
|
replyToDeleted?: boolean | undefined;
|
|
3357
3357
|
replyToMessage?: any;
|
|
3358
3358
|
}, {
|
|
3359
|
-
type: "article" | "text" | "rating" | "stadium" | "profile" | "game" | "list" | "gif" | "trivia" | "experience";
|
|
3359
|
+
type: "article" | "text" | "rating" | "stadium" | "profile" | "game" | "list" | "gif" | "trivia" | "experience" | "pickChallenge" | "pickChallengeInvite";
|
|
3360
3360
|
id: string;
|
|
3361
3361
|
content: string;
|
|
3362
3362
|
user: {
|
|
@@ -5046,7 +5046,7 @@ export declare const communityChatMessageSchema: z.ZodObject<{
|
|
|
5046
5046
|
avatarUrl?: string | null | undefined;
|
|
5047
5047
|
badge?: string | undefined;
|
|
5048
5048
|
}>;
|
|
5049
|
-
type: z.ZodUnion<[z.ZodLiteral<"game">, z.ZodLiteral<"profile">, z.ZodLiteral<"list">, z.ZodLiteral<"gif">, z.ZodLiteral<"rating">, z.ZodLiteral<"trivia">, z.ZodLiteral<"article">, z.ZodLiteral<"experience">, z.ZodLiteral<"stadium">, z.ZodLiteral<"text">]>;
|
|
5049
|
+
type: z.ZodUnion<[z.ZodLiteral<"game">, z.ZodLiteral<"profile">, z.ZodLiteral<"list">, z.ZodLiteral<"gif">, z.ZodLiteral<"rating">, z.ZodLiteral<"trivia">, z.ZodLiteral<"article">, z.ZodLiteral<"experience">, z.ZodLiteral<"stadium">, z.ZodLiteral<"pickChallenge">, z.ZodLiteral<"pickChallengeInvite">, z.ZodLiteral<"text">]>;
|
|
5050
5050
|
itemId: z.ZodOptional<z.ZodString>;
|
|
5051
5051
|
gifUrl: z.ZodOptional<z.ZodString>;
|
|
5052
5052
|
parentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -6711,7 +6711,7 @@ export declare const communityChatMessageSchema: z.ZodObject<{
|
|
|
6711
6711
|
} & {
|
|
6712
6712
|
replyToMessage: z.ZodOptional<z.ZodNullable<z.ZodType<any, z.ZodTypeDef, any>>>;
|
|
6713
6713
|
}, "strip", z.ZodTypeAny, {
|
|
6714
|
-
type: "article" | "text" | "rating" | "stadium" | "profile" | "game" | "list" | "gif" | "trivia" | "experience";
|
|
6714
|
+
type: "article" | "text" | "rating" | "stadium" | "profile" | "game" | "list" | "gif" | "trivia" | "experience" | "pickChallenge" | "pickChallengeInvite";
|
|
6715
6715
|
id: string;
|
|
6716
6716
|
user: {
|
|
6717
6717
|
id: string;
|
|
@@ -6738,7 +6738,7 @@ export declare const communityChatMessageSchema: z.ZodObject<{
|
|
|
6738
6738
|
replyToDeleted?: boolean | undefined;
|
|
6739
6739
|
replyToMessage?: any;
|
|
6740
6740
|
}, {
|
|
6741
|
-
type: "article" | "text" | "rating" | "stadium" | "profile" | "game" | "list" | "gif" | "trivia" | "experience";
|
|
6741
|
+
type: "article" | "text" | "rating" | "stadium" | "profile" | "game" | "list" | "gif" | "trivia" | "experience" | "pickChallenge" | "pickChallengeInvite";
|
|
6742
6742
|
id: string;
|
|
6743
6743
|
user: {
|
|
6744
6744
|
id: string;
|
package/dist/schemas/chat.js
CHANGED
|
@@ -23,6 +23,8 @@ const baseChatMessageSchema = zod_1.z.object({
|
|
|
23
23
|
zod_1.z.literal("article"),
|
|
24
24
|
zod_1.z.literal("experience"),
|
|
25
25
|
zod_1.z.literal("stadium"),
|
|
26
|
+
zod_1.z.literal("pickChallenge"),
|
|
27
|
+
zod_1.z.literal("pickChallengeInvite"),
|
|
26
28
|
zod_1.z.literal("text"),
|
|
27
29
|
]),
|
|
28
30
|
itemId: zod_1.z.string().optional(),
|
|
@@ -50,6 +52,8 @@ const baseCommunityChatMessageSchema = zod_1.z.object({
|
|
|
50
52
|
zod_1.z.literal("article"),
|
|
51
53
|
zod_1.z.literal("experience"),
|
|
52
54
|
zod_1.z.literal("stadium"),
|
|
55
|
+
zod_1.z.literal("pickChallenge"),
|
|
56
|
+
zod_1.z.literal("pickChallengeInvite"),
|
|
53
57
|
zod_1.z.literal("text"),
|
|
54
58
|
]),
|
|
55
59
|
itemId: zod_1.z.string().optional(),
|