/ src / constants.ts
constants.ts
 1  /**
 2   * Shared constants used across explore, synthesize, and pipeline modules.
 3   */
 4  
 5  /** Default daemon port for HTTP/WebSocket communication with browser extension */
 6  export const DEFAULT_DAEMON_PORT = 19825;
 7  
 8  
 9  /** URL query params that are volatile/ephemeral and should be stripped from patterns */
10  export const VOLATILE_PARAMS = new Set([
11    'w_rid', 'wts', '_', 'callback', 'timestamp', 't', 'nonce', 'sign',
12  ]);
13  
14  /** Search-related query parameter names */
15  export const SEARCH_PARAMS = new Set([
16    'q', 'query', 'keyword', 'search', 'wd', 'kw', 'search_query', 'w',
17  ]);
18  
19  /** Pagination-related query parameter names */
20  export const PAGINATION_PARAMS = new Set([
21    'page', 'pn', 'offset', 'cursor', 'next', 'page_num',
22  ]);
23  
24  /** Limit/page-size query parameter names */
25  export const LIMIT_PARAMS = new Set([
26    'limit', 'count', 'size', 'per_page', 'page_size', 'ps', 'num',
27  ]);
28  
29  /** Field role → common API field names mapping */
30  export const FIELD_ROLES: Record<string, string[]> = {
31    title:    ['title', 'name', 'text', 'content', 'desc', 'description', 'headline', 'subject'],
32    url:      ['url', 'uri', 'link', 'href', 'permalink', 'jump_url', 'web_url', 'share_url'],
33    author:   ['author', 'username', 'user_name', 'nickname', 'nick', 'owner', 'creator', 'up_name', 'uname'],
34    score:    ['score', 'hot', 'heat', 'likes', 'like_count', 'view_count', 'views', 'play', 'favorite_count', 'reply_count'],
35    time:     ['time', 'created_at', 'publish_time', 'pub_time', 'date', 'ctime', 'mtime', 'pubdate', 'created'],
36    id:       ['id', 'aid', 'bvid', 'mid', 'uid', 'oid', 'note_id', 'item_id'],
37    cover:    ['cover', 'pic', 'image', 'thumbnail', 'poster', 'avatar'],
38    category: ['category', 'tag', 'type', 'tname', 'channel', 'section'],
39  };