UNPKG

3.77 kBTypeScriptView Raw
1import * as ts from "typescript";
2export { Program, CompilerOptions, Symbol } from "typescript";
3export declare function getDefaultArgs(): Args;
4export declare type ValidationKeywords = {
5 [prop: string]: boolean;
6};
7export declare type Args = {
8 ref: boolean;
9 aliasRef: boolean;
10 topRef: boolean;
11 titles: boolean;
12 defaultProps: boolean;
13 noExtraProps: boolean;
14 propOrder: boolean;
15 typeOfKeyword: boolean;
16 required: boolean;
17 strictNullChecks: boolean;
18 ignoreErrors: boolean;
19 out: string;
20 validationKeywords: string[];
21 include: string[];
22 excludePrivate: boolean;
23 uniqueNames: boolean;
24 rejectDateType: boolean;
25 id: string;
26};
27export declare type PartialArgs = Partial<Args>;
28export declare type PrimitiveType = number | boolean | string | null;
29export declare type Definition = {
30 $ref?: string;
31 $schema?: string;
32 $id?: string;
33 description?: string;
34 allOf?: Definition[];
35 oneOf?: Definition[];
36 anyOf?: Definition[];
37 title?: string;
38 type?: string | string[];
39 definitions?: {
40 [key: string]: any;
41 };
42 format?: string;
43 items?: Definition | Definition[];
44 minItems?: number;
45 additionalItems?: {
46 anyOf: Definition[];
47 } | Definition;
48 enum?: PrimitiveType[] | Definition[];
49 default?: PrimitiveType | Object;
50 additionalProperties?: Definition | boolean;
51 required?: string[];
52 propertyOrder?: string[];
53 properties?: {
54 [key: string]: any;
55 };
56 defaultProperties?: string[];
57 patternProperties?: {
58 [pattern: string]: Definition;
59 };
60 typeof?: "function";
61};
62export declare type SymbolRef = {
63 name: string;
64 typeName: string;
65 fullyQualifiedName: string;
66 symbol: ts.Symbol;
67};
68export declare class JsonSchemaGenerator {
69 private args;
70 private tc;
71 private symbols;
72 private allSymbols;
73 private userSymbols;
74 private inheritingTypes;
75 private reffedDefinitions;
76 private userValidationKeywords;
77 private typeNamesById;
78 private typeNamesUsed;
79 constructor(symbols: SymbolRef[], allSymbols: {
80 [name: string]: ts.Type;
81 }, userSymbols: {
82 [name: string]: ts.Symbol;
83 }, inheritingTypes: {
84 [baseName: string]: string[];
85 }, tc: ts.TypeChecker, args?: Args);
86 readonly ReffedDefinitions: {
87 [key: string]: Definition;
88 };
89 private parseCommentsIntoDefinition;
90 private getDefinitionForRootType;
91 private getReferencedTypeSymbol;
92 private getDefinitionForProperty;
93 private getEnumDefinition;
94 private getUnionDefinition;
95 private getIntersectionDefinition;
96 private getClassDefinition;
97 private getTypeName;
98 private getTypeDefinition;
99 setSchemaOverride(symbolName: string, schema: Definition): void;
100 getSchemaForSymbol(symbolName: string, includeReffedDefinitions?: boolean): Definition;
101 getSchemaForSymbols(symbolNames: string[], includeReffedDefinitions?: boolean): Definition;
102 getSymbols(name?: string): SymbolRef[];
103 getUserSymbols(): string[];
104 getMainFileSymbols(program: ts.Program, onlyIncludeFiles?: string[]): string[];
105}
106export declare function getProgramFromFiles(files: string[], jsonCompilerOptions?: any, basePath?: string): ts.Program;
107export declare function buildGenerator(program: ts.Program, args?: PartialArgs, onlyIncludeFiles?: string[]): JsonSchemaGenerator | null;
108export declare function generateSchema(program: ts.Program, fullTypeName: string, args?: PartialArgs, onlyIncludeFiles?: string[]): Definition | null;
109export declare function programFromConfig(configFileName: string, onlyIncludeFiles?: string[]): ts.Program;
110export declare function exec(filePattern: string, fullTypeName: string, args?: Args): void;