UNPKG

2.46 kBTypeScriptView Raw
1/// <reference types="node" />
2import { IDiagnostic } from '@stoplight/types';
3import { INotifier } from '../notifier/types';
4import { ITraceData } from '../types';
5import { IGraphDom, IGraphPatch, JsonPatch, SourceNodeProp } from './dom';
6import { INodeTree, NodeInstance, NodeWithOptionalId } from './nodes';
7import { IDehydratedGraph, IdGenerator, IdGeneratorWrapper, IGraph, IPatchableGraph } from './types';
8export interface IGraphProps {
9 id: string;
10 idGenerator?: IdGenerator;
11 notifier: INotifier;
12}
13export declare function createGraph(props: IGraphProps): Graph;
14declare class Graph implements IGraph {
15 id: string;
16 dom: IGraphDom;
17 private _idGenerator;
18 private sourceNodeService;
19 notifier: INotifier;
20 constructor(props: IGraphProps);
21 readonly nodeValues: NodeInstance[];
22 readonly sourceNodes: import("./nodes").ISourceNodeInstance<Object>[];
23 readonly virtualNodes: import("./nodes").IVirtualNodeInstance[];
24 readonly rootNodes: import("./nodes").ISourceNodeInstance<Object>[];
25 getNodeById: (id: string) => NodeInstance;
26 getNodeByUri: (uri: string) => NodeInstance;
27 getNodesByType: (type: string) => NodeInstance[];
28 applyPatch(patch: IGraphPatch): import("./dom").IGraphPatchResult<import("./dom").GraphOperationResult<import("./dom").GraphOperation<D>>>;
29 addNode(node: NodeWithOptionalId, trace?: ITraceData): NodeInstance;
30 setSourceNodeDiagnostics(id: string, source: string, diagnostics: IDiagnostic[], trace?: ITraceData): void;
31 setSourceNodeProp(id: string, prop: SourceNodeProp, value: unknown, trace?: ITraceData): void;
32 reportError(nodeId: string, error: NodeJS.ErrnoException, trace?: ITraceData): void;
33 patchSourceNodeProp(id: string, prop: SourceNodeProp, value: JsonPatch, trace?: ITraceData): void;
34 moveNode(id: string, newParentId?: string | null, newPath?: string, trace?: ITraceData): void;
35 removeNode(id: string, trace?: ITraceData): void;
36 printTree(): string;
37 dehydrate(): IDehydratedGraph;
38 dispose(): void;
39 private getNodeByPathWithParent;
40}
41export declare const addNodeTree: ((helpers: Pick<IPatchableGraph, "addNode">, tree: INodeTree[], parentId?: string | undefined) => void) & import("mobx").IAction;
42export declare const defaultIdGenerator: IdGeneratorWrapper;
43export declare function generateNodeId(node: NodeWithOptionalId, idGenerator: IdGenerator, nodeFinder: Pick<IGraph, 'getNodeById'>): string;
44export {};