driftdetect-dashboard 0.7.0 → 0.8.1

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 (40) hide show
  1. package/dist/client/assets/{GalaxyTab-Bc9PKsMk.js → GalaxyTab-BsAmWarF.js} +4 -4
  2. package/dist/client/assets/{GalaxyTab-Bc9PKsMk.js.map → GalaxyTab-BsAmWarF.js.map} +1 -1
  3. package/dist/client/assets/main-CVl-4C5E.css +2 -0
  4. package/dist/client/assets/main-QuEZvA3i.js +59 -0
  5. package/dist/client/assets/main-QuEZvA3i.js.map +1 -0
  6. package/dist/client/assets/{sfxr-CO3_Kukg.js → sfxr-Cr89uVKo.js} +2 -2
  7. package/dist/client/assets/{sfxr-CO3_Kukg.js.map → sfxr-Cr89uVKo.js.map} +1 -1
  8. package/dist/client/index.html +2 -2
  9. package/dist/server/api-routes.d.ts.map +1 -1
  10. package/dist/server/quality-gates-api.d.ts.map +1 -0
  11. package/package.json +21 -21
  12. package/LICENSE +0 -21
  13. package/dist/client/assets/main-BdVQNGtK.js +0 -59
  14. package/dist/client/assets/main-BdVQNGtK.js.map +0 -1
  15. package/dist/client/assets/main-NejYwKFb.css +0 -2
  16. package/dist/server/api-routes.d.ts +0 -50
  17. package/dist/server/api-routes.js +0 -634
  18. package/dist/server/api-routes.js.map +0 -1
  19. package/dist/server/dashboard-server.d.ts +0 -64
  20. package/dist/server/dashboard-server.js +0 -154
  21. package/dist/server/dashboard-server.js.map +0 -1
  22. package/dist/server/drift-data-reader.d.ts +0 -522
  23. package/dist/server/drift-data-reader.js +0 -1550
  24. package/dist/server/drift-data-reader.js.map +0 -1
  25. package/dist/server/express-app.d.ts +0 -24
  26. package/dist/server/express-app.js +0 -74
  27. package/dist/server/express-app.js.map +0 -1
  28. package/dist/server/galaxy-data-transformer.d.ts +0 -178
  29. package/dist/server/galaxy-data-transformer.js +0 -562
  30. package/dist/server/galaxy-data-transformer.js.map +0 -1
  31. package/dist/server/index.d.ts +0 -20
  32. package/dist/server/index.js +0 -14
  33. package/dist/server/index.js.map +0 -1
  34. package/dist/server/pattern-watcher.d.ts +0 -55
  35. package/dist/server/pattern-watcher.d.ts.map +0 -1
  36. package/dist/server/pattern-watcher.js +0 -157
  37. package/dist/server/pattern-watcher.js.map +0 -1
  38. package/dist/server/websocket-server.d.ts +0 -83
  39. package/dist/server/websocket-server.js +0 -189
  40. package/dist/server/websocket-server.js.map +0 -1
@@ -1,522 +0,0 @@
1
- /**
2
- * DriftDataReader
3
- *
4
- * Reads and parses data from the .drift/ folder structure.
5
- * Provides methods for accessing patterns, violations, files, and configuration.
6
- *
7
- * OPTIMIZED: Uses DataLake for fast reads with pre-computed views.
8
- * Falls back to direct file reading when lake data is unavailable.
9
- *
10
- * @requirements 1.6 - THE Dashboard_Server SHALL read pattern and violation data from the existing `.drift/` folder structure
11
- * @requirements 8.1 - THE Dashboard_Server SHALL expose GET `/api/patterns` to list all patterns
12
- * @requirements 8.2 - THE Dashboard_Server SHALL expose GET `/api/patterns/:id` to get pattern details with locations
13
- * @requirements 8.6 - THE Dashboard_Server SHALL expose GET `/api/violations` to list all violations
14
- * @requirements 8.7 - THE Dashboard_Server SHALL expose GET `/api/files` to get the file tree
15
- * @requirements 8.8 - THE Dashboard_Server SHALL expose GET `/api/files/:path` to get patterns and violations for a specific file
16
- * @requirements 8.9 - THE Dashboard_Server SHALL expose GET `/api/stats` to get overview statistics
17
- */
18
- import type { PatternStatus, PatternCategory, Severity } from 'driftdetect-core';
19
- export interface PatternQuery {
20
- category?: string;
21
- status?: string;
22
- minConfidence?: number;
23
- search?: string;
24
- }
25
- export interface ViolationQuery {
26
- severity?: string;
27
- file?: string;
28
- patternId?: string;
29
- search?: string;
30
- }
31
- /**
32
- * Pattern representation for the dashboard API
33
- */
34
- export interface DashboardPattern {
35
- id: string;
36
- name: string;
37
- category: string;
38
- subcategory: string;
39
- status: PatternStatus;
40
- description: string;
41
- confidence: {
42
- score: number;
43
- level: string;
44
- };
45
- locationCount: number;
46
- outlierCount: number;
47
- severity: string;
48
- metadata: {
49
- firstSeen: string;
50
- lastSeen: string;
51
- tags?: string[] | undefined;
52
- };
53
- }
54
- /**
55
- * Pattern with full location details for the dashboard API
56
- */
57
- export interface DashboardPatternWithLocations extends DashboardPattern {
58
- locations: SemanticLocation[];
59
- outliers: OutlierWithDetails[];
60
- }
61
- /**
62
- * Semantic location for the dashboard
63
- */
64
- export interface SemanticLocation {
65
- file: string;
66
- range: {
67
- start: {
68
- line: number;
69
- character: number;
70
- };
71
- end: {
72
- line: number;
73
- character: number;
74
- };
75
- };
76
- }
77
- /**
78
- * Outlier with reason details
79
- */
80
- export interface OutlierWithDetails extends SemanticLocation {
81
- reason: string;
82
- deviationScore?: number | undefined;
83
- }
84
- /**
85
- * Violation representation for the dashboard API
86
- */
87
- export interface DashboardViolation {
88
- id: string;
89
- patternId: string;
90
- patternName: string;
91
- severity: string;
92
- file: string;
93
- range: {
94
- start: {
95
- line: number;
96
- character: number;
97
- };
98
- end: {
99
- line: number;
100
- character: number;
101
- };
102
- };
103
- message: string;
104
- expected: string;
105
- actual: string;
106
- }
107
- /**
108
- * File tree node for hierarchical file structure
109
- * @requirements 8.7 - GET `/api/files` to get the file tree
110
- */
111
- export interface FileTreeNode {
112
- name: string;
113
- path: string;
114
- type: 'file' | 'directory';
115
- children?: FileTreeNode[];
116
- patternCount?: number;
117
- violationCount?: number;
118
- severity?: Severity;
119
- }
120
- /**
121
- * File details with patterns and violations
122
- * @requirements 8.8 - GET `/api/files/:path` to get patterns and violations for a specific file
123
- */
124
- export interface FileDetails {
125
- path: string;
126
- language: string;
127
- lineCount: number;
128
- patterns: Array<{
129
- id: string;
130
- name: string;
131
- category: PatternCategory;
132
- locations: SemanticLocation[];
133
- }>;
134
- violations: DashboardViolation[];
135
- }
136
- /**
137
- * Drift configuration
138
- * @requirements 8.10, 8.11 - Configuration management
139
- */
140
- export interface DriftConfig {
141
- version: string;
142
- detectors: DetectorConfigEntry[];
143
- severityOverrides: Record<string, Severity>;
144
- ignorePatterns: string[];
145
- watchOptions?: {
146
- debounce: number;
147
- categories?: PatternCategory[];
148
- };
149
- }
150
- /**
151
- * Detector configuration entry
152
- */
153
- export interface DetectorConfigEntry {
154
- id: string;
155
- name: string;
156
- enabled: boolean;
157
- category: PatternCategory;
158
- options?: Record<string, unknown>;
159
- }
160
- /**
161
- * Dashboard statistics
162
- * @requirements 8.9 - GET `/api/stats` to get overview statistics
163
- */
164
- export interface DashboardStats {
165
- healthScore: number;
166
- patterns: {
167
- total: number;
168
- byStatus: Record<PatternStatus, number>;
169
- byCategory: Record<PatternCategory, number>;
170
- };
171
- violations: {
172
- total: number;
173
- bySeverity: Record<Severity, number>;
174
- };
175
- files: {
176
- total: number;
177
- scanned: number;
178
- };
179
- detectors: {
180
- active: number;
181
- total: number;
182
- };
183
- lastScan: string | null;
184
- }
185
- /**
186
- * Contract representation for the dashboard API
187
- */
188
- export interface DashboardContract {
189
- id: string;
190
- method: string;
191
- endpoint: string;
192
- status: string;
193
- backend: {
194
- file: string;
195
- line: number;
196
- framework: string;
197
- responseFields: Array<{
198
- name: string;
199
- type: string;
200
- optional: boolean;
201
- }>;
202
- };
203
- frontend: Array<{
204
- file: string;
205
- line: number;
206
- library: string;
207
- responseType?: string;
208
- responseFields: Array<{
209
- name: string;
210
- type: string;
211
- optional: boolean;
212
- }>;
213
- }>;
214
- mismatches: Array<{
215
- fieldPath: string;
216
- mismatchType: string;
217
- description: string;
218
- severity: string;
219
- }>;
220
- mismatchCount: number;
221
- confidence: {
222
- score: number;
223
- level: string;
224
- };
225
- metadata: {
226
- firstSeen: string;
227
- lastSeen: string;
228
- verifiedAt?: string;
229
- };
230
- }
231
- /**
232
- * Contract statistics for the dashboard
233
- */
234
- export interface DashboardContractStats {
235
- totalContracts: number;
236
- byStatus: Record<string, number>;
237
- byMethod: Record<string, number>;
238
- totalMismatches: number;
239
- mismatchesByType: Record<string, number>;
240
- }
241
- /**
242
- * A snapshot of a single pattern's state at a point in time
243
- */
244
- export interface PatternSnapshot {
245
- patternId: string;
246
- patternName: string;
247
- category: PatternCategory;
248
- confidence: number;
249
- locationCount: number;
250
- outlierCount: number;
251
- complianceRate: number;
252
- status: PatternStatus;
253
- }
254
- /**
255
- * Category summary in a snapshot
256
- */
257
- export interface CategorySummary {
258
- patternCount: number;
259
- avgConfidence: number;
260
- totalLocations: number;
261
- totalOutliers: number;
262
- complianceRate: number;
263
- }
264
- /**
265
- * A full snapshot of all patterns at a point in time
266
- */
267
- export interface HistorySnapshot {
268
- timestamp: string;
269
- date: string;
270
- patterns: PatternSnapshot[];
271
- summary: {
272
- totalPatterns: number;
273
- avgConfidence: number;
274
- totalLocations: number;
275
- totalOutliers: number;
276
- overallComplianceRate: number;
277
- byCategory: Record<string, CategorySummary>;
278
- };
279
- }
280
- /**
281
- * A detected regression or improvement
282
- */
283
- export interface PatternTrend {
284
- patternId: string;
285
- patternName: string;
286
- category: PatternCategory;
287
- type: 'regression' | 'improvement' | 'stable';
288
- metric: 'confidence' | 'compliance' | 'outliers';
289
- previousValue: number;
290
- currentValue: number;
291
- change: number;
292
- changePercent: number;
293
- severity: 'critical' | 'warning' | 'info';
294
- firstSeen: string;
295
- details: string;
296
- }
297
- /**
298
- * Aggregated trends for the dashboard
299
- */
300
- export interface TrendSummary {
301
- period: '7d' | '30d' | '90d';
302
- startDate: string;
303
- endDate: string;
304
- regressions: PatternTrend[];
305
- improvements: PatternTrend[];
306
- stable: number;
307
- overallTrend: 'improving' | 'declining' | 'stable';
308
- healthDelta: number;
309
- categoryTrends: Record<string, {
310
- trend: 'improving' | 'declining' | 'stable';
311
- avgConfidenceChange: number;
312
- complianceChange: number;
313
- }>;
314
- }
315
- export declare class DriftDataReader {
316
- private readonly driftDir;
317
- private readonly patternsDir;
318
- private readonly dataLake;
319
- private lakeInitialized;
320
- constructor(driftDir: string);
321
- /**
322
- * Get the drift directory path
323
- */
324
- get directory(): string;
325
- /**
326
- * Initialize the data lake (lazy initialization)
327
- */
328
- private initializeLake;
329
- /**
330
- * Get all patterns, optionally filtered
331
- * OPTIMIZED: Uses DataLake pattern shards for fast category-based queries
332
- *
333
- * @requirements 8.1 - List all patterns
334
- */
335
- getPatterns(query?: PatternQuery): Promise<DashboardPattern[]>;
336
- /**
337
- * Get patterns from DataLake (optimized path)
338
- */
339
- private getPatternsFromLake;
340
- /**
341
- * Get a single pattern by ID with all locations
342
- *
343
- * @requirements 8.2 - Get pattern details with locations
344
- */
345
- getPattern(id: string): Promise<DashboardPatternWithLocations | null>;
346
- /**
347
- * Get all violations, optionally filtered
348
- *
349
- * Violations are derived from pattern outliers.
350
- *
351
- * @requirements 8.6 - List all violations
352
- */
353
- getViolations(query?: ViolationQuery): Promise<DashboardViolation[]>;
354
- /**
355
- * Get dashboard statistics
356
- * OPTIMIZED: Uses DataLake status view for instant response
357
- * @requirements 8.9 - GET `/api/stats` to get overview statistics
358
- */
359
- getStats(): Promise<DashboardStats>;
360
- /**
361
- * Convert StatusView from DataLake to DashboardStats
362
- */
363
- private statusViewToStats;
364
- /**
365
- * Get the file tree structure
366
- * @requirements 8.7 - GET `/api/files` to get the file tree
367
- */
368
- getFileTree(): Promise<FileTreeNode[]>;
369
- /**
370
- * Get details for a specific file
371
- * @requirements 8.8 - GET `/api/files/:path` to get patterns and violations for a specific file
372
- */
373
- getFileDetails(filePath: string): Promise<FileDetails | null>;
374
- /**
375
- * Get configuration
376
- * @requirements 8.10 - GET `/api/config` to get configuration
377
- */
378
- getConfig(): Promise<DriftConfig>;
379
- /**
380
- * Update configuration
381
- * @requirements 8.11 - PUT `/api/config` to update configuration
382
- */
383
- updateConfig(partial: Partial<DriftConfig>): Promise<void>;
384
- /**
385
- * Approve a pattern - changes status to 'approved'
386
- * @requirements 4.4 - Approve pattern
387
- * @requirements 8.3 - POST `/api/patterns/:id/approve` to approve a pattern
388
- */
389
- approvePattern(id: string): Promise<void>;
390
- /**
391
- * Ignore a pattern - changes status to 'ignored'
392
- * @requirements 4.5 - Ignore pattern
393
- * @requirements 8.4 - POST `/api/patterns/:id/ignore` to ignore a pattern
394
- */
395
- ignorePattern(id: string): Promise<void>;
396
- /**
397
- * Delete a pattern - removes from storage
398
- * @requirements 4.6 - Delete pattern
399
- * @requirements 8.5 - DELETE `/api/patterns/:id` to delete a pattern
400
- */
401
- deletePattern(id: string): Promise<void>;
402
- /**
403
- * Convert a StoredPattern to DashboardPattern
404
- */
405
- private storedToDashboardPattern;
406
- /**
407
- * Convert a StoredPattern to DashboardPatternWithLocations
408
- */
409
- private storedToDashboardPatternWithLocations;
410
- /**
411
- * Convert an outlier to a violation
412
- */
413
- private outlierToViolation;
414
- /**
415
- * Filter patterns based on query
416
- */
417
- private filterPatterns;
418
- /**
419
- * Filter violations based on query
420
- */
421
- private filterViolations;
422
- /**
423
- * Calculate health score based on violations and patterns
424
- *
425
- * Health score formula:
426
- * - Base score starts at 100
427
- * - Deduct for violations by severity (error: -10, warning: -3, info: -1, hint: 0)
428
- * - Bonus for approved patterns (shows intentional architecture)
429
- * - Clamp to 0-100
430
- */
431
- private calculateHealthScore;
432
- /**
433
- * Build a hierarchical file tree from file information
434
- */
435
- private buildFileTree;
436
- /**
437
- * Sort file tree: directories first, then alphabetically
438
- */
439
- private sortFileTree;
440
- /**
441
- * Compare severity levels
442
- * Returns positive if a > b, negative if a < b, 0 if equal
443
- */
444
- private compareSeverity;
445
- /**
446
- * Get programming language from file path
447
- */
448
- private getLanguageFromPath;
449
- /**
450
- * Change pattern status (move between status directories)
451
- */
452
- private changePatternStatus;
453
- /**
454
- * Find a pattern's location in the file system
455
- */
456
- private findPatternLocation;
457
- /**
458
- * Get default configuration
459
- */
460
- private getDefaultConfig;
461
- /**
462
- * Get code snippet from a file at a specific line with context
463
- */
464
- getCodeSnippet(filePath: string, line: number, contextLines?: number): Promise<{
465
- code: string;
466
- startLine: number;
467
- endLine: number;
468
- language: string;
469
- } | null>;
470
- /**
471
- * Get all contracts, optionally filtered
472
- */
473
- getContracts(query?: {
474
- status?: string;
475
- method?: string;
476
- hasMismatches?: boolean;
477
- search?: string;
478
- }): Promise<DashboardContract[]>;
479
- /**
480
- * Get a single contract by ID
481
- */
482
- getContract(id: string): Promise<DashboardContract | null>;
483
- /**
484
- * Get contract statistics
485
- */
486
- getContractStats(): Promise<DashboardContractStats>;
487
- /**
488
- * Verify a contract
489
- */
490
- verifyContract(id: string): Promise<void>;
491
- /**
492
- * Ignore a contract
493
- */
494
- ignoreContract(id: string): Promise<void>;
495
- /**
496
- * Change contract status
497
- */
498
- private changeContractStatus;
499
- /**
500
- * Filter contracts based on query
501
- */
502
- private filterContracts;
503
- /**
504
- * Get trend summary for pattern regressions and improvements
505
- * OPTIMIZED: Uses DataLake trends view for instant response
506
- */
507
- getTrends(period?: '7d' | '30d' | '90d'): Promise<TrendSummary | null>;
508
- /**
509
- * Convert TrendsView from DataLake to TrendSummary
510
- * TrendsView has: generatedAt, period, overallTrend, healthDelta, regressions, improvements, stableCount, categoryTrends
511
- */
512
- private trendsViewToSummary;
513
- /**
514
- * Get historical snapshots for charting
515
- */
516
- getSnapshots(limit?: number): Promise<HistorySnapshot[]>;
517
- /**
518
- * Calculate trend summary between two snapshots
519
- */
520
- private calculateTrendSummary;
521
- }
522
- //# sourceMappingURL=drift-data-reader.d.ts.map