-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
141 lines (131 loc) · 3.64 KB
/
types.ts
File metadata and controls
141 lines (131 loc) · 3.64 KB
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
139
140
141
// ============================================================
// lambda-doctor core types
// ============================================================
/** Severity of a diagnostic finding */
export type Severity = 'critical' | 'warning' | 'info';
/** Category of analysis */
export type AnalyzerName =
| 'bundle-size'
| 'heavy-dependencies'
| 'import-analysis'
| 'aws-sdk'
| 'bundler-detection';
/** A single diagnostic finding */
export interface Diagnostic {
/** Which analyzer produced this */
analyzer: AnalyzerName;
/** Severity level */
severity: Severity;
/** Short human-readable title */
title: string;
/** Detailed description of the issue */
description: string;
/** Actionable fix recommendation */
recommendation: string;
/** Estimated cold start improvement in ms (0 if unknown) */
estimatedImpactMs: number;
/** File path related to this finding (optional) */
filePath?: string;
/** Line number (optional) */
line?: number;
}
/** Summary of a dependency */
export interface DependencyInfo {
/** Package name */
name: string;
/** Version string */
version: string;
/** Size on disk in bytes */
sizeBytes: number;
/** Whether it's a known heavy package */
isHeavy: boolean;
/** Suggested lighter alternative (if any) */
alternative?: string;
}
/** Result from a single analyzer */
export interface AnalyzerResult {
/** Analyzer name */
analyzer: AnalyzerName;
/** Time taken to run in ms */
durationMs: number;
/** Findings */
diagnostics: Diagnostic[];
/** Analyzer-specific metadata */
metadata?: Record<string, unknown>;
}
/** Full diagnosis report */
export interface DiagnosisReport {
/** Path that was analyzed */
targetPath: string;
/** Timestamp */
timestamp: string;
/** Total analysis duration in ms */
totalDurationMs: number;
/** Results from each analyzer */
results: AnalyzerResult[];
/** Aggregated summary */
summary: ReportSummary;
}
/** Aggregated summary across all analyzers */
export interface ReportSummary {
/** Total number of diagnostics */
totalIssues: number;
/** Count by severity */
critical: number;
warnings: number;
info: number;
/** Total estimated cold start improvement in ms */
estimatedTotalImpactMs: number;
/** Total bundle size in bytes (if detected) */
bundleSizeBytes?: number;
/** Number of heavy dependencies found */
heavyDependencies: number;
}
/** Configuration for the analyze command */
export interface AnalyzeConfig {
/** Path to the Lambda project directory */
targetPath: string;
/** Which analyzers to run (default: all) */
analyzers?: AnalyzerName[];
/** Output format */
format?: 'console' | 'json';
/** Whether to show verbose output */
verbose?: boolean;
/** Glob patterns to exclude from file scanning */
exclude?: string[];
}
/** Default glob patterns excluded from scanning */
export const DEFAULT_EXCLUDE_PATTERNS: string[] = [
// Build artifacts
'node_modules/**',
'dist/**',
'build/**',
'coverage/**',
'**/*.d.ts',
// Test files
'**/__tests__/**',
'**/*.test.*',
'**/*.spec.*',
'**/test/**',
'**/tests/**',
'**/testing/**',
'**/cypress/**',
// Serverless/IaC artifacts
'**/.serverless/**',
'**/cdk.out/**',
// IaC directories (not Lambda runtime code)
'**/pulumi/**',
'**/cdk/**',
'**/terraform/**',
// Scripts & tooling (not Lambda runtime code)
'**/scripts/**',
];
/** Interface that all analyzers must implement */
export interface Analyzer {
/** Unique name */
name: AnalyzerName;
/** Human-readable description */
description: string;
/** Run the analysis */
analyze(targetPath: string, exclude?: string[]): Promise<AnalyzerResult>;
}