1 | import * as ts from "typescript";
|
2 | import { JSONSchema7 } from "json-schema";
|
3 | export { Program, CompilerOptions, Symbol } from "typescript";
|
4 | export declare function getDefaultArgs(): Args;
|
5 | export type ValidationKeywords = {
|
6 | [prop: string]: boolean;
|
7 | };
|
8 | export type Args = {
|
9 | ref: boolean;
|
10 | aliasRef: boolean;
|
11 | topRef: boolean;
|
12 | titles: boolean;
|
13 | defaultProps: boolean;
|
14 | noExtraProps: boolean;
|
15 | propOrder: boolean;
|
16 | typeOfKeyword: boolean;
|
17 | required: boolean;
|
18 | strictNullChecks: boolean;
|
19 | esModuleInterop: boolean;
|
20 | skipLibCheck: boolean;
|
21 | ignoreErrors: boolean;
|
22 | experimentalDecorators: boolean;
|
23 | out: string;
|
24 | validationKeywords: string[];
|
25 | include: string[];
|
26 | excludePrivate: boolean;
|
27 | uniqueNames: boolean;
|
28 | rejectDateType: boolean;
|
29 | id: string;
|
30 | defaultNumberType: "number" | "integer";
|
31 | tsNodeRegister: boolean;
|
32 | constAsEnum: boolean;
|
33 | };
|
34 | export type PartialArgs = Partial<Args>;
|
35 | export type PrimitiveType = number | boolean | string | null;
|
36 | type RedefinedFields = "items" | "additionalItems" | "contains" | "properties" | "patternProperties" | "additionalProperties" | "dependencies" | "propertyNames" | "if" | "then" | "else" | "allOf" | "anyOf" | "oneOf" | "not" | "definitions";
|
37 | export type DefinitionOrBoolean = Definition | boolean;
|
38 | export interface Definition extends Omit<JSONSchema7, RedefinedFields> {
|
39 | propertyOrder?: string[];
|
40 | defaultProperties?: string[];
|
41 | typeof?: "function";
|
42 | items?: DefinitionOrBoolean | DefinitionOrBoolean[];
|
43 | additionalItems?: DefinitionOrBoolean;
|
44 | contains?: JSONSchema7;
|
45 | properties?: {
|
46 | [key: string]: DefinitionOrBoolean;
|
47 | };
|
48 | patternProperties?: {
|
49 | [key: string]: DefinitionOrBoolean;
|
50 | };
|
51 | additionalProperties?: DefinitionOrBoolean;
|
52 | dependencies?: {
|
53 | [key: string]: DefinitionOrBoolean | string[];
|
54 | };
|
55 | propertyNames?: DefinitionOrBoolean;
|
56 | if?: DefinitionOrBoolean;
|
57 | then?: DefinitionOrBoolean;
|
58 | else?: DefinitionOrBoolean;
|
59 | allOf?: DefinitionOrBoolean[];
|
60 | anyOf?: DefinitionOrBoolean[];
|
61 | oneOf?: DefinitionOrBoolean[];
|
62 | not?: DefinitionOrBoolean;
|
63 | definitions?: {
|
64 | [key: string]: DefinitionOrBoolean;
|
65 | };
|
66 | }
|
67 | export type SymbolRef = {
|
68 | name: string;
|
69 | typeName: string;
|
70 | fullyQualifiedName: string;
|
71 | symbol: ts.Symbol;
|
72 | };
|
73 | export declare function regexRequire(value: string): RegExpExecArray | null;
|
74 | export declare class JsonSchemaGenerator {
|
75 | private args;
|
76 | private tc;
|
77 | private symbols;
|
78 | private allSymbols;
|
79 | private userSymbols;
|
80 | private inheritingTypes;
|
81 | private reffedDefinitions;
|
82 | private schemaOverrides;
|
83 | private userValidationKeywords;
|
84 | private constAsEnum;
|
85 | private typeNamesById;
|
86 | private typeIdsByName;
|
87 | constructor(symbols: SymbolRef[], allSymbols: {
|
88 | [name: string]: ts.Type;
|
89 | }, userSymbols: {
|
90 | [name: string]: ts.Symbol;
|
91 | }, inheritingTypes: {
|
92 | [baseName: string]: string[];
|
93 | }, tc: ts.TypeChecker, args?: Args);
|
94 | get ReffedDefinitions(): {
|
95 | [key: string]: Definition;
|
96 | };
|
97 | private isFromDefaultLib;
|
98 | private resetSchemaSpecificProperties;
|
99 | private parseCommentsIntoDefinition;
|
100 | private getDefinitionForRootType;
|
101 | private getReferencedTypeSymbol;
|
102 | private getDefinitionForProperty;
|
103 | private getEnumDefinition;
|
104 | private getUnionDefinition;
|
105 | private getIntersectionDefinition;
|
106 | private getClassDefinition;
|
107 | private getTypeName;
|
108 | private makeTypeNameUnique;
|
109 | private recursiveTypeRef;
|
110 | private getTypeDefinition;
|
111 | setSchemaOverride(symbolName: string, schema: Definition): void;
|
112 | getSchemaForSymbol(symbolName: string, includeReffedDefinitions?: boolean, includeAllOverrides?: boolean): Definition;
|
113 | getSchemaForSymbols(symbolNames: string[], includeReffedDefinitions?: boolean, includeAllOverrides?: boolean): Definition;
|
114 | getSymbols(name?: string): SymbolRef[];
|
115 | getUserSymbols(): string[];
|
116 | getMainFileSymbols(program: ts.Program, onlyIncludeFiles?: string[]): string[];
|
117 | }
|
118 | export declare function getProgramFromFiles(files: string[], jsonCompilerOptions?: any, basePath?: string): ts.Program;
|
119 | export declare function buildGenerator(program: ts.Program, args?: PartialArgs, onlyIncludeFiles?: string[]): JsonSchemaGenerator | null;
|
120 | export declare function generateSchema(program: ts.Program, fullTypeName: string, args?: PartialArgs, onlyIncludeFiles?: string[], externalGenerator?: JsonSchemaGenerator): Definition | null;
|
121 | export declare function programFromConfig(configFileName: string, onlyIncludeFiles?: string[]): ts.Program;
|
122 | export declare function exec(filePattern: string, fullTypeName: string, args?: Args): Promise<void>;
|