UNPKG

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