@blogmcp/mdx-schema 0.1.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.
Files changed (41) hide show
  1. package/dist/checkPin.d.ts +48 -0
  2. package/dist/checkPin.js +139 -0
  3. package/dist/checkPin.js.map +1 -0
  4. package/dist/composables/useMdxParsing.d.ts +71 -0
  5. package/dist/composables/useMdxParsing.js +239 -0
  6. package/dist/composables/useMdxParsing.js.map +1 -0
  7. package/dist/index.d.ts +21 -0
  8. package/dist/index.js +22 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/metadata/customComponents.d.ts +128 -0
  11. package/dist/metadata/customComponents.js +301 -0
  12. package/dist/metadata/customComponents.js.map +1 -0
  13. package/dist/metadata/index.d.ts +24 -0
  14. package/dist/metadata/index.js +427 -0
  15. package/dist/metadata/index.js.map +1 -0
  16. package/dist/metadata/validate.d.ts +46 -0
  17. package/dist/metadata/validate.js +95 -0
  18. package/dist/metadata/validate.js.map +1 -0
  19. package/dist/prepareProps.d.ts +42 -0
  20. package/dist/prepareProps.js +177 -0
  21. package/dist/prepareProps.js.map +1 -0
  22. package/dist/styles/index.d.ts +203 -0
  23. package/dist/styles/index.js +162 -0
  24. package/dist/styles/index.js.map +1 -0
  25. package/dist/types/index.d.ts +421 -0
  26. package/dist/types/index.js +25 -0
  27. package/dist/types/index.js.map +1 -0
  28. package/dist/version.d.ts +23 -0
  29. package/dist/version.js +23 -0
  30. package/dist/version.js.map +1 -0
  31. package/package.json +80 -0
  32. package/src/checkPin.ts +163 -0
  33. package/src/composables/useMdxParsing.ts +248 -0
  34. package/src/index.ts +22 -0
  35. package/src/metadata/customComponents.ts +360 -0
  36. package/src/metadata/index.ts +437 -0
  37. package/src/metadata/validate.ts +153 -0
  38. package/src/prepareProps.ts +219 -0
  39. package/src/styles/index.ts +196 -0
  40. package/src/types/index.ts +469 -0
  41. package/src/version.ts +24 -0
@@ -0,0 +1,427 @@
1
+ /**
2
+ * MDX Component Metadata
3
+ *
4
+ * Framework-agnostic component descriptions. Consumed by:
5
+ * - MCP `editor_list_mdx_components` tool (AI agent discovery)
6
+ * - Validation (prop/enum/range checks)
7
+ * - Slash command UX in md-editor
8
+ * - Renderer registries (Vue + future React) — they import schemas and
9
+ * attach framework-specific loaders alongside.
10
+ *
11
+ * The interface declarations live in `../types/index.ts` (single
12
+ * declaration site); we re-export them from this module for backward
13
+ * compatibility with consumers importing `ComponentMetadata` /
14
+ * `PropMetadata` from `@blogmcp/mdx-schema/metadata`.
15
+ */
16
+ // Imported eagerly so future per-component default-stamping (next PR
17
+ // in the versioning series) can read SCHEMA_VERSION without adding a
18
+ // new import in the same diff. Side-effect-free.
19
+ import { SCHEMA_VERSION as _SCHEMA_VERSION } from '../version.js';
20
+ void _SCHEMA_VERSION;
21
+ /** All component metadata — single source of truth for agent-facing info. */
22
+ export const componentMetadata = [
23
+ {
24
+ name: 'Callout',
25
+ description: 'Info/warning/tip message box',
26
+ icon: '💬',
27
+ category: 'content',
28
+ aliases: ['callout', 'note', 'alert', 'info', 'warning', 'tip'],
29
+ props: [
30
+ {
31
+ name: 'type',
32
+ type: 'string',
33
+ required: false,
34
+ default: '"info"',
35
+ description: 'Callout style: info, warning, tip, or danger',
36
+ enum: ['info', 'warning', 'tip', 'danger'],
37
+ },
38
+ ],
39
+ hasChildren: true,
40
+ selfClosing: false,
41
+ defaultProps: 'type="info"',
42
+ defaultChildren: 'Your message here',
43
+ example: '<Callout type="info">\nYour message here\n</Callout>',
44
+ addedIn: '0.1.0',
45
+ deprecated: [],
46
+ },
47
+ {
48
+ name: 'YouTube',
49
+ description: 'Embedded video player',
50
+ icon: '▶',
51
+ category: 'media',
52
+ aliases: ['youtube', 'video', 'embed'],
53
+ props: [
54
+ {
55
+ name: 'id',
56
+ type: 'string',
57
+ required: true,
58
+ description: 'YouTube video ID (e.g., "dQw4w9WgXcQ")',
59
+ },
60
+ {
61
+ name: 'title',
62
+ type: 'string',
63
+ required: false,
64
+ description: 'Video title displayed below the embed',
65
+ },
66
+ ],
67
+ hasChildren: false,
68
+ selfClosing: true,
69
+ defaultProps: 'id="VIDEO_ID" title="Video title"',
70
+ defaultChildren: '',
71
+ example: '<YouTube id="dQw4w9WgXcQ" title="Video title" />',
72
+ addedIn: '0.1.0',
73
+ deprecated: [],
74
+ },
75
+ {
76
+ name: 'Gallery',
77
+ description: 'Image grid with lightbox',
78
+ icon: '🖼',
79
+ category: 'media',
80
+ aliases: ['gallery', 'images', 'grid', 'photos'],
81
+ props: [
82
+ {
83
+ name: 'images',
84
+ type: 'array',
85
+ required: true,
86
+ description: 'Array of image objects with src and alt properties: {src: string, alt: string}[]',
87
+ },
88
+ {
89
+ name: 'columns',
90
+ type: 'number',
91
+ required: false,
92
+ default: '2',
93
+ description: 'Number of columns (1-4)',
94
+ numericRange: [1, 4],
95
+ },
96
+ {
97
+ name: 'gap',
98
+ type: 'number',
99
+ required: false,
100
+ default: '4',
101
+ description: 'Gap between images (Tailwind scale)',
102
+ },
103
+ {
104
+ name: 'aspectRatio',
105
+ type: 'string',
106
+ required: false,
107
+ default: '"1"',
108
+ description: 'Tile aspect-ratio controlling height, e.g. "16/9" or "775/308". Use "auto" to drop the fixed box and let images use their natural height (full width, proportional) — ideal for a single wide image.',
109
+ addedIn: '0.2.0',
110
+ },
111
+ {
112
+ name: 'fit',
113
+ type: 'string',
114
+ required: false,
115
+ default: '"cover"',
116
+ description: 'How the image fills its tile: "cover" crops to fill, "contain" shows the whole image letterboxed (no crop). Ignored when aspectRatio="auto".',
117
+ enum: ['cover', 'contain'],
118
+ addedIn: '0.2.0',
119
+ },
120
+ {
121
+ name: 'position',
122
+ type: 'string',
123
+ required: false,
124
+ default: '"center"',
125
+ description: 'CSS object-position selecting which region shows when cropping (e.g. "top", "50% 30%"). Only applies with fit="cover" and a fixed aspect-ratio.',
126
+ addedIn: '0.2.0',
127
+ },
128
+ ],
129
+ hasChildren: false,
130
+ selfClosing: true,
131
+ defaultProps: 'images={[{"src": "/image1.jpg", "alt": "Image 1"}, {"src": "/image2.jpg", "alt": "Image 2"}]} columns={2}',
132
+ defaultChildren: '',
133
+ example: '<Gallery images={[{"src": "/banner.svg", "alt": "Banner"}]} columns={1} aspectRatio="16/9" fit="contain" />',
134
+ addedIn: '0.1.0',
135
+ deprecated: [],
136
+ },
137
+ {
138
+ name: 'CodeBlock',
139
+ description: 'Syntax-highlighted code',
140
+ icon: '{ }',
141
+ category: 'code',
142
+ aliases: ['codeblock', 'snippet', 'syntax'],
143
+ props: [
144
+ {
145
+ name: 'language',
146
+ type: 'string',
147
+ required: false,
148
+ default: '"javascript"',
149
+ description: 'Programming language for syntax highlighting',
150
+ },
151
+ {
152
+ name: 'title',
153
+ type: 'string',
154
+ required: false,
155
+ description: 'File name or title displayed in header',
156
+ },
157
+ {
158
+ name: 'showLineNumbers',
159
+ type: 'boolean',
160
+ required: false,
161
+ default: 'false',
162
+ description: 'Whether to show line numbers',
163
+ },
164
+ ],
165
+ hasChildren: true,
166
+ selfClosing: false,
167
+ defaultProps: 'language="javascript" title="example.js"',
168
+ defaultChildren: 'const hello = "world";',
169
+ example: '<CodeBlock language="javascript" title="example.js">\nconst hello = "world";\n</CodeBlock>',
170
+ addedIn: '0.1.0',
171
+ deprecated: [],
172
+ },
173
+ {
174
+ name: 'AudioPlayer',
175
+ description: 'Audio player with optional transcription',
176
+ icon: '🔊',
177
+ category: 'media',
178
+ aliases: ['audioplayer', 'audio', 'podcast', 'recording'],
179
+ props: [
180
+ {
181
+ name: 'slug',
182
+ type: 'string',
183
+ required: true,
184
+ description: 'Media slug — resolves to /api/media/file/{slug}',
185
+ },
186
+ {
187
+ name: 'title',
188
+ type: 'string',
189
+ required: false,
190
+ description: 'Displayed title',
191
+ },
192
+ {
193
+ name: 'showTranscription',
194
+ type: 'boolean',
195
+ required: false,
196
+ default: 'false',
197
+ description: 'Show collapsible transcript panel',
198
+ },
199
+ ],
200
+ hasChildren: false,
201
+ selfClosing: true,
202
+ defaultProps: 'slug="audio-slug" title="Audio title"',
203
+ defaultChildren: '',
204
+ example: '<AudioPlayer slug="interview-dr-smith" title="Interview" showTranscription />',
205
+ addedIn: '0.1.0',
206
+ deprecated: [],
207
+ },
208
+ {
209
+ name: 'Button',
210
+ description: 'Action button or CTA link. Self-closing; label is a prop so agents do not nest MDX inside.',
211
+ icon: '🔘',
212
+ category: 'action',
213
+ aliases: ['button', 'cta', 'action'],
214
+ props: [
215
+ {
216
+ name: 'label',
217
+ type: 'string',
218
+ required: true,
219
+ description: 'Button text',
220
+ },
221
+ {
222
+ name: 'to',
223
+ type: 'string',
224
+ required: false,
225
+ description: 'Link URL — when set, the button renders as an <a>',
226
+ },
227
+ {
228
+ name: 'variant',
229
+ type: 'string',
230
+ required: false,
231
+ default: '"solid"',
232
+ description: 'Visual style',
233
+ enum: ['solid', 'outline', 'soft', 'ghost', 'link'],
234
+ },
235
+ {
236
+ name: 'color',
237
+ type: 'string',
238
+ required: false,
239
+ default: '"primary"',
240
+ description: 'Semantic color',
241
+ enum: ['primary', 'neutral', 'success', 'warning', 'error'],
242
+ },
243
+ {
244
+ name: 'size',
245
+ type: 'string',
246
+ required: false,
247
+ default: '"md"',
248
+ description: 'Button size',
249
+ enum: ['sm', 'md', 'lg'],
250
+ },
251
+ ],
252
+ hasChildren: false,
253
+ selfClosing: true,
254
+ defaultProps: 'label="Read more" to="/docs"',
255
+ defaultChildren: '',
256
+ example: '<Button label="Read more" to="/docs" variant="outline" />',
257
+ addedIn: '0.1.0',
258
+ deprecated: [],
259
+ },
260
+ {
261
+ name: 'Card',
262
+ description: 'Content block with optional title. Wraps child MDX in a bordered container.',
263
+ icon: '🃏',
264
+ category: 'content',
265
+ aliases: ['card', 'panel', 'box'],
266
+ props: [
267
+ {
268
+ name: 'title',
269
+ type: 'string',
270
+ required: false,
271
+ description: 'Optional heading displayed at the top of the card',
272
+ },
273
+ ],
274
+ hasChildren: true,
275
+ selfClosing: false,
276
+ defaultProps: 'title="Card title"',
277
+ defaultChildren: 'Card body content.',
278
+ example: '<Card title="About">\nContent goes here.\n</Card>',
279
+ addedIn: '0.1.0',
280
+ deprecated: [],
281
+ },
282
+ {
283
+ name: 'Alert',
284
+ description: 'Inline notice — flatter and smaller than Callout. Use for short status messages.',
285
+ icon: '⚠️',
286
+ category: 'content',
287
+ aliases: ['alert', 'notice', 'banner'],
288
+ props: [
289
+ {
290
+ name: 'severity',
291
+ type: 'string',
292
+ required: false,
293
+ default: '"info"',
294
+ description: 'Severity level — drives color and icon',
295
+ enum: ['info', 'success', 'warning', 'error'],
296
+ },
297
+ {
298
+ name: 'title',
299
+ type: 'string',
300
+ required: false,
301
+ description: 'Optional bold heading above the body',
302
+ },
303
+ ],
304
+ hasChildren: true,
305
+ selfClosing: false,
306
+ defaultProps: 'severity="warning" title="Heads up"',
307
+ defaultChildren: 'Important message.',
308
+ example: '<Alert severity="warning" title="Heads up">\nRead this carefully.\n</Alert>',
309
+ addedIn: '0.1.0',
310
+ deprecated: [],
311
+ },
312
+ {
313
+ name: 'Badge',
314
+ description: 'Small label or tag. Self-closing; label is a prop.',
315
+ icon: '🏷',
316
+ category: 'content',
317
+ aliases: ['badge', 'tag', 'chip', 'label'],
318
+ props: [
319
+ {
320
+ name: 'label',
321
+ type: 'string',
322
+ required: true,
323
+ description: 'Badge text',
324
+ },
325
+ {
326
+ name: 'color',
327
+ type: 'string',
328
+ required: false,
329
+ default: '"neutral"',
330
+ description: 'Semantic color',
331
+ enum: ['primary', 'neutral', 'success', 'warning', 'error'],
332
+ },
333
+ {
334
+ name: 'variant',
335
+ type: 'string',
336
+ required: false,
337
+ default: '"soft"',
338
+ description: 'Visual style',
339
+ enum: ['solid', 'soft', 'outline'],
340
+ },
341
+ ],
342
+ hasChildren: false,
343
+ selfClosing: true,
344
+ defaultProps: 'label="New" color="success"',
345
+ defaultChildren: '',
346
+ example: '<Badge label="New" color="success" />',
347
+ addedIn: '0.1.0',
348
+ deprecated: [],
349
+ },
350
+ {
351
+ name: 'Icon',
352
+ description: 'Inline SVG icon from any Iconify set (lucide, mdi, heroicons, etc.). Name format: "set:icon".',
353
+ icon: '★',
354
+ category: 'media',
355
+ aliases: ['icon', 'symbol'],
356
+ props: [
357
+ {
358
+ name: 'name',
359
+ type: 'string',
360
+ required: true,
361
+ description: 'Iconify identifier, e.g. "lucide:star", "mdi:check", "heroicons:heart"',
362
+ },
363
+ {
364
+ name: 'size',
365
+ type: 'number',
366
+ required: false,
367
+ default: '20',
368
+ description: 'Pixel size (width = height)',
369
+ },
370
+ {
371
+ name: 'color',
372
+ type: 'string',
373
+ required: false,
374
+ description: 'CSS color — omit to inherit current text color',
375
+ },
376
+ ],
377
+ hasChildren: false,
378
+ selfClosing: true,
379
+ defaultProps: 'name="lucide:star"',
380
+ defaultChildren: '',
381
+ example: '<Icon name="lucide:star" size={24} />',
382
+ addedIn: '0.1.0',
383
+ deprecated: [],
384
+ },
385
+ {
386
+ name: 'Tooltip',
387
+ description: 'Hover-reveal tooltip wrapping its child. Backed by Ark UI — keyboard accessible, portals on demand.',
388
+ icon: '💡',
389
+ category: 'action',
390
+ aliases: ['tooltip', 'hint'],
391
+ props: [
392
+ {
393
+ name: 'label',
394
+ type: 'string',
395
+ required: true,
396
+ description: 'Tooltip text shown on hover or focus',
397
+ },
398
+ {
399
+ name: 'placement',
400
+ type: 'string',
401
+ required: false,
402
+ default: '"top"',
403
+ description: 'Position relative to the trigger',
404
+ enum: ['top', 'bottom', 'left', 'right'],
405
+ },
406
+ ],
407
+ hasChildren: true,
408
+ selfClosing: false,
409
+ defaultProps: 'label="Click to save"',
410
+ defaultChildren: '<Button label="Save" />',
411
+ example: '<Tooltip label="Saves instantly">\n <Button label="Save" />\n</Tooltip>',
412
+ addedIn: '0.1.0',
413
+ deprecated: [],
414
+ },
415
+ ];
416
+ const metadataMap = new Map(componentMetadata.map(m => [m.name, m]));
417
+ /** Get metadata for a single component by name */
418
+ export function getComponentMetadata(name) {
419
+ return metadataMap.get(name);
420
+ }
421
+ /** Get all registered component names */
422
+ export function getComponentNames() {
423
+ return componentMetadata.map(m => m.name);
424
+ }
425
+ // Tenant custom-component manifests (built-in ∪ custom for agent discovery + validation).
426
+ export * from './customComponents.js';
427
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/metadata/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,qEAAqE;AACrE,qEAAqE;AACrE,iDAAiD;AACjD,OAAO,EAAE,cAAc,IAAI,eAAe,EAAE,MAAM,eAAe,CAAA;AACjE,KAAK,eAAe,CAAA;AAGpB,6EAA6E;AAC7E,MAAM,CAAC,MAAM,iBAAiB,GAAwB;IACpD;QACE,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,8BAA8B;QAC3C,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,SAAS;QACnB,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC;QAC/D,KAAK,EAAE;YACL;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,QAAQ;gBACjB,WAAW,EAAE,8CAA8C;gBAC3D,IAAI,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC;aAC3C;SACF;QACD,WAAW,EAAE,IAAI;QACjB,WAAW,EAAE,KAAK;QAClB,YAAY,EAAE,aAAa;QAC3B,eAAe,EAAE,mBAAmB;QACpC,OAAO,EAAE,sDAAsD;QAC/D,OAAO,EAAE,OAAO;QAChB,UAAU,EAAE,EAAE;KACf;IACD;QACE,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,uBAAuB;QACpC,IAAI,EAAE,GAAG;QACT,QAAQ,EAAE,OAAO;QACjB,OAAO,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC;QACtC,KAAK,E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AQ;QAClB,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC;QAC5B,KAAK,EAAE;YACL;gBACE,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,sCAAsC;aACpD;YACD;gBACE,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,OAAO;gBAChB,WAAW,EAAE,kCAAkC;gBAC/C,IAAI,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC;aACzC;SACF;QACD,WAAW,EAAE,IAAI;QACjB,WAAW,EAAE,KAAK;QAClB,YAAY,EAAE,uBAAuB;QACrC,eAAe,EAAE,yBAAyB;QAC1C,OAAO,EAAE,0EAA0E;QACnF,OAAO,EAAE,OAAO;QAChB,UAAU,EAAE,EAAE;KACf;CACF,CAAA;AAED,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;AAEpE,kDAAkD;AAClD,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,OAAO,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAC9B,CAAC;AAED,yCAAyC;AACzC,MAAM,UAAU,iBAAiB;IAC/B,OAAO,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;AAC3C,CAAC;AAED,0FAA0F;AAC1F,cAAc,uBAAuB,CAAA"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * MDX Component Validation
3
+ *
4
+ * Validates MDX component usage in markdown content.
5
+ * Used by MCP save handlers and frontend editor save.
6
+ */
7
+ import type { ComponentMetadata } from '../types/index.js';
8
+ import { HAS_MDX_RE } from '../composables/useMdxParsing.js';
9
+ export { HAS_MDX_RE };
10
+ /**
11
+ * Options threading tenant custom components into validation.
12
+ */
13
+ export interface ValidateOptions {
14
+ /** Tenant custom-component metadata, keyed by name. Searched before built-ins. */
15
+ customComponents?: Map<string, ComponentMetadata>;
16
+ /**
17
+ * Whether the tenant custom-component set was successfully resolved. When `false` (e.g. the
18
+ * blog-config fetch failed), an unrecognized component is downgraded to a WARNING instead of a
19
+ * blocking error — we can't prove it is truly unknown and must not reject a legitimate save.
20
+ * Defaults to `true`.
21
+ */
22
+ customComponentsResolved?: boolean;
23
+ }
24
+ export interface ValidationResult {
25
+ valid: boolean;
26
+ errors: string[];
27
+ warnings: string[];
28
+ }
29
+ export interface ComponentValidationResult {
30
+ name: string;
31
+ line: number;
32
+ errors: string[];
33
+ warnings: string[];
34
+ }
35
+ export interface ContentValidationResult {
36
+ valid: boolean;
37
+ components: ComponentValidationResult[];
38
+ }
39
+ /**
40
+ * Validate a single component's props and children.
41
+ */
42
+ export declare function validateComponent(name: string, parsedProps: Record<string, unknown>, children?: string, options?: ValidateOptions): ValidationResult;
43
+ /**
44
+ * Validate all MDX components in markdown content.
45
+ */
46
+ export declare function validateMarkdownComponents(content: string, options?: ValidateOptions): ContentValidationResult;
@@ -0,0 +1,95 @@
1
+ /**
2
+ * MDX Component Validation
3
+ *
4
+ * Validates MDX component usage in markdown content.
5
+ * Used by MCP save handlers and frontend editor save.
6
+ */
7
+ import { extractMdxComponents, stripFrontmatter, HAS_MDX_RE } from '../composables/useMdxParsing.js';
8
+ import { getComponentMetadata, getComponentNames } from './index.js';
9
+ export { HAS_MDX_RE };
10
+ /**
11
+ * Validate a single component's props and children.
12
+ */
13
+ export function validateComponent(name, parsedProps, children, options) {
14
+ const errors = [];
15
+ const warnings = [];
16
+ const meta = options?.customComponents?.get(name) ?? getComponentMetadata(name);
17
+ if (!meta) {
18
+ const knownNames = [
19
+ ...getComponentNames(),
20
+ ...(options?.customComponents ? [...options.customComponents.keys()] : []),
21
+ ].join(', ');
22
+ // When the tenant manifest couldn't be resolved, don't block the save — the tag may be a
23
+ // legitimate custom component we simply couldn't see. Surface a warning instead.
24
+ if (options?.customComponentsResolved === false) {
25
+ warnings.push(`Component "${name}" not recognized; custom-component manifest unavailable, so it was not validated`);
26
+ return { valid: true, errors, warnings };
27
+ }
28
+ errors.push(`Unknown component "${name}". Available components: ${knownNames}`);
29
+ return { valid: false, errors, warnings };
30
+ }
31
+ // Check required props
32
+ for (const prop of meta.props) {
33
+ if (prop.required && !(prop.name in parsedProps)) {
34
+ errors.push(`Missing required prop "${prop.name}"`);
35
+ }
36
+ }
37
+ // Check prop values
38
+ const knownPropNames = new Set(meta.props.map(p => p.name));
39
+ for (const [key, value] of Object.entries(parsedProps)) {
40
+ if (!knownPropNames.has(key)) {
41
+ warnings.push(`Unknown prop "${key}"`);
42
+ continue;
43
+ }
44
+ const propMeta = meta.props.find(p => p.name === key);
45
+ // Enum validation
46
+ if (propMeta.enum && typeof value === 'string' && !propMeta.enum.includes(value)) {
47
+ errors.push(`Invalid value "${value}" for prop "${key}". Allowed: ${propMeta.enum.join(', ')}`);
48
+ }
49
+ // Numeric range validation
50
+ if (propMeta.numericRange && typeof value === 'number') {
51
+ const [min, max] = propMeta.numericRange;
52
+ if (value < min || value > max) {
53
+ errors.push(`Value ${value} for prop "${key}" is out of range [${min}, ${max}]`);
54
+ }
55
+ }
56
+ }
57
+ // Children on self-closing
58
+ if (meta.selfClosing && children && children.trim()) {
59
+ errors.push(`Component "${name}" is self-closing and cannot have children`);
60
+ }
61
+ return { valid: errors.length === 0, errors, warnings };
62
+ }
63
+ /**
64
+ * Validate all MDX components in markdown content.
65
+ */
66
+ export function validateMarkdownComponents(content, options) {
67
+ const stripped = stripFrontmatter(content);
68
+ const parsed = extractMdxComponents(stripped);
69
+ const results = [];
70
+ for (const item of parsed) {
71
+ if (item.type !== 'component')
72
+ continue;
73
+ // Find the line number of this component in the original content
74
+ const componentTag = `<${item.name}`;
75
+ const line = findLineNumber(content, componentTag);
76
+ const validation = validateComponent(item.name, item.props, item.children, options);
77
+ if (!validation.valid || validation.warnings.length > 0) {
78
+ results.push({
79
+ name: item.name,
80
+ line,
81
+ errors: validation.errors,
82
+ warnings: validation.warnings,
83
+ });
84
+ }
85
+ }
86
+ const valid = results.every(r => r.errors.length === 0);
87
+ return { valid, components: results };
88
+ }
89
+ function findLineNumber(content, search) {
90
+ const index = content.indexOf(search);
91
+ if (index === -1)
92
+ return 0;
93
+ return content.substring(0, index).split('\n').length;
94
+ }
95
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/metadata/validate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AACpG,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEpE,OAAO,EAAE,UAAU,EAAE,CAAA;AAmCrB;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,IAAY,EACZ,WAAoC,EACpC,QAAiB,EACjB,OAAyB;IAEzB,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,MAAM,QAAQ,GAAa,EAAE,CAAA;IAE7B,MAAM,IAAI,GAAG,OAAO,EAAE,gBAAgB,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAA;IAC/E,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,UAAU,GAAG;YACjB,GAAG,iBAAiB,EAAE;YACtB,GAAG,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAC3E,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACZ,yFAAyF;QACzF,iFAAiF;QACjF,IAAI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GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAA;QACpC,MAAM,IAAI,GAAG,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;QAElD,MAAM,UAAU,GAAG,iBAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QACnF,IAAI,CAAC,UAAU,CAAC,KAAK,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxD,OAAO,CAAC,IAAI,CAAC;gBACX,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,IAAI;gBACJ,MAAM,EAAE,UAAU,CAAC,MAAM;gBACzB,QAAQ,EAAE,UAAU,CAAC,QAAQ;aAC9B,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAA;IACvD,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,CAAA;AACvC,CAAC;AAED,SAAS,cAAc,CAAC,OAAe,EAAE,MAAc;IACrD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IACrC,IAAI,KAAK,KAAK,CAAC,CAAC;QAAE,OAAO,CAAC,CAAA;IAC1B,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAA;AACvD,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Render-time prop normalization shim.
3
+ *
4
+ * Centralized for ALL renderers (Vue, React, and the Headless SDK) — see
5
+ * the `prepareNotCalled` CI rule. Walks `metadata.deprecated[]` and
6
+ * applies each entry to a shallow-cloned copy of `rawProps`. Returns the
7
+ * normalized object; the input is never mutated.
8
+ *
9
+ * Per-kind behaviour:
10
+ * - propRename: if `rawProps[entry.prop]` is set AND
11
+ * `rawProps[entry.aliasFor]` is NOT set, copy the value across.
12
+ * When BOTH are present the new name wins (latest schema beats stored
13
+ * legacy). Old name is then dropped from the returned object so the
14
+ * downstream component never sees it.
15
+ * - enumValueRename: if `rawProps[entry.prop]` is a string AND is a key
16
+ * of `entry.valueAliases`, replace it with the mapped value.
17
+ * - propRemoved: KEEPS the prop in the returned object (review finding —
18
+ * deleting silently strips data that custom components, the headless
19
+ * SDK, or a future codemod-retry may still need). Logs once so an
20
+ * operator can investigate the tenant's `schema_version`.
21
+ * - propBecameRequired: if `rawProps[entry.prop]` is MISSING (legacy
22
+ * article authored before the prop became required, or stored
23
+ * content the backfill codemod hasn't touched), inject
24
+ * `entry.defaultValue` as the runtime fallback. Logs so an operator
25
+ * can investigate why the codemod hasn't caught up. If the prop is
26
+ * already present, no-op (the codemod did its job or the article
27
+ * was authored post-flip).
28
+ *
29
+ * Logging is process-deduped via the module-level `loggedKeys` Set
30
+ * keyed on `${componentName}.${kind}.${prop}` so each soft-break warns
31
+ * exactly once per process lifetime. Production silence is guaranteed
32
+ * by the `process.env.NODE_ENV === 'production'` short-circuit.
33
+ */
34
+ import type { ComponentMetadata } from './types/index.js';
35
+ /**
36
+ * Process-lifetime dedupe set. Keys: `${componentName}.${kind}.${prop}`.
37
+ * Exported only for tests (so they can clear between specs).
38
+ */
39
+ export declare const loggedKeys: Set<string>;
40
+ /** Test-only — never call from production code. */
41
+ export declare function _resetPrepareDedupeForTests(): void;
42
+ export declare function prepareProps(rawProps: Record<string, unknown>, metadata: ComponentMetadata): Record<string, unknown>;