1 |
|
2 | import { IDisposable } from '@stoplight/lifecycle';
|
3 | import { Dictionary, IDiagnostic } from '@stoplight/types';
|
4 | import { IFSTreeItem } from '../backends/filesystem';
|
5 | import { INotifier } from '../notifier';
|
6 | import { ITraceData } from '../types';
|
7 | import { IGraphDom, IGraphPatch, IGraphPatchResult, INodeFinder, JsonPatch, SourceNodeProp } from './dom/types';
|
8 | import { IBaseNode, ISourceNodeInstance, IVirtualNodeInstance, NodeInstance, NodeWithOptionalId } from './nodes/types';
|
9 | export interface IGraph<N = NodeInstance> extends IDisposable, INodeFinder, IPatchableGraph, IHydratable<IDehydratedGraph> {
|
10 | readonly dom: IGraphDom<N>;
|
11 | readonly nodeValues: NodeInstance[];
|
12 | readonly sourceNodes: ISourceNodeInstance[];
|
13 | readonly virtualNodes: IVirtualNodeInstance[];
|
14 | readonly rootNodes: ISourceNodeInstance[];
|
15 | readonly notifier: INotifier;
|
16 | processIndexedTree: (tree: IFSTreeItem[], parentId: string) => void;
|
17 | printTree: () => string;
|
18 | }
|
19 | export interface IPatchableGraph {
|
20 | applyPatch: (patch: IGraphPatch) => IGraphPatchResult;
|
21 | addNode: <NodeType extends NodeWithOptionalId>(props: NodeType, trace?: ITraceData) => NodeInstance;
|
22 | indexNode: <NodeType extends NodeWithOptionalId>(props: NodeType, trace?: ITraceData) => NodeInstance;
|
23 | setSourceNodeDiagnostics: (id: string, source: string, value: IDiagnostic[], trace?: ITraceData) => void;
|
24 | setSourceNodeProp: (id: string, prop: SourceNodeProp, value: unknown, trace?: ITraceData) => void;
|
25 | patchSourceNodeProp: (id: string, prop: SourceNodeProp, patch: JsonPatch, trace?: ITraceData) => void;
|
26 | moveNode: (id: string, newParentId?: string | null, newPath?: string, trace?: ITraceData) => void;
|
27 | removeNode: (id: string, trace?: ITraceData) => void;
|
28 | reportError: (nodeId: string, err: NodeJS.ErrnoException, trace?: ITraceData) => void;
|
29 | }
|
30 | export interface IHydratable<D = unknown> {
|
31 | dehydrate: () => D;
|
32 | }
|
33 | export interface IDehydratedGraph {
|
34 | nodes: Dictionary<IBaseNode, string>;
|
35 | }
|
36 | export declare type IdGeneratorWrapper = (node: NodeWithOptionalId) => string;
|
37 | export declare type IdGenerator = (node: NodeWithOptionalId, uri: string) => string;
|