1 import type { AnySchema, AnySchemaObject, AnyValidateFunction, EvaluatedProperties, EvaluatedItems } from "../types";
2 import type Ajv from "../core";
3 import type { InstanceOptions } from "../core";
4 import { CodeGen, Name, Code, ValueScopeName } from "./codegen";
5 import { LocalRefs } from "./resolve";
6 import { JSONType } from "./rules";
7 export declare type SchemaRefs = {
8 [Ref in string]?: SchemaEnv | AnySchema;
10 export interface SchemaCxt {
11 readonly gen: CodeGen;
12 readonly allErrors?: boolean;
14 readonly parentData: Name;
15 readonly parentDataProperty: Code | number;
16 readonly dataNames: Name[];
17 readonly dataPathArr: (Code | number)[];
18 readonly dataLevel: number;
19 dataTypes: JSONType[];
20 definedProperties: Set<string>;
21 readonly topSchemaRef: Code;
22 readonly validateName: Name;
24 readonly ValidationError?: Name;
25 readonly schema: AnySchema;
26 readonly schemaEnv: SchemaEnv;
27 readonly rootId: string;
29 readonly schemaPath: Code;
30 readonly errSchemaPath: string;
31 readonly errorPath: Code;
32 readonly propertyName?: Name;
33 readonly compositeRule?: boolean;
34 props?: EvaluatedProperties | Name;
35 items?: EvaluatedItems | Name;
36 jtdDiscriminator?: string;
37 jtdMetadata?: boolean;
38 readonly createErrors?: boolean;
39 readonly opts: InstanceOptions;
42 export interface SchemaObjCxt extends SchemaCxt {
43 readonly schema: AnySchemaObject;
45 interface SchemaEnvArgs {
46 readonly schema: AnySchema;
47 readonly root?: SchemaEnv;
48 readonly baseId?: string;
49 readonly schemaPath?: string;
50 readonly localRefs?: LocalRefs;
51 readonly meta?: boolean;
53 export declare class SchemaEnv implements SchemaEnvArgs {
54 readonly schema: AnySchema;
55 readonly root: SchemaEnv;
58 localRefs?: LocalRefs;
59 readonly meta?: boolean;
60 readonly $async?: boolean;
61 readonly refs: SchemaRefs;
62 readonly dynamicAnchors: {
63 [Ref in string]?: true;
65 validate?: AnyValidateFunction;
66 validateName?: ValueScopeName;
67 serialize?: (data: unknown) => string;
68 serializeName?: ValueScopeName;
69 parse?: (data: string) => unknown;
70 parseName?: ValueScopeName;
71 constructor(env: SchemaEnvArgs);
73 export declare function compileSchema(this: Ajv, sch: SchemaEnv): SchemaEnv;
74 export declare function resolveRef(this: Ajv, root: SchemaEnv, baseId: string, ref: string): AnySchema | SchemaEnv | undefined;
75 export declare function getCompilingSchema(this: Ajv, schEnv: SchemaEnv): SchemaEnv | void;
76 export declare function resolveSchema(this: Ajv, root: SchemaEnv, // root object with properties schema, refs TODO below SchemaEnv is assigned to it
77 ref: string): SchemaEnv | undefined;