import { Resolver } from '@stoplight/json-ref-resolver'; import { IActivatable, IDisposable } from '@stoplight/lifecycle'; import { Dictionary, IParserResult } from '@stoplight/types'; import { IGraph, ISourceNodeInstance, NodeInstance } from './graph'; import { JsonPatch } from './graph/dom'; import { INodeSelector, Node } from './graph/nodes'; import { GraphiteEvent, IGraphiteEvents, INotifier } from './notifier'; import { GraphTask, GraphTaskOp, IScheduler } from './scheduler'; import { TaskHandler } from './scheduler/taskHandler'; import { PluginRegistry } from './services/pluginRegistry'; import { SpecProviderRegistry } from './services/specProviderRegistry'; export interface IGraphite extends IDisposable { readonly graph: IGraph; readonly notifier: INotifier; readonly scheduler: IScheduler; readonly resolver: Resolver; paths?: Dictionary; readonly specRegistry: SpecProviderRegistry; readonly plugins: PluginRegistry; registerPlugins(...plugins: Array): Promise; } export declare type GraphitePaths = 'ignored' | 'readable'; export declare type SourceBackendFactory = (graph: IGraphite, ...args: any) => ISourceBackend; export interface ISourceBackend { id: string; } export interface IPluginTask { operation: T['op']; handler: TaskHandler; } export interface IPluginEvent { name: E; handler: IGraphiteEvents[E]; } declare type BaseGraphitePlugin = { tasks: IPluginTask[]; }; export declare type GraphiteStatelessPlugin

= P extends undefined ? E extends undefined ? BaseGraphitePlugin : BaseGraphitePlugin & { events: E; } : E extends undefined ? BaseGraphitePlugin & { specProvider: P; } : BaseGraphitePlugin & { events: E; specProvider: P; }; export declare type GraphiteLifecyclePlugin = IActivatable & IDisposable & { id: string; init(graphite: IGraphite): Promise; }; export interface ISpecContentProvider { spec: string; content: (parsed: unknown) => number; } export interface ISpecPathProvider { spec: string; path: RegExp; } export declare type SpecProvider = ISpecContentProvider | ISpecPathProvider; export interface IParser extends INodeSelector { serialize: SerializeFunc; deserialize: DeserializeFunc; lazy?: boolean; } export declare type SerializeFunc = (parsed: any) => string; export declare type DeserializeFunc = (raw: string) => IParserResult; export interface ISourceMapPlugin extends INodeSelector { map: ISourceNodeMap[]; } export interface ISourceNodeMap { type: string; noAdd?: boolean; subtype?: string; field?: string; match?: string; notMatch?: string; children?: ISourceNodeMap[]; } export declare enum DiffOp { AddNode = "add_node", ModifyNode = "modify_node", RemoveNode = "remove_node" } export interface IGraphDiff { [DiffOp.AddNode]: Dictionary; [DiffOp.ModifyNode]: Dictionary; [DiffOp.RemoveNode]: Dictionary; } export interface ITraceData { instanceId?: string; sourceOp?: GraphTaskOp; } export declare type GraphiteError = IPluginError | IGenericError | IUnhandledError; export declare enum GraphiteErrorCode { Plugin = 1, Unhandled = 2, Generic = 3 } interface IGraphiteError { code: GraphiteErrorCode; message: string; nodeId?: string; trace?: ITraceData; data?: D; } export interface IUnhandledError extends IGraphiteError { code: GraphiteErrorCode.Unhandled; } export interface IGenericError extends IGraphiteError { code: GraphiteErrorCode.Generic; } export interface IPluginError extends IGraphiteError { code: GraphiteErrorCode.Plugin; nodeId: string; trace: ITraceData; } export {};