@doccov/sdk 0.23.0 → 0.24.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.
- package/dist/analysis/index.d.ts +57 -16
- package/dist/analysis/index.js +58 -1
- package/dist/index.d.ts +920 -850
- package/dist/index.js +443 -302
- package/dist/shared/{chunk-nk2w5vws.js → chunk-p1stkhse.js} +325 -298
- package/dist/types/index.d.ts +153 -141
- package/package.json +4 -2
package/dist/analysis/index.d.ts
CHANGED
|
@@ -5,8 +5,26 @@ interface DetectedSchemaEntry {
|
|
|
5
5
|
schema: Record<string, unknown>;
|
|
6
6
|
vendor: string;
|
|
7
7
|
}
|
|
8
|
-
import {
|
|
9
|
-
|
|
8
|
+
import { SpecDiff } from "@openpkg-ts/spec";
|
|
9
|
+
/**
|
|
10
|
+
* All possible drift type identifiers.
|
|
11
|
+
*/
|
|
12
|
+
type DriftType = "param-mismatch" | "param-type-mismatch" | "return-type-mismatch" | "generic-constraint-mismatch" | "optionality-mismatch" | "deprecated-mismatch" | "visibility-mismatch" | "async-mismatch" | "property-type-drift" | "example-drift" | "example-syntax-error" | "example-runtime-error" | "example-assertion-failed" | "broken-link";
|
|
13
|
+
type SpecDocDrift = {
|
|
14
|
+
type: DriftType;
|
|
15
|
+
target?: string;
|
|
16
|
+
issue: string;
|
|
17
|
+
suggestion?: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Drift categories group related drift types for progressive disclosure.
|
|
21
|
+
*/
|
|
22
|
+
type DriftCategory = "structural" | "semantic" | "example";
|
|
23
|
+
type SpecDocsMetadata = {
|
|
24
|
+
coverageScore?: number;
|
|
25
|
+
missing?: string[];
|
|
26
|
+
drift?: SpecDocDrift[];
|
|
27
|
+
};
|
|
10
28
|
/**
|
|
11
29
|
* Result of computing drift for a single export.
|
|
12
30
|
*/
|
|
@@ -54,6 +72,7 @@ interface DriftSummary {
|
|
|
54
72
|
byCategory: Record<DriftCategory, number>;
|
|
55
73
|
fixable: number;
|
|
56
74
|
}
|
|
75
|
+
import { OpenPkg as OpenPkg2, SpecExport as SpecExport7 } from "@openpkg-ts/spec";
|
|
57
76
|
/**
|
|
58
77
|
* Categorize a single drift issue.
|
|
59
78
|
*
|
|
@@ -72,7 +91,7 @@ interface DriftSummary {
|
|
|
72
91
|
* console.log(categorized.fixable); // => true
|
|
73
92
|
* ```
|
|
74
93
|
*/
|
|
75
|
-
declare function categorizeDrift(drift:
|
|
94
|
+
declare function categorizeDrift(drift: SpecDocDrift): CategorizedDrift;
|
|
76
95
|
/**
|
|
77
96
|
* Group drifts by category.
|
|
78
97
|
*
|
|
@@ -87,7 +106,7 @@ declare function categorizeDrift(drift: SpecDocDrift2): CategorizedDrift;
|
|
|
87
106
|
* console.log(grouped.example.length); // Number of example issues
|
|
88
107
|
* ```
|
|
89
108
|
*/
|
|
90
|
-
declare function groupDriftsByCategory(drifts:
|
|
109
|
+
declare function groupDriftsByCategory(drifts: SpecDocDrift[]): Record<DriftCategory, CategorizedDrift[]>;
|
|
91
110
|
/**
|
|
92
111
|
* Get drift summary counts by category.
|
|
93
112
|
*
|
|
@@ -101,7 +120,7 @@ declare function groupDriftsByCategory(drifts: SpecDocDrift2[]): Record<DriftCat
|
|
|
101
120
|
* // => "5 issues: 3 fixable"
|
|
102
121
|
* ```
|
|
103
122
|
*/
|
|
104
|
-
declare function getDriftSummary(drifts:
|
|
123
|
+
declare function getDriftSummary(drifts: SpecDocDrift[]): DriftSummary;
|
|
105
124
|
/**
|
|
106
125
|
* Format drift summary for CLI output (single line).
|
|
107
126
|
*
|
|
@@ -116,7 +135,7 @@ declare function getDriftSummary(drifts: SpecDocDrift2[]): DriftSummary;
|
|
|
116
135
|
* ```
|
|
117
136
|
*/
|
|
118
137
|
declare function formatDriftSummaryLine(summary: DriftSummary): string;
|
|
119
|
-
import {
|
|
138
|
+
import { SpecExport } from "@openpkg-ts/spec";
|
|
120
139
|
import { OpenPkg } from "@openpkg-ts/spec";
|
|
121
140
|
type OpenPkgSpec = OpenPkg;
|
|
122
141
|
/**
|
|
@@ -136,7 +155,7 @@ declare function computeDrift(spec: OpenPkgSpec): DriftResult;
|
|
|
136
155
|
* @param registry - Registry of known exports and types for validation
|
|
137
156
|
* @returns Array of drift issues detected
|
|
138
157
|
*/
|
|
139
|
-
declare function computeExportDrift(entry: SpecExport, registry?: ExportRegistry):
|
|
158
|
+
declare function computeExportDrift(entry: SpecExport, registry?: ExportRegistry): SpecDocDrift[];
|
|
140
159
|
/**
|
|
141
160
|
* Calculate aggregate coverage score from a spec's exports.
|
|
142
161
|
*
|
|
@@ -185,7 +204,7 @@ declare function ensureSpecCoverage(spec: OpenPkgSpec): OpenPkgSpec & {
|
|
|
185
204
|
coverageScore: number;
|
|
186
205
|
};
|
|
187
206
|
};
|
|
188
|
-
import {
|
|
207
|
+
import { SpecExport as SpecExport2 } from "@openpkg-ts/spec";
|
|
189
208
|
interface ExampleRunResult {
|
|
190
209
|
success: boolean;
|
|
191
210
|
stdout: string;
|
|
@@ -197,7 +216,7 @@ interface ExampleRunResult {
|
|
|
197
216
|
* Detect runtime errors in @example blocks.
|
|
198
217
|
* Results are provided externally after running examples via runExamples().
|
|
199
218
|
*/
|
|
200
|
-
declare function detectExampleRuntimeErrors(entry: SpecExport2, runtimeResults: Map<number, ExampleRunResult>):
|
|
219
|
+
declare function detectExampleRuntimeErrors(entry: SpecExport2, runtimeResults: Map<number, ExampleRunResult>): SpecDocDrift[];
|
|
201
220
|
/**
|
|
202
221
|
* Parse assertion comments from example code.
|
|
203
222
|
* Matches: // => expected_value
|
|
@@ -214,8 +233,7 @@ declare function hasNonAssertionComments(code: string): boolean;
|
|
|
214
233
|
/**
|
|
215
234
|
* Detect assertion failures by comparing stdout to expected values.
|
|
216
235
|
*/
|
|
217
|
-
declare function detectExampleAssertionFailures(entry: SpecExport2, runtimeResults: Map<number, ExampleRunResult>):
|
|
218
|
-
import { OpenPkg as OpenPkg2, SpecDocDrift as SpecDocDrift8, SpecDocsMetadata, SpecExport as SpecExport7 } from "@openpkg-ts/spec";
|
|
236
|
+
declare function detectExampleAssertionFailures(entry: SpecExport2, runtimeResults: Map<number, ExampleRunResult>): SpecDocDrift[];
|
|
219
237
|
/**
|
|
220
238
|
* An enriched with computed documentation metadata.
|
|
221
239
|
* Extends SpecExport with the `docs` field for coverage analysis.
|
|
@@ -242,7 +260,7 @@ interface EnrichOptions {
|
|
|
242
260
|
* Per-drift issues to include in enrichment.
|
|
243
261
|
* Map from ID to drift issues.
|
|
244
262
|
*/
|
|
245
|
-
driftByExport?: Map<string,
|
|
263
|
+
driftByExport?: Map<string, SpecDocDrift[]>;
|
|
246
264
|
}
|
|
247
265
|
/**
|
|
248
266
|
* Enrich an OpenPkg spec with documentation coverage metadata.
|
|
@@ -265,6 +283,30 @@ interface EnrichOptions {
|
|
|
265
283
|
* ```
|
|
266
284
|
*/
|
|
267
285
|
declare function enrichSpec(spec: OpenPkg2, options?: EnrichOptions): EnrichedOpenPkg;
|
|
286
|
+
/**
|
|
287
|
+
* Extended diff result with doccov-specific coverage tracking.
|
|
288
|
+
*/
|
|
289
|
+
interface EnrichedSpecDiff extends SpecDiff {
|
|
290
|
+
coverageDelta: number;
|
|
291
|
+
oldCoverage: number;
|
|
292
|
+
newCoverage: number;
|
|
293
|
+
newUndocumented: string[];
|
|
294
|
+
improvedExports: string[];
|
|
295
|
+
regressedExports: string[];
|
|
296
|
+
driftIntroduced: number;
|
|
297
|
+
driftResolved: number;
|
|
298
|
+
}
|
|
299
|
+
type ExportWithDocs = EnrichedExport & {
|
|
300
|
+
docs?: SpecDocsMetadata;
|
|
301
|
+
};
|
|
302
|
+
type SpecWithDocs = EnrichedOpenPkg & {
|
|
303
|
+
docs?: SpecDocsMetadata;
|
|
304
|
+
exports: ExportWithDocs[];
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* Compare two enriched OpenPkg specs with coverage tracking.
|
|
308
|
+
*/
|
|
309
|
+
declare function diffEnrichedSpec(oldSpec: SpecWithDocs, newSpec: SpecWithDocs): EnrichedSpecDiff;
|
|
268
310
|
import { OpenPkg as OpenPkg3 } from "@openpkg-ts/spec";
|
|
269
311
|
/** Directory for storing history snapshots */
|
|
270
312
|
declare const HISTORY_DIR = ".doccov/history";
|
|
@@ -449,7 +491,6 @@ declare function getExtendedTrend(spec: OpenPkg3, cwd: string, options?: {
|
|
|
449
491
|
tier?: RetentionTier;
|
|
450
492
|
}): ExtendedTrendAnalysis;
|
|
451
493
|
import { OpenPkg as OpenPkg4 } from "@openpkg-ts/spec";
|
|
452
|
-
import { DriftCategory as DriftCategory3, SpecDocDrift as SpecDocDrift9 } from "@openpkg-ts/spec";
|
|
453
494
|
/**
|
|
454
495
|
* Drift summary with category breakdown.
|
|
455
496
|
*/
|
|
@@ -461,7 +502,7 @@ interface DriftReportSummary {
|
|
|
461
502
|
/**
|
|
462
503
|
* Count of issues per category.
|
|
463
504
|
*/
|
|
464
|
-
byCategory: Record<
|
|
505
|
+
byCategory: Record<DriftCategory, number>;
|
|
465
506
|
/**
|
|
466
507
|
* Number of auto-fixable issues.
|
|
467
508
|
*/
|
|
@@ -519,7 +560,7 @@ interface ExportCoverageData {
|
|
|
519
560
|
/**
|
|
520
561
|
* Drift issues for this export.
|
|
521
562
|
*/
|
|
522
|
-
drift?:
|
|
563
|
+
drift?: SpecDocDrift[];
|
|
523
564
|
}
|
|
524
565
|
/**
|
|
525
566
|
* DocCov report - a persistable coverage analysis result.
|
|
@@ -647,4 +688,4 @@ interface SchemaDetectionResult {
|
|
|
647
688
|
noCompiledJsWarning?: boolean;
|
|
648
689
|
}
|
|
649
690
|
declare function detectRuntimeSchemas(context: SchemaDetectionContext): Promise<SchemaDetectionResult>;
|
|
650
|
-
export { saveSnapshot, saveReport, renderSparkline, renderApiSurface, pruneHistory, pruneByTier, parseAssertions, loadSnapshotsForDays, loadSnapshots, loadCachedReport, isCachedReportValid, hasNonAssertionComments, groupDriftsByCategory, getTrend, getExtendedTrend, getDriftSummary, generateWeeklySummaries, generateReportFromEnriched, generateReport, formatDriftSummaryLine, formatDelta, ensureSpecCoverage, enrichSpec, detectRuntimeSchemas, detectExampleRuntimeErrors, detectExampleAssertionFailures, computeSnapshot, computeExportDrift, computeDrift, categorizeDrift, calculateAggregateCoverage, buildExportRegistry, WeeklySummary, SchemaDetectionResult, SchemaDetectionContext, RetentionTier, RETENTION_DAYS, OpenPkgSpec, HISTORY_DIR, ExtendedTrendAnalysis, ExportDriftResult, EnrichedOpenPkg, EnrichedExport, EnrichedDocsMetadata, EnrichOptions, DriftSummary, DriftResult, DetectedSchemaEntry, CoverageTrend, CoverageSnapshot, CategorizedDrift };
|
|
691
|
+
export { saveSnapshot, saveReport, renderSparkline, renderApiSurface, pruneHistory, pruneByTier, parseAssertions, loadSnapshotsForDays, loadSnapshots, loadCachedReport, isCachedReportValid, hasNonAssertionComments, groupDriftsByCategory, getTrend, getExtendedTrend, getDriftSummary, generateWeeklySummaries, generateReportFromEnriched, generateReport, formatDriftSummaryLine, formatDelta, ensureSpecCoverage, enrichSpec, diffEnrichedSpec, detectRuntimeSchemas, detectExampleRuntimeErrors, detectExampleAssertionFailures, computeSnapshot, computeExportDrift, computeDrift, categorizeDrift, calculateAggregateCoverage, buildExportRegistry, WeeklySummary, SchemaDetectionResult, SchemaDetectionContext, RetentionTier, RETENTION_DAYS, OpenPkgSpec, HISTORY_DIR, ExtendedTrendAnalysis, ExportDriftResult, EnrichedSpecDiff, EnrichedOpenPkg, EnrichedExport, EnrichedDocsMetadata, EnrichOptions, DriftSummary, DriftResult, DetectedSchemaEntry, CoverageTrend, CoverageSnapshot, CategorizedDrift };
|
package/dist/analysis/index.js
CHANGED
|
@@ -33,8 +33,64 @@ import {
|
|
|
33
33
|
renderSparkline,
|
|
34
34
|
saveReport,
|
|
35
35
|
saveSnapshot
|
|
36
|
-
} from "../shared/chunk-
|
|
36
|
+
} from "../shared/chunk-p1stkhse.js";
|
|
37
37
|
import"../shared/chunk-esptwrfq.js";
|
|
38
|
+
|
|
39
|
+
// src/analysis/diff-enriched.ts
|
|
40
|
+
import { diffSpec } from "@openpkg-ts/spec";
|
|
41
|
+
function diffEnrichedSpec(oldSpec, newSpec) {
|
|
42
|
+
const baseDiff = diffSpec(oldSpec, newSpec);
|
|
43
|
+
const result = {
|
|
44
|
+
...baseDiff,
|
|
45
|
+
coverageDelta: 0,
|
|
46
|
+
oldCoverage: 0,
|
|
47
|
+
newCoverage: 0,
|
|
48
|
+
newUndocumented: [],
|
|
49
|
+
improvedExports: [],
|
|
50
|
+
regressedExports: [],
|
|
51
|
+
driftIntroduced: 0,
|
|
52
|
+
driftResolved: 0
|
|
53
|
+
};
|
|
54
|
+
result.oldCoverage = oldSpec.docs?.coverageScore ?? 0;
|
|
55
|
+
result.newCoverage = newSpec.docs?.coverageScore ?? 0;
|
|
56
|
+
result.coverageDelta = Math.round((result.newCoverage - result.oldCoverage) * 10) / 10;
|
|
57
|
+
const oldExportMap = toExportMap(oldSpec.exports);
|
|
58
|
+
const newExportMap = toExportMap(newSpec.exports);
|
|
59
|
+
for (const [id, newExport] of newExportMap.entries()) {
|
|
60
|
+
const oldExport = oldExportMap.get(id);
|
|
61
|
+
const newScore = newExport.docs?.coverageScore ?? 0;
|
|
62
|
+
const newDriftCount = newExport.docs?.drift?.length ?? 0;
|
|
63
|
+
if (!oldExport) {
|
|
64
|
+
if (newScore < 100 || (newExport.docs?.missing?.length ?? 0) > 0) {
|
|
65
|
+
result.newUndocumented.push(id);
|
|
66
|
+
}
|
|
67
|
+
result.driftIntroduced += newDriftCount;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const oldScore = oldExport.docs?.coverageScore ?? 0;
|
|
71
|
+
const oldDriftCount = oldExport.docs?.drift?.length ?? 0;
|
|
72
|
+
if (newScore > oldScore) {
|
|
73
|
+
result.improvedExports.push(id);
|
|
74
|
+
} else if (newScore < oldScore) {
|
|
75
|
+
result.regressedExports.push(id);
|
|
76
|
+
}
|
|
77
|
+
if (newDriftCount > oldDriftCount) {
|
|
78
|
+
result.driftIntroduced += newDriftCount - oldDriftCount;
|
|
79
|
+
} else if (oldDriftCount > newDriftCount) {
|
|
80
|
+
result.driftResolved += oldDriftCount - newDriftCount;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
function toExportMap(exports) {
|
|
86
|
+
const map = new Map;
|
|
87
|
+
for (const exp of exports) {
|
|
88
|
+
if (exp && typeof exp.id === "string") {
|
|
89
|
+
map.set(exp.id, exp);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return map;
|
|
93
|
+
}
|
|
38
94
|
export {
|
|
39
95
|
saveSnapshot,
|
|
40
96
|
saveReport,
|
|
@@ -59,6 +115,7 @@ export {
|
|
|
59
115
|
formatDelta,
|
|
60
116
|
ensureSpecCoverage,
|
|
61
117
|
enrichSpec,
|
|
118
|
+
diffEnrichedSpec,
|
|
62
119
|
detectRuntimeSchemas,
|
|
63
120
|
detectExampleRuntimeErrors,
|
|
64
121
|
detectExampleAssertionFailures,
|