@fifthbell/brokaw 0.1.65 → 0.1.67
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 +31 -5
- package/dist/cronkite-manifest.d.ts +80 -0
- package/dist/cronkite-manifest.js +124 -0
- package/dist/cronkite-manifest.json +139 -0
- package/dist/json-schema-formats.d.ts +2 -0
- package/dist/json-schema-formats.js +19 -0
- package/dist/layouts.d.ts +13 -0
- package/dist/layouts.js +12 -0
- package/dist/live-program-page/index.html +2 -2
- package/dist/live-program-page/live-program-manifest.json +4 -4
- package/dist/live-program-release.d.ts +3 -0
- package/dist/live-program-release.js +76 -0
- package/dist/manifest-validation.d.ts +10 -0
- package/dist/manifest-validation.js +27 -0
- package/dist/renderer.core.d.ts +2 -1
- package/dist/renderer.core.js +2 -1
- package/dist/renderer.d.ts +3 -0
- package/dist/renderer.js +2 -0
- package/dist/renderer.node.js +7 -12
- package/dist/schemas/canonical-document.schema.json +1071 -0
- package/dist/schemas/cronkite-manifest.schema.json +501 -0
- package/dist/schemas/feed-renderable-input.schema.json +16 -0
- package/dist/schemas/live-program-release-input.schema.json +34 -0
- package/dist/types/canonical-article.d.ts +8 -262
- package/dist/types/canonical-article.js +21 -245
- package/dist/types/canonical-document-schema.generated.d.ts +1634 -0
- package/dist/types/canonical-document-schema.generated.js +1730 -0
- package/dist/types/canonical-document.generated.d.ts +541 -0
- package/dist/types/canonical-document.generated.js +3 -0
- package/dist/types/cronkite-manifest.generated.d.ts +339 -0
- package/dist/types/cronkite-manifest.generated.js +3 -0
- package/dist/types/live-program-release-input.generated.d.ts +5 -0
- package/dist/types/live-program-release-input.generated.js +3 -0
- package/dist/video/Root.d.ts +1 -0
- package/dist/video/Root.js +40 -0
- package/dist/video/ShortVideo.d.ts +3 -0
- package/dist/video/ShortVideo.js +92 -0
- package/dist/video/index.d.ts +2 -0
- package/dist/video/index.js +4 -0
- package/dist/video/types.d.ts +37 -0
- package/dist/video/types.js +1 -0
- package/package.json +19 -4
- /package/dist/live-program-page/{live-program.v0.1.65.css → live-program.v0.1.67.css} +0 -0
- /package/dist/live-program-page/{live-program.v0.1.65.js → live-program.v0.1.67.js} +0 -0
|
@@ -1,262 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
name: z.ZodString;
|
|
10
|
-
slug: z.ZodString;
|
|
11
|
-
}, z.core.$strip>>>;
|
|
12
|
-
hero: z.ZodOptional<z.ZodObject<{
|
|
13
|
-
url: z.ZodString;
|
|
14
|
-
alt: z.ZodString;
|
|
15
|
-
}, z.core.$strip>>;
|
|
16
|
-
featuredImage: z.ZodOptional<z.ZodObject<{
|
|
17
|
-
url: z.ZodString;
|
|
18
|
-
alt: z.ZodString;
|
|
19
|
-
caption: z.ZodOptional<z.ZodString>;
|
|
20
|
-
}, z.core.$strip>>;
|
|
21
|
-
updatedAt: z.ZodOptional<z.ZodString>;
|
|
22
|
-
publishedAt: z.ZodOptional<z.ZodString>;
|
|
23
|
-
featured: z.ZodOptional<z.ZodBoolean>;
|
|
24
|
-
}, z.core.$loose>;
|
|
25
|
-
export declare const canonicalArticleSchema: z.ZodObject<{
|
|
26
|
-
id: z.ZodCoercedString<unknown>;
|
|
27
|
-
slug: z.ZodString;
|
|
28
|
-
layout: z.ZodEnum<{
|
|
29
|
-
"article-page": "article-page";
|
|
30
|
-
homepage: "homepage";
|
|
31
|
-
"category-page": "category-page";
|
|
32
|
-
"search-page": "search-page";
|
|
33
|
-
404: "404";
|
|
34
|
-
"live-story": "live-story";
|
|
35
|
-
"link-in-bio": "link-in-bio";
|
|
36
|
-
"media-page": "media-page";
|
|
37
|
-
"standalone-page": "standalone-page";
|
|
38
|
-
}>;
|
|
39
|
-
canonicalUrl: z.ZodString;
|
|
40
|
-
contentVersion: z.ZodString;
|
|
41
|
-
publishedAt: z.ZodString;
|
|
42
|
-
updatedAt: z.ZodString;
|
|
43
|
-
status: z.ZodEnum<{
|
|
44
|
-
draft: "draft";
|
|
45
|
-
published: "published";
|
|
46
|
-
}>;
|
|
47
|
-
title: z.ZodString;
|
|
48
|
-
dek: z.ZodOptional<z.ZodString>;
|
|
49
|
-
excerpt: z.ZodOptional<z.ZodString>;
|
|
50
|
-
language: z.ZodEnum<{
|
|
51
|
-
en: "en";
|
|
52
|
-
es: "es";
|
|
53
|
-
it: "it";
|
|
54
|
-
}>;
|
|
55
|
-
rumConfig: z.ZodOptional<z.ZodObject<{
|
|
56
|
-
appMonitorId: z.ZodString;
|
|
57
|
-
applicationVersion: z.ZodString;
|
|
58
|
-
region: z.ZodString;
|
|
59
|
-
identityPoolId: z.ZodString;
|
|
60
|
-
guestRoleArn: z.ZodString;
|
|
61
|
-
}, z.core.$strict>>;
|
|
62
|
-
sofascore_id: z.ZodOptional<z.ZodNumber>;
|
|
63
|
-
originalArticleId: z.ZodOptional<z.ZodString>;
|
|
64
|
-
updatedVersion: z.ZodOptional<z.ZodObject<{
|
|
65
|
-
id: z.ZodCoercedString<unknown>;
|
|
66
|
-
title: z.ZodString;
|
|
67
|
-
url: z.ZodString;
|
|
68
|
-
}, z.core.$strip>>;
|
|
69
|
-
featured: z.ZodBoolean;
|
|
70
|
-
authors: z.ZodArray<z.ZodObject<{
|
|
71
|
-
name: z.ZodString;
|
|
72
|
-
slug: z.ZodString;
|
|
73
|
-
}, z.core.$strip>>;
|
|
74
|
-
categories: z.ZodArray<z.ZodObject<{
|
|
75
|
-
name: z.ZodString;
|
|
76
|
-
slug: z.ZodString;
|
|
77
|
-
}, z.core.$strip>>;
|
|
78
|
-
featuredImage: z.ZodOptional<z.ZodObject<{
|
|
79
|
-
url: z.ZodString;
|
|
80
|
-
alt: z.ZodString;
|
|
81
|
-
caption: z.ZodOptional<z.ZodString>;
|
|
82
|
-
}, z.core.$strip>>;
|
|
83
|
-
media: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
84
|
-
url: z.ZodString;
|
|
85
|
-
alt: z.ZodString;
|
|
86
|
-
caption: z.ZodOptional<z.ZodString>;
|
|
87
|
-
}, z.core.$strip>>>;
|
|
88
|
-
hero: z.ZodOptional<z.ZodObject<{
|
|
89
|
-
url: z.ZodString;
|
|
90
|
-
alt: z.ZodString;
|
|
91
|
-
}, z.core.$strip>>;
|
|
92
|
-
body: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
93
|
-
type: z.ZodLiteral<"richText">;
|
|
94
|
-
html: z.ZodString;
|
|
95
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
96
|
-
type: z.ZodLiteral<"heading">;
|
|
97
|
-
text: z.ZodString;
|
|
98
|
-
level: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>>;
|
|
99
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
100
|
-
type: z.ZodLiteral<"image">;
|
|
101
|
-
url: z.ZodString;
|
|
102
|
-
alt: z.ZodString;
|
|
103
|
-
caption: z.ZodOptional<z.ZodString>;
|
|
104
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
105
|
-
type: z.ZodLiteral<"list">;
|
|
106
|
-
ordered: z.ZodDefault<z.ZodBoolean>;
|
|
107
|
-
items: z.ZodArray<z.ZodString>;
|
|
108
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
109
|
-
type: z.ZodLiteral<"divider">;
|
|
110
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
111
|
-
type: z.ZodLiteral<"infoBox">;
|
|
112
|
-
title: z.ZodOptional<z.ZodString>;
|
|
113
|
-
tone: z.ZodDefault<z.ZodEnum<{
|
|
114
|
-
success: "success";
|
|
115
|
-
neutral: "neutral";
|
|
116
|
-
info: "info";
|
|
117
|
-
warning: "warning";
|
|
118
|
-
}>>;
|
|
119
|
-
html: z.ZodString;
|
|
120
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
121
|
-
type: z.ZodLiteral<"keyPoints">;
|
|
122
|
-
title: z.ZodDefault<z.ZodString>;
|
|
123
|
-
points: z.ZodArray<z.ZodString>;
|
|
124
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
125
|
-
type: z.ZodLiteral<"dataTable">;
|
|
126
|
-
caption: z.ZodOptional<z.ZodString>;
|
|
127
|
-
headers: z.ZodArray<z.ZodString>;
|
|
128
|
-
rows: z.ZodArray<z.ZodArray<z.ZodString>>;
|
|
129
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
130
|
-
type: z.ZodLiteral<"liveUpdate">;
|
|
131
|
-
timestamp: z.ZodString;
|
|
132
|
-
headline: z.ZodString;
|
|
133
|
-
html: z.ZodOptional<z.ZodString>;
|
|
134
|
-
media: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
135
|
-
url: z.ZodString;
|
|
136
|
-
alt: z.ZodString;
|
|
137
|
-
caption: z.ZodOptional<z.ZodString>;
|
|
138
|
-
}, z.core.$strip>>>;
|
|
139
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
140
|
-
type: z.ZodLiteral<"audio">;
|
|
141
|
-
url: z.ZodString;
|
|
142
|
-
title: z.ZodOptional<z.ZodString>;
|
|
143
|
-
caption: z.ZodOptional<z.ZodString>;
|
|
144
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
145
|
-
type: z.ZodLiteral<"youtube">;
|
|
146
|
-
videoId: z.ZodString;
|
|
147
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
148
|
-
type: z.ZodLiteral<"x">;
|
|
149
|
-
url: z.ZodString;
|
|
150
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
151
|
-
type: z.ZodLiteral<"instagram">;
|
|
152
|
-
url: z.ZodString;
|
|
153
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
154
|
-
type: z.ZodLiteral<"tiktok">;
|
|
155
|
-
url: z.ZodString;
|
|
156
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
157
|
-
type: z.ZodLiteral<"pullQuote">;
|
|
158
|
-
text: z.ZodString;
|
|
159
|
-
attribution: z.ZodOptional<z.ZodString>;
|
|
160
|
-
}, z.core.$strip>], "type">>;
|
|
161
|
-
seo: z.ZodOptional<z.ZodObject<{
|
|
162
|
-
metaTitle: z.ZodOptional<z.ZodString>;
|
|
163
|
-
metaDescription: z.ZodOptional<z.ZodString>;
|
|
164
|
-
ogImage: z.ZodOptional<z.ZodString>;
|
|
165
|
-
}, z.core.$strip>>;
|
|
166
|
-
navigation: z.ZodOptional<z.ZodObject<{
|
|
167
|
-
categories: z.ZodArray<z.ZodObject<{
|
|
168
|
-
name: z.ZodString;
|
|
169
|
-
slug: z.ZodString;
|
|
170
|
-
}, z.core.$strip>>;
|
|
171
|
-
}, z.core.$strip>>;
|
|
172
|
-
articles: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
173
|
-
id: z.ZodString;
|
|
174
|
-
url: z.ZodString;
|
|
175
|
-
title: z.ZodString;
|
|
176
|
-
excerpt: z.ZodOptional<z.ZodString>;
|
|
177
|
-
time: z.ZodOptional<z.ZodString>;
|
|
178
|
-
categories: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
179
|
-
name: z.ZodString;
|
|
180
|
-
slug: z.ZodString;
|
|
181
|
-
}, z.core.$strip>>>;
|
|
182
|
-
hero: z.ZodOptional<z.ZodObject<{
|
|
183
|
-
url: z.ZodString;
|
|
184
|
-
alt: z.ZodString;
|
|
185
|
-
}, z.core.$strip>>;
|
|
186
|
-
featuredImage: z.ZodOptional<z.ZodObject<{
|
|
187
|
-
url: z.ZodString;
|
|
188
|
-
alt: z.ZodString;
|
|
189
|
-
caption: z.ZodOptional<z.ZodString>;
|
|
190
|
-
}, z.core.$strip>>;
|
|
191
|
-
updatedAt: z.ZodOptional<z.ZodString>;
|
|
192
|
-
publishedAt: z.ZodOptional<z.ZodString>;
|
|
193
|
-
featured: z.ZodOptional<z.ZodBoolean>;
|
|
194
|
-
}, z.core.$loose>>>;
|
|
195
|
-
heroSlides: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
196
|
-
image: z.ZodString;
|
|
197
|
-
alt: z.ZodOptional<z.ZodString>;
|
|
198
|
-
}, z.core.$strip>>>;
|
|
199
|
-
heroLayout: z.ZodOptional<z.ZodEnum<{
|
|
200
|
-
spotlight: "spotlight";
|
|
201
|
-
editorial: "editorial";
|
|
202
|
-
}>>;
|
|
203
|
-
heroCategories: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
204
|
-
name: z.ZodString;
|
|
205
|
-
slug: z.ZodString;
|
|
206
|
-
}, z.core.$strip>>>;
|
|
207
|
-
showHero: z.ZodOptional<z.ZodBoolean>;
|
|
208
|
-
showEditorialHero: z.ZodOptional<z.ZodBoolean>;
|
|
209
|
-
breakingNews: z.ZodOptional<z.ZodObject<{
|
|
210
|
-
displayClass: z.ZodOptional<z.ZodString>;
|
|
211
|
-
sidebarFeature: z.ZodOptional<z.ZodObject<{
|
|
212
|
-
category: z.ZodString;
|
|
213
|
-
title: z.ZodString;
|
|
214
|
-
url: z.ZodString;
|
|
215
|
-
image: z.ZodString;
|
|
216
|
-
excerpt: z.ZodOptional<z.ZodString>;
|
|
217
|
-
publishedAt: z.ZodOptional<z.ZodString>;
|
|
218
|
-
}, z.core.$strip>>;
|
|
219
|
-
sidebarSub: z.ZodOptional<z.ZodObject<{
|
|
220
|
-
category: z.ZodString;
|
|
221
|
-
title: z.ZodString;
|
|
222
|
-
url: z.ZodString;
|
|
223
|
-
image: z.ZodString;
|
|
224
|
-
alt: z.ZodOptional<z.ZodString>;
|
|
225
|
-
readTime: z.ZodOptional<z.ZodString>;
|
|
226
|
-
excerpt: z.ZodOptional<z.ZodString>;
|
|
227
|
-
}, z.core.$strip>>;
|
|
228
|
-
main: z.ZodOptional<z.ZodObject<{
|
|
229
|
-
category: z.ZodString;
|
|
230
|
-
title: z.ZodString;
|
|
231
|
-
url: z.ZodString;
|
|
232
|
-
liveUrl: z.ZodOptional<z.ZodString>;
|
|
233
|
-
sofascore_id: z.ZodOptional<z.ZodNumber>;
|
|
234
|
-
image: z.ZodString;
|
|
235
|
-
alt: z.ZodOptional<z.ZodString>;
|
|
236
|
-
excerpt: z.ZodOptional<z.ZodString>;
|
|
237
|
-
}, z.core.$strip>>;
|
|
238
|
-
updates: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
239
|
-
timestamp: z.ZodOptional<z.ZodString>;
|
|
240
|
-
time: z.ZodOptional<z.ZodString>;
|
|
241
|
-
text: z.ZodOptional<z.ZodString>;
|
|
242
|
-
html: z.ZodOptional<z.ZodString>;
|
|
243
|
-
}, z.core.$strip>>>;
|
|
244
|
-
snacks: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
245
|
-
category: z.ZodOptional<z.ZodString>;
|
|
246
|
-
readTime: z.ZodOptional<z.ZodString>;
|
|
247
|
-
title: z.ZodString;
|
|
248
|
-
url: z.ZodString;
|
|
249
|
-
excerpt: z.ZodOptional<z.ZodString>;
|
|
250
|
-
image: z.ZodOptional<z.ZodString>;
|
|
251
|
-
alt: z.ZodOptional<z.ZodString>;
|
|
252
|
-
}, z.core.$strip>>>;
|
|
253
|
-
}, z.core.$strip>>;
|
|
254
|
-
liveStory: z.ZodOptional<z.ZodObject<{
|
|
255
|
-
lastUpdated: z.ZodOptional<z.ZodString>;
|
|
256
|
-
keyPoints: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
257
|
-
}, z.core.$strip>>;
|
|
258
|
-
}, z.core.$loose>;
|
|
259
|
-
export type SelfReference = z.infer<typeof articleReferenceSchema>;
|
|
260
|
-
export type CanonicalArticle = z.infer<typeof canonicalArticleSchema>;
|
|
261
|
-
export type CanonicalDocument = CanonicalArticle;
|
|
262
|
-
export type { RumConfig } from '../rum.js';
|
|
1
|
+
import type { CronkiteCanonicalDocument } from "./canonical-document.generated.js";
|
|
2
|
+
export declare const canonicalArticleSchema: {
|
|
3
|
+
parse(input: unknown): CanonicalDocument;
|
|
4
|
+
};
|
|
5
|
+
export type CanonicalDocument = CronkiteCanonicalDocument;
|
|
6
|
+
export type CanonicalArticle = CanonicalDocument;
|
|
7
|
+
export type RumConfig = NonNullable<CanonicalDocument["rumConfig"]>;
|
|
8
|
+
export type SelfReference = NonNullable<CanonicalDocument["articles"]>[number];
|
|
@@ -1,245 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
id: z.coerce.string(),
|
|
23
|
-
title: z.string(),
|
|
24
|
-
url: z.string()
|
|
25
|
-
});
|
|
26
|
-
const bodyBlockSchema = z.discriminatedUnion('type', [
|
|
27
|
-
z.object({
|
|
28
|
-
type: z.literal('richText'),
|
|
29
|
-
html: z.string()
|
|
30
|
-
}),
|
|
31
|
-
z.object({
|
|
32
|
-
type: z.literal('heading'),
|
|
33
|
-
text: z.string(),
|
|
34
|
-
level: z.union([z.literal(2), z.literal(3), z.literal(4)]).default(2)
|
|
35
|
-
}),
|
|
36
|
-
z.object({
|
|
37
|
-
type: z.literal('image'),
|
|
38
|
-
url: z.string(),
|
|
39
|
-
alt: z.string(),
|
|
40
|
-
caption: z.string().optional()
|
|
41
|
-
}),
|
|
42
|
-
z.object({
|
|
43
|
-
type: z.literal('list'),
|
|
44
|
-
ordered: z.boolean().default(false),
|
|
45
|
-
items: z.array(z.string()).min(1)
|
|
46
|
-
}),
|
|
47
|
-
z.object({
|
|
48
|
-
type: z.literal('divider')
|
|
49
|
-
}),
|
|
50
|
-
z.object({
|
|
51
|
-
type: z.literal('infoBox'),
|
|
52
|
-
title: z.string().optional(),
|
|
53
|
-
tone: z.enum(['neutral', 'info', 'warning', 'success']).default('neutral'),
|
|
54
|
-
html: z.string()
|
|
55
|
-
}),
|
|
56
|
-
z.object({
|
|
57
|
-
type: z.literal('keyPoints'),
|
|
58
|
-
title: z.string().default('Key Points'),
|
|
59
|
-
points: z.array(z.string()).min(1)
|
|
60
|
-
}),
|
|
61
|
-
z.object({
|
|
62
|
-
type: z.literal('dataTable'),
|
|
63
|
-
caption: z.string().optional(),
|
|
64
|
-
headers: z.array(z.string()).min(1),
|
|
65
|
-
rows: z.array(z.array(z.string())).min(1)
|
|
66
|
-
}),
|
|
67
|
-
z.object({
|
|
68
|
-
type: z.literal('liveUpdate'),
|
|
69
|
-
timestamp: isoDateTime,
|
|
70
|
-
headline: z.string(),
|
|
71
|
-
html: z.string().optional(),
|
|
72
|
-
media: z
|
|
73
|
-
.array(z.object({
|
|
74
|
-
url: z.string(),
|
|
75
|
-
alt: z.string(),
|
|
76
|
-
caption: z.string().optional()
|
|
77
|
-
}))
|
|
78
|
-
.optional()
|
|
79
|
-
}),
|
|
80
|
-
z.object({
|
|
81
|
-
type: z.literal('audio'),
|
|
82
|
-
url: z.string().url(),
|
|
83
|
-
title: z.string().optional(),
|
|
84
|
-
caption: z.string().optional()
|
|
85
|
-
}),
|
|
86
|
-
z.object({
|
|
87
|
-
type: z.literal('youtube'),
|
|
88
|
-
videoId: z.string()
|
|
89
|
-
}),
|
|
90
|
-
z.object({
|
|
91
|
-
type: z.literal('x'),
|
|
92
|
-
url: z.string().url()
|
|
93
|
-
}),
|
|
94
|
-
z.object({
|
|
95
|
-
type: z.literal('instagram'),
|
|
96
|
-
url: z.string().url()
|
|
97
|
-
}),
|
|
98
|
-
z.object({
|
|
99
|
-
type: z.literal('tiktok'),
|
|
100
|
-
url: z.string().url()
|
|
101
|
-
}),
|
|
102
|
-
z.object({
|
|
103
|
-
type: z.literal('pullQuote'),
|
|
104
|
-
text: z.string(),
|
|
105
|
-
attribution: z.string().optional()
|
|
106
|
-
})
|
|
107
|
-
]);
|
|
108
|
-
const articleReferenceSchema = z
|
|
109
|
-
.object({
|
|
110
|
-
id: z.string().uuid(),
|
|
111
|
-
url: z.string(),
|
|
112
|
-
title: z.string(),
|
|
113
|
-
excerpt: z.string().optional(),
|
|
114
|
-
time: z.string().optional(),
|
|
115
|
-
categories: z.array(categorySchema).default([]),
|
|
116
|
-
hero: heroSchema.optional(),
|
|
117
|
-
featuredImage: featuredImageSchema.optional(),
|
|
118
|
-
updatedAt: isoDateTime.optional(),
|
|
119
|
-
publishedAt: isoDateTime.optional(),
|
|
120
|
-
featured: z.boolean().optional()
|
|
121
|
-
})
|
|
122
|
-
.passthrough();
|
|
123
|
-
export const canonicalArticleSchema = z
|
|
124
|
-
.object({
|
|
125
|
-
id: z.coerce.string(),
|
|
126
|
-
slug: z.string(),
|
|
127
|
-
layout: z.enum([
|
|
128
|
-
'article-page',
|
|
129
|
-
'homepage',
|
|
130
|
-
'category-page',
|
|
131
|
-
'search-page',
|
|
132
|
-
'404',
|
|
133
|
-
'live-story',
|
|
134
|
-
'link-in-bio',
|
|
135
|
-
'media-page',
|
|
136
|
-
'standalone-page'
|
|
137
|
-
]),
|
|
138
|
-
canonicalUrl: z.string(),
|
|
139
|
-
contentVersion: isoDateTime,
|
|
140
|
-
publishedAt: isoDateTime,
|
|
141
|
-
updatedAt: isoDateTime,
|
|
142
|
-
status: z.enum(['draft', 'published']),
|
|
143
|
-
title: z.string(),
|
|
144
|
-
dek: z.string().optional(),
|
|
145
|
-
excerpt: z.string().optional(),
|
|
146
|
-
language: z.enum(['en', 'es', 'it']),
|
|
147
|
-
rumConfig: rumConfigSchema.optional(),
|
|
148
|
-
sofascore_id: z.number().int().positive().optional(),
|
|
149
|
-
originalArticleId: z.string().optional(),
|
|
150
|
-
updatedVersion: updatedVersionSchema.optional(),
|
|
151
|
-
featured: z.boolean(),
|
|
152
|
-
authors: z.array(authorSchema),
|
|
153
|
-
categories: z.array(categorySchema),
|
|
154
|
-
featuredImage: featuredImageSchema.optional(),
|
|
155
|
-
media: z.array(featuredImageSchema).optional(),
|
|
156
|
-
hero: heroSchema.optional(),
|
|
157
|
-
body: z.array(bodyBlockSchema),
|
|
158
|
-
seo: z
|
|
159
|
-
.object({
|
|
160
|
-
metaTitle: z.string().optional(),
|
|
161
|
-
metaDescription: z.string().optional(),
|
|
162
|
-
ogImage: z.string().optional()
|
|
163
|
-
})
|
|
164
|
-
.optional(),
|
|
165
|
-
navigation: z
|
|
166
|
-
.object({
|
|
167
|
-
categories: z.array(categorySchema)
|
|
168
|
-
})
|
|
169
|
-
.optional(),
|
|
170
|
-
articles: z.array(articleReferenceSchema).optional(),
|
|
171
|
-
heroSlides: z
|
|
172
|
-
.array(z.object({
|
|
173
|
-
image: z.string(),
|
|
174
|
-
alt: z.string().optional()
|
|
175
|
-
}))
|
|
176
|
-
.optional(),
|
|
177
|
-
heroLayout: z.enum(['spotlight', 'editorial']).optional(),
|
|
178
|
-
heroCategories: z.array(categorySchema).optional(),
|
|
179
|
-
showHero: z.boolean().optional(),
|
|
180
|
-
showEditorialHero: z.boolean().optional(),
|
|
181
|
-
breakingNews: z
|
|
182
|
-
.object({
|
|
183
|
-
displayClass: z.string().optional(),
|
|
184
|
-
sidebarFeature: z
|
|
185
|
-
.object({
|
|
186
|
-
category: z.string(),
|
|
187
|
-
title: z.string(),
|
|
188
|
-
url: z.string(),
|
|
189
|
-
image: z.string(),
|
|
190
|
-
excerpt: z.string().optional(),
|
|
191
|
-
publishedAt: isoDateTime.optional()
|
|
192
|
-
})
|
|
193
|
-
.optional(),
|
|
194
|
-
sidebarSub: z
|
|
195
|
-
.object({
|
|
196
|
-
category: z.string(),
|
|
197
|
-
title: z.string(),
|
|
198
|
-
url: z.string(),
|
|
199
|
-
image: z.string(),
|
|
200
|
-
alt: z.string().optional(),
|
|
201
|
-
readTime: z.string().optional(),
|
|
202
|
-
excerpt: z.string().optional()
|
|
203
|
-
})
|
|
204
|
-
.optional(),
|
|
205
|
-
main: z
|
|
206
|
-
.object({
|
|
207
|
-
category: z.string(),
|
|
208
|
-
title: z.string(),
|
|
209
|
-
url: z.string(),
|
|
210
|
-
liveUrl: z.string().optional(),
|
|
211
|
-
sofascore_id: z.number().int().positive().optional(),
|
|
212
|
-
image: z.string(),
|
|
213
|
-
alt: z.string().optional(),
|
|
214
|
-
excerpt: z.string().optional()
|
|
215
|
-
})
|
|
216
|
-
.optional(),
|
|
217
|
-
updates: z
|
|
218
|
-
.array(z.object({
|
|
219
|
-
timestamp: isoDateTime.optional(),
|
|
220
|
-
time: z.string().optional(),
|
|
221
|
-
text: z.string().optional(),
|
|
222
|
-
html: z.string().optional()
|
|
223
|
-
}))
|
|
224
|
-
.optional(),
|
|
225
|
-
snacks: z
|
|
226
|
-
.array(z.object({
|
|
227
|
-
category: z.string().optional(),
|
|
228
|
-
readTime: z.string().optional(),
|
|
229
|
-
title: z.string(),
|
|
230
|
-
url: z.string(),
|
|
231
|
-
excerpt: z.string().optional(),
|
|
232
|
-
image: z.string().optional(),
|
|
233
|
-
alt: z.string().optional()
|
|
234
|
-
}))
|
|
235
|
-
.optional()
|
|
236
|
-
})
|
|
237
|
-
.optional(),
|
|
238
|
-
liveStory: z
|
|
239
|
-
.object({
|
|
240
|
-
lastUpdated: z.string().optional(),
|
|
241
|
-
keyPoints: z.array(z.string()).optional()
|
|
242
|
-
})
|
|
243
|
-
.optional()
|
|
244
|
-
})
|
|
245
|
-
.passthrough();
|
|
1
|
+
import { Ajv2020 } from "ajv/dist/2020.js";
|
|
2
|
+
import { addContractFormats } from "../json-schema-formats.js";
|
|
3
|
+
import { canonicalDocumentSchema } from "./canonical-document-schema.generated.js";
|
|
4
|
+
const ajv = new Ajv2020({ allErrors: true, strict: false, useDefaults: true });
|
|
5
|
+
addContractFormats(ajv);
|
|
6
|
+
const validateCanonicalDocument = ajv.compile(canonicalDocumentSchema);
|
|
7
|
+
function summarizeValidationErrors(errors) {
|
|
8
|
+
return (errors ?? [])
|
|
9
|
+
.slice(0, 8)
|
|
10
|
+
.map((error) => `${error.instancePath || "/"} ${error.message ?? "is invalid"}`)
|
|
11
|
+
.join("; ");
|
|
12
|
+
}
|
|
13
|
+
export const canonicalArticleSchema = {
|
|
14
|
+
parse(input) {
|
|
15
|
+
const candidate = structuredClone(input);
|
|
16
|
+
if (!validateCanonicalDocument(candidate)) {
|
|
17
|
+
throw new Error(`Canonical document validation failed: ${summarizeValidationErrors(validateCanonicalDocument.errors)}`);
|
|
18
|
+
}
|
|
19
|
+
return candidate;
|
|
20
|
+
},
|
|
21
|
+
};
|