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.dev/license
|
7 | */
|
8 | import { Observable } from 'rxjs';
|
9 | import { JsonObject, JsonValue } from '../utils';
|
10 | import { JsonSchemaVisitor, JsonVisitor } from './interface';
|
11 | import { JsonSchema } from './schema';
|
12 | export interface ReferenceResolver<ContextT> {
|
13 | (ref: string, context?: ContextT): {
|
14 | context?: ContextT;
|
15 | schema?: JsonObject;
|
16 | };
|
17 | }
|
18 | /**
|
19 | * Visit all the properties in a JSON object, allowing to transform them. It supports calling
|
20 | * properties synchronously or asynchronously (through Observables).
|
21 | * The original object can be mutated or replaced entirely. In case where it's replaced, the new
|
22 | * value is returned. When it's mutated though the original object will be changed.
|
23 | *
|
24 | * Please note it is possible to have an infinite loop here (which will result in a stack overflow)
|
25 | * if you return 2 objects that references each others (or the same object all the time).
|
26 | *
|
27 | * @param {JsonValue} json The Json value to visit.
|
28 | * @param {JsonVisitor} visitor A function that will be called on every items.
|
29 | * @param {JsonObject} schema A JSON schema to pass through to the visitor (where possible).
|
30 | * @param refResolver a function to resolve references in the schema.
|
31 | * @returns {Observable< | undefined>} The observable of the new root, if the root changed.
|
32 | */
|
33 | export declare function visitJson<ContextT>(json: JsonValue, visitor: JsonVisitor, schema?: JsonSchema, refResolver?: ReferenceResolver<ContextT>, context?: ContextT): Observable<JsonValue>;
|
34 | export declare function visitJsonSchema(schema: JsonSchema, visitor: JsonSchemaVisitor): void;
|