@doccov/sdk 0.21.0 → 0.22.0
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/index.d.ts +2 -0
- package/dist/index.js +7 -15
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -125,6 +125,8 @@ interface DetectedSchema {
|
|
|
125
125
|
interface SchemaDetectionResult {
|
|
126
126
|
schemas: Map<string, DetectedSchema>;
|
|
127
127
|
errors: string[];
|
|
128
|
+
/** Warning when runtime was requested but compiled JS not found */
|
|
129
|
+
noCompiledJsWarning?: boolean;
|
|
128
130
|
}
|
|
129
131
|
declare function detectRuntimeSchemas(context: SchemaDetectionContext): Promise<SchemaDetectionResult>;
|
|
130
132
|
declare function clearSchemaCache(): void;
|
package/dist/index.js
CHANGED
|
@@ -204,7 +204,8 @@ async function detectRuntimeSchemas(context) {
|
|
|
204
204
|
if (!compiledPath) {
|
|
205
205
|
return {
|
|
206
206
|
schemas: new Map,
|
|
207
|
-
errors: []
|
|
207
|
+
errors: [],
|
|
208
|
+
noCompiledJsWarning: true
|
|
208
209
|
};
|
|
209
210
|
}
|
|
210
211
|
const extraction = await extractStandardSchemasFromProject(entryFile, baseDir);
|
|
@@ -646,7 +647,7 @@ function generateReturnTypeFix(drift, exportEntry, existingPatch) {
|
|
|
646
647
|
const actualReturn = signature?.returns;
|
|
647
648
|
if (!actualReturn)
|
|
648
649
|
return null;
|
|
649
|
-
const correctType =
|
|
650
|
+
const correctType = stringifySchema(actualReturn.schema);
|
|
650
651
|
const updatedReturn = {
|
|
651
652
|
...existingPatch?.returns,
|
|
652
653
|
type: correctType
|
|
@@ -1596,7 +1597,7 @@ function detectReturnTypeDrift(entry) {
|
|
|
1596
1597
|
if (!signatureReturn) {
|
|
1597
1598
|
return [];
|
|
1598
1599
|
}
|
|
1599
|
-
const declaredRaw =
|
|
1600
|
+
const declaredRaw = extractTypeFromSchema(signatureReturn.schema);
|
|
1600
1601
|
const declaredType = normalizeType(declaredRaw) ?? undefined;
|
|
1601
1602
|
if (!declaredType) {
|
|
1602
1603
|
return [];
|
|
@@ -2198,7 +2199,7 @@ function detectAsyncMismatch(entry) {
|
|
|
2198
2199
|
}
|
|
2199
2200
|
const drifts = [];
|
|
2200
2201
|
const returnsPromise = signatures.some((sig) => {
|
|
2201
|
-
const returnType =
|
|
2202
|
+
const returnType = extractTypeFromSchema(sig.returns?.schema) ?? "";
|
|
2202
2203
|
return returnType.startsWith("Promise<") || returnType === "Promise";
|
|
2203
2204
|
});
|
|
2204
2205
|
const returnsTag = entry.tags?.find((tag) => tag.name === "returns" || tag.name === "return");
|
|
@@ -5161,11 +5162,11 @@ function formatTypeReference(type, typeChecker, typeRefs, referencedTypes, visit
|
|
|
5161
5162
|
if (type.getFlags() & ts.TypeFlags.Object) {
|
|
5162
5163
|
const objectType = type;
|
|
5163
5164
|
if (objectType.objectFlags & ts.ObjectFlags.Mapped) {
|
|
5164
|
-
return { type: "object"
|
|
5165
|
+
return { type: "object" };
|
|
5165
5166
|
}
|
|
5166
5167
|
}
|
|
5167
5168
|
if (type.flags & ts.TypeFlags.Conditional) {
|
|
5168
|
-
return { type: "object"
|
|
5169
|
+
return { type: "object" };
|
|
5169
5170
|
}
|
|
5170
5171
|
if (type.isUnion()) {
|
|
5171
5172
|
const unionType = type;
|
|
@@ -6419,7 +6420,6 @@ function serializeCallSignatures(signatures, symbol, context, parsedDoc) {
|
|
|
6419
6420
|
};
|
|
6420
6421
|
});
|
|
6421
6422
|
const returnType = signature.getReturnType();
|
|
6422
|
-
const returnTypeText = returnType ? checker.typeToString(returnType) : undefined;
|
|
6423
6423
|
if (returnType) {
|
|
6424
6424
|
collectReferencedTypes(returnType, checker, referencedTypes);
|
|
6425
6425
|
}
|
|
@@ -6445,7 +6445,6 @@ function serializeCallSignatures(signatures, symbol, context, parsedDoc) {
|
|
|
6445
6445
|
returns: {
|
|
6446
6446
|
schema: returnType ? formatTypeReference(returnType, checker, typeRefs, referencedTypes) : { type: "void" },
|
|
6447
6447
|
description: functionDoc?.returns || "",
|
|
6448
|
-
tsType: returnTypeText,
|
|
6449
6448
|
...typePredicateInfo ? { typePredicate: typePredicateInfo } : {}
|
|
6450
6449
|
},
|
|
6451
6450
|
description: functionDoc?.description || undefined,
|
|
@@ -8490,13 +8489,6 @@ function extractTypeName(schema) {
|
|
|
8490
8489
|
if (typeof s.type === "string") {
|
|
8491
8490
|
return s.type;
|
|
8492
8491
|
}
|
|
8493
|
-
if (typeof s.tsType === "string") {
|
|
8494
|
-
const tsType = s.tsType;
|
|
8495
|
-
if (tsType.length > 30) {
|
|
8496
|
-
return `${tsType.slice(0, 27)}...`;
|
|
8497
|
-
}
|
|
8498
|
-
return tsType;
|
|
8499
|
-
}
|
|
8500
8492
|
return;
|
|
8501
8493
|
}
|
|
8502
8494
|
function hasSignatureChanged(oldMember, newMember) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doccov/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "DocCov SDK - Documentation coverage and drift detection for TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"dist"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@openpkg-ts/spec": "^0.
|
|
42
|
+
"@openpkg-ts/spec": "^0.11.0",
|
|
43
43
|
"@vercel/sandbox": "^1.0.3",
|
|
44
44
|
"mdast": "^3.0.0",
|
|
45
45
|
"minimatch": "^10.1.1",
|