UNPKG

@eagleoutice/flowr-dev

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

53 lines (52 loc) 2.84 kB
import type Joi from 'joi'; import { type OutputFormatter } from './text/ansi'; interface SchemaLine { level: number; text: string; } /** the leaf type, description, and any enumerated valid values of a schema path */ export interface SchemaPathInfo { readonly type?: string; readonly description?: string; readonly valids?: readonly unknown[]; } /** walk a Joi schema {@link Joi.Description|description} down a key path, returning the leaf's {@link SchemaPathInfo} (empty if the path does not exist) */ export declare function descriptionPathInfo(description: Joi.Description, path: readonly string[]): SchemaPathInfo; /** {@link descriptionPathInfo} straight from a schema (describes it once per call) */ export declare function schemaPathInfo(schema: Joi.Schema, path: readonly string[]): SchemaPathInfo; /** * The first path segment the schema does not accept, with the keys that ARE accepted there and the path to that * point -- or `undefined` when the whole path is a settable key. Used to reject typo'd config keys. A `.pattern()` * object accepts any key (validation continues into its value schema) and an `.unknown(true)` object (e.g. a * `specializeConfig` entry, which may overwrite any config key) accepts any key, so neither is reported as unknown. */ export declare function firstUnknownSchemaSegment(description: Joi.Description, path: readonly string[]): { readonly segment: string; readonly available: readonly string[]; readonly at: readonly string[]; } | undefined; /** * The keys a schema {@link Joi.Description|description} offers below `path`, i.e. every option that may be set there. * In contrast to the keys of a value, this covers the optional ones that are unset as well. */ export declare function descriptionPathKeys(description: Joi.Description, path: readonly string[]): string[]; /** every settable path in a schema description, intermediate objects included */ export declare function descriptionPaths(description: Joi.Description, path?: readonly string[]): string[][]; /** * Describes a Joi schema in a human-readable way. */ export declare function describeSchema(schema: Joi.Schema, f?: OutputFormatter): string; /** * Provides a generic description for any Joi schema. * You probably want to use {@link describeSchema}. */ export declare function genericDescription(level: number, formatter: OutputFormatter, name: string, desc: Joi.Description | undefined): SchemaLine[]; /** * Creates the header line(s) for a schema description. */ export declare function headerLine(level: number, formatter: OutputFormatter, name: string, type: string, flags: object | undefined): SchemaLine[]; /** * Describes a Joi object schema. */ export declare function describeObject(level: number, formatter: OutputFormatter, desc: Joi.Description): SchemaLine[]; export {};