1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { ValidateFunction } from 'ajv';
|
---|
9 | import { Observable } from 'rxjs';
|
---|
10 | import { BaseException } from '../../exception/exception';
|
---|
11 | import { JsonObject } from '../interface';
|
---|
12 | import { JsonVisitor, PromptProvider, SchemaFormat, SchemaRegistry, SchemaValidator, SchemaValidatorError, SmartDefaultProvider } from './interface';
|
---|
13 | import { JsonSchema } from './schema';
|
---|
14 | export declare type UriHandler = (uri: string) => Observable<JsonObject> | Promise<JsonObject> | null | undefined;
|
---|
15 | export declare class SchemaValidationException extends BaseException {
|
---|
16 | readonly errors: SchemaValidatorError[];
|
---|
17 | constructor(errors?: SchemaValidatorError[], baseMessage?: string);
|
---|
18 | static createMessages(errors?: SchemaValidatorError[]): string[];
|
---|
19 | }
|
---|
20 | export declare class CoreSchemaRegistry implements SchemaRegistry {
|
---|
21 | private _ajv;
|
---|
22 | private _uriCache;
|
---|
23 | private _uriHandlers;
|
---|
24 | private _pre;
|
---|
25 | private _post;
|
---|
26 | private _currentCompilationSchemaInfo?;
|
---|
27 | private _smartDefaultKeyword;
|
---|
28 | private _promptProvider?;
|
---|
29 | private _sourceMap;
|
---|
30 | constructor(formats?: SchemaFormat[]);
|
---|
31 | private _fetch;
|
---|
32 | /**
|
---|
33 | * Add a transformation step before the validation of any Json.
|
---|
34 | * @param {JsonVisitor} visitor The visitor to transform every value.
|
---|
35 | * @param {JsonVisitor[]} deps A list of other visitors to run before.
|
---|
36 | */
|
---|
37 | addPreTransform(visitor: JsonVisitor, deps?: JsonVisitor[]): void;
|
---|
38 | /**
|
---|
39 | * Add a transformation step after the validation of any Json. The JSON will not be validated
|
---|
40 | * after the POST, so if transformations are not compatible with the Schema it will not result
|
---|
41 | * in an error.
|
---|
42 | * @param {JsonVisitor} visitor The visitor to transform every value.
|
---|
43 | * @param {JsonVisitor[]} deps A list of other visitors to run before.
|
---|
44 | */
|
---|
45 | addPostTransform(visitor: JsonVisitor, deps?: JsonVisitor[]): void;
|
---|
46 | protected _resolver(ref: string, validate?: ValidateFunction): {
|
---|
47 | context?: ValidateFunction;
|
---|
48 | schema?: JsonObject;
|
---|
49 | };
|
---|
50 | /**
|
---|
51 | * Flatten the Schema, resolving and replacing all the refs. Makes it into a synchronous schema
|
---|
52 | * that is also easier to traverse. Does not cache the result.
|
---|
53 | *
|
---|
54 | * @param schema The schema or URI to flatten.
|
---|
55 | * @returns An Observable of the flattened schema object.
|
---|
56 | * @deprecated since 11.2 without replacement.
|
---|
57 | * Producing a flatten schema document does not in all cases produce a schema with identical behavior to the original.
|
---|
58 | * See: https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.appendix.B.2
|
---|
59 | */
|
---|
60 | flatten(schema: JsonObject): Observable<JsonObject>;
|
---|
61 | private _flatten;
|
---|
62 | /**
|
---|
63 | * Compile and return a validation function for the Schema.
|
---|
64 | *
|
---|
65 | * @param schema The schema to validate. If a string, will fetch the schema before compiling it
|
---|
66 | * (using schema as a URI).
|
---|
67 | * @returns An Observable of the Validation function.
|
---|
68 | */
|
---|
69 | compile(schema: JsonSchema): Observable<SchemaValidator>;
|
---|
70 | private _compile;
|
---|
71 | addFormat(format: SchemaFormat): void;
|
---|
72 | addSmartDefaultProvider<T>(source: string, provider: SmartDefaultProvider<T>): void;
|
---|
73 | registerUriHandler(handler: UriHandler): void;
|
---|
74 | usePromptProvider(provider: PromptProvider): void;
|
---|
75 | private _applyPrompts;
|
---|
76 | private static _set;
|
---|
77 | private _applySmartDefaults;
|
---|
78 | useXDeprecatedProvider(onUsage: (message: string) => void): void;
|
---|
79 | /**
|
---|
80 | * Workaround to avoid a breaking change in downstream schematics.
|
---|
81 | * @deprecated will be removed in version 13.
|
---|
82 | */
|
---|
83 | private _replaceDeprecatedSchemaIdKeyword;
|
---|
84 | private normalizeDataPathArr;
|
---|
85 | }
|
---|