.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / table / node_modules / ajv / dist / types / index.d.ts
1 import type { CodeGen, Code, Name, ScopeValueSets, ValueScopeName } from "../compile/codegen";
2 import type { SchemaEnv, SchemaCxt, SchemaObjCxt } from "../compile";
3 import type { JSONType } from "../compile/rules";
4 import type { KeywordCxt } from "../compile/validate";
5 import type Ajv from "../core";
6 interface _SchemaObject {
7     $id?: string;
8     $schema?: string;
9     [x: string]: any;
10 }
11 export interface SchemaObject extends _SchemaObject {
12     $id?: string;
13     $schema?: string;
14     $async?: false;
15     [x: string]: any;
16 }
17 export interface AsyncSchema extends _SchemaObject {
18     $async: true;
19 }
20 export declare type AnySchemaObject = SchemaObject | AsyncSchema;
21 export declare type Schema = SchemaObject | boolean;
22 export declare type AnySchema = Schema | AsyncSchema;
23 export declare type SchemaMap = {
24     [Key in string]?: AnySchema;
25 };
26 export interface SourceCode {
27     validateName: ValueScopeName;
28     validateCode: string;
29     scopeValues: ScopeValueSets;
30     evaluated?: Code;
31 }
32 export interface DataValidationCxt<T extends string | number = string | number> {
33     instancePath: string;
34     parentData: {
35         [K in T]: any;
36     };
37     parentDataProperty: T;
38     rootData: Record<string, any> | any[];
39     dynamicAnchors: {
40         [Ref in string]?: ValidateFunction;
41     };
42 }
43 export interface ValidateFunction<T = unknown> {
44     (this: Ajv | any, data: any, dataCxt?: DataValidationCxt): data is T;
45     errors?: null | ErrorObject[];
46     evaluated?: Evaluated;
47     schema: AnySchema;
48     schemaEnv: SchemaEnv;
49     source?: SourceCode;
50 }
51 export interface JTDParser<T = unknown> {
52     (json: string): T | undefined;
53     message?: string;
54     position?: number;
55 }
56 export declare type EvaluatedProperties = {
57     [K in string]?: true;
58 } | true;
59 export declare type EvaluatedItems = number | true;
60 export interface Evaluated {
61     props?: EvaluatedProperties;
62     items?: EvaluatedItems;
63     dynamicProps: boolean;
64     dynamicItems: boolean;
65 }
66 export interface AsyncValidateFunction<T = unknown> extends ValidateFunction<T> {
67     (...args: Parameters<ValidateFunction<T>>): Promise<T>;
68     $async: true;
69 }
70 export declare type AnyValidateFunction<T = any> = ValidateFunction<T> | AsyncValidateFunction<T>;
71 export interface ErrorObject<K extends string = string, P = Record<string, any>, S = unknown> {
72     keyword: K;
73     instancePath: string;
74     schemaPath: string;
75     params: P;
76     propertyName?: string;
77     message?: string;
78     schema?: S;
79     parentSchema?: AnySchemaObject;
80     data?: unknown;
81 }
82 export declare type ErrorNoParams<K extends string, S = unknown> = ErrorObject<K, Record<string, never>, S>;
83 interface _KeywordDef {
84     keyword: string | string[];
85     type?: JSONType | JSONType[];
86     schemaType?: JSONType | JSONType[];
87     allowUndefined?: boolean;
88     $data?: boolean;
89     implements?: string[];
90     before?: string;
91     post?: boolean;
92     metaSchema?: AnySchemaObject;
93     validateSchema?: AnyValidateFunction;
94     dependencies?: string[];
95     error?: KeywordErrorDefinition;
96     $dataError?: KeywordErrorDefinition;
97 }
98 export interface CodeKeywordDefinition extends _KeywordDef {
99     code: (cxt: KeywordCxt, ruleType?: string) => void;
100     trackErrors?: boolean;
101 }
102 export declare type MacroKeywordFunc = (schema: any, parentSchema: AnySchemaObject, it: SchemaCxt) => AnySchema;
103 export declare type CompileKeywordFunc = (schema: any, parentSchema: AnySchemaObject, it: SchemaObjCxt) => DataValidateFunction;
104 export interface DataValidateFunction {
105     (...args: Parameters<ValidateFunction>): boolean | Promise<any>;
106     errors?: Partial<ErrorObject>[];
107 }
108 export interface SchemaValidateFunction {
109     (schema: any, data: any, parentSchema?: AnySchemaObject, dataCxt?: DataValidationCxt): boolean | Promise<any>;
110     errors?: Partial<ErrorObject>[];
111 }
112 export interface FuncKeywordDefinition extends _KeywordDef {
113     validate?: SchemaValidateFunction | DataValidateFunction;
114     compile?: CompileKeywordFunc;
115     schema?: boolean;
116     modifying?: boolean;
117     async?: boolean;
118     valid?: boolean;
119     errors?: boolean | "full";
120 }
121 export interface MacroKeywordDefinition extends FuncKeywordDefinition {
122     macro: MacroKeywordFunc;
123 }
124 export declare type KeywordDefinition = CodeKeywordDefinition | FuncKeywordDefinition | MacroKeywordDefinition;
125 export declare type AddedKeywordDefinition = KeywordDefinition & {
126     type: JSONType[];
127     schemaType: JSONType[];
128 };
129 export interface KeywordErrorDefinition {
130     message: string | Code | ((cxt: KeywordErrorCxt) => string | Code);
131     params?: Code | ((cxt: KeywordErrorCxt) => Code);
132 }
133 export declare type Vocabulary = (KeywordDefinition | string)[];
134 export interface KeywordErrorCxt {
135     gen: CodeGen;
136     keyword: string;
137     data: Name;
138     $data?: string | false;
139     schema: any;
140     parentSchema?: AnySchemaObject;
141     schemaCode: Code | number | boolean;
142     schemaValue: Code | number | boolean;
143     schemaType?: JSONType[];
144     errsCount?: Name;
145     params: KeywordCxtParams;
146     it: SchemaCxt;
147 }
148 export declare type KeywordCxtParams = {
149     [P in string]?: Code | string | number;
150 };
151 export declare type FormatValidator<T extends string | number> = (data: T) => boolean;
152 export declare type FormatCompare<T extends string | number> = (data1: T, data2: T) => number | undefined;
153 export declare type AsyncFormatValidator<T extends string | number> = (data: T) => Promise<boolean>;
154 export interface FormatDefinition<T extends string | number> {
155     type?: T extends string ? "string" | undefined : "number";
156     validate: FormatValidator<T> | (T extends string ? string | RegExp : never);
157     async?: false | undefined;
158     compare?: FormatCompare<T>;
159 }
160 export interface AsyncFormatDefinition<T extends string | number> {
161     type?: T extends string ? "string" | undefined : "number";
162     validate: AsyncFormatValidator<T>;
163     async: true;
164     compare?: FormatCompare<T>;
165 }
166 export declare type AddedFormat = true | RegExp | FormatValidator<string> | FormatDefinition<string> | FormatDefinition<number> | AsyncFormatDefinition<string> | AsyncFormatDefinition<number>;
167 export declare type Format = AddedFormat | string;
168 export {};