All files / src/help topics.ts

100% Statements 138/138
100% Branches 5/5
100% Functions 3/3
100% Lines 138/138

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 1391x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 4x 4x 1x 1x 1x 1x 1x 1x 1x 5x 5x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
/**
 * @file topics.ts
 * @description
 * Central registry of all help topics with metadata.
 * Each topic maps to i18n keys for title and body content.
 *
 * @enterprise
 * - Single source of truth for topic definitions
 * - Type-safe topic IDs
 * - Easy to add/remove topics
 * - Categories for future organization
 */
 
/**
 * Help topic metadata
 */
export interface HelpTopic {
  /** Unique topic identifier */
  id: string;
  /** i18n key for topic title (e.g., "help:app.main.title") */
  titleKey: string;
  /** i18n key for topic body text (e.g., "help:app.main.body") */
  bodyKey: string;
  /** Optional i18n key for documentation link label */
  linkKey?: string;
  /** Topic category for organization */
  category: 'general' | 'inventory' | 'suppliers' | 'analytics' | 'settings';
}
 
/**
 * Registry of all help topics
 * Add new topics here and they'll automatically be available system-wide
 * @example
 * ```typescript
 * const topic = HELP_TOPICS['app.main'];
 * console.log(topic.titleKey); // "help:app.main.title"
 * 
 * ```
 */
export const HELP_TOPICS: Record<string, HelpTopic> = {
  'app.main': {
    id: 'app.main',
    titleKey: 'help:app.main.title',
    bodyKey: 'help:app.main.body',
    linkKey: 'help:app.main.link',
    category: 'general',
  },
  'inventory.overview': {
    id: 'inventory.overview',
    titleKey: 'help:inventory.overview.title',
    bodyKey: 'help:inventory.overview.body',
    category: 'inventory',
  },
  // Alias to keep older references working
  'inventory.manage': {
    id: 'inventory.manage',
    titleKey: 'help:inventory.overview.title',
    bodyKey: 'help:inventory.overview.body',
    category: 'inventory',
  },
  'inventory.editItem': {
    id: 'inventory.editItem',
    titleKey: 'help:inventory.editItem.title',
    bodyKey: 'help:inventory.editItem.body',
    category: 'inventory',
  },
  'inventory.deleteItem': {
    id: 'inventory.deleteItem',
    titleKey: 'help:inventory.deleteItem.title',
    bodyKey: 'help:inventory.deleteItem.body',
    category: 'inventory',
  },
  'inventory.adjustQuantity': {
    id: 'inventory.adjustQuantity',
    titleKey: 'help:inventory.adjustQuantity.title',
    bodyKey: 'help:inventory.adjustQuantity.body',
    category: 'inventory',
  },
  'inventory.changePrice': {
    id: 'inventory.changePrice',
    titleKey: 'help:inventory.changePrice.title',
    bodyKey: 'help:inventory.changePrice.body',
    category: 'inventory',
  },
  'suppliers.manage': {
    id: 'suppliers.manage',
    titleKey: 'help:suppliers.manage.title',
    bodyKey: 'help:suppliers.manage.body',
    category: 'suppliers',
  },
  'suppliers.delete': {
    id: 'suppliers.delete',
    titleKey: 'help:suppliers.delete.title',
    bodyKey: 'help:suppliers.delete.body',
    category: 'suppliers',
  },
  'analytics.overview': {
    id: 'analytics.overview',
    titleKey: 'help:analytics.overview.title',
    bodyKey: 'help:analytics.overview.body',
    category: 'analytics',
  },
  'settings.preferences': {
    id: 'settings.preferences',
    titleKey: 'help:settings.preferences.title',
    bodyKey: 'help:settings.preferences.body',
    category: 'settings',
  },
};
 
/**
 * Get a help topic by ID
 * @param id - Topic ID
 * @returns Help topic or undefined if not found
 * @example
 * const topic = getHelpTopic('app.main')
 */
export function getHelpTopic(id: string): HelpTopic | undefined {
  return HELP_TOPICS[id];
}
 
/**
 * Get all help topics by category
 * @param category - Category to filter by
 * @returns Array of topics in that category
 */
export function getTopicsByCategory(category: HelpTopic['category']): HelpTopic[] {
  return Object.values(HELP_TOPICS).filter((topic) => topic.category === category);
}
 
/**
 * Get all unique categories
 * @returns Array of category names
 */
export function getAllCategories(): HelpTopic['category'][] {
  const categories = new Set(Object.values(HELP_TOPICS).map((topic) => topic.category));
  return Array.from(categories).sort();
}