UNPKG

boats

Version:

Beautiful Open / Async Template System - Write less yaml with BOATS and Nunjucks.

67 lines (66 loc) 3.23 kB
import 'ts-replace-all'; import { BoatsRC } from './interfaces/BoatsRc'; import { PathInjector } from './pathInjector'; declare class Injector { fileToRouteMap: any; constructor(); /** * Render the base template and inject content if provided */ injectAndRender(inputPath: string, inputIndexYaml: string, boatsRc: BoatsRC, isAsyncApi: boolean): string; /** * Merge the JSON from the YAML with the JSON injection content * * @param {object} jsonTemplate JSON representation of the YAML file * @param {string} relativePathToRoot Path from current file to root index (../ repeated) * @param {PathInjector} injector Converts shorthand absolute paths to absolutes * @param {object} content Content to be injected * * @return {object} Merged JSON of the template */ mergeInjection(jsonTemplate: any, relativePathToRoot: string, injector: PathInjector, content: string | any): any; buildInjectRuleObject(injection: any): any; shouldSkipMethod(injectRule: any, method: string): boolean; /** * Checks if the content should be injected * * @param {object} injection Injection rule * @param {string} inputPath Path to target file * * @param {object} picomatchOptions node_modules/@types/picomatch/index.d.ts PicomatchOptions not exported from the types * @return {boolean} True if the path satisfies the rule */ shouldInject(injection: any, inputPath: string, picomatchOptions: any): boolean; /** * Returns false when the channel should not be injected into * else returns true */ shouldInjectToChannels(operationName: string, injectRule: any, methodName: string, picomatchOptions: any): boolean; /** * Returns false when the path should not be injected into * else returns true * * @param operationName The URL path (Open API) or the Channel path (Async API) * @param injectRule The injection rule, defined in th injection tpl helper * @param methodName The name of the method, Open API in BOATS, the file name is the method name, eg something/get.yml.. GET == method * @param picomatchOptions The https://www.npmjs.com/package/picomatch options (injected via the boatsrc) */ shouldInjectToPaths(operationName: string, injectRule: any, methodName: string, picomatchOptions: any): boolean; /** * Pico matching the path against the rules in the inject object * @param needle * @param haystack * @param picoOptions node_modules/@types/picomatch/index.d.ts PicomatchOptions not exported from the types * @param currentMethod */ globCheck(needle: string, haystack: any[], picoOptions: any, currentMethod: string): boolean; /** * Map filenames to routes so that exclude paths can be * calculated from the input filename */ mapPathIndex(yaml: string, inputPath: string): void; mapChannelIndex(yaml: string, inputPath: string): void; convertRootRefToRelative(content: string, relativePathToRoot: string, injector: PathInjector): string; } declare const _default: Injector; export default _default;