@rankcli/agent-runtime 0.0.8 → 0.0.11

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 (49) hide show
  1. package/README.md +90 -196
  2. package/dist/analyzer-GMURJADU.mjs +7 -0
  3. package/dist/chunk-2JADKV3Z.mjs +244 -0
  4. package/dist/chunk-3ZSCLNTW.mjs +557 -0
  5. package/dist/chunk-4E4MQOSP.mjs +374 -0
  6. package/dist/chunk-6BWS3CLP.mjs +16 -0
  7. package/dist/chunk-AK2IC22C.mjs +206 -0
  8. package/dist/chunk-K6VSXDD6.mjs +293 -0
  9. package/dist/chunk-M27NQCWW.mjs +303 -0
  10. package/dist/{chunk-YNZYHEYM.mjs → chunk-PJLNXOLN.mjs} +0 -14
  11. package/dist/chunk-VSQD74I7.mjs +474 -0
  12. package/dist/core-web-vitals-analyzer-TE6LQJMS.mjs +7 -0
  13. package/dist/geo-analyzer-D47LTMMA.mjs +25 -0
  14. package/dist/image-optimization-analyzer-XP4OQGRP.mjs +9 -0
  15. package/dist/index.d.mts +1523 -17
  16. package/dist/index.d.ts +1523 -17
  17. package/dist/index.js +9582 -2664
  18. package/dist/index.mjs +4812 -380
  19. package/dist/internal-linking-analyzer-MRMBV7NM.mjs +9 -0
  20. package/dist/mobile-seo-analyzer-67HNQ7IO.mjs +7 -0
  21. package/dist/security-headers-analyzer-3ZUQARS5.mjs +9 -0
  22. package/dist/structured-data-analyzer-2I4NQAUP.mjs +9 -0
  23. package/package.json +2 -2
  24. package/src/analyzers/core-web-vitals-analyzer.test.ts +236 -0
  25. package/src/analyzers/core-web-vitals-analyzer.ts +557 -0
  26. package/src/analyzers/geo-analyzer.test.ts +310 -0
  27. package/src/analyzers/geo-analyzer.ts +814 -0
  28. package/src/analyzers/image-optimization-analyzer.test.ts +145 -0
  29. package/src/analyzers/image-optimization-analyzer.ts +348 -0
  30. package/src/analyzers/index.ts +233 -0
  31. package/src/analyzers/internal-linking-analyzer.test.ts +141 -0
  32. package/src/analyzers/internal-linking-analyzer.ts +419 -0
  33. package/src/analyzers/mobile-seo-analyzer.test.ts +140 -0
  34. package/src/analyzers/mobile-seo-analyzer.ts +455 -0
  35. package/src/analyzers/security-headers-analyzer.test.ts +115 -0
  36. package/src/analyzers/security-headers-analyzer.ts +318 -0
  37. package/src/analyzers/structured-data-analyzer.test.ts +210 -0
  38. package/src/analyzers/structured-data-analyzer.ts +590 -0
  39. package/src/audit/engine.ts +3 -3
  40. package/src/audit/types.ts +3 -2
  41. package/src/fixer/framework-fixes.test.ts +489 -0
  42. package/src/fixer/framework-fixes.ts +3418 -0
  43. package/src/fixer/index.ts +1 -0
  44. package/src/fixer/schemas.ts +971 -0
  45. package/src/frameworks/detector.ts +642 -114
  46. package/src/frameworks/suggestion-engine.ts +38 -1
  47. package/src/index.ts +6 -0
  48. package/src/types.ts +15 -1
  49. package/dist/analyzer-2CSWIQGD.mjs +0 -6
@@ -0,0 +1,590 @@
1
+ /**
2
+ * Structured Data / Schema.org Analyzer
3
+ *
4
+ * Validates JSON-LD structured data for SEO and AI search optimization.
5
+ * Checks for common schema types, required properties, and best practices.
6
+ */
7
+
8
+ import * as cheerio from 'cheerio';
9
+ import type { AuditIssue } from '../audit/types.js';
10
+
11
+ export interface StructuredDataResult {
12
+ score: number;
13
+ schemas: SchemaItem[];
14
+ hasOrganization: boolean;
15
+ hasWebSite: boolean;
16
+ hasWebPage: boolean;
17
+ hasBreadcrumb: boolean;
18
+ hasArticle: boolean;
19
+ hasProduct: boolean;
20
+ hasFAQ: boolean;
21
+ hasHowTo: boolean;
22
+ hasLocalBusiness: boolean;
23
+ hasEvent: boolean;
24
+ hasReview: boolean;
25
+ issues: AuditIssue[];
26
+ recommendations: string[];
27
+ }
28
+
29
+ export interface SchemaItem {
30
+ type: string;
31
+ isValid: boolean;
32
+ errors: string[];
33
+ warnings: string[];
34
+ properties: string[];
35
+ }
36
+
37
+ // Required and recommended properties for common schema types
38
+ const SCHEMA_REQUIREMENTS: Record<string, { required: string[]; recommended: string[] }> = {
39
+ 'Organization': {
40
+ required: ['name', 'url'],
41
+ recommended: ['logo', 'sameAs', 'contactPoint', 'address'],
42
+ },
43
+ 'WebSite': {
44
+ required: ['name', 'url'],
45
+ recommended: ['potentialAction', 'publisher'],
46
+ },
47
+ 'WebPage': {
48
+ required: ['name'],
49
+ recommended: ['description', 'url', 'breadcrumb', 'mainEntity'],
50
+ },
51
+ 'Article': {
52
+ required: ['headline', 'author', 'datePublished'],
53
+ recommended: ['image', 'dateModified', 'publisher', 'description', 'mainEntityOfPage'],
54
+ },
55
+ 'BlogPosting': {
56
+ required: ['headline', 'author', 'datePublished'],
57
+ recommended: ['image', 'dateModified', 'publisher', 'description'],
58
+ },
59
+ 'NewsArticle': {
60
+ required: ['headline', 'author', 'datePublished', 'image'],
61
+ recommended: ['dateModified', 'publisher', 'description'],
62
+ },
63
+ 'Product': {
64
+ required: ['name'],
65
+ recommended: ['image', 'description', 'offers', 'brand', 'sku', 'aggregateRating', 'review'],
66
+ },
67
+ 'Offer': {
68
+ required: ['price', 'priceCurrency'],
69
+ recommended: ['availability', 'url', 'priceValidUntil'],
70
+ },
71
+ 'FAQPage': {
72
+ required: ['mainEntity'],
73
+ recommended: [],
74
+ },
75
+ 'Question': {
76
+ required: ['name', 'acceptedAnswer'],
77
+ recommended: [],
78
+ },
79
+ 'HowTo': {
80
+ required: ['name', 'step'],
81
+ recommended: ['image', 'totalTime', 'estimatedCost', 'supply', 'tool'],
82
+ },
83
+ 'BreadcrumbList': {
84
+ required: ['itemListElement'],
85
+ recommended: [],
86
+ },
87
+ 'LocalBusiness': {
88
+ required: ['name', 'address'],
89
+ recommended: ['telephone', 'openingHours', 'geo', 'image', 'priceRange'],
90
+ },
91
+ 'Event': {
92
+ required: ['name', 'startDate', 'location'],
93
+ recommended: ['endDate', 'description', 'image', 'offers', 'performer', 'organizer'],
94
+ },
95
+ 'Review': {
96
+ required: ['itemReviewed', 'reviewRating', 'author'],
97
+ recommended: ['reviewBody', 'datePublished'],
98
+ },
99
+ 'AggregateRating': {
100
+ required: ['ratingValue', 'reviewCount'],
101
+ recommended: ['bestRating', 'worstRating'],
102
+ },
103
+ 'Person': {
104
+ required: ['name'],
105
+ recommended: ['url', 'image', 'jobTitle', 'sameAs'],
106
+ },
107
+ 'VideoObject': {
108
+ required: ['name', 'thumbnailUrl', 'uploadDate'],
109
+ recommended: ['description', 'contentUrl', 'duration', 'embedUrl'],
110
+ },
111
+ 'ImageObject': {
112
+ required: ['contentUrl'],
113
+ recommended: ['caption', 'creditText', 'creator'],
114
+ },
115
+ 'SoftwareApplication': {
116
+ required: ['name'],
117
+ recommended: ['operatingSystem', 'applicationCategory', 'offers', 'aggregateRating'],
118
+ },
119
+ 'Recipe': {
120
+ required: ['name', 'recipeIngredient', 'recipeInstructions'],
121
+ recommended: ['image', 'author', 'prepTime', 'cookTime', 'totalTime', 'nutrition'],
122
+ },
123
+ 'Course': {
124
+ required: ['name', 'provider'],
125
+ recommended: ['description', 'offers'],
126
+ },
127
+ };
128
+
129
+ /**
130
+ * Parse and validate JSON-LD structured data
131
+ */
132
+ function parseJsonLd(script: string): { data: any; error?: string } {
133
+ try {
134
+ const data = JSON.parse(script);
135
+ return { data };
136
+ } catch (e) {
137
+ return { data: null, error: `Invalid JSON: ${(e as Error).message}` };
138
+ }
139
+ }
140
+
141
+ /**
142
+ * Get all types from a schema object (handles @graph and nested types)
143
+ */
144
+ function extractTypes(data: any): string[] {
145
+ const types: string[] = [];
146
+
147
+ if (!data) return types;
148
+
149
+ if (Array.isArray(data)) {
150
+ for (const item of data) {
151
+ types.push(...extractTypes(item));
152
+ }
153
+ } else if (typeof data === 'object') {
154
+ if (data['@type']) {
155
+ const schemaType = Array.isArray(data['@type']) ? data['@type'] : [data['@type']];
156
+ types.push(...schemaType);
157
+ }
158
+ if (data['@graph']) {
159
+ types.push(...extractTypes(data['@graph']));
160
+ }
161
+ }
162
+
163
+ return types;
164
+ }
165
+
166
+ /**
167
+ * Validate a schema object against requirements
168
+ */
169
+ function validateSchema(data: any, type: string): SchemaItem {
170
+ const errors: string[] = [];
171
+ const warnings: string[] = [];
172
+ const properties: string[] = [];
173
+
174
+ if (!data || typeof data !== 'object') {
175
+ return { type, isValid: false, errors: ['Invalid schema object'], warnings, properties };
176
+ }
177
+
178
+ // Extract properties
179
+ for (const key of Object.keys(data)) {
180
+ if (!key.startsWith('@')) {
181
+ properties.push(key);
182
+ }
183
+ }
184
+
185
+ // Check requirements
186
+ const requirements = SCHEMA_REQUIREMENTS[type];
187
+ if (requirements) {
188
+ // Check required properties
189
+ for (const prop of requirements.required) {
190
+ if (!data[prop]) {
191
+ errors.push(`Missing required property: ${prop}`);
192
+ }
193
+ }
194
+
195
+ // Check recommended properties
196
+ for (const prop of requirements.recommended) {
197
+ if (!data[prop]) {
198
+ warnings.push(`Missing recommended property: ${prop}`);
199
+ }
200
+ }
201
+ }
202
+
203
+ // Type-specific validations
204
+ if (type === 'Article' || type === 'BlogPosting' || type === 'NewsArticle') {
205
+ // Check for proper author format
206
+ if (data.author && typeof data.author === 'string') {
207
+ warnings.push('author should be a Person or Organization object, not a string');
208
+ }
209
+ // Check for proper publisher format
210
+ if (data.publisher && typeof data.publisher === 'string') {
211
+ warnings.push('publisher should be an Organization object, not a string');
212
+ }
213
+ // Check date format
214
+ if (data.datePublished && !/^\d{4}-\d{2}-\d{2}/.test(data.datePublished)) {
215
+ warnings.push('datePublished should be in ISO 8601 format (YYYY-MM-DD)');
216
+ }
217
+ }
218
+
219
+ if (type === 'Product') {
220
+ // Check for offers
221
+ if (!data.offers) {
222
+ warnings.push('Product without offers/price - may not show rich results');
223
+ }
224
+ }
225
+
226
+ if (type === 'FAQPage') {
227
+ // Check for valid Q&A structure
228
+ if (data.mainEntity) {
229
+ const questions = Array.isArray(data.mainEntity) ? data.mainEntity : [data.mainEntity];
230
+ for (let i = 0; i < questions.length; i++) {
231
+ const q = questions[i];
232
+ if (!q.name && !q['@type']?.includes('Question')) {
233
+ errors.push(`FAQ item ${i + 1} is not a valid Question`);
234
+ }
235
+ if (!q.acceptedAnswer) {
236
+ errors.push(`FAQ item ${i + 1} missing acceptedAnswer`);
237
+ }
238
+ }
239
+ }
240
+ }
241
+
242
+ if (type === 'BreadcrumbList') {
243
+ // Check for proper item list
244
+ if (data.itemListElement) {
245
+ const items = Array.isArray(data.itemListElement) ? data.itemListElement : [data.itemListElement];
246
+ items.forEach((item: Record<string, unknown>, i: number) => {
247
+ if (!item.position) {
248
+ errors.push(`Breadcrumb item ${i + 1} missing position`);
249
+ }
250
+ if (!item.name && !(item.item as Record<string, unknown>)?.name) {
251
+ errors.push(`Breadcrumb item ${i + 1} missing name`);
252
+ }
253
+ });
254
+ }
255
+ }
256
+
257
+ if (type === 'LocalBusiness') {
258
+ // Check for geo coordinates
259
+ if (data.geo) {
260
+ if (!data.geo.latitude || !data.geo.longitude) {
261
+ warnings.push('geo should include latitude and longitude');
262
+ }
263
+ }
264
+ // Check opening hours format
265
+ if (data.openingHours && typeof data.openingHours === 'string') {
266
+ warnings.push('openingHours should be an array of OpeningHoursSpecification objects for rich results');
267
+ }
268
+ }
269
+
270
+ return {
271
+ type,
272
+ isValid: errors.length === 0,
273
+ errors,
274
+ warnings,
275
+ properties,
276
+ };
277
+ }
278
+
279
+ /**
280
+ * Analyze all structured data on a page
281
+ */
282
+ export function analyzeStructuredData(html: string, url: string): StructuredDataResult {
283
+ const $ = cheerio.load(html);
284
+ const schemas: SchemaItem[] = [];
285
+ const issues: AuditIssue[] = [];
286
+ const recommendations: string[] = [];
287
+ let score = 100;
288
+
289
+ // Track schema types
290
+ const foundTypes = new Set<string>();
291
+
292
+ // Parse all JSON-LD scripts
293
+ $('script[type="application/ld+json"]').each((_, el) => {
294
+ const content = $(el).html();
295
+ if (!content) return;
296
+
297
+ const { data, error } = parseJsonLd(content);
298
+
299
+ if (error) {
300
+ issues.push({
301
+ code: 'SCHEMA_INVALID_JSON',
302
+ severity: 'critical',
303
+ category: 'technical',
304
+ title: 'Invalid JSON-LD syntax',
305
+ description: error,
306
+ impact: 'Schema will not be parsed by search engines',
307
+ howToFix: 'Fix JSON syntax errors. Use a JSON validator.',
308
+ affectedUrls: [url],
309
+ });
310
+ score -= 20;
311
+ return;
312
+ }
313
+
314
+ // Extract and validate all types
315
+ const types = extractTypes(data);
316
+
317
+ // Process each schema item
318
+ const processItem = (item: any) => {
319
+ if (!item || typeof item !== 'object') return;
320
+
321
+ let itemType = item['@type'];
322
+ if (Array.isArray(itemType)) itemType = itemType[0];
323
+
324
+ if (itemType) {
325
+ foundTypes.add(itemType);
326
+ const validation = validateSchema(item, itemType);
327
+ schemas.push(validation);
328
+
329
+ if (!validation.isValid) {
330
+ for (const err of validation.errors) {
331
+ issues.push({
332
+ code: 'SCHEMA_VALIDATION_ERROR',
333
+ severity: 'warning',
334
+ category: 'technical',
335
+ title: `${itemType} schema error: ${err}`,
336
+ description: `The ${itemType} schema is missing required properties or has invalid data.`,
337
+ impact: 'May not qualify for rich results',
338
+ howToFix: `Add the missing property: ${err.replace('Missing required property: ', '')}`,
339
+ affectedUrls: [url],
340
+ });
341
+ score -= 5;
342
+ }
343
+ }
344
+ }
345
+
346
+ // Process @graph
347
+ if (item['@graph'] && Array.isArray(item['@graph'])) {
348
+ item['@graph'].forEach(processItem);
349
+ }
350
+ };
351
+
352
+ if (Array.isArray(data)) {
353
+ data.forEach(processItem);
354
+ } else {
355
+ processItem(data);
356
+ }
357
+ });
358
+
359
+ // Check for essential schemas
360
+ const hasOrganization = foundTypes.has('Organization');
361
+ const hasWebSite = foundTypes.has('WebSite');
362
+ const hasWebPage = foundTypes.has('WebPage');
363
+ const hasBreadcrumb = foundTypes.has('BreadcrumbList');
364
+ const hasArticle = foundTypes.has('Article') || foundTypes.has('BlogPosting') || foundTypes.has('NewsArticle');
365
+ const hasProduct = foundTypes.has('Product');
366
+ const hasFAQ = foundTypes.has('FAQPage');
367
+ const hasHowTo = foundTypes.has('HowTo');
368
+ const hasLocalBusiness = foundTypes.has('LocalBusiness');
369
+ const hasEvent = foundTypes.has('Event');
370
+ const hasReview = foundTypes.has('Review') || foundTypes.has('AggregateRating');
371
+
372
+ // Generate recommendations
373
+ if (!hasOrganization) {
374
+ recommendations.push('Add Organization schema for brand knowledge panel');
375
+ score -= 5;
376
+ }
377
+
378
+ if (!hasWebSite) {
379
+ recommendations.push('Add WebSite schema with SearchAction for sitelinks search box');
380
+ score -= 3;
381
+ }
382
+
383
+ if (!hasBreadcrumb) {
384
+ recommendations.push('Add BreadcrumbList schema for breadcrumb rich results');
385
+ score -= 3;
386
+ }
387
+
388
+ // Check for page-type specific schemas
389
+ if (!hasArticle && !hasProduct && !hasFAQ && !hasHowTo && !hasLocalBusiness && !hasEvent) {
390
+ recommendations.push('Add page-specific schema (Article, Product, FAQ, HowTo, etc.)');
391
+ score -= 10;
392
+
393
+ issues.push({
394
+ code: 'SCHEMA_NO_RICH_RESULT_TYPE',
395
+ severity: 'warning',
396
+ category: 'technical',
397
+ title: 'No rich result schema found',
398
+ description: 'Page lacks schema types that enable rich results (Article, Product, FAQ, etc.)',
399
+ impact: 'Missing opportunity for enhanced search results',
400
+ howToFix: 'Add appropriate schema type for your content (e.g., Article for blog posts, Product for products, FAQ for Q&A)',
401
+ affectedUrls: [url],
402
+ });
403
+ }
404
+
405
+ // Check for no schema at all
406
+ if (schemas.length === 0) {
407
+ score -= 20;
408
+ issues.push({
409
+ code: 'SCHEMA_NONE_FOUND',
410
+ severity: 'warning',
411
+ category: 'technical',
412
+ title: 'No structured data found',
413
+ description: 'No JSON-LD structured data detected on the page.',
414
+ impact: 'Missing rich results, reduced AI understanding, lower search visibility',
415
+ howToFix: 'Add JSON-LD structured data. At minimum, include Organization and WebPage schemas.',
416
+ affectedUrls: [url],
417
+ });
418
+ }
419
+
420
+ // AI-specific recommendations
421
+ if (schemas.length > 0 && !hasFAQ) {
422
+ recommendations.push('Consider adding FAQPage schema - excellent for AI search citations');
423
+ }
424
+
425
+ if (!foundTypes.has('Person') && hasArticle) {
426
+ recommendations.push('Use Person schema for authors to improve E-E-A-T signals');
427
+ }
428
+
429
+ return {
430
+ score: Math.max(0, Math.min(100, score)),
431
+ schemas,
432
+ hasOrganization,
433
+ hasWebSite,
434
+ hasWebPage,
435
+ hasBreadcrumb,
436
+ hasArticle,
437
+ hasProduct,
438
+ hasFAQ,
439
+ hasHowTo,
440
+ hasLocalBusiness,
441
+ hasEvent,
442
+ hasReview,
443
+ issues,
444
+ recommendations,
445
+ };
446
+ }
447
+
448
+ /**
449
+ * Generate recommended schema for a page type
450
+ */
451
+ export function generateSchemaTemplate(pageType: 'article' | 'product' | 'faq' | 'local-business' | 'website', options: {
452
+ siteName: string;
453
+ siteUrl: string;
454
+ authorName?: string;
455
+ organizationName?: string;
456
+ }): string {
457
+ const { siteName, siteUrl, authorName, organizationName } = options;
458
+
459
+ const baseSchemas = [
460
+ {
461
+ '@context': 'https://schema.org',
462
+ '@type': 'Organization',
463
+ name: organizationName || siteName,
464
+ url: siteUrl,
465
+ logo: `${siteUrl}/logo.png`,
466
+ },
467
+ {
468
+ '@context': 'https://schema.org',
469
+ '@type': 'WebSite',
470
+ name: siteName,
471
+ url: siteUrl,
472
+ potentialAction: {
473
+ '@type': 'SearchAction',
474
+ target: {
475
+ '@type': 'EntryPoint',
476
+ urlTemplate: `${siteUrl}/search?q={search_term_string}`,
477
+ },
478
+ 'query-input': 'required name=search_term_string',
479
+ },
480
+ },
481
+ ];
482
+
483
+ const pageSchemas: Record<string, object> = {
484
+ article: {
485
+ '@context': 'https://schema.org',
486
+ '@type': 'Article',
487
+ headline: '{{title}}',
488
+ description: '{{description}}',
489
+ image: '{{image_url}}',
490
+ datePublished: '{{date_published}}',
491
+ dateModified: '{{date_modified}}',
492
+ author: {
493
+ '@type': 'Person',
494
+ name: authorName || '{{author_name}}',
495
+ url: '{{author_url}}',
496
+ },
497
+ publisher: {
498
+ '@type': 'Organization',
499
+ name: organizationName || siteName,
500
+ logo: {
501
+ '@type': 'ImageObject',
502
+ url: `${siteUrl}/logo.png`,
503
+ },
504
+ },
505
+ },
506
+ product: {
507
+ '@context': 'https://schema.org',
508
+ '@type': 'Product',
509
+ name: '{{product_name}}',
510
+ description: '{{product_description}}',
511
+ image: '{{product_image}}',
512
+ brand: {
513
+ '@type': 'Brand',
514
+ name: '{{brand_name}}',
515
+ },
516
+ sku: '{{sku}}',
517
+ offers: {
518
+ '@type': 'Offer',
519
+ price: '{{price}}',
520
+ priceCurrency: 'USD',
521
+ availability: 'https://schema.org/InStock',
522
+ url: '{{product_url}}',
523
+ },
524
+ aggregateRating: {
525
+ '@type': 'AggregateRating',
526
+ ratingValue: '{{rating}}',
527
+ reviewCount: '{{review_count}}',
528
+ },
529
+ },
530
+ faq: {
531
+ '@context': 'https://schema.org',
532
+ '@type': 'FAQPage',
533
+ mainEntity: [
534
+ {
535
+ '@type': 'Question',
536
+ name: '{{question_1}}',
537
+ acceptedAnswer: {
538
+ '@type': 'Answer',
539
+ text: '{{answer_1}}',
540
+ },
541
+ },
542
+ {
543
+ '@type': 'Question',
544
+ name: '{{question_2}}',
545
+ acceptedAnswer: {
546
+ '@type': 'Answer',
547
+ text: '{{answer_2}}',
548
+ },
549
+ },
550
+ ],
551
+ },
552
+ 'local-business': {
553
+ '@context': 'https://schema.org',
554
+ '@type': 'LocalBusiness',
555
+ name: '{{business_name}}',
556
+ description: '{{description}}',
557
+ url: siteUrl,
558
+ telephone: '{{phone}}',
559
+ address: {
560
+ '@type': 'PostalAddress',
561
+ streetAddress: '{{street}}',
562
+ addressLocality: '{{city}}',
563
+ addressRegion: '{{state}}',
564
+ postalCode: '{{zip}}',
565
+ addressCountry: '{{country}}',
566
+ },
567
+ geo: {
568
+ '@type': 'GeoCoordinates',
569
+ latitude: '{{latitude}}',
570
+ longitude: '{{longitude}}',
571
+ },
572
+ openingHoursSpecification: [
573
+ {
574
+ '@type': 'OpeningHoursSpecification',
575
+ dayOfWeek: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
576
+ opens: '09:00',
577
+ closes: '17:00',
578
+ },
579
+ ],
580
+ },
581
+ website: baseSchemas[1],
582
+ };
583
+
584
+ const result: object[] = [...baseSchemas];
585
+ if (pageType !== 'website' && pageSchemas[pageType]) {
586
+ result.push(pageSchemas[pageType]);
587
+ }
588
+
589
+ return JSON.stringify(result, null, 2);
590
+ }
@@ -454,7 +454,7 @@ function createReport(url: string, domain: string, issues: AuditIssue[], pages:
454
454
 
455
455
  function calculateHealthScore(issues: AuditIssue[]): HealthScore {
456
456
  // Weight issues by severity
457
- const weights = { error: 10, warning: 3, notice: 1 };
457
+ const weights: Record<string, number> = { critical: 15, error: 10, warning: 3, info: 1, notice: 1 };
458
458
 
459
459
  // Calculate deductions per category
460
460
  const categoryDeductions: Record<string, number> = {
@@ -611,8 +611,8 @@ function groupIssuesByCategory(issues: AuditIssue[]): Record<string, AuditIssue[
611
611
  // Sort by severity within each category
612
612
  for (const category of Object.keys(grouped)) {
613
613
  grouped[category].sort((a, b) => {
614
- const order = { error: 0, warning: 1, notice: 2 };
615
- return order[a.severity] - order[b.severity];
614
+ const order: Record<string, number> = { critical: 0, error: 1, warning: 2, info: 3, notice: 4 };
615
+ return (order[a.severity] ?? 5) - (order[b.severity] ?? 5);
616
616
  });
617
617
  }
618
618
 
@@ -1,6 +1,6 @@
1
1
  // Comprehensive SEO Audit Types - Matching Ahrefs 170+ checks
2
2
 
3
- export type IssueSeverity = 'error' | 'warning' | 'notice';
3
+ export type IssueSeverity = 'critical' | 'error' | 'warning' | 'info' | 'notice';
4
4
 
5
5
  export type IssueCategory =
6
6
  | 'crawlability'
@@ -18,7 +18,8 @@ export type IssueCategory =
18
18
  | 'social'
19
19
  | 'local-seo'
20
20
  | 'accessibility'
21
- | 'framework';
21
+ | 'framework'
22
+ | 'technical';
22
23
 
23
24
  export interface AuditIssue {
24
25
  code: string;