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