import { ModelRenderer } from './renderer'; import { ParsedMeshRAML, ModelMap, Endpoint, ObjectProperty, PropertyDefinition, CombinedResponseInfo, Parameter } from '../interfaces'; export declare const defaultOptions: { addEndpointList: boolean; emitIntegerAs: string; emitInterfacesAsReadonly: boolean; emitRequestExamples: boolean; emitRequestURLs: boolean; emitResponseExamples: boolean; endpointInterface: string; indentation: string; interfacePrefix: string; interfaceSuffix: string; maxLineLength: number; methodSortOrder: ("GET" | "POST" | "PATCH" | "PUT" | "DELETE")[]; sortInterfaces: boolean; sortKeys: boolean; }; export declare type Options = typeof defaultOptions; export declare type ModelFilter = (model: ObjectProperty, modelMap: ModelMap) => boolean; /** * Renders the request/response models as TypeScript interfaces. */ export declare class TypescriptModelRenderer implements ModelRenderer { options: Options; constructor(options?: Partial); renderAll(raml: ParsedMeshRAML): Promise; protected fileHead(version: string): Promise; /** * Generate a TypeScript interface that lists all API endpoints and their request & response models. */ generateEndpointList(raml: ParsedMeshRAML): Promise; protected groupEndpointsByMethod(endpoints: Endpoint[]): { [method: string]: Endpoint[]; }; protected groupEndpointsByUrl(endpoints: Endpoint[]): { [url: string]: Endpoint[]; }; protected formatEndpointInterface(endpoint: Endpoint): Promise; /** Formats url parameters / query parameters / form parameters as TypeScript interface. */ protected formatParameters(paramMap: { [key: string]: Parameter; } | undefined, resultKey?: string): string[]; /** * Generate the TypeScript interfaces for all models in the parsed RAML input. * @param raml The parsed mesh raml, output by `MeshRamlParser`. * @param filter A filter function similar to Array.prototype.filter. */ generateInterfaces(raml: ParsedMeshRAML, filter: ModelFilter): Promise; /** * Returns a list of all endpoints that return the passed schema as Response for any status code. */ protected endpointsWithResponseType(schema: PropertyDefinition, endpoints: Endpoint[]): CombinedResponseInfo[]; /** * Generate the output interface name of a model reference. * * @param {string} schemaRef The full name of the referenced model, * e.g. "urn:jsonschema:com:gentics:mesh:core:rest:user:UserCreateRequest" */ protected generateModelName(schemaRef: string): string; /** * Format an interface name with prefix and suffix. * Can be overwritten by the consuming code to add conditional logic. * * @param {string} shortName The short name of the referenced model, * e.g. "UserCreateRequest" * @param {string} fullSchemaRef The full name of the referenced model, * e.g. "urn:jsonschema:com:gentics:mesh:core:rest:user:UserCreateRequest" */ protected formatModelName(shortName: string, fullSchemaRef: string): string; /** Format a request example as a string for a JsDoc comment. */ protected formatRequestExample(responseExample: object): Promise; /** Format a response example as a string for a JsDoc comment. */ protected formatResponseExample(responseExample: object): Promise; /** Returns lines representing a JsDoc comment for the passed information */ protected generateJsDoc({description, defaultValue, example, responses}: { description?: string; defaultValue?: any; example?: string; responses?: CombinedResponseInfo[]; }): string[]; /** Indent lines of text with the indentation provided in the renderer options */ protected indent(text: string[]): string[]; /** * Sort a list of responses by (method -> url). * Can be overwritten by the consuming code to add additional logic. */ protected sortEndpointsForJsDoc(list: CombinedResponseInfo[]): CombinedResponseInfo[]; protected renderTypescriptProperties(props: { [name: string]: PropertyDefinition; }): Promise; protected renderTypescriptPropertyDefinition(prop: PropertyDefinition): Promise; }