@sarimarcus/content-sites-core 0.55.3 → 0.56.0

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.
@@ -0,0 +1,473 @@
1
+ import type { z as Zod } from 'astro/zod';
2
+ import { type InterludeSchemaConfig } from '../interludes/index.ts';
3
+ import type { FieldIssue } from '../internal/issues.ts';
4
+ /** Metadata for a controlled article tag (used in `src/data/articleTags.ts` and `/articles/tag/[tag]` hubs). */
5
+ export interface ArticleTagMeta {
6
+ label: string;
7
+ description: string;
8
+ seoTitle?: string;
9
+ h1?: string;
10
+ }
11
+ export interface ArticleSchemaOptions {
12
+ /** Mandatory non-empty tuple of category slugs for `/articles/topic/<category>`. */
13
+ categories: readonly [string, ...string[]];
14
+ /** Optional controlled vocabulary of tag slugs for `/articles/tag/<tag>` (1-4 tags per article when set). */
15
+ tags?: readonly [string, ...string[]];
16
+ /** Allowed `relatedContent[].type` values from `src/utils/relatedTargets.ts`. */
17
+ relatedTargetTypes: readonly [string, ...string[]];
18
+ /** Interlude schema config (`scripts/interludes.config.json`). Either `interludeConfig` or `interludeSchema` is required. */
19
+ interludeConfig?: InterludeSchemaConfig;
20
+ /** Pre-built interlude schema if the site constructs `createInterludeSchema` itself. */
21
+ interludeSchema?: unknown;
22
+ /** Optional site audience enum; defaults to optional `z.array(z.string()).max(5)`. */
23
+ audiences?: readonly [string, ...string[]];
24
+ /** Optional site theme enum; defaults to optional `z.array(z.string()).max(4)`. */
25
+ themes?: readonly [string, ...string[]];
26
+ /** Optional historical era IDs (`@sarimarcus/content-sites-core/eras`). */
27
+ eras?: readonly [string, ...string[]];
28
+ /** Optional editorial dossier slugs. */
29
+ dossiers?: readonly [string, ...string[]];
30
+ /** Whether to include `people: z.array(z.string()).optional()` (defaults to true when `eras` is provided). */
31
+ people?: boolean;
32
+ /** Whether `category` is optional on legacy corpora (defaults to false on new sites). */
33
+ optionalCategory?: boolean;
34
+ }
35
+ type ZodLike = typeof Zod;
36
+ /**
37
+ * Pure validation issues for an article object's `superRefine` block:
38
+ * - format & section/FAQ count shape rules (`articleShapeIssues`)
39
+ * - historical year ordering (`eraYearIssues`)
40
+ * - `discoverAngle` presence & source URL matching when `editorialMode === 'discover'`
41
+ * - duplicate tag check when `tags` is present
42
+ */
43
+ export declare function articleSuperRefineIssues(article: unknown): FieldIssue[];
44
+ /**
45
+ * Returns the Zod field map for an `articles` collection so a site can spread or extend it,
46
+ * or pass it to `createArticleSchema(z, options)`.
47
+ */
48
+ export declare function articleSchemaFields(z: ZodLike, options: ArticleSchemaOptions): {
49
+ relatedContent: Zod.ZodOptional<Zod.ZodArray<Zod.ZodObject<{
50
+ type: Zod.ZodEnum<{
51
+ [x: string]: string;
52
+ }>;
53
+ slug: Zod.ZodString;
54
+ }, Zod.z.core.$strip>>>;
55
+ sources: Zod.ZodOptional<Zod.ZodArray<Zod.ZodUnion<readonly [Zod.ZodString, Zod.ZodObject<{
56
+ url: Zod.ZodString;
57
+ name: Zod.ZodOptional<Zod.ZodString>;
58
+ quote: Zod.ZodString;
59
+ }, Zod.z.core.$strip>]>>>;
60
+ affiliates: Zod.ZodOptional<Zod.ZodObject<{
61
+ amazonProductIds: Zod.ZodOptional<Zod.ZodArray<Zod.ZodString>>;
62
+ }, Zod.z.core.$strip>>;
63
+ author: Zod.ZodString;
64
+ datePublished: Zod.ZodString;
65
+ dateModified: Zod.ZodString;
66
+ era?: Zod.ZodOptional<Zod.ZodEnum<{
67
+ [x: string]: string;
68
+ }>> | undefined;
69
+ yearStart?: Zod.ZodOptional<Zod.ZodNumber> | undefined;
70
+ yearEnd?: Zod.ZodOptional<Zod.ZodNumber> | undefined;
71
+ dossiers?: Zod.ZodOptional<Zod.ZodArray<Zod.ZodEnum<{
72
+ [x: string]: string;
73
+ }>>> | undefined;
74
+ themes: Zod.ZodOptional<Zod.ZodArray<Zod.ZodString>> | Zod.ZodOptional<Zod.ZodArray<Zod.ZodEnum<{
75
+ [x: string]: string;
76
+ }>>>;
77
+ tags: Zod.ZodOptional<Zod.ZodArray<Zod.ZodEnum<{
78
+ [x: string]: string;
79
+ }>>>;
80
+ title: Zod.ZodString;
81
+ seoTitle: Zod.ZodString;
82
+ description: Zod.ZodString;
83
+ intro: Zod.ZodString;
84
+ keyFacts: Zod.ZodOptional<Zod.ZodArray<Zod.ZodObject<{
85
+ figure: Zod.ZodString;
86
+ label: Zod.ZodString;
87
+ detail: Zod.ZodString;
88
+ }, Zod.z.core.$strip>>>;
89
+ targetKeyword: Zod.ZodString;
90
+ editorialMode: Zod.ZodOptional<Zod.ZodEnum<{
91
+ evergreen: "evergreen";
92
+ discover: "discover";
93
+ }>>;
94
+ editorialFormat: Zod.ZodOptional<Zod.ZodEnum<{
95
+ "direct-answer": "direct-answer";
96
+ explainer: "explainer";
97
+ "narrative-profile": "narrative-profile";
98
+ "claim-check": "claim-check";
99
+ roundup: "roundup";
100
+ "how-to": "how-to";
101
+ comparison: "comparison";
102
+ "faq-hub": "faq-hub";
103
+ }>>;
104
+ discoverAngle: Zod.ZodOptional<Zod.ZodObject<{
105
+ audience: Zod.ZodString;
106
+ hook: Zod.ZodString;
107
+ payoff: Zod.ZodString;
108
+ evidenceUrls: Zod.ZodArray<Zod.ZodString>;
109
+ }, Zod.z.core.$strip>>;
110
+ sections: Zod.ZodArray<Zod.ZodObject<{
111
+ heading: Zod.ZodString;
112
+ body: Zod.ZodString;
113
+ subsections: Zod.ZodOptional<Zod.ZodArray<Zod.ZodObject<{
114
+ heading: Zod.ZodString;
115
+ body: Zod.ZodString;
116
+ }, Zod.z.core.$strip>>>;
117
+ interludes: Zod.ZodOptional<Zod.ZodArray<Zod.ZodType<{
118
+ type: string;
119
+ afterParagraph?: number;
120
+ } & Record<string, unknown>, unknown, Zod.z.core.$ZodTypeInternals<{
121
+ type: string;
122
+ afterParagraph?: number;
123
+ } & Record<string, unknown>, unknown>>>>;
124
+ inlineImages: Zod.ZodOptional<Zod.ZodArray<Zod.ZodObject<{
125
+ slug: Zod.ZodString;
126
+ alt: Zod.ZodString;
127
+ caption: Zod.ZodOptional<Zod.ZodString>;
128
+ afterParagraph: Zod.ZodNumber;
129
+ }, Zod.z.core.$strip>>>;
130
+ affiliateCarousels: Zod.ZodOptional<Zod.ZodArray<Zod.ZodObject<{
131
+ ids: Zod.ZodOptional<Zod.ZodArray<Zod.ZodNumber>>;
132
+ afterParagraph: Zod.ZodNumber;
133
+ heading: Zod.ZodOptional<Zod.ZodString>;
134
+ }, Zod.z.core.$strip>>>;
135
+ }, Zod.z.core.$strip>>;
136
+ faqs: Zod.ZodArray<Zod.ZodObject<{
137
+ question: Zod.ZodString;
138
+ answer: Zod.ZodString;
139
+ }, Zod.z.core.$strip>>;
140
+ image: Zod.ZodOptional<Zod.ZodString>;
141
+ imageAlt: Zod.ZodString;
142
+ imageTitle: Zod.ZodOptional<Zod.ZodString>;
143
+ semanticField: Zod.ZodArray<Zod.ZodString>;
144
+ audiences: Zod.ZodOptional<Zod.ZodArray<Zod.ZodString>> | Zod.ZodOptional<Zod.ZodArray<Zod.ZodEnum<{
145
+ [x: string]: string;
146
+ }>>>;
147
+ category: Zod.ZodEnum<{
148
+ [x: string]: string;
149
+ }> | Zod.ZodOptional<Zod.ZodEnum<{
150
+ [x: string]: string;
151
+ }>>;
152
+ people?: Zod.ZodOptional<Zod.ZodArray<Zod.ZodString>> | undefined;
153
+ slug: Zod.ZodString;
154
+ } | {
155
+ relatedContent: Zod.ZodOptional<Zod.ZodArray<Zod.ZodObject<{
156
+ type: Zod.ZodEnum<{
157
+ [x: string]: string;
158
+ }>;
159
+ slug: Zod.ZodString;
160
+ }, Zod.z.core.$strip>>>;
161
+ sources: Zod.ZodOptional<Zod.ZodArray<Zod.ZodUnion<readonly [Zod.ZodString, Zod.ZodObject<{
162
+ url: Zod.ZodString;
163
+ name: Zod.ZodOptional<Zod.ZodString>;
164
+ quote: Zod.ZodString;
165
+ }, Zod.z.core.$strip>]>>>;
166
+ affiliates: Zod.ZodOptional<Zod.ZodObject<{
167
+ amazonProductIds: Zod.ZodOptional<Zod.ZodArray<Zod.ZodString>>;
168
+ }, Zod.z.core.$strip>>;
169
+ author: Zod.ZodString;
170
+ datePublished: Zod.ZodString;
171
+ dateModified: Zod.ZodString;
172
+ era?: Zod.ZodOptional<Zod.ZodEnum<{
173
+ [x: string]: string;
174
+ }>> | undefined;
175
+ yearStart?: Zod.ZodOptional<Zod.ZodNumber> | undefined;
176
+ yearEnd?: Zod.ZodOptional<Zod.ZodNumber> | undefined;
177
+ dossiers?: Zod.ZodOptional<Zod.ZodArray<Zod.ZodEnum<{
178
+ [x: string]: string;
179
+ }>>> | undefined;
180
+ themes: Zod.ZodOptional<Zod.ZodArray<Zod.ZodString>> | Zod.ZodOptional<Zod.ZodArray<Zod.ZodEnum<{
181
+ [x: string]: string;
182
+ }>>>;
183
+ tags: Zod.ZodOptional<Zod.ZodArray<Zod.ZodString>>;
184
+ title: Zod.ZodString;
185
+ seoTitle: Zod.ZodString;
186
+ description: Zod.ZodString;
187
+ intro: Zod.ZodString;
188
+ keyFacts: Zod.ZodOptional<Zod.ZodArray<Zod.ZodObject<{
189
+ figure: Zod.ZodString;
190
+ label: Zod.ZodString;
191
+ detail: Zod.ZodString;
192
+ }, Zod.z.core.$strip>>>;
193
+ targetKeyword: Zod.ZodString;
194
+ editorialMode: Zod.ZodOptional<Zod.ZodEnum<{
195
+ evergreen: "evergreen";
196
+ discover: "discover";
197
+ }>>;
198
+ editorialFormat: Zod.ZodOptional<Zod.ZodEnum<{
199
+ "direct-answer": "direct-answer";
200
+ explainer: "explainer";
201
+ "narrative-profile": "narrative-profile";
202
+ "claim-check": "claim-check";
203
+ roundup: "roundup";
204
+ "how-to": "how-to";
205
+ comparison: "comparison";
206
+ "faq-hub": "faq-hub";
207
+ }>>;
208
+ discoverAngle: Zod.ZodOptional<Zod.ZodObject<{
209
+ audience: Zod.ZodString;
210
+ hook: Zod.ZodString;
211
+ payoff: Zod.ZodString;
212
+ evidenceUrls: Zod.ZodArray<Zod.ZodString>;
213
+ }, Zod.z.core.$strip>>;
214
+ sections: Zod.ZodArray<Zod.ZodObject<{
215
+ heading: Zod.ZodString;
216
+ body: Zod.ZodString;
217
+ subsections: Zod.ZodOptional<Zod.ZodArray<Zod.ZodObject<{
218
+ heading: Zod.ZodString;
219
+ body: Zod.ZodString;
220
+ }, Zod.z.core.$strip>>>;
221
+ interludes: Zod.ZodOptional<Zod.ZodArray<Zod.ZodType<{
222
+ type: string;
223
+ afterParagraph?: number;
224
+ } & Record<string, unknown>, unknown, Zod.z.core.$ZodTypeInternals<{
225
+ type: string;
226
+ afterParagraph?: number;
227
+ } & Record<string, unknown>, unknown>>>>;
228
+ inlineImages: Zod.ZodOptional<Zod.ZodArray<Zod.ZodObject<{
229
+ slug: Zod.ZodString;
230
+ alt: Zod.ZodString;
231
+ caption: Zod.ZodOptional<Zod.ZodString>;
232
+ afterParagraph: Zod.ZodNumber;
233
+ }, Zod.z.core.$strip>>>;
234
+ affiliateCarousels: Zod.ZodOptional<Zod.ZodArray<Zod.ZodObject<{
235
+ ids: Zod.ZodOptional<Zod.ZodArray<Zod.ZodNumber>>;
236
+ afterParagraph: Zod.ZodNumber;
237
+ heading: Zod.ZodOptional<Zod.ZodString>;
238
+ }, Zod.z.core.$strip>>>;
239
+ }, Zod.z.core.$strip>>;
240
+ faqs: Zod.ZodArray<Zod.ZodObject<{
241
+ question: Zod.ZodString;
242
+ answer: Zod.ZodString;
243
+ }, Zod.z.core.$strip>>;
244
+ image: Zod.ZodOptional<Zod.ZodString>;
245
+ imageAlt: Zod.ZodString;
246
+ imageTitle: Zod.ZodOptional<Zod.ZodString>;
247
+ semanticField: Zod.ZodArray<Zod.ZodString>;
248
+ audiences: Zod.ZodOptional<Zod.ZodArray<Zod.ZodString>> | Zod.ZodOptional<Zod.ZodArray<Zod.ZodEnum<{
249
+ [x: string]: string;
250
+ }>>>;
251
+ category: Zod.ZodEnum<{
252
+ [x: string]: string;
253
+ }> | Zod.ZodOptional<Zod.ZodEnum<{
254
+ [x: string]: string;
255
+ }>>;
256
+ people?: Zod.ZodOptional<Zod.ZodArray<Zod.ZodString>> | undefined;
257
+ slug: Zod.ZodString;
258
+ };
259
+ /**
260
+ * Full `z.object(...).superRefine(...)` schema for an `articles` collection.
261
+ */
262
+ export declare function createArticleSchema(z: ZodLike, options: ArticleSchemaOptions): Zod.ZodObject<{
263
+ relatedContent: Zod.ZodOptional<Zod.ZodArray<Zod.ZodObject<{
264
+ type: Zod.ZodEnum<{
265
+ [x: string]: string;
266
+ }>;
267
+ slug: Zod.ZodString;
268
+ }, Zod.z.core.$strip>>>;
269
+ sources: Zod.ZodOptional<Zod.ZodArray<Zod.ZodUnion<readonly [Zod.ZodString, Zod.ZodObject<{
270
+ url: Zod.ZodString;
271
+ name: Zod.ZodOptional<Zod.ZodString>;
272
+ quote: Zod.ZodString;
273
+ }, Zod.z.core.$strip>]>>>;
274
+ affiliates: Zod.ZodOptional<Zod.ZodObject<{
275
+ amazonProductIds: Zod.ZodOptional<Zod.ZodArray<Zod.ZodString>>;
276
+ }, Zod.z.core.$strip>>;
277
+ author: Zod.ZodString;
278
+ datePublished: Zod.ZodString;
279
+ dateModified: Zod.ZodString;
280
+ era?: Zod.ZodOptional<Zod.ZodEnum<{
281
+ [x: string]: string;
282
+ }>> | undefined;
283
+ yearStart?: Zod.ZodOptional<Zod.ZodNumber> | undefined;
284
+ yearEnd?: Zod.ZodOptional<Zod.ZodNumber> | undefined;
285
+ dossiers?: Zod.ZodOptional<Zod.ZodArray<Zod.ZodEnum<{
286
+ [x: string]: string;
287
+ }>>> | undefined;
288
+ themes: Zod.ZodOptional<Zod.ZodArray<Zod.ZodString>> | Zod.ZodOptional<Zod.ZodArray<Zod.ZodEnum<{
289
+ [x: string]: string;
290
+ }>>>;
291
+ tags: Zod.ZodOptional<Zod.ZodArray<Zod.ZodEnum<{
292
+ [x: string]: string;
293
+ }>>>;
294
+ title: Zod.ZodString;
295
+ seoTitle: Zod.ZodString;
296
+ description: Zod.ZodString;
297
+ intro: Zod.ZodString;
298
+ keyFacts: Zod.ZodOptional<Zod.ZodArray<Zod.ZodObject<{
299
+ figure: Zod.ZodString;
300
+ label: Zod.ZodString;
301
+ detail: Zod.ZodString;
302
+ }, Zod.z.core.$strip>>>;
303
+ targetKeyword: Zod.ZodString;
304
+ editorialMode: Zod.ZodOptional<Zod.ZodEnum<{
305
+ evergreen: "evergreen";
306
+ discover: "discover";
307
+ }>>;
308
+ editorialFormat: Zod.ZodOptional<Zod.ZodEnum<{
309
+ "direct-answer": "direct-answer";
310
+ explainer: "explainer";
311
+ "narrative-profile": "narrative-profile";
312
+ "claim-check": "claim-check";
313
+ roundup: "roundup";
314
+ "how-to": "how-to";
315
+ comparison: "comparison";
316
+ "faq-hub": "faq-hub";
317
+ }>>;
318
+ discoverAngle: Zod.ZodOptional<Zod.ZodObject<{
319
+ audience: Zod.ZodString;
320
+ hook: Zod.ZodString;
321
+ payoff: Zod.ZodString;
322
+ evidenceUrls: Zod.ZodArray<Zod.ZodString>;
323
+ }, Zod.z.core.$strip>>;
324
+ sections: Zod.ZodArray<Zod.ZodObject<{
325
+ heading: Zod.ZodString;
326
+ body: Zod.ZodString;
327
+ subsections: Zod.ZodOptional<Zod.ZodArray<Zod.ZodObject<{
328
+ heading: Zod.ZodString;
329
+ body: Zod.ZodString;
330
+ }, Zod.z.core.$strip>>>;
331
+ interludes: Zod.ZodOptional<Zod.ZodArray<Zod.ZodType<{
332
+ type: string;
333
+ afterParagraph?: number;
334
+ } & Record<string, unknown>, unknown, Zod.z.core.$ZodTypeInternals<{
335
+ type: string;
336
+ afterParagraph?: number;
337
+ } & Record<string, unknown>, unknown>>>>;
338
+ inlineImages: Zod.ZodOptional<Zod.ZodArray<Zod.ZodObject<{
339
+ slug: Zod.ZodString;
340
+ alt: Zod.ZodString;
341
+ caption: Zod.ZodOptional<Zod.ZodString>;
342
+ afterParagraph: Zod.ZodNumber;
343
+ }, Zod.z.core.$strip>>>;
344
+ affiliateCarousels: Zod.ZodOptional<Zod.ZodArray<Zod.ZodObject<{
345
+ ids: Zod.ZodOptional<Zod.ZodArray<Zod.ZodNumber>>;
346
+ afterParagraph: Zod.ZodNumber;
347
+ heading: Zod.ZodOptional<Zod.ZodString>;
348
+ }, Zod.z.core.$strip>>>;
349
+ }, Zod.z.core.$strip>>;
350
+ faqs: Zod.ZodArray<Zod.ZodObject<{
351
+ question: Zod.ZodString;
352
+ answer: Zod.ZodString;
353
+ }, Zod.z.core.$strip>>;
354
+ image: Zod.ZodOptional<Zod.ZodString>;
355
+ imageAlt: Zod.ZodString;
356
+ imageTitle: Zod.ZodOptional<Zod.ZodString>;
357
+ semanticField: Zod.ZodArray<Zod.ZodString>;
358
+ audiences: Zod.ZodOptional<Zod.ZodArray<Zod.ZodString>> | Zod.ZodOptional<Zod.ZodArray<Zod.ZodEnum<{
359
+ [x: string]: string;
360
+ }>>>;
361
+ category: Zod.ZodEnum<{
362
+ [x: string]: string;
363
+ }> | Zod.ZodOptional<Zod.ZodEnum<{
364
+ [x: string]: string;
365
+ }>>;
366
+ people?: Zod.ZodOptional<Zod.ZodArray<Zod.ZodString>> | undefined;
367
+ slug: Zod.ZodString;
368
+ } | {
369
+ relatedContent: Zod.ZodOptional<Zod.ZodArray<Zod.ZodObject<{
370
+ type: Zod.ZodEnum<{
371
+ [x: string]: string;
372
+ }>;
373
+ slug: Zod.ZodString;
374
+ }, Zod.z.core.$strip>>>;
375
+ sources: Zod.ZodOptional<Zod.ZodArray<Zod.ZodUnion<readonly [Zod.ZodString, Zod.ZodObject<{
376
+ url: Zod.ZodString;
377
+ name: Zod.ZodOptional<Zod.ZodString>;
378
+ quote: Zod.ZodString;
379
+ }, Zod.z.core.$strip>]>>>;
380
+ affiliates: Zod.ZodOptional<Zod.ZodObject<{
381
+ amazonProductIds: Zod.ZodOptional<Zod.ZodArray<Zod.ZodString>>;
382
+ }, Zod.z.core.$strip>>;
383
+ author: Zod.ZodString;
384
+ datePublished: Zod.ZodString;
385
+ dateModified: Zod.ZodString;
386
+ era?: Zod.ZodOptional<Zod.ZodEnum<{
387
+ [x: string]: string;
388
+ }>> | undefined;
389
+ yearStart?: Zod.ZodOptional<Zod.ZodNumber> | undefined;
390
+ yearEnd?: Zod.ZodOptional<Zod.ZodNumber> | undefined;
391
+ dossiers?: Zod.ZodOptional<Zod.ZodArray<Zod.ZodEnum<{
392
+ [x: string]: string;
393
+ }>>> | undefined;
394
+ themes: Zod.ZodOptional<Zod.ZodArray<Zod.ZodString>> | Zod.ZodOptional<Zod.ZodArray<Zod.ZodEnum<{
395
+ [x: string]: string;
396
+ }>>>;
397
+ tags: Zod.ZodOptional<Zod.ZodArray<Zod.ZodString>>;
398
+ title: Zod.ZodString;
399
+ seoTitle: Zod.ZodString;
400
+ description: Zod.ZodString;
401
+ intro: Zod.ZodString;
402
+ keyFacts: Zod.ZodOptional<Zod.ZodArray<Zod.ZodObject<{
403
+ figure: Zod.ZodString;
404
+ label: Zod.ZodString;
405
+ detail: Zod.ZodString;
406
+ }, Zod.z.core.$strip>>>;
407
+ targetKeyword: Zod.ZodString;
408
+ editorialMode: Zod.ZodOptional<Zod.ZodEnum<{
409
+ evergreen: "evergreen";
410
+ discover: "discover";
411
+ }>>;
412
+ editorialFormat: Zod.ZodOptional<Zod.ZodEnum<{
413
+ "direct-answer": "direct-answer";
414
+ explainer: "explainer";
415
+ "narrative-profile": "narrative-profile";
416
+ "claim-check": "claim-check";
417
+ roundup: "roundup";
418
+ "how-to": "how-to";
419
+ comparison: "comparison";
420
+ "faq-hub": "faq-hub";
421
+ }>>;
422
+ discoverAngle: Zod.ZodOptional<Zod.ZodObject<{
423
+ audience: Zod.ZodString;
424
+ hook: Zod.ZodString;
425
+ payoff: Zod.ZodString;
426
+ evidenceUrls: Zod.ZodArray<Zod.ZodString>;
427
+ }, Zod.z.core.$strip>>;
428
+ sections: Zod.ZodArray<Zod.ZodObject<{
429
+ heading: Zod.ZodString;
430
+ body: Zod.ZodString;
431
+ subsections: Zod.ZodOptional<Zod.ZodArray<Zod.ZodObject<{
432
+ heading: Zod.ZodString;
433
+ body: Zod.ZodString;
434
+ }, Zod.z.core.$strip>>>;
435
+ interludes: Zod.ZodOptional<Zod.ZodArray<Zod.ZodType<{
436
+ type: string;
437
+ afterParagraph?: number;
438
+ } & Record<string, unknown>, unknown, Zod.z.core.$ZodTypeInternals<{
439
+ type: string;
440
+ afterParagraph?: number;
441
+ } & Record<string, unknown>, unknown>>>>;
442
+ inlineImages: Zod.ZodOptional<Zod.ZodArray<Zod.ZodObject<{
443
+ slug: Zod.ZodString;
444
+ alt: Zod.ZodString;
445
+ caption: Zod.ZodOptional<Zod.ZodString>;
446
+ afterParagraph: Zod.ZodNumber;
447
+ }, Zod.z.core.$strip>>>;
448
+ affiliateCarousels: Zod.ZodOptional<Zod.ZodArray<Zod.ZodObject<{
449
+ ids: Zod.ZodOptional<Zod.ZodArray<Zod.ZodNumber>>;
450
+ afterParagraph: Zod.ZodNumber;
451
+ heading: Zod.ZodOptional<Zod.ZodString>;
452
+ }, Zod.z.core.$strip>>>;
453
+ }, Zod.z.core.$strip>>;
454
+ faqs: Zod.ZodArray<Zod.ZodObject<{
455
+ question: Zod.ZodString;
456
+ answer: Zod.ZodString;
457
+ }, Zod.z.core.$strip>>;
458
+ image: Zod.ZodOptional<Zod.ZodString>;
459
+ imageAlt: Zod.ZodString;
460
+ imageTitle: Zod.ZodOptional<Zod.ZodString>;
461
+ semanticField: Zod.ZodArray<Zod.ZodString>;
462
+ audiences: Zod.ZodOptional<Zod.ZodArray<Zod.ZodString>> | Zod.ZodOptional<Zod.ZodArray<Zod.ZodEnum<{
463
+ [x: string]: string;
464
+ }>>>;
465
+ category: Zod.ZodEnum<{
466
+ [x: string]: string;
467
+ }> | Zod.ZodOptional<Zod.ZodEnum<{
468
+ [x: string]: string;
469
+ }>>;
470
+ people?: Zod.ZodOptional<Zod.ZodArray<Zod.ZodString>> | undefined;
471
+ slug: Zod.ZodString;
472
+ }, Zod.z.core.$strip>;
473
+ export {};
@@ -0,0 +1,165 @@
1
+ import { eraSchemaFields, eraYearIssues } from "../eras/index.js";
2
+ import { createInterludeSchema, INTERLUDE_MAX_PER_SECTION } from "../interludes/index.js";
3
+ import { isObject } from "../internal/guards.js";
4
+ import { ARTICLE_FORMATS, ARTICLE_SHAPE_UNION, articleShapeIssues } from "./formats.js";
5
+ /**
6
+ * Pure validation issues for an article object's `superRefine` block:
7
+ * - format & section/FAQ count shape rules (`articleShapeIssues`)
8
+ * - historical year ordering (`eraYearIssues`)
9
+ * - `discoverAngle` presence & source URL matching when `editorialMode === 'discover'`
10
+ * - duplicate tag check when `tags` is present
11
+ */
12
+ export function articleSuperRefineIssues(article) {
13
+ if (!isObject(article))
14
+ return [{ path: '', message: 'article: expected a JSON object' }];
15
+ const issues = [
16
+ ...articleShapeIssues(article),
17
+ ...eraYearIssues(article),
18
+ ];
19
+ const discover = article.editorialMode === 'discover';
20
+ const discoverAngle = isObject(article.discoverAngle) ? article.discoverAngle : null;
21
+ if (discover && !discoverAngle) {
22
+ issues.push({ path: 'discoverAngle', message: 'Discover rationale required' });
23
+ }
24
+ if (!discover && article.discoverAngle !== undefined) {
25
+ issues.push({ path: 'discoverAngle', message: 'Only allowed with editorialMode discover' });
26
+ }
27
+ if (discoverAngle && Array.isArray(discoverAngle.evidenceUrls)) {
28
+ const sources = Array.isArray(article.sources) ? article.sources : [];
29
+ const urls = new Set(sources.map((s) => (typeof s === 'string' ? s : isObject(s) && typeof s.url === 'string' ? s.url : '')));
30
+ for (const url of discoverAngle.evidenceUrls) {
31
+ if (typeof url === 'string' && !urls.has(url)) {
32
+ issues.push({ path: 'discoverAngle', message: 'Each evidence URL must match an article source' });
33
+ }
34
+ }
35
+ }
36
+ if (Array.isArray(article.tags)) {
37
+ const seen = new Set();
38
+ for (const tag of article.tags) {
39
+ if (typeof tag === 'string') {
40
+ if (seen.has(tag)) {
41
+ issues.push({ path: 'tags', message: `Duplicate tag "${tag}"` });
42
+ }
43
+ seen.add(tag);
44
+ }
45
+ }
46
+ }
47
+ return issues;
48
+ }
49
+ /**
50
+ * Returns the Zod field map for an `articles` collection so a site can spread or extend it,
51
+ * or pass it to `createArticleSchema(z, options)`.
52
+ */
53
+ export function articleSchemaFields(z, options) {
54
+ if (!options.categories.length) {
55
+ throw new Error('articleSchemaFields: categories must be a non-empty tuple');
56
+ }
57
+ if (!options.relatedTargetTypes.length) {
58
+ throw new Error('articleSchemaFields: relatedTargetTypes must be a non-empty tuple');
59
+ }
60
+ const interlude = (options.interludeSchema ??
61
+ (options.interludeConfig ? createInterludeSchema(z, options.interludeConfig) : null));
62
+ if (!interlude) {
63
+ throw new Error('articleSchemaFields: either interludeConfig or interludeSchema is required');
64
+ }
65
+ const keyFactsSchema = z.array(z.object({
66
+ figure: z.string().min(1).max(14),
67
+ label: z.string().min(1).max(28),
68
+ detail: z.string().min(1).max(90),
69
+ })).min(ARTICLE_SHAPE_UNION.keyFacts[0]).max(ARTICLE_SHAPE_UNION.keyFacts[1]).optional();
70
+ const sourcesSchema = z.array(z.union([
71
+ z.string().url(),
72
+ z.object({
73
+ url: z.string().url(),
74
+ name: z.string().optional(),
75
+ quote: z.string().min(1),
76
+ }),
77
+ ])).optional();
78
+ const relatedContentSchema = z.array(z.object({
79
+ type: z.enum(options.relatedTargetTypes),
80
+ slug: z.string(),
81
+ })).optional();
82
+ const audiencesSchema = options.audiences?.length
83
+ ? z.array(z.enum(options.audiences)).max(5).optional()
84
+ : z.array(z.string()).max(5).optional();
85
+ const themesSchema = options.themes?.length
86
+ ? z.array(z.enum(options.themes)).max(4).optional()
87
+ : z.array(z.string()).max(4).optional();
88
+ const categorySchema = options.optionalCategory
89
+ ? z.enum(options.categories).optional()
90
+ : z.enum(options.categories);
91
+ const tagsField = options.tags?.length
92
+ ? { tags: z.array(z.enum(options.tags)).min(1).max(4).optional() }
93
+ : { tags: z.array(z.string().regex(/^[a-z0-9]+(-[a-z0-9]+)*$/)).min(1).max(4).optional() };
94
+ const includePeople = options.people ?? Boolean(options.eras?.length);
95
+ return {
96
+ slug: z.string(),
97
+ ...(includePeople ? { people: z.array(z.string()).optional() } : {}),
98
+ title: z.string().max(65),
99
+ seoTitle: z.string(),
100
+ description: z.string(),
101
+ intro: z.string(),
102
+ keyFacts: keyFactsSchema,
103
+ targetKeyword: z.string(),
104
+ editorialMode: z.enum(['evergreen', 'discover']).optional(),
105
+ editorialFormat: z.enum(ARTICLE_FORMATS).optional(),
106
+ discoverAngle: z.object({
107
+ audience: z.string().trim().min(1),
108
+ hook: z.string().trim().min(1),
109
+ payoff: z.string().trim().min(1),
110
+ evidenceUrls: z.array(z.string().url().refine((url) => url.startsWith('https:'), 'HTTPS URL required')).min(1),
111
+ }).optional(),
112
+ sections: z.array(z.object({
113
+ heading: z.string(),
114
+ body: z.string(),
115
+ subsections: z.array(z.object({
116
+ heading: z.string(),
117
+ body: z.string(),
118
+ })).max(3).optional(),
119
+ interludes: z.array(interlude).max(INTERLUDE_MAX_PER_SECTION).optional(),
120
+ inlineImages: z.array(z.object({
121
+ slug: z.string(),
122
+ alt: z.string(),
123
+ caption: z.string().optional(),
124
+ afterParagraph: z.number().int().min(0),
125
+ })).max(2).optional(),
126
+ affiliateCarousels: z.array(z.object({
127
+ ids: z.array(z.number().int()).min(1).max(4).optional(),
128
+ afterParagraph: z.number().int().min(0),
129
+ heading: z.string().min(1).max(60).optional(),
130
+ })).max(1).optional(),
131
+ })).min(ARTICLE_SHAPE_UNION.sections[0]).max(ARTICLE_SHAPE_UNION.sections[1]),
132
+ faqs: z.array(z.object({
133
+ question: z.string(),
134
+ answer: z.string(),
135
+ })).max(ARTICLE_SHAPE_UNION.faqs[1]),
136
+ image: z.string().optional(),
137
+ imageAlt: z.string(),
138
+ imageTitle: z.string().optional(),
139
+ semanticField: z.array(z.string()).min(3),
140
+ audiences: audiencesSchema,
141
+ category: categorySchema,
142
+ ...tagsField,
143
+ themes: themesSchema,
144
+ ...(options.dossiers?.length ? { dossiers: z.array(z.enum(options.dossiers)).max(2).optional() } : {}),
145
+ ...(options.eras?.length ? eraSchemaFields(z, options.eras) : {}),
146
+ relatedContent: relatedContentSchema,
147
+ sources: sourcesSchema,
148
+ affiliates: z.object({
149
+ amazonProductIds: z.array(z.string()).optional(),
150
+ }).optional(),
151
+ author: z.string(),
152
+ datePublished: z.string(),
153
+ dateModified: z.string(),
154
+ };
155
+ }
156
+ /**
157
+ * Full `z.object(...).superRefine(...)` schema for an `articles` collection.
158
+ */
159
+ export function createArticleSchema(z, options) {
160
+ return z.object(articleSchemaFields(z, options)).superRefine((article, ctx) => {
161
+ for (const { path, message } of articleSuperRefineIssues(article)) {
162
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: path ? [path] : [], message });
163
+ }
164
+ });
165
+ }