All files / src/platform/cache cache-namespace.registry.ts

0% Statements 0/2
100% Branches 0/0
100% Functions 0/0
0% Lines 0/2

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                                                                                                                                           
export type CacheNamespace =
  | 'permissions'
  | 'module-licenses'
  | 'feature-flags'
  | 'settings'
  | 'user-sessions'
  | 'dashboards'
  | 'widgets'
  | 'reports'
  | 'search-suggestions'
  | 'reference-data'
  | 'organization-tree'
  | 'employee-directory'
  | 'attendance-summary'
  | 'leave-balances'
  | 'payroll-summary'
  | 'project-summary'
  | 'integration-health'
  | 'ai-usage'
  | 'general';
 
export interface NamespacePolicy {
  namespace: CacheNamespace;
  ttlSeconds: number;
  maxValueSizeBytes?: number;
  allowSensitive?: boolean;
}
 
/**
 * Default TTL and policies for each registered cache namespace.
 */
export const NAMESPACE_POLICIES: Record<CacheNamespace, NamespacePolicy> = {
  permissions: { namespace: 'permissions', ttlSeconds: 300 },
  'module-licenses': { namespace: 'module-licenses', ttlSeconds: 600 },
  'feature-flags': { namespace: 'feature-flags', ttlSeconds: 120 },
  settings: { namespace: 'settings', ttlSeconds: 300 },
  'user-sessions': { namespace: 'user-sessions', ttlSeconds: 3600 },
  dashboards: { namespace: 'dashboards', ttlSeconds: 60 },
  widgets: { namespace: 'widgets', ttlSeconds: 60 },
  reports: { namespace: 'reports', ttlSeconds: 120 },
  'search-suggestions': { namespace: 'search-suggestions', ttlSeconds: 300 },
  'reference-data': { namespace: 'reference-data', ttlSeconds: 3600 },
  'organization-tree': { namespace: 'organization-tree', ttlSeconds: 600 },
  'employee-directory': { namespace: 'employee-directory', ttlSeconds: 300 },
  'attendance-summary': { namespace: 'attendance-summary', ttlSeconds: 60 },
  'leave-balances': { namespace: 'leave-balances', ttlSeconds: 120 },
  'payroll-summary': { namespace: 'payroll-summary', ttlSeconds: 180 },
  'project-summary': { namespace: 'project-summary', ttlSeconds: 120 },
  'integration-health': { namespace: 'integration-health', ttlSeconds: 30 },
  'ai-usage': { namespace: 'ai-usage', ttlSeconds: 60 },
  general: { namespace: 'general', ttlSeconds: 60 },
};
 
/**
 * Fields that must NEVER be cached.
 */
export const SENSITIVE_CACHE_EXCLUSIONS = [
  'bankAccountNumber',
  'ifscCode',
  'passwordHash',
  'refreshToken',
  'otp',
  'taxIdentifier',
  'ssn',
  'aadharNumber',
  'panNumber',
  'rawAiPrompt',
  'providerApiKey',
];