import type { Location } from '../ref-utils'; import type { ProblemSeverity, UserContext } from '../walk'; import type { Oas3PreprocessorsSet, SpecMajorVersion, Oas3DecoratorsSet, Oas2RuleSet, Oas2PreprocessorsSet, Oas2DecoratorsSet, Oas3RuleSet, SpecVersion, Async2PreprocessorsSet, Async2DecoratorsSet, Async2RuleSet, Async3PreprocessorsSet, Async3DecoratorsSet, Async3RuleSet, Arazzo1RuleSet, Arazzo1PreprocessorsSet, Arazzo1DecoratorsSet, RuleMap, Overlay1PreprocessorsSet, Overlay1DecoratorsSet, Overlay1RuleSet, } from '../oas-types'; import type { NodeType } from '../types'; import type { SkipFunctionContext } from '../visitors'; import type { JSONSchema } from 'json-schema-to-ts'; export type RuleSeverity = ProblemSeverity | 'off'; export type RuleSettings = { severity: RuleSeverity; message?: string }; export type PreprocessorSeverity = RuleSeverity | 'on'; export type RuleConfig = RuleSeverity | (Partial & Record); export type PreprocessorConfig = | PreprocessorSeverity | ({ severity?: ProblemSeverity; } & Record); export type DecoratorConfig = PreprocessorConfig; export type StyleguideRawConfig = { plugins?: (string | Plugin)[]; extends?: string[]; doNotResolveExamples?: boolean; recommendedFallback?: boolean; rules?: RuleMap; oas2Rules?: RuleMap; oas3_0Rules?: RuleMap; oas3_1Rules?: RuleMap; async2Rules?: RuleMap; async3Rules?: RuleMap; arazzo1Rules?: RuleMap; overlay1Rules?: RuleMap; preprocessors?: Record; oas2Preprocessors?: Record; oas3_0Preprocessors?: Record; oas3_1Preprocessors?: Record; async2Preprocessors?: Record; async3Preprocessors?: Record; arazzo1Preprocessors?: Record; overlay1Preprocessors?: Record; decorators?: Record; oas2Decorators?: Record; oas3_0Decorators?: Record; oas3_1Decorators?: Record; async2Decorators?: Record; async3Decorators?: Record; arazzo1Decorators?: Record; overlay1Decorators?: Record; }; export type ApiStyleguideRawConfig = Omit; export type ResolvedStyleguideConfig = PluginStyleguideConfig & { plugins?: Plugin[]; recommendedFallback?: boolean; extends?: void | never; extendPaths?: string[]; pluginPaths?: string[]; }; export type PreprocessorsConfig = { oas3?: Oas3PreprocessorsSet; oas2?: Oas2PreprocessorsSet; async2?: Async2PreprocessorsSet; async3?: Async3PreprocessorsSet; arazzo1?: Arazzo1PreprocessorsSet; overlay1?: Overlay1PreprocessorsSet; }; export type DecoratorsConfig = { oas3?: Oas3DecoratorsSet; oas2?: Oas2DecoratorsSet; async2?: Async2DecoratorsSet; async3?: Async3DecoratorsSet; arazzo1?: Arazzo1DecoratorsSet; overlay1?: Overlay1DecoratorsSet; }; export type TypesExtensionFn = ( types: Record, oasVersion: SpecVersion ) => Record; export type TypeExtensionsConfig = Partial>; export type RulesConfig = { oas3?: Oas3RuleSet; oas2?: Oas2RuleSet; async2?: Async2RuleSet; async3?: Async3RuleSet; arazzo1?: Arazzo1RuleSet; overlay1?: Overlay1RuleSet; }; export type CustomRulesConfig = RulesConfig; export type AssertionContext = Partial & SkipFunctionContext & { node: any }; export type AssertResult = { message?: string; location?: Location }; export type CustomFunction = ( value: any, options: unknown, baseLocation: Location ) => AssertResult[]; export type AssertionsConfig = Record; export type Plugin = { id: string; configs?: Record; rules?: RulesConfig; preprocessors?: PreprocessorsConfig; decorators?: DecoratorsConfig; typeExtension?: TypeExtensionsConfig; assertions?: AssertionsConfig; // Realm properties path?: string; absolutePath?: string; processContent?: (actions: any, content: any) => Promise | void; afterRoutesCreated?: (actions: any, content: any) => Promise | void; loaders?: Record< string, (path: string, context: any, reportError: (error: Error) => void) => Promise >; requiredEntitlements?: string[]; ssoConfigSchema?: JSONSchema; redoclyConfigSchema?: JSONSchema; ejectIgnore?: string[]; }; type PluginCreatorOptions = { contentDir: string; }; export type PluginCreator = (options: PluginCreatorOptions) => Plugin | Promise; export type ImportedPlugin = // ES Modules | { default?: PluginCreator; } // CommonJS | PluginCreator // Deprecated format | Plugin; export type PluginStyleguideConfig = Omit< StyleguideRawConfig, 'plugins' | 'extends' >; export type ResolveHeader = | { name: string; envVariable?: undefined; value: string; matches: string; } | { name: string; value?: undefined; envVariable: string; matches: string; }; export type RawResolveConfig = { http?: Partial; doNotResolveExamples?: boolean; }; export type HttpResolveConfig = { headers: ResolveHeader[]; // eslint-disable-next-line @typescript-eslint/ban-types customFetch?: Function; }; export type ResolveConfig = { http: HttpResolveConfig; }; export type Region = 'us' | 'eu'; export type Telemetry = 'on' | 'off'; export type AccessTokens = { [region in Region]?: string }; export type DeprecatedInRawConfig = { apiDefinitions?: Record; lint?: StyleguideRawConfig; styleguide?: StyleguideRawConfig; referenceDocs?: Record; apis?: Record; } & DeprecatedFeaturesConfig; export type Api = { root: string; output?: string; styleguide?: ApiStyleguideRawConfig; } & ThemeConfig; export type DeprecatedInApi = { lint?: ApiStyleguideRawConfig; } & DeprecatedFeaturesConfig; export type ResolvedApi = Omit & { styleguide: ResolvedStyleguideConfig; files?: string[]; }; export type RawConfig = { apis?: Record; styleguide?: StyleguideRawConfig; resolve?: RawResolveConfig; region?: Region; organization?: string; files?: string[]; telemetry?: Telemetry; } & ThemeConfig; // RawConfig is legacy, use RawUniversalConfig in public APIs export type RawUniversalConfig = Omit & StyleguideRawConfig; export type FlatApi = Omit & Omit; export type FlatRawConfig = Omit & Omit & { resolve?: RawResolveConfig; apis?: Record; } & ThemeRawConfig; export type ResolvedConfig = Omit & { apis: Record; styleguide: ResolvedStyleguideConfig; }; type DeprecatedFeaturesConfig = { 'features.openapi'?: Record; 'features.mockServer'?: Record; }; export type ThemeConfig = { theme?: ThemeRawConfig; }; export type ThemeRawConfig = { openapi?: Record; mockServer?: Record; }; // TODO: sync types export type RulesFields = | 'rules' | 'oas2Rules' | 'oas3_0Rules' | 'oas3_1Rules' | 'async2Rules' | 'async3Rules' | 'arazzo1Rules' | 'overlay1Rules' | 'preprocessors' | 'oas2Preprocessors' | 'oas3_0Preprocessors' | 'oas3_1Preprocessors' | 'async2Preprocessors' | 'async3Preprocessors' | 'arazzo1Preprocessors' | 'overlay1Preprocessors' | 'decorators' | 'oas2Decorators' | 'oas3_0Decorators' | 'oas3_1Decorators' | 'async2Decorators' | 'async3Decorators' | 'arazzo1Decorators' | 'overlay1Decorators';