@openpkg-ts/extract 0.14.4 → 0.15.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/bin/tspec.js +10 -9
- package/dist/shared/{chunk-axmbd6k1.js → chunk-0bt6mcnx.js} +703 -623
- package/dist/src/index.d.ts +38 -31
- package/dist/src/index.js +1 -1
- package/package.json +1 -1
package/dist/src/index.d.ts
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import { SpecType } from "@openpkg-ts/spec";
|
|
2
|
+
import ts2 from "typescript";
|
|
2
3
|
import ts from "typescript";
|
|
4
|
+
interface SerializerContext {
|
|
5
|
+
typeChecker: ts.TypeChecker;
|
|
6
|
+
program: ts.Program;
|
|
7
|
+
sourceFile: ts.SourceFile;
|
|
8
|
+
maxTypeDepth: number;
|
|
9
|
+
maxExternalTypeDepth: number;
|
|
10
|
+
currentDepth: number;
|
|
11
|
+
resolveExternalTypes: boolean;
|
|
12
|
+
typeRegistry: TypeRegistry;
|
|
13
|
+
exportedIds: Set<string>;
|
|
14
|
+
/** Track visited types to prevent infinite recursion */
|
|
15
|
+
visitedTypes: Set<ts.Type>;
|
|
16
|
+
}
|
|
3
17
|
declare class TypeRegistry {
|
|
4
18
|
private types;
|
|
5
19
|
private processing;
|
|
@@ -8,24 +22,31 @@ declare class TypeRegistry {
|
|
|
8
22
|
has(id: string): boolean;
|
|
9
23
|
getAll(): SpecType[];
|
|
10
24
|
/**
|
|
11
|
-
* Register a type from a ts.Type
|
|
25
|
+
* Register a type from a ts.Type with structured schema.
|
|
12
26
|
* Returns the type ID if registered, undefined if skipped.
|
|
13
27
|
*/
|
|
14
|
-
registerType(type:
|
|
28
|
+
registerType(type: ts2.Type, ctx: SerializerContext): string | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Build a SpecType with structured schema using buildSchema.
|
|
31
|
+
*/
|
|
32
|
+
private buildSpecType;
|
|
15
33
|
/**
|
|
16
|
-
*
|
|
34
|
+
* Check if schema is a self-referential $ref
|
|
17
35
|
*/
|
|
18
|
-
private
|
|
19
|
-
|
|
36
|
+
private isSelfRef;
|
|
37
|
+
/**
|
|
38
|
+
* Build object schema from type properties (for interfaces/classes)
|
|
39
|
+
*/
|
|
40
|
+
private buildObjectSchemaFromType;
|
|
20
41
|
}
|
|
21
42
|
import { SpecExample, SpecSource, SpecTag, SpecTypeParameter } from "@openpkg-ts/spec";
|
|
22
|
-
import
|
|
23
|
-
declare function getJSDocComment(node:
|
|
43
|
+
import ts3 from "typescript";
|
|
44
|
+
declare function getJSDocComment(node: ts3.Node): {
|
|
24
45
|
description?: string;
|
|
25
46
|
tags: SpecTag[];
|
|
26
47
|
examples: SpecExample[];
|
|
27
48
|
};
|
|
28
|
-
declare function getSourceLocation(node:
|
|
49
|
+
declare function getSourceLocation(node: ts3.Node, sourceFile: ts3.SourceFile): SpecSource;
|
|
29
50
|
/**
|
|
30
51
|
* Get description for a destructured parameter property from JSDoc @param tags.
|
|
31
52
|
* Matches patterns like:
|
|
@@ -33,16 +54,16 @@ declare function getSourceLocation(node: ts2.Node, sourceFile: ts2.SourceFile):
|
|
|
33
54
|
* - @param opts.paramName - dotted notation with alias
|
|
34
55
|
* - @param {type} paramName - type annotation format
|
|
35
56
|
*/
|
|
36
|
-
declare function getParamDescription(propertyName: string, jsdocTags: readonly
|
|
37
|
-
type DeclarationWithTypeParams =
|
|
57
|
+
declare function getParamDescription(propertyName: string, jsdocTags: readonly ts3.JSDocTag[], inferredAlias?: string): string | undefined;
|
|
58
|
+
type DeclarationWithTypeParams = ts3.FunctionDeclaration | ts3.ClassDeclaration | ts3.InterfaceDeclaration | ts3.TypeAliasDeclaration | ts3.MethodDeclaration | ts3.ArrowFunction;
|
|
38
59
|
/**
|
|
39
60
|
* Extract type parameters from declarations like `<T extends Base, K = Default>`
|
|
40
61
|
*/
|
|
41
|
-
declare function extractTypeParameters(node: DeclarationWithTypeParams, checker:
|
|
62
|
+
declare function extractTypeParameters(node: DeclarationWithTypeParams, checker: ts3.TypeChecker): SpecTypeParameter[] | undefined;
|
|
42
63
|
/**
|
|
43
64
|
* Check if a symbol is marked as deprecated via @deprecated JSDoc tag.
|
|
44
65
|
*/
|
|
45
|
-
declare function isSymbolDeprecated(symbol:
|
|
66
|
+
declare function isSymbolDeprecated(symbol: ts3.Symbol | undefined): boolean;
|
|
46
67
|
import { OpenPkg } from "@openpkg-ts/spec";
|
|
47
68
|
interface ExtractOptions {
|
|
48
69
|
entryFile: string;
|
|
@@ -71,17 +92,17 @@ interface Diagnostic {
|
|
|
71
92
|
};
|
|
72
93
|
}
|
|
73
94
|
declare function extract(options: ExtractOptions): Promise<ExtractResult>;
|
|
74
|
-
import
|
|
95
|
+
import ts4 from "typescript";
|
|
75
96
|
interface ProgramOptions {
|
|
76
97
|
entryFile: string;
|
|
77
98
|
baseDir?: string;
|
|
78
99
|
content?: string;
|
|
79
100
|
}
|
|
80
101
|
interface ProgramResult {
|
|
81
|
-
program:
|
|
82
|
-
compilerHost:
|
|
83
|
-
compilerOptions:
|
|
84
|
-
sourceFile?:
|
|
102
|
+
program: ts4.Program;
|
|
103
|
+
compilerHost: ts4.CompilerHost;
|
|
104
|
+
compilerOptions: ts4.CompilerOptions;
|
|
105
|
+
sourceFile?: ts4.SourceFile;
|
|
85
106
|
configPath?: string;
|
|
86
107
|
}
|
|
87
108
|
declare function createProgram({ entryFile, baseDir, content }: ProgramOptions): ProgramResult;
|
|
@@ -209,20 +230,6 @@ declare function extractStandardSchemas(compiledJsPath: string, options?: Extrac
|
|
|
209
230
|
declare function extractStandardSchemasFromProject(entryFile: string, baseDir: string, options?: ExtractStandardSchemasOptions): Promise<StandardSchemaExtractionOutput>;
|
|
210
231
|
import { SpecExport } from "@openpkg-ts/spec";
|
|
211
232
|
import ts5 from "typescript";
|
|
212
|
-
import ts4 from "typescript";
|
|
213
|
-
interface SerializerContext {
|
|
214
|
-
typeChecker: ts4.TypeChecker;
|
|
215
|
-
program: ts4.Program;
|
|
216
|
-
sourceFile: ts4.SourceFile;
|
|
217
|
-
maxTypeDepth: number;
|
|
218
|
-
maxExternalTypeDepth: number;
|
|
219
|
-
currentDepth: number;
|
|
220
|
-
resolveExternalTypes: boolean;
|
|
221
|
-
typeRegistry: TypeRegistry;
|
|
222
|
-
exportedIds: Set<string>;
|
|
223
|
-
/** Track visited types to prevent infinite recursion */
|
|
224
|
-
visitedTypes: Set<ts4.Type>;
|
|
225
|
-
}
|
|
226
233
|
declare function serializeClass(node: ts5.ClassDeclaration, ctx: SerializerContext): SpecExport | null;
|
|
227
234
|
import { SpecExport as SpecExport2 } from "@openpkg-ts/spec";
|
|
228
235
|
import ts6 from "typescript";
|
package/dist/src/index.js
CHANGED
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
serializeTypeAlias,
|
|
27
27
|
serializeVariable,
|
|
28
28
|
withDescription
|
|
29
|
-
} from "../shared/chunk-
|
|
29
|
+
} from "../shared/chunk-0bt6mcnx.js";
|
|
30
30
|
// src/schema/registry.ts
|
|
31
31
|
function isTypeReference(type) {
|
|
32
32
|
return !!(type.flags & 524288 && type.objectFlags && type.objectFlags & 4);
|